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