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

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

CVSweb <webmaster@jp.NetBSD.org>