version 1.2, 1993/03/22 08:09:40 |
version 1.157, 2002/09/08 03:59:02 |
|
|
# @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 |
# $NetBSD$ |
|
# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 |
|
|
.if exists(${.CURDIR}/../Makefile.inc) |
.include <bsd.init.mk> |
.include "${.CURDIR}/../Makefile.inc" |
|
.endif |
|
|
|
.SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0 |
|
|
|
.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0: |
##### Basic targets |
nroff -mandoc ${.IMPSRC} > ${.TARGET} |
.PHONY: cleanextra cleanobjs cleanprog proginstall scriptsinstall |
|
realinstall: proginstall scriptsinstall |
CFLAGS+=${COPTS} |
clean: cleanprog |
|
|
STRIP?= -s |
##### Default values |
|
CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include} |
BINGRP?= bin |
CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++} |
BINOWN?= bin |
CFLAGS+= ${COPTS} |
BINMODE?= 555 |
.if ${MACHINE_ARCH} == "sparc64" |
|
CFLAGS+= -mcmodel=medlow |
LIBC?= /usr/lib/libc.a |
.endif |
LIBCOMPAT?= /usr/lib/libcompat.a |
|
LIBCURSES?= /usr/lib/libcurses.a |
# ELF platforms depend on crtbegin.o and crtend.o |
LIBDBM?= /usr/lib/libdbm.a |
.if ${OBJECT_FMT} == "ELF" |
LIBDES?= /usr/lib/libdes.a |
.ifndef LIBCRTBEGIN |
LIBL?= /usr/lib/libl.a |
LIBCRTBEGIN= ${DESTDIR}/usr/lib/crtbegin.o |
LIBKDB?= /usr/lib/libkdb.a |
.MADE: ${LIBCRTBEGIN} |
LIBKRB?= /usr/lib/libkrb.a |
.endif |
LIBM?= /usr/lib/libm.a |
.ifndef LIBCRTEND |
LIBMP?= /usr/lib/libmp.a |
LIBCRTEND= ${DESTDIR}/usr/lib/crtend.o |
LIBPC?= /usr/lib/libpc.a |
.MADE: ${LIBCRTEND} |
LIBPLOT?= /usr/lib/libplot.a |
.endif |
LIBRESOLV?= /usr/lib/libresolv.a |
_SHLINKER= ${SHLINKDIR}/ld.elf_so |
LIBRPC?= /usr/lib/sunrpc.a |
.else |
LIBTERM?= /usr/lib/libterm.a |
LIBCRTBEGIN?= |
LIBUTIL?= /usr/lib/libutil.a |
LIBCRTEND?= |
|
_SHLINKER= ${SHLINKDIR}/ld.so |
|
.endif |
|
|
|
.ifndef LIBCRT0 |
|
LIBCRT0= ${DESTDIR}/usr/lib/crt0.o |
|
.MADE: ${LIBCRT0} |
|
.endif |
|
|
|
##### Installed system library definitions |
|
# E.g. LIBC?=${DESTDIR}/usr/lib/libc.a |
|
# etc.. |
|
# |
|
__bsd_prog_mk_system_libs?= \ |
|
BZ2 C C_PIC CDK COM_ERR COMPAT CRYPT CRYPTO CRYPTO_RC5 CRYPTO_IDEA \ |
|
CURSES DBM DES EDIT FORM GCC GNUMALLOC GSSAPI HDB INTL IPSEC \ |
|
KADM KADM5CLNT KADM5SRV KAFS KDB KRB KRB5 KSTREAM KVM L M MENU \ |
|
OBJC OSSAUDIO PCAP PCI PMC POSIX RESOLV RMT ROKEN RPCSVC SKEY SS SSL \ |
|
SL TERMCAP TELNET USBHID UTIL WRAP Y Z |
|
|
|
.for _n in ${__bsd_prog_mk_system_libs} |
|
.ifndef LIB${_n} |
|
LIB${_n}= ${DESTDIR}/usr/lib/lib${_n:tl}.a |
|
# XXX - note that ${DESTDIR} will expanded in the following rule |
|
.MADE: ${LIB${_n}} |
|
.endif |
|
.endfor |
|
.undef __bsd_prog_mk_system_libs |
|
|
|
##### Build and install rules |
.if defined(SHAREDSTRINGS) |
.if defined(SHAREDSTRINGS) |
CLEANFILES+=strings |
CLEANFILES+=strings |
.c.o: |
.c.o: |
${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c - |
${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c - |
@${CC} ${CFLAGS} -c x.c -o ${.TARGET} |
@${CC} ${CFLAGS} -c x.c -o ${.TARGET} |
@rm -f x.c |
@rm -f x.c |
.endif |
|
|
|
.if defined(PROG) |
.cc.o: |
.if defined(SRCS) |
${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c - |
|
@mv -f x.c x.cc |
OBJS+= ${SRCS:R:S/$/.o/g} |
@${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET} |
|
@rm -f x.cc |
|
|
|
.C.o: |
|
${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c - |
|
@mv -f x.c x.C |
|
@${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET} |
|
@rm -f x.C |
|
.endif |
|
|
${PROG}: ${OBJS} ${LIBC} ${DPADD} |
.if defined(PROG_CXX) |
${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} |
PROG= ${PROG_CXX} |
|
.endif |
|
|
.else defined(PROG) |
.if defined(PROG) |
|
.if defined(PROG_CXX) |
|
SRCS?= ${PROG}.cc |
|
.else |
|
SRCS?= ${PROG}.c |
|
.endif |
|
|
SRCS= ${PROG}.c |
DPSRCS+= ${SRCS:M*.[ly]:C/\..$/.c/} |
|
CLEANFILES+= ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}} |
|
|
${PROG}: ${SRCS} ${LIBC} ${DPADD} |
.if !empty(SRCS:N*.h:N*.sh:N*.fth) |
${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD} |
OBJS+= ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g} |
|
LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} |
|
.endif |
|
|
MKDEP= -p |
.if defined(OBJS) && !empty(OBJS) |
|
.NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} |
|
|
|
_PROGLDOPTS= |
|
.if ${SHLINKDIR} != "/usr/libexec" # XXX: change or remove if ld.so moves |
|
_PROGLDOPTS+= -Wl,-dynamic-linker=${_SHLINKER} |
|
.endif |
|
.if ${SHLIBDIR} != ${LIBDIR} |
|
_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \ |
|
-Wl,-rpath,${SHLIBDIR}:/usr/lib \ |
|
-L${DESTDIR}${SHLIBDIR} |
.endif |
.endif |
|
|
.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ |
.if defined(PROG_CXX) |
!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ |
_CCLINK= ${CXX} |
!defined(MAN7) && !defined(MAN8) && !defined(NOMAN) |
_SUPCXX= -lstdc++ -lm |
MAN1= ${PROG}.0 |
.else |
|
_CCLINK= ${CC} |
.endif |
.endif |
|
|
|
.gdbinit: |
|
rm -f .gdbinit |
|
.if defined(DESTDIR) && !empty(DESTDIR) |
|
echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit |
|
.else |
|
touch .gdbinit |
.endif |
.endif |
MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8} |
.for __gdbinit in ${GDBINIT} |
|
echo "source ${__gdbinit}" >> .gdbinit |
|
.endfor |
|
|
|
.if defined(DESTDIR) |
|
|
_PROGSUBDIR: .USE |
${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD} |
.if defined(SUBDIR) && !empty(SUBDIR) |
.if !commands(${PROG}) |
@for entry in ${SUBDIR}; do \ |
${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND} |
(echo "===> $$entry"; \ |
|
if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ |
|
cd ${.CURDIR}/$${entry}.${MACHINE}; \ |
|
else \ |
|
cd ${.CURDIR}/$${entry}; \ |
|
fi; \ |
|
${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \ |
|
done |
|
.endif |
.endif |
|
|
.MAIN: all |
.else |
all: ${PROG} ${MANALL} _PROGSUBDIR |
|
|
|
.if !target(clean) |
${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD} |
clean: _PROGSUBDIR |
.if !commands(${PROG}) |
rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES} |
${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD} |
.endif |
.endif |
|
|
.if !target(cleandir) |
.endif # defined(DESTDIR) |
cleandir: _PROGSUBDIR |
.endif # defined(OBJS) && !empty(OBJS) |
rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES} |
|
rm -f .depend ${MANALL} |
.if !defined(MAN) |
|
MAN= ${PROG}.1 |
|
.endif # !defined(MAN) |
|
.endif # defined(PROG) |
|
|
|
realall: ${PROG} ${SCRIPTS} |
|
|
|
cleanprog: cleanobjs cleanextra |
|
rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG} |
|
|
|
cleanobjs: |
|
.if defined(OBJS) && !empty(OBJS) |
|
rm -f ${OBJS} ${LOBJS} |
.endif |
.endif |
|
|
# some of the rules involve .h sources, so remove them from mkdep line |
cleanextra: |
.if !target(depend) |
.if defined(CLEANFILES) && !empty(CLEANFILES) |
depend: .depend _PROGSUBDIR |
rm -f ${CLEANFILES} |
.depend: ${SRCS} |
|
.if defined(PROG) |
|
mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c} |
|
.endif |
.endif |
|
|
|
.if defined(SRCS) && !target(afterdepend) |
|
afterdepend: .depend |
|
@(TMP=/tmp/_depend$$$$; \ |
|
sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \ |
|
< .depend > $$TMP; \ |
|
mv $$TMP .depend) |
.endif |
.endif |
|
|
.if !target(install) |
.if defined(PROG) && !target(proginstall) |
.if !target(beforeinstall) |
PROGNAME?=${PROG} |
beforeinstall: |
|
|
proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME} |
|
.PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME} |
|
|
|
__proginstall: .USE |
|
${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ |
|
${STRIPFLAG} ${.ALLSRC} ${.TARGET} |
|
|
|
.if !defined(UPDATE) |
|
${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall |
|
.if !defined(BUILD) && !make(all) && !make(${PROG}) |
|
${DESTDIR}${BINDIR}/${PROGNAME}! .MADE |
.endif |
.endif |
.if !target(afterinstall) |
.else |
afterinstall: |
${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall |
|
.if !defined(BUILD) && !make(all) && !make(${PROG}) |
|
${DESTDIR}${BINDIR}/${PROGNAME}: .MADE |
.endif |
.endif |
|
|
realinstall: _PROGSUBDIR |
|
.if defined(PROG) |
|
install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ |
|
${PROG} ${DESTDIR}${BINDIR} |
|
.endif |
.endif |
.if defined(HIDEGAME) |
|
(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ |
|
chown games.bin ${PROG}) |
|
.endif |
|
.if defined(LINKS) && !empty(LINKS) |
|
@set ${LINKS}; \ |
|
while test $$# -ge 2; do \ |
|
l=${DESTDIR}$$1; \ |
|
shift; \ |
|
t=${DESTDIR}$$1; \ |
|
shift; \ |
|
echo $$t -\> $$l; \ |
|
rm -f $$t; \ |
|
ln $$l $$t; \ |
|
done; true |
|
.endif |
|
|
|
install: maninstall |
|
maninstall: afterinstall |
|
afterinstall: realinstall |
|
realinstall: beforeinstall |
|
.endif |
.endif |
|
|
.if !target(lint) |
.if !target(proginstall) |
lint: ${SRCS} _PROGSUBDIR |
proginstall:: |
.if defined(PROG) |
|
@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 |
|
.endif |
|
.endif |
.endif |
|
|
.if !target(obj) |
.if defined(SCRIPTS) && !target(scriptsinstall) |
.if defined(NOOBJ) |
SCRIPTSDIR?=${BINDIR} |
obj: _PROGSUBDIR |
SCRIPTSOWN?=${BINOWN} |
.else |
SCRIPTSGRP?=${BINGRP} |
obj: _PROGSUBDIR |
SCRIPTSMODE?=${BINMODE} |
@cd ${.CURDIR}; \ |
|
here=`pwd`; subdir=`echo $$here | sed 's,^/usr/src/,,'`; \ |
scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@} |
if test $$here != $$subdir ; then \ |
.PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@} |
rm -rf obj; \ |
|
dest=/usr/obj/$$subdir ; \ |
__scriptinstall: .USE |
echo "$$here -> $$dest"; ln -s $$dest obj; \ |
${INSTALL_FILE} \ |
if test -d /usr/obj -a ! -d $$dest; then \ |
-o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \ |
mkdir -p $$dest; \ |
-g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \ |
else \ |
-m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \ |
true; \ |
${.ALLSRC} ${.TARGET} |
fi; \ |
|
else \ |
.for S in ${SCRIPTS:O:u} |
true ; \ |
.if !defined(UPDATE) |
dest=$$here/obj ; \ |
${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall |
/bin/rm -f $$dest 2> /dev/null || true; \ |
.if !defined(BUILD) && !make(all) && !make(${S}) |
echo "making $$here/obj" ; \ |
${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE |
if test ! -d obj ; then \ |
.endif |
mkdir $$here/obj; \ |
.else |
fi ; \ |
${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall |
fi; |
.if !defined(BUILD) && !make(all) && !make(${S}) |
|
${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE |
.endif |
.endif |
.endif |
.endif |
|
.endfor |
|
.endif |
|
|
.if !target(tags) |
.if !target(scriptsinstall) |
tags: ${SRCS} _PROGSUBDIR |
scriptsinstall:: |
.if defined(PROG) |
|
-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \ |
|
sed "s;\${.CURDIR}/;;" > tags |
|
.endif |
.endif |
|
|
|
lint: ${LOBJS} |
|
.if defined(LOBJS) && !empty(LOBJS) |
|
${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD} |
.endif |
.endif |
|
|
.if !defined(NOMAN) |
##### Pull in related .mk logic |
.include <bsd.man.mk> |
.include <bsd.man.mk> |
.endif |
.include <bsd.nls.mk> |
|
.include <bsd.files.mk> |
|
.include <bsd.inc.mk> |
|
.include <bsd.links.mk> |
|
.include <bsd.dep.mk> |
|
.include <bsd.sys.mk> |
|
|
|
${TARGETS}: # ensure existence |