bsd.prog.mk revision 41562
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $Id: bsd.prog.mk,v 1.79 1998/10/18 09:35:17 obrien 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.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .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 30# If there are Objective C sources, link with Objective C libraries. 31.if ${SRCS:M*.m} != "" 32OBJCLIBS?= -lobjc 33LDADD+= ${OBJCLIBS} 34.endif 35 36OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 37 38${PROG}: ${OBJS} 39 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 40 41.else !defined(SRCS) 42 43.if !target(${PROG}) 44SRCS= ${PROG}.c 45 46# Always make an intermediate object file because: 47# - it saves time rebuilding when only the library has changed 48# - the name of the object gets put into the executable symbol table instead of 49# the name of a variable temporary object. 50# - it's useful to keep objects around for crunching. 51OBJS= ${PROG}.o 52 53${PROG}: ${OBJS} 54 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 55.endif 56 57.endif 58 59.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 60 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 61 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) && \ 62 !defined(MAN1aout) 63MAN1= ${PROG}.1 64.endif 65.endif 66 67.MAIN: all 68all: objwarn ${PROG} all-man _SUBDIR 69 70CLEANFILES+= ${PROG} ${OBJS} 71 72.if defined(PROG) && !defined(NOEXTRADEPEND) 73_EXTRADEPEND: 74.if ${OBJFORMAT} == 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}/${GBINDIR}; 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} ${.OBJDIR} 142.if defined(HTML) 143 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 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 !target(regress) 156regress: 157.endif 158 159.if ${OBJFORMAT} != aout || make(checkdpadd) 160.include <bsd.libnames.mk> 161.endif 162 163.include <bsd.dep.mk> 164 165.if defined(PROG) && !exists(${DEPENDFILE}) 166${OBJS}: ${SRCS:M*.h} 167.endif 168 169.include <bsd.obj.mk> 170