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