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

1.209   ! jwise       1: #      $NetBSD: bsd.prog.mk,v 1.208 2006/01/20 16:54:11 christos 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.80      mycroft    15: realinstall:   proginstall scriptsinstall
1.132     tv         16: clean:         cleanprog
1.1       cgd        17:
1.185     erh        18: ##### PROG specific flags.
1.186     erh        19: COPTS+=     ${COPTS.${PROG}}
1.185     erh        20: CPPFLAGS+=  ${CPPFLAGS.${PROG}}
                     21: CXXFLAGS+=  ${CXXFLAGS.${PROG}}
                     22: LDADD+=     ${LDADD.${PROG}}
1.186     erh        23: LDFLAGS+=   ${LDFLAGS.${PROG}}
                     24: LDSTATIC+=  ${LDSTATIC.${PROG}}
1.185     erh        25:
1.138     tv         26: ##### Default values
1.142     thorpej    27: CPPFLAGS+=     ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.175     mrg        28: CXXFLAGS+=     ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
1.25      mycroft    29: CFLAGS+=       ${COPTS}
1.193     dsl        30: MKDEP_SUFFIXES?=       .o .ln
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.202     lukem      54: ##### Installed system library definitions
                     55: #
                     56: #      E.g.
                     57: #              LIBC?=${DESTDIR}/usr/lib/libc.a
                     58: #              LIBX11?=${DESTDIR}/usr/X11R6/lib/libX11.a
                     59: #      etc..
                     60:
                     61: .for _lib in \
1.203     lukem      62:        asn1 bsdmalloc bz2 c c_pic cdk com_err compat crypt \
                     63:        crypto crypto_idea crypto_mdc2 crypto_rc5 \
                     64:        curses dbm des edit event \
                     65:        form fl g2c gcc gnumalloc gssapi hdb intl ipsec \
1.202     lukem      66:        kadm kadm5clnt kadm5srv kafs kdb krb krb5 kstream kvm l \
1.203     lukem      67:        m magic menu objc ossaudio pam pcap pci pmc posix pthread pthread_dbg \
1.205     christos   68:        radius resolv rmt roken rpcsvc rt skey sl ss ssh ssl termcap \
1.203     lukem      69:        usbhid util wrap y z
1.202     lukem      70: .ifndef LIB${_lib:tu}
                     71: LIB${_lib:tu}= ${DESTDIR}/usr/lib/lib${_lib}.a
                     72: .MADE:         ${LIB${_lib:tu}}        # Note: ${DESTDIR} will be expanded
                     73: .endif
                     74: .endfor
                     75:
1.206     he         76: # PAM applications, if linked statically, need more libraries
                     77: .if (${MKPIC} == "no")
1.208     christos   78: .if (${MKCRYPTO} != "no")
                     79: PAM_STATIC_LDADD+= -lssh
                     80: PAM_STATIC_DPADD+= ${LIBSSH}
                     81: .endif
                     82: .if (${MKKERBEROS} != "no")
                     83: PAM_STATIC_LDADD+= -lkafs -lkrb -lkrb5 -lasn1 -lroken -lcom_err -lcrypto
                     84: PAM_STATIC_DPADD+= ${LIBKAFS} ${LIBKRB} ${LIBKRB5} ${LIBASN1} ${LIBROKEN} \
                     85:        ${LIBCOM_ERR} ${LIBCRYPTO}
                     86: .endif
                     87: .if (${MKSKEY} != "no")
                     88: PAM_STATIC_LDADD+= -lskey
                     89: PAM_STATIC_DPADD+= ${LIBSKEY}
                     90: .endif
                     91: PAM_STATIC_LDADD+= -lradius -lcrypt -lrpcsvc -lutil
                     92: PAM_STATIC_DPADD+= ${LIBRADIUS} ${LIBCRYPT} ${LIBRPCSVC} ${LIBUTIL}
1.206     he         93: .else
                     94: PAM_STATIC_LDADD=
                     95: PAM_STATIC_DPADD=
                     96: .endif
                     97:
1.202     lukem      98: .ifndef LIBSTDCXX
                     99: LIBSTDCXX=     ${DESTDIR}/usr/lib/libstdc++.a
                    100: .MADE:         ${LIBSTDCXX}
                    101: .endif
                    102:
                    103: .for _lib in \
                    104:        dps expat fntstubs fontcache fontconfig fontenc freetype FS \
                    105:        GL GLU ICE lbxutil SM X11 Xau Xaw Xdmcp Xext Xfont Xft \
                    106:        Xi Xinerama xkbfile Xmu Xmuu Xpm Xrandr Xrender Xss Xt \
                    107:        XTrap Xtst Xv Xxf86dga Xxf86misc Xxf86vm
                    108: .ifndef LIB${_lib:tu}
                    109: LIB${_lib:tu}= ${DESTDIR}/usr/X11R6/lib/lib${_lib}.a
                    110: .MADE:         ${LIB${_lib:tu}}        # Note: ${DESTDIR} will be expanded
                    111: .endif
                    112: .endfor
                    113:
                    114:
1.138     tv        115: ##### Build and install rules
1.1       cgd       116: .if defined(SHAREDSTRINGS)
                    117: CLEANFILES+=strings
                    118: .c.o:
                    119:        ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
                    120:        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
                    121:        @rm -f x.c
1.18      mycroft   122:
1.173     lukem     123: .cc.o .cpp.o .cxx.o .C.o:
1.18      mycroft   124:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                    125:        @mv -f x.c x.cc
                    126:        @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
1.26      mycroft   127:        @rm -f x.cc
1.146     thorpej   128: .endif
1.38      jtc       129:
1.1       cgd       130: .if defined(PROG)
1.146     thorpej   131: .if defined(PROG_CXX)
                    132: SRCS?=         ${PROG}.cc
                    133: .else
1.80      mycroft   134: SRCS?=         ${PROG}.c
1.146     thorpej   135: .endif
1.80      mycroft   136:
1.204     lukem     137: .if defined(RESCUEDIR)
                    138: CPPFLAGS+=     -DRESCUEDIR=\"${RESCUEDIR}\"
                    139: .endif
                    140:
1.200     lukem     141: _YPSRCS=       ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
                    142:
                    143: DPSRCS+=       ${_YPSRCS}
                    144: CLEANFILES+=   ${_YPSRCS}
1.80      mycroft   145:
1.108     eeh       146: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                    147: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft   148: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd       149: .endif
1.1       cgd       150:
1.47      cgd       151: .if defined(OBJS) && !empty(OBJS)
1.200     lukem     152: .NOPATH: ${OBJS} ${PROG} ${_YPSRCS}
1.137     tv        153:
1.144     lukem     154: _PROGLDOPTS=
                    155: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
1.161     itohy     156: .if ${OBJECT_FMT} == "ELF"
1.144     lukem     157: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
1.161     itohy     158: .endif
1.144     lukem     159: .endif
1.187     lukem     160: .if ${SHLIBDIR} != "/usr/lib"
1.144     lukem     161: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
1.179     lukem     162:                -R${SHLIBDIR} \
1.144     lukem     163:                -L${DESTDIR}${SHLIBDIR}
1.187     lukem     164: .elif ${SHLIBINSTALLDIR} != "/usr/lib"
1.159     thorpej   165: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    166:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     167: .endif
                    168:
1.145     thorpej   169: .if defined(PROG_CXX)
                    170: _CCLINK=       ${CXX}
1.177     lukem     171: .if ${USE_LIBSTDCXX} == "no"
1.174     mrg       172: _SUPCXX=       -lsupc++ -lm
                    173: .else
1.145     thorpej   174: _SUPCXX=       -lstdc++ -lm
1.174     mrg       175: .endif
1.145     thorpej   176: .else
                    177: _CCLINK=       ${CC}
                    178: .endif
                    179:
1.157     thorpej   180: .gdbinit:
                    181:        rm -f .gdbinit
                    182: .if defined(DESTDIR) && !empty(DESTDIR)
                    183:        echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
                    184: .else
                    185:        touch .gdbinit
                    186: .endif
                    187: .for __gdbinit in ${GDBINIT}
                    188:        echo "source ${__gdbinit}" >> .gdbinit
                    189: .endfor
                    190:
1.182     lukem     191: ${OBJS} ${LOBJS}: ${DPSRCS}
                    192:
                    193: ${PROG}: .gdbinit ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  194: .if !commands(${PROG})
1.194     lukem     195:        ${_MKTARGET_LINK}
1.181     lukem     196: .if defined(DESTDIR)
1.198     skrll     197:        ${_CCLINK} -Wl,-nostdlib \
                    198:            ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} \
                    199:            -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/  \
                    200:            ${OBJS} ${LDADD} \
                    201:            -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib
1.46      mycroft   202: .else
1.145     thorpej   203:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.181     lukem     204: .endif # defined(DESTDIR)
                    205: .endif # !commands(${PROG})
1.183     dsl       206:
                    207: ${PROG}.ro: ${OBJS} ${DPADD}
1.207     dsl       208:        ${_MKTARGET_LINK}
1.183     dsl       209:        ${LD} -r -dc -o ${.TARGET} ${OBJS}
1.1       cgd       210:
1.47      cgd       211: .endif # defined(OBJS) && !empty(OBJS)
1.1       cgd       212:
1.100     lukem     213: .if !defined(MAN)
1.49      cgd       214: MAN=   ${PROG}.1
                    215: .endif # !defined(MAN)
                    216: .endif # defined(PROG)
1.11      mycroft   217:
1.107     mycroft   218: realall: ${PROG} ${SCRIPTS}
1.1       cgd       219:
1.197     lukem     220: cleanprog: .PHONY cleanobjs cleanextra
1.157     thorpej   221:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG}
1.134     tls       222:
1.197     lukem     223: cleanobjs: .PHONY
1.135     lukem     224: .if defined(OBJS) && !empty(OBJS)
1.134     tls       225:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     226: .endif
1.134     tls       227:
1.197     lukem     228: cleanextra: .PHONY
1.135     lukem     229: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       230:        rm -f ${CLEANFILES}
1.59      cgd       231: .endif
1.27      mycroft   232:
1.74      mycroft   233: .if defined(PROG) && !target(proginstall)
1.114     mycroft   234: PROGNAME?=${PROG}
                    235:
1.63      christos  236: proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
1.114     mycroft   237: .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
                    238:
1.115     mycroft   239: __proginstall: .USE
1.192     lukem     240:        ${_MKTARGET_INSTALL}
1.139     tv        241:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.209   ! jwise     242:                ${STRIPFLAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   243:
1.172     lukem     244: .if ${MKUPDATE} == "no"
1.154     mycroft   245: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    246: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    247: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    248: .endif
                    249: .else
                    250: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     251: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  252: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    253: .endif
1.154     mycroft   254: .endif
1.23      mycroft   255: .endif
                    256:
1.74      mycroft   257: .if !target(proginstall)
                    258: proginstall::
                    259: .endif
1.197     lukem     260: .PHONY:                proginstall
1.74      mycroft   261:
                    262: .if defined(SCRIPTS) && !target(scriptsinstall)
1.65      mycroft   263: SCRIPTSDIR?=${BINDIR}
                    264: SCRIPTSOWN?=${BINOWN}
                    265: SCRIPTSGRP?=${BINGRP}
                    266: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   267:
                    268: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   269: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   270:
1.115     mycroft   271: __scriptinstall: .USE
1.192     lukem     272:        ${_MKTARGET_INSTALL}
1.139     tv        273:        ${INSTALL_FILE} \
1.116     mycroft   274:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    275:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    276:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.209   ! jwise     277:            ${.ALLSRC} ${.TARGET}
1.115     mycroft   278:
1.130     sommerfe  279: .for S in ${SCRIPTS:O:u}
1.172     lukem     280: .if ${MKUPDATE} == "no"
1.154     mycroft   281: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    282: .if !defined(BUILD) && !make(all) && !make(${S})
                    283: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    284: .endif
                    285: .else
                    286: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     287: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   288: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  289: .endif
1.154     mycroft   290: .endif
1.63      christos  291: .endfor
1.14      mycroft   292: .endif
1.1       cgd       293:
1.74      mycroft   294: .if !target(scriptsinstall)
                    295: scriptsinstall::
1.1       cgd       296: .endif
1.197     lukem     297: .PHONY:                scriptsinstall
1.1       cgd       298:
1.52      cgd       299: lint: ${LOBJS}
                    300: .if defined(LOBJS) && !empty(LOBJS)
1.196     lukem     301:        ${LINT} ${LINTFLAGS} ${LDFLAGS:C/-L[  ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       302: .endif
                    303:
1.138     tv        304: ##### Pull in related .mk logic
1.1       cgd       305: .include <bsd.man.mk>
1.50      jtc       306: .include <bsd.nls.mk>
1.66      christos  307: .include <bsd.files.mk>
1.63      christos  308: .include <bsd.inc.mk>
1.83      mycroft   309: .include <bsd.links.mk>
1.180     lukem     310: .include <bsd.sys.mk>
1.26      mycroft   311: .include <bsd.dep.mk>
1.88      mycroft   312:
1.138     tv        313: ${TARGETS}:    # ensure existence
1.166     lukem     314:
                    315: .endif # HOSTPROG

CVSweb <webmaster@jp.NetBSD.org>