Home | History | Annotate | Line # | Download | only in mk
bsd.prog.mk revision 1.1
      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 LIBC?=		/usr/lib/libc.a
     21 LIBCOMPAT?=	/usr/lib/libcompat.a
     22 LIBCURSES?=	/usr/lib/libcurses.a
     23 LIBDBM?=	/usr/lib/libdbm.a
     24 LIBDES?=	/usr/lib/libdes.a
     25 LIBL?=		/usr/lib/libl.a
     26 LIBKDB?=	/usr/lib/libkdb.a
     27 LIBKRB?=	/usr/lib/libkrb.a
     28 LIBM?=		/usr/lib/libm.a
     29 LIBMP?=		/usr/lib/libmp.a
     30 LIBPC?=		/usr/lib/libpc.a
     31 LIBPLOT?=	/usr/lib/libplot.a
     32 LIBRESOLV?=	/usr/lib/libresolv.a
     33 LIBRPC?=	/usr/lib/sunrpc.a
     34 LIBTERM?=	/usr/lib/libterm.a
     35 LIBUTIL?=	/usr/lib/libutil.a
     36 
     37 .if defined(SHAREDSTRINGS)
     38 CLEANFILES+=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 
     48 OBJS+=  ${SRCS:R:S/$/.o/g}
     49 
     50 ${PROG}: ${OBJS} ${LIBC} ${DPADD}
     51 	${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
     52 
     53 .else defined(PROG)
     54 
     55 SRCS= ${PROG}.c
     56 
     57 ${PROG}: ${SRCS} ${LIBC} ${DPADD}
     58 	${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
     59 
     60 MKDEP=	-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)
     67 MAN1=	${PROG}.0
     68 .endif
     69 .endif
     70 MANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
     71 
     72 _PROGSUBDIR: .USE
     73 .if defined(SUBDIR) && !empty(SUBDIR)
     74 	@for entry in ${SUBDIR}; do \
     75 		(echo "===> $$entry"; \
     76 		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
     77 			cd ${.CURDIR}/$${entry}.${MACHINE}; \
     78 		else \
     79 			cd ${.CURDIR}/$${entry}; \
     80 		fi; \
     81 		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
     82 	done
     83 .endif
     84 
     85 .MAIN: all
     86 all: ${PROG} ${MANALL} _PROGSUBDIR
     87 
     88 .if !target(clean)
     89 clean: _PROGSUBDIR
     90 	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
     91 .endif
     92 
     93 .if !target(cleandir)
     94 cleandir: _PROGSUBDIR
     95 	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
     96 	rm -f .depend ${MANALL}
     97 .endif
     98 
     99 # some of the rules involve .h sources, so remove them from mkdep line
    100 .if !target(depend)
    101 depend: .depend _PROGSUBDIR
    102 .depend: ${SRCS}
    103 .if defined(PROG)
    104 	mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
    105 .endif
    106 .endif
    107 
    108 .if !target(install)
    109 .if !target(beforeinstall)
    110 beforeinstall:
    111 .endif
    112 .if !target(afterinstall)
    113 afterinstall:
    114 .endif
    115 
    116 realinstall: _PROGSUBDIR
    117 .if defined(PROG)
    118 	install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
    119 	    ${PROG} ${DESTDIR}${BINDIR}
    120 .endif
    121 .if defined(HIDEGAME)
    122 	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
    123 	    chown games.bin ${PROG})
    124 .endif
    125 .if defined(LINKS) && !empty(LINKS)
    126 	@set ${LINKS}; \
    127 	while test $$# -ge 2; do \
    128 		l=${DESTDIR}$$1; \
    129 		shift; \
    130 		t=${DESTDIR}$$1; \
    131 		shift; \
    132 		echo $$t -\> $$l; \
    133 		rm -f $$t; \
    134 		ln $$l $$t; \
    135 	done; true
    136 .endif
    137 
    138 install: maninstall
    139 maninstall: afterinstall
    140 afterinstall: realinstall
    141 realinstall: beforeinstall
    142 .endif
    143 
    144 .if !target(lint)
    145 lint: ${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)
    153 obj: _PROGSUBDIR
    154 .else
    155 obj: _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(tags)
    168 tags: ${SRCS} _PROGSUBDIR
    169 .if defined(PROG)
    170 	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
    171 	    sed "s;\${.CURDIR}/;;" > tags
    172 .endif
    173 .endif
    174 
    175 .if !defined(NOMAN)
    176 .include <bsd.man.mk>
    177 .endif
    178