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

1.184   ! lukem       1: #      $NetBSD: bsd.prog.mk,v 1.183 2003/08/22 19:17:00 dsl 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.138     tv         10: ##### Basic targets
1.148     enami      11: .PHONY:                cleanextra cleanobjs cleanprog proginstall scriptsinstall
1.80      mycroft    12: realinstall:   proginstall scriptsinstall
1.132     tv         13: clean:         cleanprog
1.1       cgd        14:
1.138     tv         15: ##### Default values
1.142     thorpej    16: CPPFLAGS+=     ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.175     mrg        17: CXXFLAGS+=     ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
1.25      mycroft    18: CFLAGS+=       ${COPTS}
1.155     eeh        19: .if ${MACHINE_ARCH} == "sparc64"
                     20: CFLAGS+=       -mcmodel=medlow
                     21: .endif
1.1       cgd        22:
1.162     thorpej    23: # ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o
1.100     lukem      24: .if ${OBJECT_FMT} == "ELF"
1.153     pk         25: .ifndef LIBCRTBEGIN
1.167     thorpej    26: LIBCRTBEGIN=   ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGIN}
1.152     christos   27: .MADE: ${LIBCRTBEGIN}
1.153     pk         28: .endif
                     29: .ifndef LIBCRTEND
1.167     thorpej    30: LIBCRTEND=     ${_GCC_CRTEND} ${DESTDIR}/usr/lib/crtn.o
1.152     christos   31: .MADE: ${LIBCRTEND}
1.153     pk         32: .endif
1.144     lukem      33: _SHLINKER=     ${SHLINKDIR}/ld.elf_so
1.69      thorpej    34: .else
                     35: LIBCRTBEGIN?=
                     36: LIBCRTEND?=
1.144     lukem      37: _SHLINKER=     ${SHLINKDIR}/ld.so
1.69      thorpej    38: .endif
                     39:
1.153     pk         40: .ifndef LIBCRT0
                     41: LIBCRT0=       ${DESTDIR}/usr/lib/crt0.o
1.152     christos   42: .MADE: ${LIBCRT0}
1.153     pk         43: .endif
1.95      ross       44:
1.153     pk         45: ##### Installed system library definitions
                     46: #     E.g. LIBC?=${DESTDIR}/usr/lib/libc.a
                     47: #     etc..
                     48: #
                     49: __bsd_prog_mk_system_libs?= \
1.158     itojun     50:        BZ2 C C_PIC CDK COM_ERR COMPAT CRYPT CRYPTO CRYPTO_IDEA CRYPTO_MDC2 \
                     51:        CRYPTO_RC5 \
1.169     itojun     52:        CURSES DBM DES EDIT EVENT FORM GCC GNUMALLOC GSSAPI HDB INTL IPSEC \
1.153     pk         53:        KADM KADM5CLNT KADM5SRV KAFS KDB KRB KRB5 KSTREAM KVM L M MENU \
1.163     thorpej    54:        OBJC OSSAUDIO PCAP PCI PMC POSIX PTHREAD PTHREAD_DBG RESOLV RMT \
1.171     itojun     55:        ROKEN RPCSVC RT SKEY SS SSL SL TERMCAP USBHID UTIL WRAP Y Z
1.153     pk         56:
                     57: .for _n in ${__bsd_prog_mk_system_libs}
                     58: .ifndef LIB${_n}
                     59: LIB${_n}= ${DESTDIR}/usr/lib/lib${_n:tl}.a
1.184   ! lukem      60: # Note: ${DESTDIR} will be expanded in the following rule
1.153     pk         61: .MADE: ${LIB${_n}}
                     62: .endif
                     63: .endfor
                     64: .undef __bsd_prog_mk_system_libs
1.184   ! lukem      65:
        !            66: ##### Installed X11R6 library definitions
        !            67: #     E.g. LIBX11?=${DESTDIR}/usr/X11R6/lib/libX11.a
        !            68: #     etc..
        !            69: #
        !            70: __bsd_prog_mk_x11r6_libs?= \
        !            71:        dps expat fntstubs fontcache fontconfig fontenc freetype FS \
        !            72:        GL GLU ICE lbxutil SM X11 Xau Xaw Xdmcp Xext Xfont Xft \
        !            73:        Xi Xinerama xkbfile Xmu Xmuu Xpm Xrandr Xrender Xss Xt \
        !            74:        XTrap Xtst Xv Xxf86dga Xxf86misc Xxf86vm
        !            75:
        !            76: .for _n in ${__bsd_prog_mk_x11r6_libs}
        !            77: .ifndef LIB${_n:tu}
        !            78: LIB${_n:tu}= ${DESTDIR}/usr/X11R6/lib/lib${_n}.a
        !            79: # Note: ${DESTDIR} will be expanded in the following rule
        !            80: .MADE: ${LIB${_n:tu}}
        !            81: .endif
        !            82: .endfor
        !            83: .undef __bsd_prog_mk_x11r6_libs
1.1       cgd        84:
1.138     tv         85: ##### Build and install rules
1.1       cgd        86: .if defined(SHAREDSTRINGS)
                     87: CLEANFILES+=strings
                     88: .c.o:
                     89:        ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
                     90:        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
                     91:        @rm -f x.c
1.18      mycroft    92:
1.173     lukem      93: .cc.o .cpp.o .cxx.o .C.o:
1.18      mycroft    94:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                     95:        @mv -f x.c x.cc
                     96:        @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
1.26      mycroft    97:        @rm -f x.cc
1.1       cgd        98: .endif
                     99:
1.146     thorpej   100: .if defined(PROG_CXX)
                    101: PROG=  ${PROG_CXX}
                    102: .endif
1.38      jtc       103:
1.1       cgd       104: .if defined(PROG)
1.146     thorpej   105: .if defined(PROG_CXX)
                    106: SRCS?=         ${PROG}.cc
                    107: .else
1.80      mycroft   108: SRCS?=         ${PROG}.c
1.146     thorpej   109: .endif
1.80      mycroft   110:
1.178     lukem     111: DPSRCS+=       ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
1.182     lukem     112: DPSRCS+=       ${YHEADER:D${SRCS:M*.y:.y=.h}}
                    113: CLEANFILES+=   ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
                    114: CLEANFILES+=   ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.80      mycroft   115:
1.108     eeh       116: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                    117: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft   118: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd       119: .endif
1.1       cgd       120:
1.47      cgd       121: .if defined(OBJS) && !empty(OBJS)
1.141     tv        122: .NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.137     tv        123:
1.144     lukem     124: _PROGLDOPTS=
                    125: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
1.161     itohy     126: .if ${OBJECT_FMT} == "ELF"
1.144     lukem     127: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
1.161     itohy     128: .endif
                    129: .if ${OBJECT_FMT} == "a.out"
                    130: LIBCRT0=       ${DESTDIR}/lib/crt0.o
                    131: .endif
1.144     lukem     132: .endif
                    133: .if ${SHLIBDIR} != ${LIBDIR}
                    134: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
1.179     lukem     135:                -R${SHLIBDIR} \
1.144     lukem     136:                -L${DESTDIR}${SHLIBDIR}
1.159     thorpej   137: .elif ${SHLIBINSTALLDIR} != ${LIBDIR}
                    138: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    139:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     140: .endif
                    141:
1.145     thorpej   142: .if defined(PROG_CXX)
                    143: _CCLINK=       ${CXX}
1.177     lukem     144: .if ${USE_LIBSTDCXX} == "no"
1.174     mrg       145: _SUPCXX=       -lsupc++ -lm
                    146: .else
1.145     thorpej   147: _SUPCXX=       -lstdc++ -lm
1.174     mrg       148: .endif
1.145     thorpej   149: .else
                    150: _CCLINK=       ${CC}
                    151: .endif
                    152:
1.157     thorpej   153: .gdbinit:
                    154:        rm -f .gdbinit
                    155: .if defined(DESTDIR) && !empty(DESTDIR)
                    156:        echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
                    157: .else
                    158:        touch .gdbinit
                    159: .endif
                    160: .for __gdbinit in ${GDBINIT}
                    161:        echo "source ${__gdbinit}" >> .gdbinit
                    162: .endfor
                    163:
1.182     lukem     164: ${OBJS} ${LOBJS}: ${DPSRCS}
                    165:
                    166: ${PROG}: .gdbinit ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  167: .if !commands(${PROG})
1.181     lukem     168: .if defined(DESTDIR)
1.167     thorpej   169:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
1.46      mycroft   170: .else
1.145     thorpej   171:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.181     lukem     172: .endif # defined(DESTDIR)
                    173: .endif # !commands(${PROG})
1.183     dsl       174:
                    175: ${PROG}.ro: ${OBJS} ${DPADD}
                    176:        ${LD} -r -dc -o ${.TARGET} ${OBJS}
1.1       cgd       177:
1.47      cgd       178: .endif # defined(OBJS) && !empty(OBJS)
1.1       cgd       179:
1.100     lukem     180: .if !defined(MAN)
1.49      cgd       181: MAN=   ${PROG}.1
                    182: .endif # !defined(MAN)
                    183: .endif # defined(PROG)
1.11      mycroft   184:
1.107     mycroft   185: realall: ${PROG} ${SCRIPTS}
1.1       cgd       186:
1.134     tls       187: cleanprog: cleanobjs cleanextra
1.157     thorpej   188:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG}
1.134     tls       189:
                    190: cleanobjs:
1.135     lukem     191: .if defined(OBJS) && !empty(OBJS)
1.134     tls       192:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     193: .endif
1.134     tls       194:
                    195: cleanextra:
1.135     lukem     196: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       197:        rm -f ${CLEANFILES}
1.135     lukem     198: .endif
1.1       cgd       199:
1.129     jmc       200: .if defined(SRCS) && !target(afterdepend)
1.59      cgd       201: afterdepend: .depend
1.168     msaitoh   202:        @(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
1.59      cgd       203:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
                    204:              < .depend > $$TMP; \
                    205:            mv $$TMP .depend)
                    206: .endif
1.27      mycroft   207:
1.74      mycroft   208: .if defined(PROG) && !target(proginstall)
1.114     mycroft   209: PROGNAME?=${PROG}
                    210:
1.63      christos  211: proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
1.114     mycroft   212: .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
                    213:
1.115     mycroft   214: __proginstall: .USE
1.139     tv        215:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.160     perry     216:                ${STRIPFLAG} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   217:
1.172     lukem     218: .if ${MKUPDATE} == "no"
1.154     mycroft   219: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    220: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    221: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    222: .endif
                    223: .else
                    224: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     225: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  226: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    227: .endif
1.154     mycroft   228: .endif
1.23      mycroft   229: .endif
                    230:
1.74      mycroft   231: .if !target(proginstall)
                    232: proginstall::
                    233: .endif
                    234:
                    235: .if defined(SCRIPTS) && !target(scriptsinstall)
1.65      mycroft   236: SCRIPTSDIR?=${BINDIR}
                    237: SCRIPTSOWN?=${BINOWN}
                    238: SCRIPTSGRP?=${BINGRP}
                    239: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   240:
                    241: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   242: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   243:
1.115     mycroft   244: __scriptinstall: .USE
1.139     tv        245:        ${INSTALL_FILE} \
1.116     mycroft   246:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    247:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    248:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.160     perry     249:            ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   250:
1.130     sommerfe  251: .for S in ${SCRIPTS:O:u}
1.172     lukem     252: .if ${MKUPDATE} == "no"
1.154     mycroft   253: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    254: .if !defined(BUILD) && !make(all) && !make(${S})
                    255: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    256: .endif
                    257: .else
                    258: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     259: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   260: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  261: .endif
1.154     mycroft   262: .endif
1.63      christos  263: .endfor
1.14      mycroft   264: .endif
1.1       cgd       265:
1.74      mycroft   266: .if !target(scriptsinstall)
                    267: scriptsinstall::
1.1       cgd       268: .endif
                    269:
1.52      cgd       270: lint: ${LOBJS}
                    271: .if defined(LOBJS) && !empty(LOBJS)
1.90      cgd       272:        ${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       273: .endif
                    274:
1.138     tv        275: ##### Pull in related .mk logic
1.1       cgd       276: .include <bsd.man.mk>
1.50      jtc       277: .include <bsd.nls.mk>
1.66      christos  278: .include <bsd.files.mk>
1.63      christos  279: .include <bsd.inc.mk>
1.83      mycroft   280: .include <bsd.links.mk>
1.180     lukem     281: .include <bsd.sys.mk>
1.26      mycroft   282: .include <bsd.dep.mk>
1.88      mycroft   283:
1.138     tv        284: ${TARGETS}:    # ensure existence
1.166     lukem     285:
                    286: .endif # HOSTPROG

CVSweb <webmaster@jp.NetBSD.org>