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