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