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

1.156   ! thorpej     1: #      $NetBSD: bsd.prog.mk,v 1.155 2002/03/27 05:40:54 eeh 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.74      mycroft     5:
1.138     tv          6: ##### Basic targets
1.148     enami       7: .PHONY:                cleanextra cleanobjs cleanprog proginstall scriptsinstall
1.80      mycroft     8: realinstall:   proginstall scriptsinstall
1.132     tv          9: clean:         cleanprog
1.1       cgd        10:
1.138     tv         11: ##### Default values
1.142     thorpej    12: CPPFLAGS+=     ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.143     tv         13: CXXFLAGS+=     ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++}
1.25      mycroft    14: CFLAGS+=       ${COPTS}
1.155     eeh        15: .if ${MACHINE_ARCH} == "sparc64"
                     16: CFLAGS+=       -mcmodel=medlow
                     17: .endif
1.1       cgd        18:
1.69      thorpej    19: # ELF platforms depend on crtbegin.o and crtend.o
1.100     lukem      20: .if ${OBJECT_FMT} == "ELF"
1.153     pk         21: .ifndef LIBCRTBEGIN
                     22: LIBCRTBEGIN=   ${DESTDIR}/usr/lib/crtbegin.o
1.152     christos   23: .MADE: ${LIBCRTBEGIN}
1.153     pk         24: .endif
                     25: .ifndef LIBCRTEND
                     26: LIBCRTEND=     ${DESTDIR}/usr/lib/crtend.o
1.152     christos   27: .MADE: ${LIBCRTEND}
1.153     pk         28: .endif
1.144     lukem      29: _SHLINKER=     ${SHLINKDIR}/ld.elf_so
1.69      thorpej    30: .else
                     31: LIBCRTBEGIN?=
                     32: LIBCRTEND?=
1.144     lukem      33: _SHLINKER=     ${SHLINKDIR}/ld.so
1.69      thorpej    34: .endif
                     35:
1.153     pk         36: .ifndef LIBCRT0
                     37: LIBCRT0=       ${DESTDIR}/usr/lib/crt0.o
1.152     christos   38: .MADE: ${LIBCRT0}
1.153     pk         39: .endif
1.95      ross       40:
1.153     pk         41: ##### Installed system library definitions
                     42: #     E.g. LIBC?=${DESTDIR}/usr/lib/libc.a
                     43: #     etc..
                     44: #
                     45: __bsd_prog_mk_system_libs?= \
                     46:        BZ2 C C_PIC CDK COM_ERR COMPAT CRYPT CRYPTO CRYPTO_RC5 CRYPTO_IDEA \
                     47:        CURSES DBM DES EDIT FORM GCC GNUMALLOC GSSAPI HDB INTL IPSEC \
                     48:        KADM KADM5CLNT KADM5SRV KAFS KDB KRB KRB5 KSTREAM KVM L M MENU \
1.156   ! thorpej    49:        OBJC OSSAUDIO PCAP PCI PMC POSIX RESOLV RMT ROKEN RPCSVC SKEY SS SSL \
        !            50:        SL TERMCAP TELNET USBHID UTIL WRAP Y Z
1.153     pk         51:
                     52: .for _n in ${__bsd_prog_mk_system_libs}
                     53: .ifndef LIB${_n}
                     54: LIB${_n}= ${DESTDIR}/usr/lib/lib${_n:tl}.a
                     55: # XXX - note that ${DESTDIR} will expanded in the following rule
                     56: .MADE: ${LIB${_n}}
                     57: .endif
                     58: .endfor
                     59: .undef __bsd_prog_mk_system_libs
1.1       cgd        60:
1.138     tv         61: ##### Build and install rules
1.1       cgd        62: .if defined(SHAREDSTRINGS)
                     63: CLEANFILES+=strings
                     64: .c.o:
                     65:        ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
                     66:        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
                     67:        @rm -f x.c
1.18      mycroft    68:
                     69: .cc.o:
                     70:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                     71:        @mv -f x.c x.cc
                     72:        @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
1.26      mycroft    73:        @rm -f x.cc
1.18      mycroft    74:
                     75: .C.o:
                     76:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                     77:        @mv -f x.c x.C
                     78:        @${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
1.26      mycroft    79:        @rm -f x.C
1.1       cgd        80: .endif
                     81:
1.146     thorpej    82: .if defined(PROG_CXX)
                     83: PROG=  ${PROG_CXX}
                     84: .endif
1.38      jtc        85:
1.1       cgd        86: .if defined(PROG)
1.146     thorpej    87: .if defined(PROG_CXX)
                     88: SRCS?=         ${PROG}.cc
                     89: .else
1.80      mycroft    90: SRCS?=         ${PROG}.c
1.146     thorpej    91: .endif
1.80      mycroft    92:
1.141     tv         93: DPSRCS+=       ${SRCS:M*.[ly]:C/\..$/.c/}
1.137     tv         94: CLEANFILES+=   ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.80      mycroft    95:
1.108     eeh        96: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                     97: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft    98: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd        99: .endif
1.1       cgd       100:
1.47      cgd       101: .if defined(OBJS) && !empty(OBJS)
1.141     tv        102: .NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.137     tv        103:
1.144     lukem     104: _PROGLDOPTS=
                    105: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
                    106: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
                    107: .endif
                    108: .if ${SHLIBDIR} != ${LIBDIR}
                    109: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
                    110:                -Wl,-rpath,${SHLIBDIR}:/usr/lib \
                    111:                -L${DESTDIR}${SHLIBDIR}
                    112: .endif
                    113:
1.145     thorpej   114: .if defined(PROG_CXX)
                    115: _CCLINK=       ${CXX}
                    116: _SUPCXX=       -lstdc++ -lm
                    117: .else
                    118: _CCLINK=       ${CC}
                    119: .endif
                    120:
1.86      cjs       121: .if defined(DESTDIR)
                    122:
1.80      mycroft   123: ${PROG}: ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  124: .if !commands(${PROG})
1.145     thorpej   125:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
1.125     christos  126: .endif
1.4       nate      127:
1.46      mycroft   128: .else
1.86      cjs       129:
1.80      mycroft   130: ${PROG}: ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  131: .if !commands(${PROG})
1.145     thorpej   132:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.125     christos  133: .endif
1.1       cgd       134:
1.86      cjs       135: .endif # defined(DESTDIR)
1.47      cgd       136: .endif # defined(OBJS) && !empty(OBJS)
1.1       cgd       137:
1.100     lukem     138: .if !defined(MAN)
1.49      cgd       139: MAN=   ${PROG}.1
                    140: .endif # !defined(MAN)
                    141: .endif # defined(PROG)
1.11      mycroft   142:
1.107     mycroft   143: realall: ${PROG} ${SCRIPTS}
1.1       cgd       144:
1.134     tls       145: cleanprog: cleanobjs cleanextra
                    146:        rm -f a.out [Ee]rrs mklog core *.core ${PROG}
                    147:
                    148: cleanobjs:
1.135     lukem     149: .if defined(OBJS) && !empty(OBJS)
1.134     tls       150:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     151: .endif
1.134     tls       152:
                    153: cleanextra:
1.135     lukem     154: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       155:        rm -f ${CLEANFILES}
1.135     lukem     156: .endif
1.1       cgd       157:
1.129     jmc       158: .if defined(SRCS) && !target(afterdepend)
1.59      cgd       159: afterdepend: .depend
                    160:        @(TMP=/tmp/_depend$$$$; \
                    161:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
                    162:              < .depend > $$TMP; \
                    163:            mv $$TMP .depend)
                    164: .endif
1.27      mycroft   165:
1.74      mycroft   166: .if defined(PROG) && !target(proginstall)
1.114     mycroft   167: PROGNAME?=${PROG}
                    168:
1.63      christos  169: proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
1.114     mycroft   170: .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
                    171:
1.115     mycroft   172: __proginstall: .USE
1.139     tv        173:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
                    174:                ${STRIPFLAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   175:
1.154     mycroft   176: .if !defined(UPDATE)
                    177: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    178: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    179: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    180: .endif
                    181: .else
                    182: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     183: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  184: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    185: .endif
1.154     mycroft   186: .endif
1.23      mycroft   187: .endif
                    188:
1.74      mycroft   189: .if !target(proginstall)
                    190: proginstall::
                    191: .endif
                    192:
                    193: .if defined(SCRIPTS) && !target(scriptsinstall)
1.65      mycroft   194: SCRIPTSDIR?=${BINDIR}
                    195: SCRIPTSOWN?=${BINOWN}
                    196: SCRIPTSGRP?=${BINGRP}
                    197: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   198:
                    199: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   200: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   201:
1.115     mycroft   202: __scriptinstall: .USE
1.139     tv        203:        ${INSTALL_FILE} \
1.116     mycroft   204:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    205:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    206:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.115     mycroft   207:            ${.ALLSRC} ${.TARGET}
                    208:
1.130     sommerfe  209: .for S in ${SCRIPTS:O:u}
1.154     mycroft   210: .if !defined(UPDATE)
                    211: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    212: .if !defined(BUILD) && !make(all) && !make(${S})
                    213: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    214: .endif
                    215: .else
                    216: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     217: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   218: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  219: .endif
1.154     mycroft   220: .endif
1.63      christos  221: .endfor
1.14      mycroft   222: .endif
1.1       cgd       223:
1.74      mycroft   224: .if !target(scriptsinstall)
                    225: scriptsinstall::
1.1       cgd       226: .endif
                    227:
1.52      cgd       228: lint: ${LOBJS}
                    229: .if defined(LOBJS) && !empty(LOBJS)
1.90      cgd       230:        ${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       231: .endif
                    232:
1.138     tv        233: ##### Pull in related .mk logic
1.1       cgd       234: .include <bsd.man.mk>
1.50      jtc       235: .include <bsd.nls.mk>
1.66      christos  236: .include <bsd.files.mk>
1.63      christos  237: .include <bsd.inc.mk>
1.83      mycroft   238: .include <bsd.links.mk>
1.26      mycroft   239: .include <bsd.dep.mk>
1.54      christos  240: .include <bsd.sys.mk>
1.88      mycroft   241:
1.138     tv        242: ${TARGETS}:    # ensure existence

CVSweb <webmaster@jp.NetBSD.org>