bsd.prog.mk revision 3493
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $Id: bsd.prog.mk,v 1.7 1994/10/07 03:10:05 ache 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 24INSTALL?= install 25.if !defined(DESTDIR) 26LIBCRT0?= /usr/lib/crt0.o 27LIBC?= /usr/lib/libc.a 28LIBCOMPAT?= /usr/lib/libcompat.a 29LIBCRYPT?= /usr/lib/libcrypt.a 30LIBCURSES?= /usr/lib/libcurses.a 31LIBDBM?= /usr/lib/libdbm.a 32LIBDES?= /usr/lib/libdes.a 33LIBGNUMALLOC?= /usr/lib/libgnumalloc.a 34LIBGNUREGEX?= /usr/lib/libgnuregex.a 35LIBL?= /usr/lib/libl.a 36LIBKDB?= /usr/lib/libkdb.a 37LIBKRB?= /usr/lib/libkrb.a 38LIBM?= /usr/lib/libm.a 39LIBMP?= /usr/lib/libmp.a 40LIBMYTINFO?= /usr/lib/libmytinfo.a 41LIBNCURSES?= /usr/lib/libncurses.a 42LIBPC?= /usr/lib/libpc.a 43LIBPLOT?= /usr/lib/libplot.a 44LIBREADLINE?= /usr/lib/libreadline.a 45LIBRESOLV?= /usr/lib/libresolv.a 46LIBRPCSVC?= /usr/lib/librpcsvc.a 47LIBSKEY?= /usr/lib/libskey.a 48LIBTELNET?= /usr/lib/libtelnet.a 49LIBTERMCAP?= /usr/lib/libtermcap.a 50LIBUTIL?= /usr/lib/libutil.a 51.else 52LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o 53LIBC?= ${DESTDIR}/usr/lib/libc.a 54LIBCOMPAT?= ${DESTDIR}/usr/lib/libcompat.a 55LIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a 56LIBCURSES?= ${DESTDIR}/usr/lib/libcurses.a 57LIBDBM?= ${DESTDIR}/usr/lib/libdbm.a 58LIBDES?= ${DESTDIR}/usr/lib/libdes.a 59LIBGNUMALLOC?= ${DESTDIR}/usr/lib/libgnumalloc.a 60LIBGNUREGEX?= ${DESTDIR}/usr/lib/libgnuregex.a 61LIBL?= ${DESTDIR}/usr/lib/libl.a 62LIBKDB?= ${DESTDIR}/usr/lib/libkdb.a 63LIBKRB?= ${DESTDIR}/usr/lib/libkrb.a 64LIBM?= ${DESTDIR}/usr/lib/libm.a 65LIBMP?= ${DESTDIR}/usr/lib/libmp.a 66LIBMYTINFO?= ${DESTDIR}/usr/lib/libmytinfo.a 67LIBNCURSES?= ${DESTDIR}/usr/lib/libncurses.a 68LIBPC?= ${DESTDIR}/usr/lib/libpc.a 69LIBPLOT?= ${DESTDIR}/usr/lib/libplot.a 70LIBREADLINE?= ${DESTDIR}/usr/lib/libreadline.a 71LIBRESOLV?= ${DESTDIR}/usr/lib/libresolv.a 72LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a 73LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a 74LIBTELNET?= ${DESTDIR}/usr/lib/libtelnet.a 75LIBTERMCAP?= ${DESTDIR}/usr/lib/libtermcap.a 76LIBUTIL?= ${DESTDIR}/usr/lib/libutil.a 77.endif 78.if defined(NOSHARED) 79LDFLAGS+= -static 80.endif 81 82.if defined(DESTDIR) 83LDDESTDIR?= -L${DESTDIR}/usr/lib 84.endif 85 86.if defined(PROG) 87.if defined(SRCS) 88 89DPSRCS+= ${SRCS:M*.h} 90OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 91 92.if defined(LDONLY) 93 94${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD} 95 ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \ 96 ${LDADD} 97 98.else defined(LDONLY) 99 100${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD} 101 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 102 103.endif 104 105.else defined(PROG) 106 107SRCS= ${PROG}.c 108 109.if 0 110${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD} 111 ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \ 112 ${LDDESTDIR} ${LDADD} 113.else 114# Always make an intermediate object file because: 115# - it saves time rebuilding when only the library has changed 116# - the name of the object gets put into the executable symbol table instead of 117# the name of a variable temporary object. 118# - it's useful to keep objects around for crunching. 119OBJS= ${PROG}.o 120${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD} 121 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 122.endif 123 124MKDEP= -p 125 126.endif 127 128.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 129 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 130 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) 131MAN1= ${PROG}.1 132.endif 133.endif 134 135_PROGSUBDIR: .USE 136.if defined(SUBDIR) && !empty(SUBDIR) 137 @for entry in ${SUBDIR}; do \ 138 (${ECHODIR} "===> $$entry"; \ 139 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 140 cd ${.CURDIR}/$${entry}.${MACHINE}; \ 141 else \ 142 cd ${.CURDIR}/$${entry}; \ 143 fi; \ 144 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \ 145 done 146.endif 147 148.MAIN: all 149all: ${PROG} _PROGSUBDIR 150 151.if !target(clean) 152clean: _PROGSUBDIR 153 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES} 154.endif 155 156.if !target(cleandir) 157cleandir: _PROGSUBDIR 158 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES} 159 rm -f ${.CURDIR}/tags .depend 160 cd ${.CURDIR}; rm -rf obj; 161.endif 162 163.if !target(install) 164.if !target(beforeinstall) 165beforeinstall: 166.endif 167.if !target(afterinstall) 168afterinstall: 169.endif 170 171realinstall: _PROGSUBDIR 172.if defined(PROG) 173 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 174 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 175.endif 176.if defined(HIDEGAME) 177 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ 178 chown games.bin ${PROG}) 179.endif 180.if defined(LINKS) && !empty(LINKS) 181 @set ${LINKS}; \ 182 while test $$# -ge 2; do \ 183 l=${DESTDIR}$$1; \ 184 shift; \ 185 t=${DESTDIR}$$1; \ 186 shift; \ 187 ${ECHO} $$t -\> $$l; \ 188 rm -f $$t; \ 189 ln $$l $$t; \ 190 done; true 191.endif 192 193install: afterinstall 194.if !defined(NOMAN) 195afterinstall: realinstall maninstall 196.else 197afterinstall: realinstall 198.endif 199realinstall: beforeinstall 200.endif 201 202.if !target(lint) 203lint: ${SRCS} _PROGSUBDIR 204.if defined(PROG) 205 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 206.endif 207.endif 208 209.if !target(obj) 210.if defined(NOOBJ) 211obj: _PROGSUBDIR 212.else 213obj: _PROGSUBDIR 214 @cd ${.CURDIR}; rm -rf obj; \ 215 here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \ 216 ${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \ 217 if test -d /usr/obj -a ! -d $$dest; then \ 218 mkdir -p $$dest; \ 219 else \ 220 true; \ 221 fi; 222.endif 223.endif 224 225.if !target(tags) 226tags: ${SRCS} _PROGSUBDIR 227.if defined(PROG) 228 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \ 229 sed "s;\${.CURDIR}/;;" > tags 230.endif 231.endif 232 233.if !defined(NOMAN) 234.include <bsd.man.mk> 235.elif !target(maninstall) 236maninstall: 237.endif 238 239.include <bsd.dep.mk> 240