xref: /csrg-svn/share/mk/bsd.prog.mk (revision 50803)
1*50803Skarels#	@(#)bsd.prog.mk	5.27 (Berkeley) 08/07/91
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:
1048946Sbostic	/usr/old/bin/nroff -mandoc ${.IMPSRC} > ${.TARGET}
1141559Sbostic
1241559SbosticCFLAGS+=${COPTS}
1341559Sbostic
1441602SbosticSTRIP?=	-s
1541602Sbostic
1641602SbosticBINGRP?=	bin
1741602SbosticBINOWN?=	bin
1841602SbosticBINMODE?=	555
1941602Sbostic
2044598SbosticLIBC?=		/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
4846047SbosticOBJS+=  ${SRCS:R:S/$/.o/g}
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}
71*50803Skarelsmanpages: ${MANALL}
7239208Sbostic
7341602Sbostic_PROGSUBDIR: .USE
7441369Sbostic.if defined(SUBDIR) && !empty(SUBDIR)
7541369Sbostic	@for entry in ${SUBDIR}; do \
7641602Sbostic		(echo "===> $$entry"; \
7741369Sbostic		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
7841369Sbostic			cd ${.CURDIR}/$${entry}.${MACHINE}; \
7941369Sbostic		else \
8041369Sbostic			cd ${.CURDIR}/$${entry}; \
8141369Sbostic		fi; \
8246193Sbostic		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
8341369Sbostic	done
8441369Sbostic.endif
8539193Sbostic
8641369Sbostic.MAIN: all
8741602Sbosticall: ${PROG} ${MANALL} _PROGSUBDIR
8839193Sbostic
8941369Sbostic.if !target(clean)
9041602Sbosticclean: _PROGSUBDIR
9141369Sbostic	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
9239208Sbostic.endif
9339208Sbostic
9441461Sbostic.if !target(cleandir)
9541602Sbosticcleandir: _PROGSUBDIR
9641369Sbostic	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
9750130Sbostic	rm -f .depend ${MANALL}
9841461Sbostic.endif
9939193Sbostic
10041369Sbostic# some of the rules involve .h sources, so remove them from mkdep line
10141461Sbostic.if !target(depend)
10242442Sbosticdepend: .depend _PROGSUBDIR
10342442Sbostic.depend: ${SRCS}
10442069Sbostic.if defined(PROG)
10543505Sbostic	mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
10641461Sbostic.endif
10742069Sbostic.endif
10839193Sbostic
10941461Sbostic.if !target(install)
11041461Sbostic.if !target(beforeinstall)
11141461Sbosticbeforeinstall:
11241461Sbostic.endif
11341602Sbostic.if !target(afterinstall)
11441602Sbosticafterinstall:
11541602Sbostic.endif
11641461Sbostic
11741602Sbosticrealinstall: _PROGSUBDIR
11841602Sbostic.if defined(PROG)
11939208Sbostic	install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
12040510Sbostic	    ${PROG} ${DESTDIR}${BINDIR}
12141602Sbostic.endif
12241369Sbostic.if defined(HIDEGAME)
12341369Sbostic	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
12441369Sbostic	    chown games.bin ${PROG})
12539208Sbostic.endif
12641602Sbostic.if defined(LINKS) && !empty(LINKS)
12741602Sbostic	@set ${LINKS}; \
12841602Sbostic	while test $$# -ge 2; do \
12941602Sbostic		l=${DESTDIR}$$1; \
13041602Sbostic		shift; \
13141602Sbostic		t=${DESTDIR}$$1; \
13241602Sbostic		shift; \
13341602Sbostic		echo $$t -\> $$l; \
13441602Sbostic		rm -f $$t; \
13541602Sbostic		ln $$l $$t; \
13641602Sbostic	done; true
13741602Sbostic.endif
13840510Sbostic
139*50803Skarelsinstall: afterinstall maninstall
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/,,'`; \
15845780Sbostic	echo "$$here -> $$dest"; ln -s $$dest obj; \
15945780Sbostic	if test -d /usr/obj -a ! -d $$dest; then \
16045780Sbostic		mkdir -p $$dest; \
16145780Sbostic	else \
16245780Sbostic		true; \
16345780Sbostic	fi;
16443473Sbostic.endif
16543473Sbostic.endif
16643473Sbostic
167*50803Skarels.if !target(objdir)
168*50803Skarels.if defined(NOOBJ)
169*50803Skarelsobjdir: _PROGSUBDIR
170*50803Skarels.else
171*50803Skarelsobjdir: _PROGSUBDIR
172*50803Skarels	@cd ${.CURDIR}; \
173*50803Skarels	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
174*50803Skarels	if test -d /usr/obj -a ! -d $$dest; then \
175*50803Skarels		mkdir -p $$dest; \
176*50803Skarels	else \
177*50803Skarels		true; \
178*50803Skarels	fi;
179*50803Skarels.endif
180*50803Skarels.endif
181*50803Skarels
18241461Sbostic.if !target(tags)
18341602Sbostictags: ${SRCS} _PROGSUBDIR
18442069Sbostic.if defined(PROG)
18543473Sbostic	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
18641874Sbostic	    sed "s;\${.CURDIR}/;;" > tags
18741461Sbostic.endif
18842069Sbostic.endif
18941369Sbostic
19041602Sbostic.if !defined(NOMAN)
19141602Sbostic.include <bsd.man.mk>
19241602Sbostic.endif
193