bsd.prog.mk revision 35780
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $Id: bsd.prog.mk,v 1.70 1998/05/05 03:59:27 bde Exp $ 3 4.if exists(${.CURDIR}/../Makefile.inc) 5.include "${.CURDIR}/../Makefile.inc" 6.endif 7 8# Default executable format 9BINFORMAT?= aout 10 11.SUFFIXES: .out .o .c .cc .cxx .C .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 30CLEANFILES?= 31 32.for _LSRC in ${SRCS:M*.l:N*/*} 33.for _LC in ${_LSRC:S/.l/.c/} 34${_LC}: ${_LSRC} 35 ${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET} 36SRCS:= ${SRCS:S/${_LSRC}/${_LC}/} 37CLEANFILES:= ${CLEANFILES} ${_LC} 38.endfor 39.endfor 40 41.for _YSRC in ${SRCS:M*.y:N*/*} 42.for _YC in ${_YSRC:S/.y/.c/} 43SRCS:= ${SRCS:S/${_YSRC}/${_YC}/} 44CLEANFILES:= ${CLEANFILES} ${_YC} 45.if ${YFLAGS:M-d} != "" && ${SRCS:My.tab.h} 46.ORDER: ${_YC} y.tab.h 47${_YC} y.tab.h: ${_YSRC} 48 ${YACC} ${YFLAGS} ${.ALLSRC} 49 cp y.tab.c ${_YC} 50SRCS:= ${SRCS} y.tab.h 51CLEANFILES:= ${CLEANFILES} y.tab.c y.tab.h 52.elif ${YFLAGS:M-d} != "" 53.for _YH in ${_YC:S/.c/.h/} 54.ORDER: ${_YC} ${_YH} 55${_YC} ${_YH}: ${_YSRC} 56 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC} 57SRCS:= ${SRCS} ${_YH} 58CLEANFILES:= ${CLEANFILES} ${_YH} 59.endfor 60.else 61${_YC}: ${_YSRC} 62 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC} 63.endif 64.endfor 65.endfor 66 67OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 68 69${PROG}: ${OBJS} 70 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 71 72.else !defined(SRCS) 73 74.if !target(${PROG}) 75SRCS= ${PROG}.c 76 77# Always make an intermediate object file because: 78# - it saves time rebuilding when only the library has changed 79# - the name of the object gets put into the executable symbol table instead of 80# the name of a variable temporary object. 81# - it's useful to keep objects around for crunching. 82OBJS= ${PROG}.o 83 84${PROG}: ${OBJS} 85 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 86.endif 87 88.endif 89 90.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 91 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 92 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) 93MAN1= ${PROG}.1 94.endif 95.endif 96 97.MAIN: all 98all: objwarn ${PROG} all-man _SUBDIR 99 100CLEANFILES+= ${PROG} ${OBJS} 101 102.if defined(PROG) && !defined(NOEXTRADEPEND) 103_EXTRADEPEND: 104.if ${BINFORMAT} == aout 105 echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \ 106 ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} 107.else 108.if defined(DPADD) && !empty(DPADD) 109 echo ${PROG}: ${DPADD} >> ${DEPENDFILE} 110.endif 111.endif 112.endif 113 114.if !target(install) 115.if !target(beforeinstall) 116beforeinstall: 117.endif 118 119realinstall: beforeinstall 120.if defined(PROG) 121 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 122 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 123.endif 124.if defined(HIDEGAME) 125 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ 126 chown games:bin ${PROG}) 127.endif 128.if defined(LINKS) && !empty(LINKS) 129 @set ${LINKS}; \ 130 while test $$# -ge 2; do \ 131 l=${DESTDIR}$$1; \ 132 shift; \ 133 t=${DESTDIR}$$1; \ 134 shift; \ 135 ${ECHO} $$t -\> $$l; \ 136 rm -f $$t; \ 137 ln ${LN_FLAGS} $$l $$t; \ 138 done; true 139.endif 140 141install: afterinstall _SUBDIR 142.if !defined(NOMAN) 143afterinstall: realinstall maninstall 144.else 145afterinstall: realinstall 146.endif 147.endif 148 149DISTRIBUTION?= bin 150.if !target(distribute) 151distribute: _SUBDIR 152.for dist in ${DISTRIBUTION} 153 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 154.endfor 155.endif 156 157.if !target(lint) 158lint: ${SRCS} _SUBDIR 159.if defined(PROG) 160 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 161.endif 162.endif 163 164.if defined(NOTAGS) 165tags: 166.endif 167 168.if !target(tags) 169tags: ${SRCS} _SUBDIR 170.if defined(PROG) 171 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 172.if defined(HTML) 173 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 174.endif 175.endif 176.endif 177 178.if !defined(NOMAN) 179.include <bsd.man.mk> 180.elif !target(maninstall) 181maninstall: 182all-man: 183.endif 184 185.if !target(regress) 186regress: 187.endif 188 189.if ${BINFORMAT} != aout || make(checkdpadd) 190.include <bsd.libnames.mk> 191.endif 192 193.include <bsd.dep.mk> 194 195.if defined(PROG) && !exists(${DEPENDFILE}) 196${OBJS}: ${SRCS:M*.h} 197.endif 198 199.include <bsd.obj.mk> 200