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