bsd.prog.mk revision 25110
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $Id: bsd.prog.mk,v 1.48 1997/04/19 14:36:49 bde 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}${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 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies 116.endif 117 118.if !target(lint) 119lint: ${SRCS} _SUBDIR 120.if defined(PROG) 121 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 122.endif 123.endif 124 125.if defined(NOTAGS) 126tags: 127.endif 128 129.if !target(tags) 130tags: ${SRCS} _SUBDIR 131.if defined(PROG) 132 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} 133.if defined(HTML) 134 @cd ${.CURDIR} && htags ${HTAGSFLAGS} 135.endif 136.endif 137.endif 138 139.if !defined(NOMAN) 140.include <bsd.man.mk> 141.elif !target(maninstall) 142maninstall: 143all-man: 144.endif 145 146.include <bsd.dep.mk> 147.include <bsd.obj.mk> 148