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

1.159   ! thorpej     1: #      $NetBSD: bsd.prog.mk,v 1.158 2002/09/26 13:05:56 itojun Exp $
1.67      mikel       2: #      @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
1.1       cgd         3:
1.138     tv          4: .include <bsd.init.mk>
1.159   ! thorpej     5: .include <bsd.shlib.mk>
1.74      mycroft     6:
1.138     tv          7: ##### Basic targets
1.148     enami       8: .PHONY:                cleanextra cleanobjs cleanprog proginstall scriptsinstall
1.80      mycroft     9: realinstall:   proginstall scriptsinstall
1.132     tv         10: clean:         cleanprog
1.1       cgd        11:
1.138     tv         12: ##### Default values
1.142     thorpej    13: CPPFLAGS+=     ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.143     tv         14: CXXFLAGS+=     ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++}
1.25      mycroft    15: CFLAGS+=       ${COPTS}
1.155     eeh        16: .if ${MACHINE_ARCH} == "sparc64"
                     17: CFLAGS+=       -mcmodel=medlow
                     18: .endif
1.1       cgd        19:
1.69      thorpej    20: # ELF platforms depend on crtbegin.o and crtend.o
1.100     lukem      21: .if ${OBJECT_FMT} == "ELF"
1.153     pk         22: .ifndef LIBCRTBEGIN
                     23: LIBCRTBEGIN=   ${DESTDIR}/usr/lib/crtbegin.o
1.152     christos   24: .MADE: ${LIBCRTBEGIN}
1.153     pk         25: .endif
                     26: .ifndef LIBCRTEND
                     27: LIBCRTEND=     ${DESTDIR}/usr/lib/crtend.o
1.152     christos   28: .MADE: ${LIBCRTEND}
1.153     pk         29: .endif
1.144     lukem      30: _SHLINKER=     ${SHLINKDIR}/ld.elf_so
1.69      thorpej    31: .else
                     32: LIBCRTBEGIN?=
                     33: LIBCRTEND?=
1.144     lukem      34: _SHLINKER=     ${SHLINKDIR}/ld.so
1.69      thorpej    35: .endif
                     36:
1.153     pk         37: .ifndef LIBCRT0
                     38: LIBCRT0=       ${DESTDIR}/usr/lib/crt0.o
1.152     christos   39: .MADE: ${LIBCRT0}
1.153     pk         40: .endif
1.95      ross       41:
1.153     pk         42: ##### Installed system library definitions
                     43: #     E.g. LIBC?=${DESTDIR}/usr/lib/libc.a
                     44: #     etc..
                     45: #
                     46: __bsd_prog_mk_system_libs?= \
1.158     itojun     47:        BZ2 C C_PIC CDK COM_ERR COMPAT CRYPT CRYPTO CRYPTO_IDEA CRYPTO_MDC2 \
                     48:        CRYPTO_RC5 \
1.153     pk         49:        CURSES DBM DES EDIT FORM GCC GNUMALLOC GSSAPI HDB INTL IPSEC \
                     50:        KADM KADM5CLNT KADM5SRV KAFS KDB KRB KRB5 KSTREAM KVM L M MENU \
1.156     thorpej    51:        OBJC OSSAUDIO PCAP PCI PMC POSIX RESOLV RMT ROKEN RPCSVC SKEY SS SSL \
                     52:        SL TERMCAP TELNET USBHID UTIL WRAP Y Z
1.153     pk         53:
                     54: .for _n in ${__bsd_prog_mk_system_libs}
                     55: .ifndef LIB${_n}
                     56: LIB${_n}= ${DESTDIR}/usr/lib/lib${_n:tl}.a
                     57: # XXX - note that ${DESTDIR} will expanded in the following rule
                     58: .MADE: ${LIB${_n}}
                     59: .endif
                     60: .endfor
                     61: .undef __bsd_prog_mk_system_libs
1.1       cgd        62:
1.138     tv         63: ##### Build and install rules
1.1       cgd        64: .if defined(SHAREDSTRINGS)
                     65: CLEANFILES+=strings
                     66: .c.o:
                     67:        ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
                     68:        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
                     69:        @rm -f x.c
1.18      mycroft    70:
                     71: .cc.o:
                     72:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                     73:        @mv -f x.c x.cc
                     74:        @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
1.26      mycroft    75:        @rm -f x.cc
1.18      mycroft    76:
                     77: .C.o:
                     78:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                     79:        @mv -f x.c x.C
                     80:        @${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
1.26      mycroft    81:        @rm -f x.C
1.1       cgd        82: .endif
                     83:
1.146     thorpej    84: .if defined(PROG_CXX)
                     85: PROG=  ${PROG_CXX}
                     86: .endif
1.38      jtc        87:
1.1       cgd        88: .if defined(PROG)
1.146     thorpej    89: .if defined(PROG_CXX)
                     90: SRCS?=         ${PROG}.cc
                     91: .else
1.80      mycroft    92: SRCS?=         ${PROG}.c
1.146     thorpej    93: .endif
1.80      mycroft    94:
1.141     tv         95: DPSRCS+=       ${SRCS:M*.[ly]:C/\..$/.c/}
1.137     tv         96: CLEANFILES+=   ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.80      mycroft    97:
1.108     eeh        98: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                     99: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft   100: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd       101: .endif
1.1       cgd       102:
1.47      cgd       103: .if defined(OBJS) && !empty(OBJS)
1.141     tv        104: .NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.137     tv        105:
1.144     lukem     106: _PROGLDOPTS=
                    107: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
                    108: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
                    109: .endif
                    110: .if ${SHLIBDIR} != ${LIBDIR}
                    111: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
                    112:                -Wl,-rpath,${SHLIBDIR}:/usr/lib \
                    113:                -L${DESTDIR}${SHLIBDIR}
1.159   ! thorpej   114: .elif ${SHLIBINSTALLDIR} != ${LIBDIR}
        !           115: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
        !           116:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     117: .endif
                    118:
1.145     thorpej   119: .if defined(PROG_CXX)
                    120: _CCLINK=       ${CXX}
                    121: _SUPCXX=       -lstdc++ -lm
                    122: .else
                    123: _CCLINK=       ${CC}
                    124: .endif
                    125:
1.157     thorpej   126: .gdbinit:
                    127:        rm -f .gdbinit
                    128: .if defined(DESTDIR) && !empty(DESTDIR)
                    129:        echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
                    130: .else
                    131:        touch .gdbinit
                    132: .endif
                    133: .for __gdbinit in ${GDBINIT}
                    134:        echo "source ${__gdbinit}" >> .gdbinit
                    135: .endfor
                    136:
1.86      cjs       137: .if defined(DESTDIR)
                    138:
1.157     thorpej   139: ${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  140: .if !commands(${PROG})
1.145     thorpej   141:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
1.125     christos  142: .endif
1.4       nate      143:
1.46      mycroft   144: .else
1.86      cjs       145:
1.157     thorpej   146: ${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  147: .if !commands(${PROG})
1.145     thorpej   148:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.125     christos  149: .endif
1.1       cgd       150:
1.86      cjs       151: .endif # defined(DESTDIR)
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
                    176:        @(TMP=/tmp/_depend$$$$; \
                    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} \
                    190:                ${STRIPFLAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   191:
1.154     mycroft   192: .if !defined(UPDATE)
                    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.115     mycroft   223:            ${.ALLSRC} ${.TARGET}
                    224:
1.130     sommerfe  225: .for S in ${SCRIPTS:O:u}
1.154     mycroft   226: .if !defined(UPDATE)
                    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.26      mycroft   255: .include <bsd.dep.mk>
1.54      christos  256: .include <bsd.sys.mk>
1.88      mycroft   257:
1.138     tv        258: ${TARGETS}:    # ensure existence

CVSweb <webmaster@jp.NetBSD.org>