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

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

CVSweb <webmaster@jp.NetBSD.org>