bsd.prog.mk revision 74806
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $FreeBSD: head/share/mk/bsd.prog.mk 74806 2001-03-26 08:04:11Z ru $ 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(NOMAN) && !defined(MAN) && \ 60 !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 61 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 62 !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 63 !defined(MAN1aout) 64MANSECT?= 1 65.for sect in ${MANSECT} 66MAN${sect}= ${PROG}.${sect} 67.endfor 68.endif 69.endif 70 71.MAIN: all 72.if !defined(NOMAN) 73all: objwarn ${PROG} all-man _SUBDIR 74.else 75all: objwarn ${PROG} _SUBDIR 76.endif 77 78CLEANFILES+= ${PROG} ${OBJS} 79 80.if defined(PROG) 81_EXTRADEPEND: 82.if ${OBJFORMAT} == aout 83 echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \ 84 ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} 85.else 86 echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 87.endif 88.endif 89 90.if !target(install) 91.if !target(beforeinstall) 92beforeinstall: 93.endif 94 95_INSTALLFLAGS:= ${INSTALLFLAGS} 96.for ie in ${INSTALLFLAGS_EDIT} 97_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 98.endfor 99 100realinstall: beforeinstall 101.if defined(PROG) 102 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 103 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 104.endif 105.if defined(HIDEGAME) 106 (cd ${DESTDIR}/${GBINDIR}; rm -f ${PROG}; ln -s dm ${PROG}; \ 107 chown games:bin ${PROG}) 108.endif 109.if defined(LINKS) && !empty(LINKS) 110 @set ${LINKS}; \ 111 while test $$# -ge 2; do \ 112 l=${DESTDIR}$$1; \ 113 shift; \ 114 t=${DESTDIR}$$1; \ 115 shift; \ 116 ${ECHO} $$t -\> $$l; \ 117 ln -f $$l $$t; \ 118 done; true 119.endif 120.if defined(SYMLINKS) && !empty(SYMLINKS) 121 @set ${SYMLINKS}; \ 122 while test $$# -ge 2; do \ 123 l=$$1; \ 124 shift; \ 125 t=${DESTDIR}$$1; \ 126 shift; \ 127 ${ECHO} $$t -\> $$l; \ 128 ln -fs $$l $$t; \ 129 done; true 130.endif 131 132install: afterinstall _SUBDIR 133.if !defined(NOMAN) 134afterinstall: realinstall maninstall 135.else 136afterinstall: realinstall 137.endif 138.endif 139 140DISTRIBUTION?= bin 141.if !target(distribute) 142distribute: _SUBDIR 143.for dist in ${DISTRIBUTION} 144 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 145.endfor 146.endif 147 148.if !target(lint) 149lint: ${SRCS} _SUBDIR 150.if defined(PROG) 151 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 152.endif 153.endif 154 155.if defined(NOTAGS) 156tags: 157.endif 158 159.if !target(tags) 160tags: ${SRCS} _SUBDIR 161.if defined(PROG) 162 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 163.if defined(HTML) 164 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 165.endif 166.endif 167.endif 168 169.if !defined(NOMAN) 170.include <bsd.man.mk> 171.elif !target(maninstall) 172maninstall: 173.endif 174 175.if !target(regress) 176regress: 177.endif 178 179.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES) 180.include <bsd.libnames.mk> 181.endif 182 183.include <bsd.dep.mk> 184 185.if defined(PROG) && !exists(${DEPENDFILE}) 186${OBJS}: ${SRCS:M*.h} 187.endif 188 189.include <bsd.obj.mk> 190