bsd.prog.mk revision 14701
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $Id: bsd.prog.mk,v 1.28 1996/03/09 23:48:55 wosch Exp $ 3 4.if exists(${.CURDIR}/../Makefile.inc) 5.include "${.CURDIR}/../Makefile.inc" 6.endif 7 8.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S 9 10CFLAGS+=${COPTS} ${DEBUG_FLAGS} 11.if defined(DESTDIR) 12CFLAGS+= -I${DESTDIR}/usr/include 13CXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX} 14.endif 15 16.if !defined(DEBUG_FLAGS) 17STRIP?= -s 18.endif 19 20BINGRP?= bin 21BINOWN?= bin 22BINMODE?= 555 23 24LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o 25LIBKZHEAD?= ${DESTDIR}/usr/lib/kzhead.o 26LIBKZTAIL?= ${DESTDIR}/usr/lib/kztail.o 27 28LIBC?= ${DESTDIR}/usr/lib/libc.a 29LIBC_PIC= ${DESTDIR}/usr/lib/libc_pic.a 30LIBCOM_ERR= ${DESTDIR}/usr/lib/libcom_err.a 31LIBCOMPAT?= ${DESTDIR}/usr/lib/libcompat.a 32LIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a 33LIBCURSES?= ${DESTDIR}/usr/lib/libcurses.a 34LIBDES?= ${DESTDIR}/usr/lib/libdes.a # XXX doesn't exist 35LIBDIALOG?= ${DESTDIR}/usr/lib/libdialog.a 36LIBDISK?= ${DESTDIR}/usr/lib/libdisk.a 37LIBEDIT?= ${DESTDIR}/usr/lib/libedit.a 38LIBF2C?= ${DESTDIR}/usr/lib/libf2c.a 39LIBFL?= "don't use LIBFL, use LIBL" 40LIBFORMS?= ${DESTDIR}/usr/lib/libforms.a 41LIBGPLUSPLUS?= ${DESTDIR}/usr/lib/libg++.a 42LIBGCC?= ${DESTDIR}/usr/lib/libgcc.a 43LIBGCC_PIC?= ${DESTDIR}/usr/lib/libgcc_pic.a 44LIBGMP?= ${DESTDIR}/usr/lib/libgmp.a 45LIBGNUREGEX?= ${DESTDIR}/usr/lib/libgnuregex.a 46LIBIPX?= ${DESTDIR}/usr/lib/libipx.a 47LIBKDB?= ${DESTDIR}/usr/lib/libkdb.a # XXX doesn't exist 48LIBKRB?= ${DESTDIR}/usr/lib/libkrb.a # XXX doesn't exist 49LIBKEYCAP?= ${DESTDIR}/usr/lib/libkeycap.a 50LIBKVM?= ${DESTDIR}/usr/lib/libkvm.a 51LIBL?= ${DESTDIR}/usr/lib/libl.a 52LIBLN?= "don't use, LIBLN, use LIBL" 53LIBM?= ${DESTDIR}/usr/lib/libm.a 54LIBMD?= ${DESTDIR}/usr/lib/libmd.a 55LIBMP?= ${DESTDIR}/usr/lib/libmp.a 56LIBMYTINFO?= ${DESTDIR}/usr/lib/libmytinfo.a 57LIBNCURSES?= ${DESTDIR}/usr/lib/libncurses.a 58LIBPC?= ${DESTDIR}/usr/lib/libpc.a # XXX doesn't exist 59LIBPCAP?= ${DESTDIR}/usr/lib/libpcap.a 60LIBPLOT?= ${DESTDIR}/usr/lib/libplot.a # XXX doesn't exist 61LIBREADLINE?= ${DESTDIR}/usr/lib/libreadline.a 62LIBRESOLV?= ${DESTDIR}/usr/lib/libresolv.a 63LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a 64LIBSCRYPT?= "don't use LIBSCRYPT, use LIBCRYPT" 65LIBSCSI?= ${DESTDIR}/usr/lib/libscsi.a 66LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a 67LIBSS?= ${DESTDIR}/usr/lib/libss.a 68LIBTELNET?= ${DESTDIR}/usr/lib/libtelnet.a 69LIBTERMCAP?= ${DESTDIR}/usr/lib/libtermcap.a 70LIBTERMLIB?= "don't use LIBTERMLIB, use LIBTERMCAP" 71LIBUTIL?= ${DESTDIR}/usr/lib/libutil.a 72LIBXPG4?= ${DESTDIR}/usr/lib/libxpg4.a 73LIBY?= ${DESTDIR}/usr/lib/liby.a 74 75.if defined(NOSHARED) 76LDFLAGS+= -static 77.endif 78 79.if defined(DESTDIR) 80LDDESTDIR+= -L${DESTDIR}/usr/lib 81.endif 82 83.if defined(PROG) 84.if defined(SRCS) 85 86DPSRCS+= ${SRCS:M*.h} 87.if !defined(NOOBJ) 88OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 89.endif 90 91.if defined(LDONLY) 92 93${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD} 94 ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \ 95 ${LDADD} 96 97.else defined(LDONLY) 98 99${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD} 100 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 101 102.endif 103 104.else !defined(SRCS) 105 106SRCS= ${PROG}.c 107 108.if 0 109${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD} 110 ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \ 111 ${LDDESTDIR} ${LDADD} 112 113MKDEP= -p 114.else 115# Always make an intermediate object file because: 116# - it saves time rebuilding when only the library has changed 117# - the name of the object gets put into the executable symbol table instead of 118# the name of a variable temporary object. 119# - it's useful to keep objects around for crunching. 120OBJS= ${PROG}.o 121${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD} 122 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 123.endif 124 125.endif 126 127.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 128 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 129 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) 130MAN1= ${PROG}.1 131.endif 132.endif 133 134_PROGSUBDIR: .USE 135.if defined(SUBDIR) && !empty(SUBDIR) 136 @for entry in ${SUBDIR}; do \ 137 (${ECHODIR} "===> ${DIRPRFX}$$entry"; \ 138 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 139 cd ${.CURDIR}/$${entry}.${MACHINE}; \ 140 else \ 141 cd ${.CURDIR}/$${entry}; \ 142 fi; \ 143 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \ 144 done 145.endif 146 147# XXX I think MANDEPEND is only used for groff. It should be named more 148# generally and perhaps not be in the maninstall dependencies now it is 149# here (or does maninstall always work when nothing is made?), 150 151.MAIN: all 152all: ${PROG} all-man _PROGSUBDIR 153 154.if !target(clean) 155clean: _PROGSUBDIR 156 rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES} 157.endif 158 159.if !target(cleandir) 160cleandir: _PROGSUBDIR 161 rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES} 162 rm -f ${.CURDIR}/tags .depend 163 cd ${.CURDIR}; rm -rf obj; 164.endif 165 166.if !target(install) 167.if !target(beforeinstall) 168beforeinstall: 169.endif 170.if !target(afterinstall) 171afterinstall: 172.endif 173 174realinstall: _PROGSUBDIR 175.if defined(PROG) 176 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 177 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 178.endif 179.if defined(HIDEGAME) 180 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ 181 chown games.bin ${PROG}) 182.endif 183.if defined(LINKS) && !empty(LINKS) 184 @set ${LINKS}; \ 185 while test $$# -ge 2; do \ 186 l=${DESTDIR}$$1; \ 187 shift; \ 188 t=${DESTDIR}$$1; \ 189 shift; \ 190 ${ECHO} $$t -\> $$l; \ 191 rm -f $$t; \ 192 ln ${LN_FLAGS} $$l $$t; \ 193 done; true 194.endif 195 196install: afterinstall 197.if !defined(NOMAN) 198afterinstall: realinstall maninstall 199.else 200afterinstall: realinstall 201.endif 202realinstall: beforeinstall 203.endif 204 205DISTRIBUTION?= bin 206.if !target(distribute) 207distribute: 208 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies 209.endif 210 211.if !target(lint) 212lint: ${SRCS} _PROGSUBDIR 213.if defined(PROG) 214 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 215.endif 216.endif 217 218.if !target(obj) 219.if defined(NOOBJ) 220obj: _PROGSUBDIR 221.else 222obj: _PROGSUBDIR 223 @cd ${.CURDIR}; rm -rf obj; \ 224 here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \ 225 ${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \ 226 if test -d /usr/obj -a ! -d $$dest; then \ 227 mkdir -p $$dest; \ 228 else \ 229 true; \ 230 fi; 231.endif 232.endif 233 234.if !target(tags) 235tags: ${SRCS} _PROGSUBDIR 236.if defined(PROG) 237 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \ 238 sed "s;\${.CURDIR}/;;" > tags 239.endif 240.endif 241 242.if !defined(NOMAN) 243.include <bsd.man.mk> 244.elif !target(maninstall) 245maninstall: 246all-man: 247.endif 248 249_DEPSUBDIR= _PROGSUBDIR 250.include <bsd.dep.mk> 251