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

1.162   ! thorpej     1: #      $NetBSD: bsd.prog.mk,v 1.161 2002/11/12 14:33:49 itohy 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.162   ! thorpej    20: # ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o
1.100     lukem      21: .if ${OBJECT_FMT} == "ELF"
1.153     pk         22: .ifndef LIBCRTBEGIN
1.162   ! thorpej    23: LIBCRTBEGIN=   ${DESTDIR}/usr/lib/crti.o ${DESTDIR}/usr/lib/crtbegin.o
1.152     christos   24: .MADE: ${LIBCRTBEGIN}
1.153     pk         25: .endif
                     26: .ifndef LIBCRTEND
1.162   ! thorpej    27: LIBCRTEND=     ${DESTDIR}/usr/lib/crtend.o ${DESTDIR}/usr/lib/crtn.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
1.161     itohy     108: .if ${OBJECT_FMT} == "ELF"
1.144     lukem     109: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
1.161     itohy     110: .endif
                    111: .if ${OBJECT_FMT} == "a.out"
                    112: LIBCRT0=       ${DESTDIR}/lib/crt0.o
                    113: .endif
1.144     lukem     114: .endif
                    115: .if ${SHLIBDIR} != ${LIBDIR}
                    116: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
                    117:                -Wl,-rpath,${SHLIBDIR}:/usr/lib \
                    118:                -L${DESTDIR}${SHLIBDIR}
1.159     thorpej   119: .elif ${SHLIBINSTALLDIR} != ${LIBDIR}
                    120: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    121:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     122: .endif
                    123:
1.145     thorpej   124: .if defined(PROG_CXX)
                    125: _CCLINK=       ${CXX}
                    126: _SUPCXX=       -lstdc++ -lm
                    127: .else
                    128: _CCLINK=       ${CC}
                    129: .endif
                    130:
1.157     thorpej   131: .gdbinit:
                    132:        rm -f .gdbinit
                    133: .if defined(DESTDIR) && !empty(DESTDIR)
                    134:        echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
                    135: .else
                    136:        touch .gdbinit
                    137: .endif
                    138: .for __gdbinit in ${GDBINIT}
                    139:        echo "source ${__gdbinit}" >> .gdbinit
                    140: .endfor
                    141:
1.86      cjs       142: .if defined(DESTDIR)
                    143:
1.157     thorpej   144: ${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  145: .if !commands(${PROG})
1.145     thorpej   146:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
1.125     christos  147: .endif
1.4       nate      148:
1.46      mycroft   149: .else
1.86      cjs       150:
1.157     thorpej   151: ${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  152: .if !commands(${PROG})
1.145     thorpej   153:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.125     christos  154: .endif
1.1       cgd       155:
1.86      cjs       156: .endif # defined(DESTDIR)
1.47      cgd       157: .endif # defined(OBJS) && !empty(OBJS)
1.1       cgd       158:
1.100     lukem     159: .if !defined(MAN)
1.49      cgd       160: MAN=   ${PROG}.1
                    161: .endif # !defined(MAN)
                    162: .endif # defined(PROG)
1.11      mycroft   163:
1.107     mycroft   164: realall: ${PROG} ${SCRIPTS}
1.1       cgd       165:
1.134     tls       166: cleanprog: cleanobjs cleanextra
1.157     thorpej   167:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG}
1.134     tls       168:
                    169: cleanobjs:
1.135     lukem     170: .if defined(OBJS) && !empty(OBJS)
1.134     tls       171:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     172: .endif
1.134     tls       173:
                    174: cleanextra:
1.135     lukem     175: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       176:        rm -f ${CLEANFILES}
1.135     lukem     177: .endif
1.1       cgd       178:
1.129     jmc       179: .if defined(SRCS) && !target(afterdepend)
1.59      cgd       180: afterdepend: .depend
                    181:        @(TMP=/tmp/_depend$$$$; \
                    182:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
                    183:              < .depend > $$TMP; \
                    184:            mv $$TMP .depend)
                    185: .endif
1.27      mycroft   186:
1.74      mycroft   187: .if defined(PROG) && !target(proginstall)
1.114     mycroft   188: PROGNAME?=${PROG}
                    189:
1.63      christos  190: proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
1.114     mycroft   191: .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
                    192:
1.115     mycroft   193: __proginstall: .USE
1.139     tv        194:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.160     perry     195:                ${STRIPFLAG} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   196:
1.154     mycroft   197: .if !defined(UPDATE)
                    198: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    199: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    200: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    201: .endif
                    202: .else
                    203: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     204: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  205: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    206: .endif
1.154     mycroft   207: .endif
1.23      mycroft   208: .endif
                    209:
1.74      mycroft   210: .if !target(proginstall)
                    211: proginstall::
                    212: .endif
                    213:
                    214: .if defined(SCRIPTS) && !target(scriptsinstall)
1.65      mycroft   215: SCRIPTSDIR?=${BINDIR}
                    216: SCRIPTSOWN?=${BINOWN}
                    217: SCRIPTSGRP?=${BINGRP}
                    218: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   219:
                    220: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   221: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   222:
1.115     mycroft   223: __scriptinstall: .USE
1.139     tv        224:        ${INSTALL_FILE} \
1.116     mycroft   225:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    226:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    227:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.160     perry     228:            ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   229:
1.130     sommerfe  230: .for S in ${SCRIPTS:O:u}
1.154     mycroft   231: .if !defined(UPDATE)
                    232: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    233: .if !defined(BUILD) && !make(all) && !make(${S})
                    234: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    235: .endif
                    236: .else
                    237: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     238: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   239: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  240: .endif
1.154     mycroft   241: .endif
1.63      christos  242: .endfor
1.14      mycroft   243: .endif
1.1       cgd       244:
1.74      mycroft   245: .if !target(scriptsinstall)
                    246: scriptsinstall::
1.1       cgd       247: .endif
                    248:
1.52      cgd       249: lint: ${LOBJS}
                    250: .if defined(LOBJS) && !empty(LOBJS)
1.90      cgd       251:        ${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       252: .endif
                    253:
1.138     tv        254: ##### Pull in related .mk logic
1.1       cgd       255: .include <bsd.man.mk>
1.50      jtc       256: .include <bsd.nls.mk>
1.66      christos  257: .include <bsd.files.mk>
1.63      christos  258: .include <bsd.inc.mk>
1.83      mycroft   259: .include <bsd.links.mk>
1.26      mycroft   260: .include <bsd.dep.mk>
1.54      christos  261: .include <bsd.sys.mk>
1.88      mycroft   262:
1.138     tv        263: ${TARGETS}:    # ensure existence

CVSweb <webmaster@jp.NetBSD.org>