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