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

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

CVSweb <webmaster@jp.NetBSD.org>