1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $Id: bsd.prog.mk,v 1.40 1996/09/18 06:09:19 swallace 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 20.if defined(NOSHARED) 21LDFLAGS+= -static 22.endif 23 24.if defined(DESTDIR) 25LDDESTDIR+= -L${DESTDIR}/usr/lib 26.endif 27 28.include <bsd.libnames.mk> 29 30.if defined(PROG) 31.if defined(SRCS) 32 33DPSRCS+= ${SRCS:M*.h} 34.if !defined(NOOBJ) 35OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 36.endif 37 38.if defined(LDONLY) 39 40${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD} 41 ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \ 42 ${LDADD} 43 44.else defined(LDONLY) 45 46${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD} 47 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 48 49.endif 50 51.else !defined(SRCS) 52 53SRCS= ${PROG}.c 54 55.if 0 56${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD} 57 ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \ 58 ${LDDESTDIR} ${LDADD} 59 60MKDEP= -p 61.else 62# Always make an intermediate object file because: 63# - it saves time rebuilding when only the library has changed 64# - the name of the object gets put into the executable symbol table instead of 65# the name of a variable temporary object. 66# - it's useful to keep objects around for crunching. 67OBJS= ${PROG}.o 68${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD} 69 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 70.endif 71 72.endif 73 74.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 75 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 76 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) 77MAN1= ${PROG}.1 78.endif 79.endif 80 81# XXX I think MANDEPEND is only used for groff. It should be named more 82# generally and perhaps not be in the maninstall dependencies now it is 83# here (or does maninstall always work when nothing is made?), 84 85.MAIN: all 86all: objwarn ${PROG} all-man _SUBDIR 87 88.if !target(clean) 89clean: _SUBDIR 90 rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES} 91.if defined(CLEANDIRS) && !empty(CLEANDIRS) 92 rm -rf ${CLEANDIRS} 93.endif 94.endif 95 96.if !target(install) 97.if !target(beforeinstall) 98beforeinstall: 99.endif 100 101realinstall: beforeinstall 102.if defined(PROG) 103 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 104 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 105.endif 106.if defined(HIDEGAME) 107 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ 108 chown games.bin ${PROG}) 109.endif 110.if defined(LINKS) && !empty(LINKS) 111 @set ${LINKS}; \ 112 while test $$# -ge 2; do \ 113 l=${DESTDIR}$$1; \ 114 shift; \ 115 t=${DESTDIR}$$1; \ 116 shift; \ 117 ${ECHO} $$t -\> $$l; \ 118 rm -f $$t; \ 119 ln ${LN_FLAGS} $$l $$t; \ 120 done; true 121.endif 122 123install: afterinstall _SUBDIR 124.if !defined(NOMAN) 125afterinstall: realinstall maninstall 126.else 127afterinstall: realinstall 128.endif 129.endif 130 131DISTRIBUTION?= bin 132.if !target(distribute) 133distribute: _SUBDIR 134 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies 135.endif 136 137.if !target(lint) 138lint: ${SRCS} _SUBDIR 139.if defined(PROG) 140 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 141.endif 142.endif 143 144.if !target(tags) 145tags: ${SRCS} _SUBDIR 146.if defined(PROG) 147 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \ 148 sed "s;\${.CURDIR}/;;" > tags 149.endif 150.endif 151 152.if !defined(NOMAN) 153.include <bsd.man.mk> 154.elif !target(maninstall) 155maninstall: 156all-man: 157.endif 158 159.include <bsd.dep.mk> 160.include <bsd.obj.mk> 161