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

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

CVSweb <webmaster@jp.NetBSD.org>