xref: /csrg-svn/share/mk/bsd.prog.mk (revision 44598)
1*44598Sbostic#	@(#)bsd.prog.mk	5.20 (Berkeley) 06/29/90
241563Sbostic
341369Sbostic.if exists(${.CURDIR}/../Makefile.inc)
441369Sbostic.include "${.CURDIR}/../Makefile.inc"
540510Sbostic.endif
639193Sbostic
741559Sbostic.SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
841559Sbostic
941559Sbostic.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
1043473Sbostic	nroff -mandoc -h ${.IMPSRC} > ${.TARGET}
1141559Sbostic
1241559SbosticCFLAGS+=${COPTS}
1341559Sbostic
1441602SbosticSTRIP?=	-s
1541602Sbostic
1641602SbosticBINGRP?=	bin
1741602SbosticBINOWN?=	bin
1841602SbosticBINMODE?=	555
1941602Sbostic
20*44598SbosticLIBC?=		/usr/lib/libc.a
2141369SbosticLIBCOMPAT?=	/usr/lib/libcompat.a
2241369SbosticLIBCURSES?=	/usr/lib/libcurses.a
2341369SbosticLIBDBM?=	/usr/lib/libdbm.a
2441369SbosticLIBDES?=	/usr/lib/libdes.a
2541369SbosticLIBL?=		/usr/lib/libl.a
2641369SbosticLIBKDB?=	/usr/lib/libkdb.a
2741369SbosticLIBKRB?=	/usr/lib/libkrb.a
2841369SbosticLIBM?=		/usr/lib/libm.a
2941369SbosticLIBMP?=		/usr/lib/libmp.a
3041369SbosticLIBPC?=		/usr/lib/libpc.a
3141369SbosticLIBPLOT?=	/usr/lib/libplot.a
3243473SbosticLIBRESOLV?=	/usr/lib/libresolv.a
3341369SbosticLIBRPC?=	/usr/lib/sunrpc.a
3441369SbosticLIBTERM?=	/usr/lib/libterm.a
3541369SbosticLIBUTIL?=	/usr/lib/libutil.a
3639208Sbostic
3741559Sbostic.if defined(SHAREDSTRINGS)
3843649SbosticCLEANFILES+=strings
3941559Sbostic.c.o:
4042446Sbostic	${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
4141559Sbostic	@${CC} ${CFLAGS} -c x.c -o ${.TARGET}
4241559Sbostic	@rm -f x.c
4341559Sbostic.endif
4441559Sbostic
4541556Sbostic.if defined(PROG)
4641369Sbostic.if defined(SRCS)
4739199Sbostic
4841369SbosticOBJS+=	${SRCS:.c=.o}
4939199Sbostic
5041369Sbostic${PROG}: ${OBJS} ${LIBC} ${DPADD}
5141369Sbostic	${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
5239208Sbostic
5341556Sbostic.else defined(PROG)
5439208Sbostic
5541369SbosticSRCS= ${PROG}.c
5639208Sbostic
5741369Sbostic${PROG}: ${SRCS} ${LIBC} ${DPADD}
5841369Sbostic	${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
5939193Sbostic
6043505SbosticMKDEP=	-p
6143505Sbostic
6241369Sbostic.endif
6339193Sbostic
6441369Sbostic.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
6541369Sbostic	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
6641369Sbostic	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
6740510SbosticMAN1=	${PROG}.0
6839208Sbostic.endif
6941556Sbostic.endif
7041369SbosticMANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
7139208Sbostic
7241602Sbostic_PROGSUBDIR: .USE
7341369Sbostic.if defined(SUBDIR) && !empty(SUBDIR)
7441369Sbostic	@for entry in ${SUBDIR}; do \
7541602Sbostic		(echo "===> $$entry"; \
7641369Sbostic		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
7741369Sbostic			cd ${.CURDIR}/$${entry}.${MACHINE}; \
7841369Sbostic		else \
7941369Sbostic			cd ${.CURDIR}/$${entry}; \
8041369Sbostic		fi; \
8142069Sbostic		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}) \
8241369Sbostic	done
8341369Sbostic.endif
8439193Sbostic
8541369Sbostic.MAIN: all
8641602Sbosticall: ${PROG} ${MANALL} _PROGSUBDIR
8739193Sbostic
8841369Sbostic.if !target(clean)
8941602Sbosticclean: _PROGSUBDIR
9041369Sbostic	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
9139208Sbostic.endif
9239208Sbostic
9341461Sbostic.if !target(cleandir)
9441602Sbosticcleandir: _PROGSUBDIR
9541369Sbostic	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
9641369Sbostic	rm -f .depend ${.CURDIR}/tags ${MANALL}
9741461Sbostic.endif
9839193Sbostic
9941369Sbostic# some of the rules involve .h sources, so remove them from mkdep line
10041461Sbostic.if !target(depend)
10142442Sbosticdepend: .depend _PROGSUBDIR
10242442Sbostic.depend: ${SRCS}
10342069Sbostic.if defined(PROG)
10443505Sbostic	mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
10541461Sbostic.endif
10642069Sbostic.endif
10739193Sbostic
10841461Sbostic.if !target(install)
10941461Sbostic.if !target(beforeinstall)
11041461Sbosticbeforeinstall:
11141461Sbostic.endif
11241602Sbostic.if !target(afterinstall)
11341602Sbosticafterinstall:
11441602Sbostic.endif
11541461Sbostic
11641602Sbosticrealinstall: _PROGSUBDIR
11741602Sbostic.if defined(PROG)
11839208Sbostic	install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
11940510Sbostic	    ${PROG} ${DESTDIR}${BINDIR}
12041602Sbostic.endif
12141369Sbostic.if defined(HIDEGAME)
12241369Sbostic	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
12341369Sbostic	    chown games.bin ${PROG})
12439208Sbostic.endif
12541602Sbostic.if defined(LINKS) && !empty(LINKS)
12641602Sbostic	@set ${LINKS}; \
12741602Sbostic	while test $$# -ge 2; do \
12841602Sbostic		l=${DESTDIR}$$1; \
12941602Sbostic		shift; \
13041602Sbostic		t=${DESTDIR}$$1; \
13141602Sbostic		shift; \
13241602Sbostic		echo $$t -\> $$l; \
13341602Sbostic		rm -f $$t; \
13441602Sbostic		ln $$l $$t; \
13541602Sbostic	done; true
13641602Sbostic.endif
13740510Sbostic
13841602Sbosticinstall: maninstall
13941602Sbosticmaninstall: afterinstall
14041602Sbosticafterinstall: realinstall
14141602Sbosticrealinstall: beforeinstall
14241461Sbostic.endif
14341461Sbostic
14441461Sbostic.if !target(lint)
14541602Sbosticlint: ${SRCS} _PROGSUBDIR
14642069Sbostic.if defined(PROG)
14741369Sbostic	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
14841461Sbostic.endif
14942069Sbostic.endif
15041369Sbostic
15143473Sbostic.if !target(obj)
15243473Sbostic.if defined(NOOBJ)
15343473Sbosticobj: _PROGSUBDIR
15443473Sbostic.else
15543473Sbosticobj: _PROGSUBDIR
15643473Sbostic	@cd ${.CURDIR}; rm -rf obj; \
15743473Sbostic	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
15843473Sbostic	echo "$$here -> $$dest"; ln -s $$dest obj
15943473Sbostic.endif
16043473Sbostic.endif
16143473Sbostic
16241461Sbostic.if !target(tags)
16341602Sbostictags: ${SRCS} _PROGSUBDIR
16442069Sbostic.if defined(PROG)
16543473Sbostic	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
16641874Sbostic	    sed "s;\${.CURDIR}/;;" > tags
16741461Sbostic.endif
16842069Sbostic.endif
16941369Sbostic
17041602Sbostic.if !defined(NOMAN)
17141602Sbostic.include <bsd.man.mk>
17241602Sbostic.endif
173