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