bsd.prog.mk revision 8321
1139826Simp# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 253541Sshin# $Id: bsd.prog.mk,v 1.25 1995/04/26 14:34:19 jkh Exp $ 353541Sshin 453541Sshin.if exists(${.CURDIR}/../Makefile.inc) 553541Sshin.include "${.CURDIR}/../Makefile.inc" 653541Sshin.endif 753541Sshin 853541Sshin.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S 953541Sshin 1053541SshinCFLAGS+=${COPTS} ${DEBUG_FLAGS} 1153541Sshin.if defined(DESTDIR) 1253541SshinCFLAGS+= -I${DESTDIR}/usr/include 1353541SshinCXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX} 1453541Sshin.endif 1553541Sshin 1653541Sshin.if !defined(DEBUG_FLAGS) 1753541SshinSTRIP?= -s 1853541Sshin.endif 1953541Sshin 2053541SshinBINGRP?= bin 2153541SshinBINOWN?= bin 2253541SshinBINMODE?= 555 2353541Sshin 2453541SshinLIBCRT0?= ${DESTDIR}/usr/lib/crt0.o 2553541SshinLIBC?= ${DESTDIR}/usr/lib/libc.a 2653541SshinLIBCOMPAT?= ${DESTDIR}/usr/lib/libcompat.a 2753541SshinLIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a 2853541SshinLIBCURSES?= ${DESTDIR}/usr/lib/libcurses.a 29174510SobrienLIBDES?= ${DESTDIR}/usr/lib/libdes.a # XXX doesn't exist 3053541SshinLIBDIALOG?= ${DESTDIR}/usr/lib/libdialog.a 3153541SshinLIBEDIT?= ${DESTDIR}/usr/lib/libedit.a 32139826SimpLIBFORMS?= ${DESTDIR}/usr/lib/libforms.a 3353541SshinLIBFTP?= ${DESTDIR}/usr/lib/libftp.a 3453541SshinLIBGCC?= ${DESTDIR}/usr/lib/libgcc.a 3553541SshinLIBGNUMALLOC?= ${DESTDIR}/usr/lib/libgnumalloc.a 3653541SshinLIBGNUREGEX?= ${DESTDIR}/usr/lib/libgnuregex.a 3753541SshinLIBKDB?= ${DESTDIR}/usr/lib/libkdb.a # XXX doesn't exist 3853541SshinLIBKRB?= ${DESTDIR}/usr/lib/libkrb.a # XXX doesn't exist 3953541SshinLIBKVM?= ${DESTDIR}/usr/lib/libkvm.a 4053541SshinLIBL?= ${DESTDIR}/usr/lib/libl.a 4153541SshinLIBM?= ${DESTDIR}/usr/lib/libm.a 4253541SshinLIBMD?= ${DESTDIR}/usr/lib/libmd.a 4353541SshinLIBMP?= ${DESTDIR}/usr/lib/libmp.a # XXX doesn't exist 4453541SshinLIBMYTINFO?= ${DESTDIR}/usr/lib/libmytinfo.a 4553541SshinLIBNCURSES?= ${DESTDIR}/usr/lib/libncurses.a 4653541SshinLIBPC?= ${DESTDIR}/usr/lib/libpc.a # XXX doesn't exist 4753541SshinLIBPCAP?= ${DESTDIR}/usr/lib/libpcap.a 4853541SshinLIBPLOT?= ${DESTDIR}/usr/lib/libplot.a # XXX doesn't exist 4953541SshinLIBREADLINE?= ${DESTDIR}/usr/lib/libreadline.a 5053541SshinLIBRESOLV?= ${DESTDIR}/usr/lib/libresolv.a 5153541SshinLIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a 5253541SshinLIBSCRYPT?= ${DESTDIR}/usr/lib/libscrypt.a # XXX don't use, use LIBCRYPT 5353541SshinLIBSCSI?= ${DESTDIR}/usr/lib/libscsi.a 5453541SshinLIBSKEY?= ${DESTDIR}/usr/lib/libskey.a 5553541SshinLIBTELNET?= ${DESTDIR}/usr/lib/libtelnet.a 5653541SshinLIBTERMCAP?= ${DESTDIR}/usr/lib/libtermcap.a 5753541SshinLIBUTIL?= ${DESTDIR}/usr/lib/libutil.a 5853541SshinLIBY?= ${DESTDIR}/usr/lib/liby.a 5953541Sshin 6053541Sshin.if defined(NOSHARED) 61174510SobrienLDFLAGS+= -static 6253541Sshin.endif 6353541Sshin 6453541Sshin.if defined(DESTDIR) 6553541SshinLDDESTDIR+= -L${DESTDIR}/usr/lib 6653541Sshin.endif 6755205Speter 6853541Sshin.if defined(PROG) 6953541Sshin.if defined(SRCS) 7053541Sshin 7153541SshinDPSRCS+= ${SRCS:M*.h} 72222748Srwatson.if !defined(NOOBJ) 73222748SrwatsonOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 74222748Srwatson.endif 75222748Srwatson 76222748Srwatson.if defined(LDONLY) 77222748Srwatson 78222748Srwatson${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD} 79222748Srwatson ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \ 80222748Srwatson ${LDADD} 81222748Srwatson 82157978Srwatson.else defined(LDONLY) 8353541Sshin 84127505Spjd${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD} 85127505Spjd ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 86222691Srwatson 87222691Srwatson.endif 8853541Sshin 89194777Sbz.else !defined(SRCS) 9053541Sshin 9153541SshinSRCS= ${PROG}.c 92180427Sbz 93180427Sbz.if 0 9453541Sshin${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD} 95222488Srwatson ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \ 96222488Srwatson ${LDDESTDIR} ${LDADD} 97222488Srwatson 98222488SrwatsonMKDEP= -p 99222488Srwatson.else 100222488Srwatson# Always make an intermediate object file because: 101222488Srwatson# - it saves time rebuilding when only the library has changed 102222691Srwatson# - the name of the object gets put into the executable symbol table instead of 103222691Srwatson# the name of a variable temporary object. 104222691Srwatson# - it's useful to keep objects around for crunching. 105222691SrwatsonOBJS= ${PROG}.o 106133192Srwatson${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD} 107125776Sume ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 10898211Shsu.endif 10998211Shsu 11098211Shsu.endif 111102218Struckman 112102218Struckman.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 113102218Struckman !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 114102218Struckman !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) 115169462SrwatsonMAN1= ${PROG}.1 116169462Srwatson.endif 11753541Sshin.endif 11853541Sshin 11962587Sitojun_PROGSUBDIR: .USE 120127505Spjd.if defined(SUBDIR) && !empty(SUBDIR) 12162587Sitojun @for entry in ${SUBDIR}; do \ 12255205Speter (${ECHODIR} "===> ${DIRPRFX}$$entry"; \ 12353541Sshin if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 12453541Sshin cd ${.CURDIR}/$${entry}.${MACHINE}; \ 125 else \ 126 cd ${.CURDIR}/$${entry}; \ 127 fi; \ 128 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \ 129 done 130.endif 131 132# XXX I think MANDEPEND is only used for groff. It should be named more 133# generally and perhaps not be in the maninstall dependencies now it is 134# here (or does maninstall always work when nothing is made?), 135 136.MAIN: all 137all: ${PROG} ${MANDEPEND} _PROGSUBDIR 138 139.if !target(clean) 140clean: _PROGSUBDIR 141 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES} 142.endif 143 144.if !target(cleandir) 145cleandir: _PROGSUBDIR 146 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES} 147 rm -f ${.CURDIR}/tags .depend 148 cd ${.CURDIR}; rm -rf obj; 149.endif 150 151.if !target(install) 152.if !target(beforeinstall) 153beforeinstall: 154.endif 155.if !target(afterinstall) 156afterinstall: 157.endif 158 159realinstall: _PROGSUBDIR 160.if defined(PROG) 161 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 162 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 163.endif 164.if defined(HIDEGAME) 165 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ 166 chown games.bin ${PROG}) 167.endif 168.if defined(LINKS) && !empty(LINKS) 169 @set ${LINKS}; \ 170 while test $$# -ge 2; do \ 171 l=${DESTDIR}$$1; \ 172 shift; \ 173 t=${DESTDIR}$$1; \ 174 shift; \ 175 ${ECHO} $$t -\> $$l; \ 176 rm -f $$t; \ 177 ln ${LN_FLAGS} $$l $$t; \ 178 done; true 179.endif 180 181install: afterinstall 182.if !defined(NOMAN) 183afterinstall: realinstall maninstall 184.else 185afterinstall: realinstall 186.endif 187realinstall: beforeinstall 188.endif 189 190DISTRIBUTION?= bin 191.if !target(distribute) 192distribute: 193 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies 194.endif 195 196.if !target(lint) 197lint: ${SRCS} _PROGSUBDIR 198.if defined(PROG) 199 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 200.endif 201.endif 202 203.if !target(obj) 204.if defined(NOOBJ) 205obj: _PROGSUBDIR 206.else 207obj: _PROGSUBDIR 208 @cd ${.CURDIR}; rm -rf obj; \ 209 here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \ 210 ${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \ 211 if test -d /usr/obj -a ! -d $$dest; then \ 212 mkdir -p $$dest; \ 213 else \ 214 true; \ 215 fi; 216.endif 217.endif 218 219.if !target(tags) 220tags: ${SRCS} _PROGSUBDIR 221.if defined(PROG) 222 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \ 223 sed "s;\${.CURDIR}/;;" > tags 224.endif 225.endif 226 227.if !defined(NOMAN) 228.include <bsd.man.mk> 229.elif !target(maninstall) 230maninstall: 231.endif 232 233_DEPSUBDIR= _PROGSUBDIR 234.include <bsd.dep.mk> 235