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

1.216   ! mrg         1: #      $NetBSD: bsd.prog.mk,v 1.215 2006/07/23 11:41:27 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.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.214     gdamore    64:        asn1 bluetooth bsdmalloc bz2 c c_pic cdk com_err compat crypt \
1.203     lukem      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.214     gdamore    70:        radius resolv rmt roken rpcsvc rt sdp 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.216   ! mrg       100: # These need + -> X transformations
1.202     lukem     101: .ifndef LIBSTDCXX
                    102: LIBSTDCXX=     ${DESTDIR}/usr/lib/libstdc++.a
                    103: .MADE:         ${LIBSTDCXX}
                    104: .endif
                    105:
1.216   ! mrg       106: .ifndef LIBSUPCXX
        !           107: LIBSUPCXX=     ${DESTDIR}/usr/lib/libsupc++.a
        !           108: .MADE:         ${LIBSUPCXX}
        !           109: .endif
        !           110:
1.202     lukem     111: .for _lib in \
                    112:        dps expat fntstubs fontcache fontconfig fontenc freetype FS \
                    113:        GL GLU ICE lbxutil SM X11 Xau Xaw Xdmcp Xext Xfont Xft \
                    114:        Xi Xinerama xkbfile Xmu Xmuu Xpm Xrandr Xrender Xss Xt \
                    115:        XTrap Xtst Xv Xxf86dga Xxf86misc Xxf86vm
                    116: .ifndef LIB${_lib:tu}
                    117: LIB${_lib:tu}= ${DESTDIR}/usr/X11R6/lib/lib${_lib}.a
                    118: .MADE:         ${LIB${_lib:tu}}        # Note: ${DESTDIR} will be expanded
                    119: .endif
                    120: .endfor
                    121:
                    122:
1.138     tv        123: ##### Build and install rules
1.1       cgd       124: .if defined(SHAREDSTRINGS)
                    125: CLEANFILES+=strings
                    126: .c.o:
1.213     christos  127:        ${CC} -E ${CPPFLAGS} ${CFLAGS} ${.IMPSRC} | xstr -c -
                    128:        @${CC} ${CPPFLAGS} ${CFLAGS} -c x.c -o ${.TARGET}
1.1       cgd       129:        @rm -f x.c
1.18      mycroft   130:
1.173     lukem     131: .cc.o .cpp.o .cxx.o .C.o:
1.213     christos  132:        ${CXX} -E ${CPPFLAGS} ${CXXFLAGS} ${.IMPSRC} | xstr -c -
1.18      mycroft   133:        @mv -f x.c x.cc
1.213     christos  134:        @${CXX} ${CPPFLAGS} ${CXXFLAGS} -c x.cc -o ${.TARGET}
1.26      mycroft   135:        @rm -f x.cc
1.146     thorpej   136: .endif
1.38      jtc       137:
1.215     lukem     138: .if defined(PROG)                                                      # {
1.146     thorpej   139: .if defined(PROG_CXX)
                    140: SRCS?=         ${PROG}.cc
                    141: .else
1.80      mycroft   142: SRCS?=         ${PROG}.c
1.146     thorpej   143: .endif
1.80      mycroft   144:
1.215     lukem     145: PROGNAME?=     ${PROG}
                    146:
1.204     lukem     147: .if defined(RESCUEDIR)
                    148: CPPFLAGS+=     -DRESCUEDIR=\"${RESCUEDIR}\"
                    149: .endif
                    150:
1.200     lukem     151: _YPSRCS=       ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
                    152:
                    153: DPSRCS+=       ${_YPSRCS}
                    154: CLEANFILES+=   ${_YPSRCS}
1.80      mycroft   155:
1.108     eeh       156: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                    157: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft   158: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd       159: .endif
1.1       cgd       160:
1.215     lukem     161: .if defined(OBJS) && !empty(OBJS)                                      # {
1.200     lukem     162: .NOPATH: ${OBJS} ${PROG} ${_YPSRCS}
1.137     tv        163:
1.144     lukem     164: _PROGLDOPTS=
                    165: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
1.161     itohy     166: .if ${OBJECT_FMT} == "ELF"
1.144     lukem     167: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
1.161     itohy     168: .endif
1.144     lukem     169: .endif
1.187     lukem     170: .if ${SHLIBDIR} != "/usr/lib"
1.144     lukem     171: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
1.179     lukem     172:                -R${SHLIBDIR} \
1.144     lukem     173:                -L${DESTDIR}${SHLIBDIR}
1.187     lukem     174: .elif ${SHLIBINSTALLDIR} != "/usr/lib"
1.159     thorpej   175: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    176:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     177: .endif
                    178:
1.145     thorpej   179: .if defined(PROG_CXX)
                    180: _CCLINK=       ${CXX}
                    181: .else
                    182: _CCLINK=       ${CC}
                    183: .endif
                    184:
1.215     lukem     185: .if ${MKDEBUG} != "no" && ${OBJECT_FMT} == "ELF" && !commands(${PROG})
                    186: _PROGDEBUG=    ${PROGNAME}.debug
                    187: .endif
                    188:
1.157     thorpej   189: .gdbinit:
                    190:        rm -f .gdbinit
                    191: .if defined(DESTDIR) && !empty(DESTDIR)
                    192:        echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
                    193: .else
                    194:        touch .gdbinit
                    195: .endif
                    196: .for __gdbinit in ${GDBINIT}
                    197:        echo "source ${__gdbinit}" >> .gdbinit
                    198: .endfor
                    199:
1.182     lukem     200: ${OBJS} ${LOBJS}: ${DPSRCS}
                    201:
                    202: ${PROG}: .gdbinit ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  203: .if !commands(${PROG})
1.194     lukem     204:        ${_MKTARGET_LINK}
1.181     lukem     205: .if defined(DESTDIR)
1.198     skrll     206:        ${_CCLINK} -Wl,-nostdlib \
                    207:            ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} \
                    208:            -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/  \
                    209:            ${OBJS} ${LDADD} \
                    210:            -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib
1.46      mycroft   211: .else
1.145     thorpej   212:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.181     lukem     213: .endif # defined(DESTDIR)
                    214: .endif # !commands(${PROG})
1.183     dsl       215:
                    216: ${PROG}.ro: ${OBJS} ${DPADD}
1.207     dsl       217:        ${_MKTARGET_LINK}
1.183     dsl       218:        ${LD} -r -dc -o ${.TARGET} ${OBJS}
1.1       cgd       219:
1.215     lukem     220: .if defined(_PROGDEBUG)
                    221: ${_PROGDEBUG}: ${PROG}
                    222:        ${_MKTARGET_CREATE}
                    223:        ${OBJCOPY} --only-keep-debug ${PROG} ${_PROGDEBUG}
                    224:        ${OBJCOPY} -R .gnu_debuglink --add-gnu-debuglink=${_PROGDEBUG} ${PROG} \
                    225:            || rm -f ${_PROGDEBUG}
                    226: .endif
                    227:
                    228: .endif # defined(OBJS) && !empty(OBJS)                                 # }
1.1       cgd       229:
1.100     lukem     230: .if !defined(MAN)
1.49      cgd       231: MAN=   ${PROG}.1
                    232: .endif # !defined(MAN)
1.215     lukem     233: .endif # defined(PROG)                                                 # }
1.11      mycroft   234:
1.215     lukem     235: realall: ${PROG} ${_PROGDEBUG} ${SCRIPTS}
1.1       cgd       236:
1.197     lukem     237: cleanprog: .PHONY cleanobjs cleanextra
1.215     lukem     238:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG} ${_PROGDEBUG}
1.134     tls       239:
1.197     lukem     240: cleanobjs: .PHONY
1.135     lukem     241: .if defined(OBJS) && !empty(OBJS)
1.134     tls       242:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     243: .endif
1.134     tls       244:
1.197     lukem     245: cleanextra: .PHONY
1.135     lukem     246: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       247:        rm -f ${CLEANFILES}
1.59      cgd       248: .endif
1.27      mycroft   249:
1.215     lukem     250: .if defined(PROG) && !target(proginstall)                              # {
1.114     mycroft   251:
1.215     lukem     252: proginstall::  ${DESTDIR}${BINDIR}/${PROGNAME} ${_PROGDEBUG:D${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}}
                    253: .PRECIOUS:     ${DESTDIR}${BINDIR}/${PROGNAME} ${_PROGDEBUG:D${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}}
1.114     mycroft   254:
1.115     mycroft   255: __proginstall: .USE
1.192     lukem     256:        ${_MKTARGET_INSTALL}
1.139     tv        257:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.209     jwise     258:                ${STRIPFLAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   259:
1.215     lukem     260: __progdebuginstall: .USE
                    261:        ${_MKTARGET_INSTALL}
                    262:        ${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \
                    263:                ${.ALLSRC} ${.TARGET}
                    264:
1.172     lukem     265: .if ${MKUPDATE} == "no"
1.154     mycroft   266: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    267: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    268: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    269: .endif
1.215     lukem     270: .if defined(_PROGDEBUG)
                    271: ${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}! ${_PROGDEBUG} __progdebuginstall
                    272: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    273: ${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}! .MADE
                    274: .endif
                    275: .endif #  define(_PROGDEBUG)
                    276: .else  # MKUPDATE != no
1.154     mycroft   277: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     278: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  279: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    280: .endif
1.215     lukem     281: .if defined(_PROGDEBUG)
                    282: ${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}: ${_PROGDEBUG} __progdebuginstall
                    283: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    284: ${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}: .MADE
1.154     mycroft   285: .endif
1.215     lukem     286: .endif #  defined(_PROGDEBUG)
                    287: .endif # MKUPDATE != no
                    288:
                    289: .endif # defined(PROG) && !target(proginstall)                         # }
1.23      mycroft   290:
1.74      mycroft   291: .if !target(proginstall)
                    292: proginstall::
                    293: .endif
1.197     lukem     294: .PHONY:                proginstall
1.74      mycroft   295:
1.215     lukem     296: .if defined(SCRIPTS) && !target(scriptsinstall)                                # {
1.65      mycroft   297: SCRIPTSDIR?=${BINDIR}
                    298: SCRIPTSOWN?=${BINOWN}
                    299: SCRIPTSGRP?=${BINGRP}
                    300: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   301:
                    302: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   303: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   304:
1.115     mycroft   305: __scriptinstall: .USE
1.192     lukem     306:        ${_MKTARGET_INSTALL}
1.139     tv        307:        ${INSTALL_FILE} \
1.116     mycroft   308:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    309:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    310:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.209     jwise     311:            ${.ALLSRC} ${.TARGET}
1.115     mycroft   312:
1.130     sommerfe  313: .for S in ${SCRIPTS:O:u}
1.172     lukem     314: .if ${MKUPDATE} == "no"
1.154     mycroft   315: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    316: .if !defined(BUILD) && !make(all) && !make(${S})
                    317: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    318: .endif
                    319: .else
                    320: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     321: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   322: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  323: .endif
1.154     mycroft   324: .endif
1.63      christos  325: .endfor
1.215     lukem     326: .endif                                                                 # }
1.1       cgd       327:
1.74      mycroft   328: .if !target(scriptsinstall)
                    329: scriptsinstall::
1.1       cgd       330: .endif
1.197     lukem     331: .PHONY:                scriptsinstall
1.1       cgd       332:
1.52      cgd       333: lint: ${LOBJS}
                    334: .if defined(LOBJS) && !empty(LOBJS)
1.196     lukem     335:        ${LINT} ${LINTFLAGS} ${LDFLAGS:C/-L[  ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       336: .endif
                    337:
1.138     tv        338: ##### Pull in related .mk logic
1.1       cgd       339: .include <bsd.man.mk>
1.50      jtc       340: .include <bsd.nls.mk>
1.66      christos  341: .include <bsd.files.mk>
1.63      christos  342: .include <bsd.inc.mk>
1.83      mycroft   343: .include <bsd.links.mk>
1.180     lukem     344: .include <bsd.sys.mk>
1.26      mycroft   345: .include <bsd.dep.mk>
1.88      mycroft   346:
1.138     tv        347: ${TARGETS}:    # ensure existence
1.166     lukem     348:
                    349: .endif # HOSTPROG

CVSweb <webmaster@jp.NetBSD.org>