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

1.183   ! dsl         1: #      $NetBSD: bsd.prog.mk,v 1.182 2003/08/01 17:04:01 lukem 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.175     mrg        17: CXXFLAGS+=     ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${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:
1.173     lukem      74: .cc.o .cpp.o .cxx.o .C.o:
1.18      mycroft    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.1       cgd        79: .endif
                     80:
1.146     thorpej    81: .if defined(PROG_CXX)
                     82: PROG=  ${PROG_CXX}
                     83: .endif
1.38      jtc        84:
1.1       cgd        85: .if defined(PROG)
1.146     thorpej    86: .if defined(PROG_CXX)
                     87: SRCS?=         ${PROG}.cc
                     88: .else
1.80      mycroft    89: SRCS?=         ${PROG}.c
1.146     thorpej    90: .endif
1.80      mycroft    91:
1.178     lukem      92: DPSRCS+=       ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
1.182     lukem      93: DPSRCS+=       ${YHEADER:D${SRCS:M*.y:.y=.h}}
                     94: CLEANFILES+=   ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
                     95: CLEANFILES+=   ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.80      mycroft    96:
1.108     eeh        97: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                     98: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft    99: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd       100: .endif
1.1       cgd       101:
1.47      cgd       102: .if defined(OBJS) && !empty(OBJS)
1.141     tv        103: .NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.137     tv        104:
1.144     lukem     105: _PROGLDOPTS=
                    106: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
1.161     itohy     107: .if ${OBJECT_FMT} == "ELF"
1.144     lukem     108: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
1.161     itohy     109: .endif
                    110: .if ${OBJECT_FMT} == "a.out"
                    111: LIBCRT0=       ${DESTDIR}/lib/crt0.o
                    112: .endif
1.144     lukem     113: .endif
                    114: .if ${SHLIBDIR} != ${LIBDIR}
                    115: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
1.179     lukem     116:                -R${SHLIBDIR} \
1.144     lukem     117:                -L${DESTDIR}${SHLIBDIR}
1.159     thorpej   118: .elif ${SHLIBINSTALLDIR} != ${LIBDIR}
                    119: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    120:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     121: .endif
                    122:
1.145     thorpej   123: .if defined(PROG_CXX)
                    124: _CCLINK=       ${CXX}
1.177     lukem     125: .if ${USE_LIBSTDCXX} == "no"
1.174     mrg       126: _SUPCXX=       -lsupc++ -lm
                    127: .else
1.145     thorpej   128: _SUPCXX=       -lstdc++ -lm
1.174     mrg       129: .endif
1.145     thorpej   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.182     lukem     145: ${OBJS} ${LOBJS}: ${DPSRCS}
                    146:
                    147: ${PROG}: .gdbinit ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  148: .if !commands(${PROG})
1.181     lukem     149: .if defined(DESTDIR)
1.167     thorpej   150:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
1.46      mycroft   151: .else
1.145     thorpej   152:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.181     lukem     153: .endif # defined(DESTDIR)
                    154: .endif # !commands(${PROG})
1.183   ! dsl       155:
        !           156: ${PROG}.ro: ${OBJS} ${DPADD}
        !           157:        ${LD} -r -dc -o ${.TARGET} ${OBJS}
1.1       cgd       158:
1.47      cgd       159: .endif # defined(OBJS) && !empty(OBJS)
1.1       cgd       160:
1.100     lukem     161: .if !defined(MAN)
1.49      cgd       162: MAN=   ${PROG}.1
                    163: .endif # !defined(MAN)
                    164: .endif # defined(PROG)
1.11      mycroft   165:
1.107     mycroft   166: realall: ${PROG} ${SCRIPTS}
1.1       cgd       167:
1.134     tls       168: cleanprog: cleanobjs cleanextra
1.157     thorpej   169:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG}
1.134     tls       170:
                    171: cleanobjs:
1.135     lukem     172: .if defined(OBJS) && !empty(OBJS)
1.134     tls       173:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     174: .endif
1.134     tls       175:
                    176: cleanextra:
1.135     lukem     177: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       178:        rm -f ${CLEANFILES}
1.135     lukem     179: .endif
1.1       cgd       180:
1.129     jmc       181: .if defined(SRCS) && !target(afterdepend)
1.59      cgd       182: afterdepend: .depend
1.168     msaitoh   183:        @(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
1.59      cgd       184:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
                    185:              < .depend > $$TMP; \
                    186:            mv $$TMP .depend)
                    187: .endif
1.27      mycroft   188:
1.74      mycroft   189: .if defined(PROG) && !target(proginstall)
1.114     mycroft   190: PROGNAME?=${PROG}
                    191:
1.63      christos  192: proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
1.114     mycroft   193: .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
                    194:
1.115     mycroft   195: __proginstall: .USE
1.139     tv        196:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.160     perry     197:                ${STRIPFLAG} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   198:
1.172     lukem     199: .if ${MKUPDATE} == "no"
1.154     mycroft   200: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    201: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    202: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    203: .endif
                    204: .else
                    205: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     206: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  207: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    208: .endif
1.154     mycroft   209: .endif
1.23      mycroft   210: .endif
                    211:
1.74      mycroft   212: .if !target(proginstall)
                    213: proginstall::
                    214: .endif
                    215:
                    216: .if defined(SCRIPTS) && !target(scriptsinstall)
1.65      mycroft   217: SCRIPTSDIR?=${BINDIR}
                    218: SCRIPTSOWN?=${BINOWN}
                    219: SCRIPTSGRP?=${BINGRP}
                    220: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   221:
                    222: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   223: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   224:
1.115     mycroft   225: __scriptinstall: .USE
1.139     tv        226:        ${INSTALL_FILE} \
1.116     mycroft   227:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    228:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    229:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.160     perry     230:            ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   231:
1.130     sommerfe  232: .for S in ${SCRIPTS:O:u}
1.172     lukem     233: .if ${MKUPDATE} == "no"
1.154     mycroft   234: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    235: .if !defined(BUILD) && !make(all) && !make(${S})
                    236: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    237: .endif
                    238: .else
                    239: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     240: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   241: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  242: .endif
1.154     mycroft   243: .endif
1.63      christos  244: .endfor
1.14      mycroft   245: .endif
1.1       cgd       246:
1.74      mycroft   247: .if !target(scriptsinstall)
                    248: scriptsinstall::
1.1       cgd       249: .endif
                    250:
1.52      cgd       251: lint: ${LOBJS}
                    252: .if defined(LOBJS) && !empty(LOBJS)
1.90      cgd       253:        ${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       254: .endif
                    255:
1.138     tv        256: ##### Pull in related .mk logic
1.1       cgd       257: .include <bsd.man.mk>
1.50      jtc       258: .include <bsd.nls.mk>
1.66      christos  259: .include <bsd.files.mk>
1.63      christos  260: .include <bsd.inc.mk>
1.83      mycroft   261: .include <bsd.links.mk>
1.180     lukem     262: .include <bsd.sys.mk>
1.26      mycroft   263: .include <bsd.dep.mk>
1.88      mycroft   264:
1.138     tv        265: ${TARGETS}:    # ensure existence
1.166     lukem     266:
                    267: .endif # HOSTPROG

CVSweb <webmaster@jp.NetBSD.org>