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

1.181   ! lukem       1: #      $NetBSD: bsd.prog.mk,v 1.180 2003/07/31 13:47:32 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.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.164     uwe        60: # XXX - note that ${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.1       cgd        65:
1.138     tv         66: ##### Build and install rules
1.1       cgd        67: .if defined(SHAREDSTRINGS)
                     68: CLEANFILES+=strings
                     69: .c.o:
                     70:        ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
                     71:        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
                     72:        @rm -f x.c
1.18      mycroft    73:
1.173     lukem      74: .cc.o .cpp.o .cxx.o .C.o:
1.18      mycroft    75:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                     76:        @mv -f x.c x.cc
                     77:        @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
1.26      mycroft    78:        @rm -f x.cc
1.1       cgd        79: .endif
                     80:
1.146     thorpej    81: .if defined(PROG_CXX)
                     82: PROG=  ${PROG_CXX}
                     83: .endif
1.38      jtc        84:
1.1       cgd        85: .if defined(PROG)
1.146     thorpej    86: .if defined(PROG_CXX)
                     87: SRCS?=         ${PROG}.cc
                     88: .else
1.80      mycroft    89: SRCS?=         ${PROG}.c
1.146     thorpej    90: .endif
1.80      mycroft    91:
1.178     lukem      92: DPSRCS+=       ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
1.137     tv         93: CLEANFILES+=   ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.80      mycroft    94:
1.108     eeh        95: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                     96: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft    97: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd        98: .endif
1.1       cgd        99:
1.47      cgd       100: .if defined(OBJS) && !empty(OBJS)
1.141     tv        101: .NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.137     tv        102:
1.144     lukem     103: _PROGLDOPTS=
                    104: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
1.161     itohy     105: .if ${OBJECT_FMT} == "ELF"
1.144     lukem     106: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
1.161     itohy     107: .endif
                    108: .if ${OBJECT_FMT} == "a.out"
                    109: LIBCRT0=       ${DESTDIR}/lib/crt0.o
                    110: .endif
1.144     lukem     111: .endif
                    112: .if ${SHLIBDIR} != ${LIBDIR}
                    113: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
1.179     lukem     114:                -R${SHLIBDIR} \
1.144     lukem     115:                -L${DESTDIR}${SHLIBDIR}
1.159     thorpej   116: .elif ${SHLIBINSTALLDIR} != ${LIBDIR}
                    117: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    118:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     119: .endif
                    120:
1.145     thorpej   121: .if defined(PROG_CXX)
                    122: _CCLINK=       ${CXX}
1.177     lukem     123: .if ${USE_LIBSTDCXX} == "no"
1.174     mrg       124: _SUPCXX=       -lsupc++ -lm
                    125: .else
1.145     thorpej   126: _SUPCXX=       -lstdc++ -lm
1.174     mrg       127: .endif
1.145     thorpej   128: .else
                    129: _CCLINK=       ${CC}
                    130: .endif
                    131:
1.157     thorpej   132: .gdbinit:
                    133:        rm -f .gdbinit
                    134: .if defined(DESTDIR) && !empty(DESTDIR)
                    135:        echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
                    136: .else
                    137:        touch .gdbinit
                    138: .endif
                    139: .for __gdbinit in ${GDBINIT}
                    140:        echo "source ${__gdbinit}" >> .gdbinit
                    141: .endfor
                    142:
                    143: ${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  144: .if !commands(${PROG})
1.181   ! lukem     145: .if defined(DESTDIR)
1.167     thorpej   146:        ${_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   147: .else
1.145     thorpej   148:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.181   ! lukem     149: .endif # defined(DESTDIR)
        !           150: .endif # !commands(${PROG})
1.1       cgd       151:
1.47      cgd       152: .endif # defined(OBJS) && !empty(OBJS)
1.1       cgd       153:
1.100     lukem     154: .if !defined(MAN)
1.49      cgd       155: MAN=   ${PROG}.1
                    156: .endif # !defined(MAN)
                    157: .endif # defined(PROG)
1.11      mycroft   158:
1.107     mycroft   159: realall: ${PROG} ${SCRIPTS}
1.1       cgd       160:
1.134     tls       161: cleanprog: cleanobjs cleanextra
1.157     thorpej   162:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG}
1.134     tls       163:
                    164: cleanobjs:
1.135     lukem     165: .if defined(OBJS) && !empty(OBJS)
1.134     tls       166:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     167: .endif
1.134     tls       168:
                    169: cleanextra:
1.135     lukem     170: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       171:        rm -f ${CLEANFILES}
1.135     lukem     172: .endif
1.1       cgd       173:
1.129     jmc       174: .if defined(SRCS) && !target(afterdepend)
1.59      cgd       175: afterdepend: .depend
1.168     msaitoh   176:        @(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
1.59      cgd       177:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
                    178:              < .depend > $$TMP; \
                    179:            mv $$TMP .depend)
                    180: .endif
1.27      mycroft   181:
1.74      mycroft   182: .if defined(PROG) && !target(proginstall)
1.114     mycroft   183: PROGNAME?=${PROG}
                    184:
1.63      christos  185: proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
1.114     mycroft   186: .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
                    187:
1.115     mycroft   188: __proginstall: .USE
1.139     tv        189:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.160     perry     190:                ${STRIPFLAG} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   191:
1.172     lukem     192: .if ${MKUPDATE} == "no"
1.154     mycroft   193: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    194: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    195: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    196: .endif
                    197: .else
                    198: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     199: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  200: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    201: .endif
1.154     mycroft   202: .endif
1.23      mycroft   203: .endif
                    204:
1.74      mycroft   205: .if !target(proginstall)
                    206: proginstall::
                    207: .endif
                    208:
                    209: .if defined(SCRIPTS) && !target(scriptsinstall)
1.65      mycroft   210: SCRIPTSDIR?=${BINDIR}
                    211: SCRIPTSOWN?=${BINOWN}
                    212: SCRIPTSGRP?=${BINGRP}
                    213: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   214:
                    215: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   216: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   217:
1.115     mycroft   218: __scriptinstall: .USE
1.139     tv        219:        ${INSTALL_FILE} \
1.116     mycroft   220:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    221:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    222:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.160     perry     223:            ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   224:
1.130     sommerfe  225: .for S in ${SCRIPTS:O:u}
1.172     lukem     226: .if ${MKUPDATE} == "no"
1.154     mycroft   227: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    228: .if !defined(BUILD) && !make(all) && !make(${S})
                    229: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    230: .endif
                    231: .else
                    232: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     233: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   234: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  235: .endif
1.154     mycroft   236: .endif
1.63      christos  237: .endfor
1.14      mycroft   238: .endif
1.1       cgd       239:
1.74      mycroft   240: .if !target(scriptsinstall)
                    241: scriptsinstall::
1.1       cgd       242: .endif
                    243:
1.52      cgd       244: lint: ${LOBJS}
                    245: .if defined(LOBJS) && !empty(LOBJS)
1.90      cgd       246:        ${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       247: .endif
                    248:
1.138     tv        249: ##### Pull in related .mk logic
1.1       cgd       250: .include <bsd.man.mk>
1.50      jtc       251: .include <bsd.nls.mk>
1.66      christos  252: .include <bsd.files.mk>
1.63      christos  253: .include <bsd.inc.mk>
1.83      mycroft   254: .include <bsd.links.mk>
1.180     lukem     255: .include <bsd.sys.mk>
1.26      mycroft   256: .include <bsd.dep.mk>
1.88      mycroft   257:
1.138     tv        258: ${TARGETS}:    # ensure existence
1.166     lukem     259:
                    260: .endif # HOSTPROG

CVSweb <webmaster@jp.NetBSD.org>