[BACK]Return to bsd.prog.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / mk

Annotation of src/share/mk/bsd.prog.mk, Revision 1.165

1.165   ! thorpej     1: #      $NetBSD: bsd.prog.mk,v 1.164 2003/02/22 04:46:08 uwe Exp $
1.67      mikel       2: #      @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
1.1       cgd         3:
1.138     tv          4: .include <bsd.init.mk>
1.159     thorpej     5: .include <bsd.shlib.mk>
1.74      mycroft     6:
1.138     tv          7: ##### Basic targets
1.148     enami       8: .PHONY:                cleanextra cleanobjs cleanprog proginstall scriptsinstall
1.80      mycroft     9: realinstall:   proginstall scriptsinstall
1.132     tv         10: clean:         cleanprog
1.1       cgd        11:
1.138     tv         12: ##### Default values
1.142     thorpej    13: CPPFLAGS+=     ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.143     tv         14: CXXFLAGS+=     ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++}
1.25      mycroft    15: CFLAGS+=       ${COPTS}
1.155     eeh        16: .if ${MACHINE_ARCH} == "sparc64"
                     17: CFLAGS+=       -mcmodel=medlow
                     18: .endif
1.1       cgd        19:
1.162     thorpej    20: # ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o
1.100     lukem      21: .if ${OBJECT_FMT} == "ELF"
1.153     pk         22: .ifndef LIBCRTBEGIN
1.162     thorpej    23: LIBCRTBEGIN=   ${DESTDIR}/usr/lib/crti.o ${DESTDIR}/usr/lib/crtbegin.o
1.152     christos   24: .MADE: ${LIBCRTBEGIN}
1.153     pk         25: .endif
                     26: .ifndef LIBCRTEND
1.165   ! thorpej    27: .if ${MACHINE_ARCH} == "powerpc" && defined(HAVE_GCC3)
        !            28: LIBCRTEND=     ${DESTDIR}/usr/lib/crtsavres.o \
        !            29:                ${DESTDIR}/usr/lib/crtend.o ${DESTDIR}/usr/lib/crtn.o
        !            30: .else
1.162     thorpej    31: LIBCRTEND=     ${DESTDIR}/usr/lib/crtend.o ${DESTDIR}/usr/lib/crtn.o
1.165   ! thorpej    32: .endif
1.152     christos   33: .MADE: ${LIBCRTEND}
1.153     pk         34: .endif
1.144     lukem      35: _SHLINKER=     ${SHLINKDIR}/ld.elf_so
1.69      thorpej    36: .else
                     37: LIBCRTBEGIN?=
                     38: LIBCRTEND?=
1.144     lukem      39: _SHLINKER=     ${SHLINKDIR}/ld.so
1.69      thorpej    40: .endif
                     41:
1.153     pk         42: .ifndef LIBCRT0
                     43: LIBCRT0=       ${DESTDIR}/usr/lib/crt0.o
1.152     christos   44: .MADE: ${LIBCRT0}
1.153     pk         45: .endif
1.95      ross       46:
1.153     pk         47: ##### Installed system library definitions
                     48: #     E.g. LIBC?=${DESTDIR}/usr/lib/libc.a
                     49: #     etc..
                     50: #
                     51: __bsd_prog_mk_system_libs?= \
1.158     itojun     52:        BZ2 C C_PIC CDK COM_ERR COMPAT CRYPT CRYPTO CRYPTO_IDEA CRYPTO_MDC2 \
                     53:        CRYPTO_RC5 \
1.153     pk         54:        CURSES DBM DES EDIT FORM GCC GNUMALLOC GSSAPI HDB INTL IPSEC \
                     55:        KADM KADM5CLNT KADM5SRV KAFS KDB KRB KRB5 KSTREAM KVM L M MENU \
1.163     thorpej    56:        OBJC OSSAUDIO PCAP PCI PMC POSIX PTHREAD PTHREAD_DBG RESOLV RMT \
                     57:        ROKEN RPCSVC RT SKEY SS SSL SL TERMCAP TELNET USBHID UTIL WRAP Y Z
1.153     pk         58:
                     59: .for _n in ${__bsd_prog_mk_system_libs}
                     60: .ifndef LIB${_n}
                     61: LIB${_n}= ${DESTDIR}/usr/lib/lib${_n:tl}.a
1.164     uwe        62: # XXX - note that ${DESTDIR} will be expanded in the following rule
1.153     pk         63: .MADE: ${LIB${_n}}
                     64: .endif
                     65: .endfor
                     66: .undef __bsd_prog_mk_system_libs
1.1       cgd        67:
1.138     tv         68: ##### Build and install rules
1.1       cgd        69: .if defined(SHAREDSTRINGS)
                     70: CLEANFILES+=strings
                     71: .c.o:
                     72:        ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
                     73:        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
                     74:        @rm -f x.c
1.18      mycroft    75:
                     76: .cc.o:
                     77:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                     78:        @mv -f x.c x.cc
                     79:        @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
1.26      mycroft    80:        @rm -f x.cc
1.18      mycroft    81:
                     82: .C.o:
                     83:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                     84:        @mv -f x.c x.C
                     85:        @${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
1.26      mycroft    86:        @rm -f x.C
1.1       cgd        87: .endif
                     88:
1.146     thorpej    89: .if defined(PROG_CXX)
                     90: PROG=  ${PROG_CXX}
                     91: .endif
1.38      jtc        92:
1.1       cgd        93: .if defined(PROG)
1.146     thorpej    94: .if defined(PROG_CXX)
                     95: SRCS?=         ${PROG}.cc
                     96: .else
1.80      mycroft    97: SRCS?=         ${PROG}.c
1.146     thorpej    98: .endif
1.80      mycroft    99:
1.141     tv        100: DPSRCS+=       ${SRCS:M*.[ly]:C/\..$/.c/}
1.137     tv        101: CLEANFILES+=   ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.80      mycroft   102:
1.108     eeh       103: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                    104: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft   105: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd       106: .endif
1.1       cgd       107:
1.47      cgd       108: .if defined(OBJS) && !empty(OBJS)
1.141     tv        109: .NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.137     tv        110:
1.144     lukem     111: _PROGLDOPTS=
                    112: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
1.161     itohy     113: .if ${OBJECT_FMT} == "ELF"
1.144     lukem     114: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
1.161     itohy     115: .endif
                    116: .if ${OBJECT_FMT} == "a.out"
                    117: LIBCRT0=       ${DESTDIR}/lib/crt0.o
                    118: .endif
1.144     lukem     119: .endif
                    120: .if ${SHLIBDIR} != ${LIBDIR}
                    121: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
                    122:                -Wl,-rpath,${SHLIBDIR}:/usr/lib \
                    123:                -L${DESTDIR}${SHLIBDIR}
1.159     thorpej   124: .elif ${SHLIBINSTALLDIR} != ${LIBDIR}
                    125: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    126:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     127: .endif
                    128:
1.145     thorpej   129: .if defined(PROG_CXX)
                    130: _CCLINK=       ${CXX}
                    131: _SUPCXX=       -lstdc++ -lm
                    132: .else
                    133: _CCLINK=       ${CC}
                    134: .endif
                    135:
1.157     thorpej   136: .gdbinit:
                    137:        rm -f .gdbinit
                    138: .if defined(DESTDIR) && !empty(DESTDIR)
                    139:        echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
                    140: .else
                    141:        touch .gdbinit
                    142: .endif
                    143: .for __gdbinit in ${GDBINIT}
                    144:        echo "source ${__gdbinit}" >> .gdbinit
                    145: .endfor
                    146:
1.86      cjs       147: .if defined(DESTDIR)
                    148:
1.157     thorpej   149: ${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  150: .if !commands(${PROG})
1.145     thorpej   151:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
1.125     christos  152: .endif
1.4       nate      153:
1.46      mycroft   154: .else
1.86      cjs       155:
1.157     thorpej   156: ${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  157: .if !commands(${PROG})
1.145     thorpej   158:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.125     christos  159: .endif
1.1       cgd       160:
1.86      cjs       161: .endif # defined(DESTDIR)
1.47      cgd       162: .endif # defined(OBJS) && !empty(OBJS)
1.1       cgd       163:
1.100     lukem     164: .if !defined(MAN)
1.49      cgd       165: MAN=   ${PROG}.1
                    166: .endif # !defined(MAN)
                    167: .endif # defined(PROG)
1.11      mycroft   168:
1.107     mycroft   169: realall: ${PROG} ${SCRIPTS}
1.1       cgd       170:
1.134     tls       171: cleanprog: cleanobjs cleanextra
1.157     thorpej   172:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG}
1.134     tls       173:
                    174: cleanobjs:
1.135     lukem     175: .if defined(OBJS) && !empty(OBJS)
1.134     tls       176:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     177: .endif
1.134     tls       178:
                    179: cleanextra:
1.135     lukem     180: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       181:        rm -f ${CLEANFILES}
1.135     lukem     182: .endif
1.1       cgd       183:
1.129     jmc       184: .if defined(SRCS) && !target(afterdepend)
1.59      cgd       185: afterdepend: .depend
                    186:        @(TMP=/tmp/_depend$$$$; \
                    187:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
                    188:              < .depend > $$TMP; \
                    189:            mv $$TMP .depend)
                    190: .endif
1.27      mycroft   191:
1.74      mycroft   192: .if defined(PROG) && !target(proginstall)
1.114     mycroft   193: PROGNAME?=${PROG}
                    194:
1.63      christos  195: proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
1.114     mycroft   196: .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
                    197:
1.115     mycroft   198: __proginstall: .USE
1.139     tv        199:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.160     perry     200:                ${STRIPFLAG} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   201:
1.154     mycroft   202: .if !defined(UPDATE)
                    203: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    204: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    205: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    206: .endif
                    207: .else
                    208: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     209: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  210: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    211: .endif
1.154     mycroft   212: .endif
1.23      mycroft   213: .endif
                    214:
1.74      mycroft   215: .if !target(proginstall)
                    216: proginstall::
                    217: .endif
                    218:
                    219: .if defined(SCRIPTS) && !target(scriptsinstall)
1.65      mycroft   220: SCRIPTSDIR?=${BINDIR}
                    221: SCRIPTSOWN?=${BINOWN}
                    222: SCRIPTSGRP?=${BINGRP}
                    223: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   224:
                    225: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   226: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   227:
1.115     mycroft   228: __scriptinstall: .USE
1.139     tv        229:        ${INSTALL_FILE} \
1.116     mycroft   230:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    231:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    232:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.160     perry     233:            ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   234:
1.130     sommerfe  235: .for S in ${SCRIPTS:O:u}
1.154     mycroft   236: .if !defined(UPDATE)
                    237: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    238: .if !defined(BUILD) && !make(all) && !make(${S})
                    239: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    240: .endif
                    241: .else
                    242: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     243: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   244: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  245: .endif
1.154     mycroft   246: .endif
1.63      christos  247: .endfor
1.14      mycroft   248: .endif
1.1       cgd       249:
1.74      mycroft   250: .if !target(scriptsinstall)
                    251: scriptsinstall::
1.1       cgd       252: .endif
                    253:
1.52      cgd       254: lint: ${LOBJS}
                    255: .if defined(LOBJS) && !empty(LOBJS)
1.90      cgd       256:        ${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       257: .endif
                    258:
1.138     tv        259: ##### Pull in related .mk logic
1.1       cgd       260: .include <bsd.man.mk>
1.50      jtc       261: .include <bsd.nls.mk>
1.66      christos  262: .include <bsd.files.mk>
1.63      christos  263: .include <bsd.inc.mk>
1.83      mycroft   264: .include <bsd.links.mk>
1.26      mycroft   265: .include <bsd.dep.mk>
1.54      christos  266: .include <bsd.sys.mk>
1.88      mycroft   267:
1.138     tv        268: ${TARGETS}:    # ensure existence

CVSweb <webmaster@jp.NetBSD.org>