1# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 2 3.if !defined(NOINCLUDE) && exists(${.CURDIR}/../Makefile.inc) 4.include "${.CURDIR}/../Makefile.inc" 5.endif 6 7.SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0 8 9.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0: 10 nroff -man ${.IMPSRC} > ${.TARGET} 11 12CFLAGS+=${COPTS} 13 14STRIP?= -s 15 16BINGRP?= bin 17BINOWN?= bin 18BINMODE?= 555 19 20LIBC?= /usr/lib/libc.a 21LIBCOMPAT?= /usr/lib/libcompat.a 22LIBCURSES?= /usr/lib/libcurses.a 23LIBDBM?= /usr/lib/libdbm.a 24LIBDES?= /usr/lib/libdes.a 25LIBL?= /usr/lib/libl.a 26LIBKDB?= /usr/lib/libkdb.a 27LIBKRB?= /usr/lib/libkrb.a 28LIBKVM?= /usr/lib/libkvm.a 29LIBM?= /usr/lib/libm.a 30LIBMP?= /usr/lib/libmp.a 31LIBPC?= /usr/lib/libpc.a 32LIBPLOT?= /usr/lib/libplot.a 33LIBRESOLV?= /usr/lib/libresolv.a 34LIBRPC?= /usr/lib/sunrpc.a 35LIBTERM?= /usr/lib/libterm.a 36LIBUTIL?= /usr/lib/libutil.a 37 38.if defined(SHAREDSTRINGS) 39CLEANFILES+=strings 40.c.o: 41 ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c - 42 @${CC} ${CFLAGS} -c x.c -o ${.TARGET} 43 @rm -f x.c 44.endif 45 46.if defined(PROG) 47.if defined(SRCS) 48 49OBJS+= ${SRCS:R:S/$/.o/g} 50 51${PROG}: ${OBJS} ${LIBC} ${DPADD} 52 ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 53 54.else defined(SRCS) 55 56SRCS= ${PROG}.c 57 58${PROG}: ${SRCS} ${LIBC} ${DPADD} 59 ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD} 60 61MKDEP= -p 62 63.endif 64 65.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 66 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 67 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) 68MAN1= ${PROG}.0 69.endif 70.endif 71.if !defined(NOMAN) 72MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8} 73.else 74MANALL= 75.endif 76manpages: ${MANALL} 77 78_PROGSUBDIR: .USE 79.if defined(SUBDIR) && !empty(SUBDIR) 80 @for entry in ${SUBDIR}; do \ 81 (echo "===> $$entry"; \ 82 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 83 cd ${.CURDIR}/$${entry}.${MACHINE}; \ 84 else \ 85 cd ${.CURDIR}/$${entry}; \ 86 fi; \ 87 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \ 88 done 89.endif 90 91.if !target(all) 92.MAIN: all 93all: ${PROG} ${MANALL} _PROGSUBDIR 94.endif 95 96.if !target(clean) 97clean: _PROGSUBDIR 98 rm -f a.out [Ee]rrs mklog ${PROG}.core ${PROG} ${OBJS} ${CLEANFILES} 99.endif 100 101.if !target(cleandir) 102cleandir: _PROGSUBDIR 103 rm -f a.out [Ee]rrs mklog ${PROG}.core ${PROG} ${OBJS} ${CLEANFILES} 104 rm -f .depend ${MANALL} 105.endif 106 107# some of the rules involve .h sources, so remove them from mkdep line 108.if !target(depend) 109depend: .depend _PROGSUBDIR 110.depend: ${SRCS} 111.if defined(PROG) 112 mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c} 113.endif 114.endif 115 116.if !target(install) 117.if !target(beforeinstall) 118beforeinstall: 119.endif 120.if !target(afterinstall) 121afterinstall: 122.endif 123 124realinstall: _PROGSUBDIR 125.if defined(PROG) 126 install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 127 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 128.endif 129.if defined(HIDEGAME) 130 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ 131 chown games.bin ${PROG}) 132.endif 133.if defined(LINKS) && !empty(LINKS) 134 @set ${LINKS}; \ 135 while test $$# -ge 2; do \ 136 l=${DESTDIR}$$1; \ 137 shift; \ 138 t=${DESTDIR}$$1; \ 139 shift; \ 140 echo $$t -\> $$l; \ 141 rm -f $$t; \ 142 ln $$l $$t; \ 143 done; true 144.endif 145 146install: afterinstall maninstall 147afterinstall: realinstall 148realinstall: beforeinstall 149.endif 150 151.if !target(lint) 152lint: ${SRCS} _PROGSUBDIR 153.if defined(PROG) 154 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 155.endif 156.endif 157 158.if !target(obj) 159.if defined(NOOBJ) 160obj: _PROGSUBDIR 161.else 162obj: _PROGSUBDIR 163 @cd ${.CURDIR}; rm -rf obj; \ 164 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \ 165 echo "$$here -> $$dest"; ln -s $$dest obj; \ 166 if test -d /usr/obj -a ! -d $$dest; then \ 167 mkdir -p $$dest; \ 168 else \ 169 true; \ 170 fi; 171.endif 172.endif 173 174.if !target(objdir) 175.if defined(NOOBJ) 176objdir: _PROGSUBDIR 177.else 178objdir: _PROGSUBDIR 179 @cd ${.CURDIR}; \ 180 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \ 181 if test -d /usr/obj -a ! -d $$dest; then \ 182 mkdir -p $$dest; \ 183 else \ 184 true; \ 185 fi; 186.endif 187.endif 188 189.if !target(tags) 190tags: ${SRCS} _PROGSUBDIR 191.if defined(PROG) 192 -ctags -f /dev/stdout ${.ALLSRC} | \ 193 sed "s;${.CURDIR}/;;" > ${.CURDIR}/tags 194.endif 195.endif 196 197.if !defined(NOMAN) 198.include <bsd.man.mk> 199.else 200maninstall: 201.endif 202