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

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

CVSweb <webmaster@jp.NetBSD.org>