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

1.221.6.2! joerg       1: #      $NetBSD: bsd.prog.mk,v 1.221 2007/07/29 17:06:02 joerg Exp $
        !             2: #      @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
        !             3:
        !             4: .ifndef HOSTPROG
        !             5:
        !             6: .include <bsd.init.mk>
        !             7: .include <bsd.shlib.mk>
        !             8: .include <bsd.gcc.mk>
        !             9:
        !            10: .if defined(PROG_CXX)
        !            11: PROG=  ${PROG_CXX}
        !            12: .endif
        !            13:
        !            14: .if defined(PAXCTL_FLAGS)
        !            15: PAXCTL_FLAGS.${PROG}?= ${PAXCTL_FLAGS}
        !            16: .endif
        !            17:
        !            18: ##### Basic targets
        !            19: realinstall:   proginstall scriptsinstall
        !            20: clean:         cleanprog
        !            21:
        !            22: ##### PROG specific flags.
        !            23: COPTS+=     ${COPTS.${PROG}}
        !            24: CPPFLAGS+=  ${CPPFLAGS.${PROG}}
        !            25: CXXFLAGS+=  ${CXXFLAGS.${PROG}}
        !            26: OBJCOPTS+=  ${OBJCOPTS.${PROG}}
        !            27: LDADD+=     ${LDADD.${PROG}}
        !            28: LDFLAGS+=   ${LDFLAGS.${PROG}}
        !            29: LDSTATIC+=  ${LDSTATIC.${PROG}}
        !            30:
        !            31: ##### Default values
        !            32: CPPFLAGS+=     ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
        !            33: CXXFLAGS+=     ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
        !            34: CFLAGS+=       ${COPTS}
        !            35: OBJCFLAGS+=    ${OBJCOPTS}
        !            36: MKDEP_SUFFIXES?=       .o .ln
        !            37:
        !            38: # ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o
        !            39: .if ${OBJECT_FMT} == "ELF"
        !            40: .ifndef LIBCRTBEGIN
        !            41: LIBCRTBEGIN=   ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGIN}
        !            42: .MADE: ${LIBCRTBEGIN}
        !            43: .endif
        !            44: .ifndef LIBCRTEND
        !            45: LIBCRTEND=     ${_GCC_CRTEND} ${DESTDIR}/usr/lib/crtn.o
        !            46: .MADE: ${LIBCRTEND}
        !            47: .endif
        !            48: _SHLINKER=     ${SHLINKDIR}/ld.elf_so
        !            49: .else
        !            50: LIBCRTBEGIN?=
        !            51: LIBCRTEND?=
        !            52: _SHLINKER=     ${SHLINKDIR}/ld.so
        !            53: .endif
        !            54:
        !            55: .ifndef LIBCRT0
        !            56: LIBCRT0=       ${DESTDIR}/usr/lib/crt0.o
        !            57: .MADE: ${LIBCRT0}
        !            58: .endif
        !            59:
        !            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 \
        !            68:        archive asn1 bluetooth bsdmalloc bz2 c c_pic cdk com_err compat \
        !            69:        crypt crypto crypto_idea crypto_mdc2 crypto_rc5 \
        !            70:        curses dbm des edit event \
        !            71:        form fl g2c gcc gnumalloc gssapi hdb intl ipsec \
        !            72:        kadm5clnt kadm5srv kafs krb5 kvm l \
        !            73:        m magic menu objc ossaudio pam pcap pci pmc posix pthread pthread_dbg \
        !            74:        puffs radius resolv rmt roken rpcsvc rt sdp skey sl ss ssh ssl termcap \
        !            75:        usbhid util wrap y z
        !            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:
        !            82: # PAM applications, if linked statically, need more libraries
        !            83: .if (${MKPIC} == "no")
        !            84: .if (${MKCRYPTO} != "no")
        !            85: PAM_STATIC_LDADD+= -lssh
        !            86: PAM_STATIC_DPADD+= ${LIBSSH}
        !            87: .endif
        !            88: .if (${MKKERBEROS} != "no")
        !            89: PAM_STATIC_LDADD+= -lkafs -lkrb5 -lasn1 -lroken -lcom_err -lcrypto
        !            90: PAM_STATIC_DPADD+= ${LIBKAFS} ${LIBKRB5} ${LIBASN1} ${LIBROKEN} \
        !            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}
        !            99: .else
        !           100: PAM_STATIC_LDADD=
        !           101: PAM_STATIC_DPADD=
        !           102: .endif
        !           103:
        !           104: # These need + -> X transformations
        !           105: .ifndef LIBSTDCXX
        !           106: LIBSTDCXX=     ${DESTDIR}/usr/lib/libstdc++.a
        !           107: .MADE:         ${LIBSTDCXX}
        !           108: .endif
        !           109:
        !           110: .ifndef LIBSUPCXX
        !           111: LIBSUPCXX=     ${DESTDIR}/usr/lib/libsupc++.a
        !           112: .MADE:         ${LIBSUPCXX}
        !           113: .endif
        !           114:
        !           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:
        !           127: ##### Build and install rules
        !           128: .if defined(SHAREDSTRINGS)
        !           129: CLEANFILES+=strings
        !           130: .c.o:
        !           131:        ${CC} -E ${CPPFLAGS} ${CFLAGS} ${.IMPSRC} | xstr -c -
        !           132:        @${CC} ${CPPFLAGS} ${CFLAGS} -c x.c -o ${.TARGET}
        !           133:        @rm -f x.c
        !           134:
        !           135: .cc.o .cpp.o .cxx.o .C.o:
        !           136:        ${CXX} -E ${CPPFLAGS} ${CXXFLAGS} ${.IMPSRC} | xstr -c -
        !           137:        @mv -f x.c x.cc
        !           138:        @${CXX} ${CPPFLAGS} ${CXXFLAGS} -c x.cc -o ${.TARGET}
        !           139:        @rm -f x.cc
        !           140: .endif
        !           141:
        !           142: .if defined(PROG)                                                      # {
        !           143: .if defined(PROG_CXX)
        !           144: SRCS?=         ${PROG}.cc
        !           145: .else
        !           146: SRCS?=         ${PROG}.c
        !           147: .endif
        !           148:
        !           149: PROGNAME?=     ${PROG}
        !           150:
        !           151: .if defined(RESCUEDIR)
        !           152: CPPFLAGS+=     -DRESCUEDIR=\"${RESCUEDIR}\"
        !           153: .endif
        !           154:
        !           155: _YPSRCS=       ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
        !           156:
        !           157: DPSRCS+=       ${_YPSRCS}
        !           158: CLEANFILES+=   ${_YPSRCS}
        !           159:
        !           160: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
        !           161: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
        !           162: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
        !           163: .endif
        !           164:
        !           165: .if defined(OBJS) && !empty(OBJS)                                      # {
        !           166: .NOPATH: ${OBJS} ${PROG} ${_YPSRCS}
        !           167:
        !           168: _PROGLDOPTS=
        !           169: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
        !           170: .if ${OBJECT_FMT} == "ELF"
        !           171: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
        !           172: .endif
        !           173: .endif
        !           174: .if ${SHLIBDIR} != "/usr/lib"
        !           175: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
        !           176:                -R${SHLIBDIR} \
        !           177:                -L${DESTDIR}${SHLIBDIR}
        !           178: .elif ${SHLIBINSTALLDIR} != "/usr/lib"
        !           179: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
        !           180:                -L${DESTDIR}${SHLIBINSTALLDIR}
        !           181: .endif
        !           182:
        !           183: .if defined(PROG_CXX)
        !           184: _CCLINK=       ${CXX}
        !           185: .else
        !           186: _CCLINK=       ${CC}
        !           187: .endif
        !           188:
        !           189: .if ${MKDEBUG} != "no" && ${OBJECT_FMT} == "ELF" && !commands(${PROG})
        !           190: _PROGDEBUG=    ${PROGNAME}.debug
        !           191: .endif
        !           192:
        !           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:
        !           204: ${OBJS} ${LOBJS}: ${DPSRCS}
        !           205:
        !           206: ${PROG}: .gdbinit ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
        !           207: .if !commands(${PROG})
        !           208:        ${_MKTARGET_LINK}
        !           209: .if defined(DESTDIR)
        !           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
        !           215: .else
        !           216:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
        !           217: .endif # defined(DESTDIR)
        !           218: .if defined(PAXCTL_FLAGS.${PROG})
        !           219:        ${PAXCTL} ${PAXCTL_FLAGS.${PROG}} ${.TARGET}
        !           220: .endif
        !           221: .endif # !commands(${PROG})
        !           222:
        !           223: ${PROG}.ro: ${OBJS} ${DPADD}
        !           224:        ${_MKTARGET_LINK}
        !           225:        ${LD} -r -dc -o ${.TARGET} ${OBJS}
        !           226:
        !           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)                                 # }
        !           236:
        !           237: .if !defined(MAN)
        !           238: MAN=   ${PROG}.1
        !           239: .endif # !defined(MAN)
        !           240: .endif # defined(PROG)                                                 # }
        !           241:
        !           242: realall: ${PROG} ${_PROGDEBUG} ${SCRIPTS}
        !           243:
        !           244: cleanprog: .PHONY cleanobjs cleanextra
        !           245:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG} ${_PROGDEBUG}
        !           246:
        !           247: cleanobjs: .PHONY
        !           248: .if defined(OBJS) && !empty(OBJS)
        !           249:        rm -f ${OBJS} ${LOBJS}
        !           250: .endif
        !           251:
        !           252: cleanextra: .PHONY
        !           253: .if defined(CLEANFILES) && !empty(CLEANFILES)
        !           254:        rm -f ${CLEANFILES}
        !           255: .endif
        !           256:
        !           257: .if defined(PROG) && !target(proginstall)                              # {
        !           258:
        !           259: proginstall::  ${DESTDIR}${BINDIR}/${PROGNAME} ${_PROGDEBUG:D${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}}
        !           260: .PRECIOUS:     ${DESTDIR}${BINDIR}/${PROGNAME} ${_PROGDEBUG:D${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}}
        !           261:
        !           262: __proginstall: .USE
        !           263:        ${_MKTARGET_INSTALL}
        !           264:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
        !           265:                ${STRIPFLAG} ${.ALLSRC} ${.TARGET}
        !           266:
        !           267: __progdebuginstall: .USE
        !           268:        ${_MKTARGET_INSTALL}
        !           269:        ${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \
        !           270:                ${.ALLSRC} ${.TARGET}
        !           271:
        !           272: .if ${MKUPDATE} == "no"
        !           273: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
        !           274: .if !defined(BUILD) && !make(all) && !make(${PROG})
        !           275: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
        !           276: .endif
        !           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
        !           284: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
        !           285: .if !defined(BUILD) && !make(all) && !make(${PROG})
        !           286: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
        !           287: .endif
        !           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
        !           292: .endif
        !           293: .endif #  defined(_PROGDEBUG)
        !           294: .endif # MKUPDATE != no
        !           295:
        !           296: .endif # defined(PROG) && !target(proginstall)                         # }
        !           297:
        !           298: .if !target(proginstall)
        !           299: proginstall::
        !           300: .endif
        !           301: .PHONY:                proginstall
        !           302:
        !           303: .if defined(SCRIPTS) && !target(scriptsinstall)                                # {
        !           304: SCRIPTSDIR?=${BINDIR}
        !           305: SCRIPTSOWN?=${BINOWN}
        !           306: SCRIPTSGRP?=${BINGRP}
        !           307: SCRIPTSMODE?=${BINMODE}
        !           308:
        !           309: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
        !           310: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
        !           311:
        !           312: __scriptinstall: .USE
        !           313:        ${_MKTARGET_INSTALL}
        !           314:        ${INSTALL_FILE} \
        !           315:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
        !           316:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
        !           317:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
        !           318:            ${.ALLSRC} ${.TARGET}
        !           319:
        !           320: .for S in ${SCRIPTS:O:u}
        !           321: .if ${MKUPDATE} == "no"
        !           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
        !           328: .if !defined(BUILD) && !make(all) && !make(${S})
        !           329: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
        !           330: .endif
        !           331: .endif
        !           332: .endfor
        !           333: .endif                                                                 # }
        !           334:
        !           335: .if !target(scriptsinstall)
        !           336: scriptsinstall::
        !           337: .endif
        !           338: .PHONY:                scriptsinstall
        !           339:
        !           340: lint: ${LOBJS}
        !           341: .if defined(LOBJS) && !empty(LOBJS)
        !           342:        ${LINT} ${LINTFLAGS} ${LDFLAGS:C/-L[  ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD}
        !           343: .endif
        !           344:
        !           345: ##### Pull in related .mk logic
        !           346: .include <bsd.man.mk>
        !           347: .include <bsd.nls.mk>
        !           348: .include <bsd.files.mk>
        !           349: .include <bsd.inc.mk>
        !           350: .include <bsd.links.mk>
        !           351: .include <bsd.sys.mk>
        !           352: .include <bsd.dep.mk>
        !           353:
        !           354: ${TARGETS}:    # ensure existence
        !           355:
        !           356: .endif # HOSTPROG

CVSweb <webmaster@jp.NetBSD.org>