[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.172

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

CVSweb <webmaster@jp.NetBSD.org>