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

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

CVSweb <webmaster@jp.NetBSD.org>