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(NOMAN) 75 .if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 76 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 77 !defined(MAN7) && !defined(MAN8) 78 MAN1= ${PROG}.0 79 .endif 80 .endif 81 MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8} 82 .endif 83 84 _PROGSUBDIR: .USE 85 .if defined(SUBDIR) && !empty(SUBDIR) 86 @for entry in ${SUBDIR}; do \ 87 (echo "===> $$entry"; \ 88 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 89 cd ${.CURDIR}/$${entry}.${MACHINE}; \ 90 else \ 91 cd ${.CURDIR}/$${entry}; \ 92 fi; \ 93 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \ 94 done 95 .endif 96 97 .MAIN: all 98 all: ${PROG} ${MANALL} _PROGSUBDIR 99 100 .if !target(clean) 101 clean: _PROGSUBDIR 102 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES} 103 .endif 104 105 .if !target(cleandir) 106 cleandir: _PROGSUBDIR 107 rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES} 108 rm -f .depend ${MANALL} 109 .endif 110 111 # some of the rules involve .h sources, so remove them from mkdep line 112 .if !target(depend) 113 depend: .depend _PROGSUBDIR 114 .depend: ${SRCS} 115 .if defined(PROG) 116 mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c} 117 .endif 118 .endif 119 120 .if !target(install) 121 .if !target(beforeinstall) 122 beforeinstall: 123 @if [ ! -d "${DESTDIR}${BINDIR}" ]; then \ 124 /bin/rm -f ${DESTDIR}${BINDIR} ; \ 125 mkdir -p ${DESTDIR}${BINDIR} ; \ 126 chown root.wheel ${DESTDIR}${BINDIR} ; \ 127 chmod 755 ${DESTDIR}${BINDIR} ; \ 128 else \ 129 true ; \ 130 fi 131 .endif 132 .if !target(afterinstall) 133 afterinstall: 134 .endif 135 136 realinstall: _PROGSUBDIR 137 .if defined(PROG) 138 install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 139 ${PROG} ${DESTDIR}${BINDIR} 140 .endif 141 .if defined(HIDEGAME) 142 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ 143 chown games.bin ${PROG}) 144 .endif 145 .if defined(LINKS) && !empty(LINKS) 146 @set ${LINKS}; \ 147 while test $$# -ge 2; do \ 148 l=${DESTDIR}$$1; \ 149 shift; \ 150 t=${DESTDIR}$$1; \ 151 shift; \ 152 echo $$t -\> $$l; \ 153 rm -f $$t; \ 154 ln $$l $$t; \ 155 done; true 156 .endif 157 158 install: maninstall 159 maninstall: afterinstall 160 afterinstall: realinstall 161 realinstall: beforeinstall 162 .endif 163 164 .if !target(lint) 165 lint: ${SRCS} _PROGSUBDIR 166 .if defined(PROG) 167 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 168 .endif 169 .endif 170 171 .if !target(obj) 172 .if defined(NOOBJ) 173 obj: _PROGSUBDIR 174 .else 175 obj: _PROGSUBDIR 176 @cd ${.CURDIR}; rm -f obj > /dev/null 2>&1 || true; \ 177 here=`pwd`; subdir=`echo $$here | sed 's,^/usr/src/,,'`; \ 178 if test $$here != $$subdir ; then \ 179 dest=/usr/obj/$$subdir ; \ 180 echo "$$here -> $$dest"; ln -s $$dest obj; \ 181 if test -d /usr/obj -a ! -d $$dest; then \ 182 mkdir -p $$dest; \ 183 else \ 184 true; \ 185 fi; \ 186 else \ 187 true ; \ 188 dest=$$here/obj ; \ 189 echo "making $$here/obj" ; \ 190 if test ! -d obj ; then \ 191 mkdir $$here/obj; \ 192 fi ; \ 193 fi; 194 .endif 195 .endif 196 197 .if !target(tags) 198 tags: ${SRCS} _PROGSUBDIR 199 .if defined(PROG) 200 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \ 201 sed "s;\${.CURDIR}/;;" > tags 202 .endif 203 .endif 204 205 .if !defined(NOMAN) 206 .include <bsd.man.mk> 207 .endif 208