1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $Id: bsd.prog.mk,v 1.78 1998/09/07 05:55:02 jb 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 12OBJFORMAT?= 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) && \ 65 !defined(MAN1aout) 66MAN1= ${PROG}.1 67.endif 68.endif 69 70.MAIN: all 71all: objwarn ${PROG} all-man _SUBDIR 72 73CLEANFILES+= ${PROG} ${OBJS} 74 75.if defined(PROG) && !defined(NOEXTRADEPEND) 76_EXTRADEPEND: 77.if ${OBJFORMAT} == aout 78 echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \ 79 ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} 80.else 81.if defined(DPADD) && !empty(DPADD) 82 echo ${PROG}: ${DPADD} >> ${DEPENDFILE} 83.endif 84.endif 85.endif 86 87.if !target(install) 88.if !target(beforeinstall) 89beforeinstall: 90.endif 91 92realinstall: beforeinstall 93.if defined(PROG) 94 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 95 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 96.endif 97.if defined(HIDEGAME) 98 (cd ${DESTDIR}/${GBINDIR}; rm -f ${PROG}; ln -s dm ${PROG}; \ 99 chown games:bin ${PROG}) 100.endif 101.if defined(LINKS) && !empty(LINKS) 102 @set ${LINKS}; \ 103 while test $$# -ge 2; do \ 104 l=${DESTDIR}$$1; \ 105 shift; \ 106 t=${DESTDIR}$$1; \ 107 shift; \ 108 ${ECHO} $$t -\> $$l; \ 109 rm -f $$t; \ 110 ln ${LN_FLAGS} $$l $$t; \ 111 done; true 112.endif 113 114install: afterinstall _SUBDIR 115.if !defined(NOMAN) 116afterinstall: realinstall maninstall 117.else 118afterinstall: realinstall 119.endif 120.endif 121 122DISTRIBUTION?= bin 123.if !target(distribute) 124distribute: _SUBDIR 125.for dist in ${DISTRIBUTION} 126 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 127.endfor 128.endif 129 130.if !target(lint) 131lint: ${SRCS} _SUBDIR 132.if defined(PROG) 133 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 134.endif 135.endif 136 137.if defined(NOTAGS) 138tags: 139.endif 140 141.if !target(tags) 142tags: ${SRCS} _SUBDIR 143.if defined(PROG) 144 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 145.if defined(HTML) 146 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 147.endif 148.endif 149.endif 150 151.if !defined(NOMAN) 152.include <bsd.man.mk> 153.elif !target(maninstall) 154maninstall: 155all-man: 156.endif 157 158.if !target(regress) 159regress: 160.endif 161 162.if ${OBJFORMAT} != aout || make(checkdpadd) 163.include <bsd.libnames.mk> 164.endif 165 166.include <bsd.dep.mk> 167 168.if defined(PROG) && !exists(${DEPENDFILE}) 169${OBJS}: ${SRCS:M*.h} 170.endif 171 172.include <bsd.obj.mk> 173