xref: /freebsd/share/mk/bsd.prog.mk (revision afe61c15161c324a7af299a9b8457aba5afc92db)
1afe61c15SRodney W. Grimes#	@(#)bsd.prog.mk	8.2 (Berkeley) 4/2/94
2afe61c15SRodney W. Grimes
3afe61c15SRodney W. Grimes.if !defined(NOINCLUDE) && exists(${.CURDIR}/../Makefile.inc)
4afe61c15SRodney W. Grimes.include "${.CURDIR}/../Makefile.inc"
5afe61c15SRodney W. Grimes.endif
6afe61c15SRodney W. Grimes
7afe61c15SRodney W. Grimes.SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
8afe61c15SRodney W. Grimes
9afe61c15SRodney W. Grimes.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
10afe61c15SRodney W. Grimes	nroff -man ${.IMPSRC} > ${.TARGET}
11afe61c15SRodney W. Grimes
12afe61c15SRodney W. GrimesCFLAGS+=${COPTS}
13afe61c15SRodney W. Grimes
14afe61c15SRodney W. GrimesSTRIP?=	-s
15afe61c15SRodney W. Grimes
16afe61c15SRodney W. GrimesBINGRP?=	bin
17afe61c15SRodney W. GrimesBINOWN?=	bin
18afe61c15SRodney W. GrimesBINMODE?=	555
19afe61c15SRodney W. Grimes
20afe61c15SRodney W. GrimesLIBC?=		/usr/lib/libc.a
21afe61c15SRodney W. GrimesLIBCOMPAT?=	/usr/lib/libcompat.a
22afe61c15SRodney W. GrimesLIBCURSES?=	/usr/lib/libcurses.a
23afe61c15SRodney W. GrimesLIBDBM?=	/usr/lib/libdbm.a
24afe61c15SRodney W. GrimesLIBDES?=	/usr/lib/libdes.a
25afe61c15SRodney W. GrimesLIBL?=		/usr/lib/libl.a
26afe61c15SRodney W. GrimesLIBKDB?=	/usr/lib/libkdb.a
27afe61c15SRodney W. GrimesLIBKRB?=	/usr/lib/libkrb.a
28afe61c15SRodney W. GrimesLIBKVM?=	/usr/lib/libkvm.a
29afe61c15SRodney W. GrimesLIBM?=		/usr/lib/libm.a
30afe61c15SRodney W. GrimesLIBMP?=		/usr/lib/libmp.a
31afe61c15SRodney W. GrimesLIBPC?=		/usr/lib/libpc.a
32afe61c15SRodney W. GrimesLIBPLOT?=	/usr/lib/libplot.a
33afe61c15SRodney W. GrimesLIBRESOLV?=	/usr/lib/libresolv.a
34afe61c15SRodney W. GrimesLIBRPC?=	/usr/lib/sunrpc.a
35afe61c15SRodney W. GrimesLIBTERM?=	/usr/lib/libterm.a
36afe61c15SRodney W. GrimesLIBUTIL?=	/usr/lib/libutil.a
37afe61c15SRodney W. Grimes
38afe61c15SRodney W. Grimes.if defined(SHAREDSTRINGS)
39afe61c15SRodney W. GrimesCLEANFILES+=strings
40afe61c15SRodney W. Grimes.c.o:
41afe61c15SRodney W. Grimes	${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
42afe61c15SRodney W. Grimes	@${CC} ${CFLAGS} -c x.c -o ${.TARGET}
43afe61c15SRodney W. Grimes	@rm -f x.c
44afe61c15SRodney W. Grimes.endif
45afe61c15SRodney W. Grimes
46afe61c15SRodney W. Grimes.if defined(PROG)
47afe61c15SRodney W. Grimes.if defined(SRCS)
48afe61c15SRodney W. Grimes
49afe61c15SRodney W. GrimesOBJS+=  ${SRCS:R:S/$/.o/g}
50afe61c15SRodney W. Grimes
51afe61c15SRodney W. Grimes${PROG}: ${OBJS} ${LIBC} ${DPADD}
52afe61c15SRodney W. Grimes	${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
53afe61c15SRodney W. Grimes
54afe61c15SRodney W. Grimes.else defined(SRCS)
55afe61c15SRodney W. Grimes
56afe61c15SRodney W. GrimesSRCS= ${PROG}.c
57afe61c15SRodney W. Grimes
58afe61c15SRodney W. Grimes${PROG}: ${SRCS} ${LIBC} ${DPADD}
59afe61c15SRodney W. Grimes	${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
60afe61c15SRodney W. Grimes
61afe61c15SRodney W. GrimesMKDEP=	-p
62afe61c15SRodney W. Grimes
63afe61c15SRodney W. Grimes.endif
64afe61c15SRodney W. Grimes
65afe61c15SRodney W. Grimes.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
66afe61c15SRodney W. Grimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
67afe61c15SRodney W. Grimes	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
68afe61c15SRodney W. GrimesMAN1=	${PROG}.0
69afe61c15SRodney W. Grimes.endif
70afe61c15SRodney W. Grimes.endif
71afe61c15SRodney W. Grimes.if !defined(NOMAN)
72afe61c15SRodney W. GrimesMANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
73afe61c15SRodney W. Grimes.else
74afe61c15SRodney W. GrimesMANALL=
75afe61c15SRodney W. Grimes.endif
76afe61c15SRodney W. Grimesmanpages: ${MANALL}
77afe61c15SRodney W. Grimes
78afe61c15SRodney W. Grimes_PROGSUBDIR: .USE
79afe61c15SRodney W. Grimes.if defined(SUBDIR) && !empty(SUBDIR)
80afe61c15SRodney W. Grimes	@for entry in ${SUBDIR}; do \
81afe61c15SRodney W. Grimes		(echo "===> $$entry"; \
82afe61c15SRodney W. Grimes		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
83afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}.${MACHINE}; \
84afe61c15SRodney W. Grimes		else \
85afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}; \
86afe61c15SRodney W. Grimes		fi; \
87afe61c15SRodney W. Grimes		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
88afe61c15SRodney W. Grimes	done
89afe61c15SRodney W. Grimes.endif
90afe61c15SRodney W. Grimes
91afe61c15SRodney W. Grimes.if !target(all)
92afe61c15SRodney W. Grimes.MAIN: all
93afe61c15SRodney W. Grimesall: ${PROG} ${MANALL} _PROGSUBDIR
94afe61c15SRodney W. Grimes.endif
95afe61c15SRodney W. Grimes
96afe61c15SRodney W. Grimes.if !target(clean)
97afe61c15SRodney W. Grimesclean: _PROGSUBDIR
98afe61c15SRodney W. Grimes	rm -f a.out [Ee]rrs mklog ${PROG}.core ${PROG} ${OBJS} ${CLEANFILES}
99afe61c15SRodney W. Grimes.endif
100afe61c15SRodney W. Grimes
101afe61c15SRodney W. Grimes.if !target(cleandir)
102afe61c15SRodney W. Grimescleandir: _PROGSUBDIR
103afe61c15SRodney W. Grimes	rm -f a.out [Ee]rrs mklog ${PROG}.core ${PROG} ${OBJS} ${CLEANFILES}
104afe61c15SRodney W. Grimes	rm -f .depend ${MANALL}
105afe61c15SRodney W. Grimes.endif
106afe61c15SRodney W. Grimes
107afe61c15SRodney W. Grimes# some of the rules involve .h sources, so remove them from mkdep line
108afe61c15SRodney W. Grimes.if !target(depend)
109afe61c15SRodney W. Grimesdepend: .depend _PROGSUBDIR
110afe61c15SRodney W. Grimes.depend: ${SRCS}
111afe61c15SRodney W. Grimes.if defined(PROG)
112afe61c15SRodney W. Grimes	mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
113afe61c15SRodney W. Grimes.endif
114afe61c15SRodney W. Grimes.endif
115afe61c15SRodney W. Grimes
116afe61c15SRodney W. Grimes.if !target(install)
117afe61c15SRodney W. Grimes.if !target(beforeinstall)
118afe61c15SRodney W. Grimesbeforeinstall:
119afe61c15SRodney W. Grimes.endif
120afe61c15SRodney W. Grimes.if !target(afterinstall)
121afe61c15SRodney W. Grimesafterinstall:
122afe61c15SRodney W. Grimes.endif
123afe61c15SRodney W. Grimes
124afe61c15SRodney W. Grimesrealinstall: _PROGSUBDIR
125afe61c15SRodney W. Grimes.if defined(PROG)
126afe61c15SRodney W. Grimes	install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
127afe61c15SRodney W. Grimes	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
128afe61c15SRodney W. Grimes.endif
129afe61c15SRodney W. Grimes.if defined(HIDEGAME)
130afe61c15SRodney W. Grimes	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
131afe61c15SRodney W. Grimes	    chown games.bin ${PROG})
132afe61c15SRodney W. Grimes.endif
133afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS)
134afe61c15SRodney W. Grimes	@set ${LINKS}; \
135afe61c15SRodney W. Grimes	while test $$# -ge 2; do \
136afe61c15SRodney W. Grimes		l=${DESTDIR}$$1; \
137afe61c15SRodney W. Grimes		shift; \
138afe61c15SRodney W. Grimes		t=${DESTDIR}$$1; \
139afe61c15SRodney W. Grimes		shift; \
140afe61c15SRodney W. Grimes		echo $$t -\> $$l; \
141afe61c15SRodney W. Grimes		rm -f $$t; \
142afe61c15SRodney W. Grimes		ln $$l $$t; \
143afe61c15SRodney W. Grimes	done; true
144afe61c15SRodney W. Grimes.endif
145afe61c15SRodney W. Grimes
146afe61c15SRodney W. Grimesinstall: afterinstall maninstall
147afe61c15SRodney W. Grimesafterinstall: realinstall
148afe61c15SRodney W. Grimesrealinstall: beforeinstall
149afe61c15SRodney W. Grimes.endif
150afe61c15SRodney W. Grimes
151afe61c15SRodney W. Grimes.if !target(lint)
152afe61c15SRodney W. Grimeslint: ${SRCS} _PROGSUBDIR
153afe61c15SRodney W. Grimes.if defined(PROG)
154afe61c15SRodney W. Grimes	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
155afe61c15SRodney W. Grimes.endif
156afe61c15SRodney W. Grimes.endif
157afe61c15SRodney W. Grimes
158afe61c15SRodney W. Grimes.if !target(obj)
159afe61c15SRodney W. Grimes.if defined(NOOBJ)
160afe61c15SRodney W. Grimesobj: _PROGSUBDIR
161afe61c15SRodney W. Grimes.else
162afe61c15SRodney W. Grimesobj: _PROGSUBDIR
163afe61c15SRodney W. Grimes	@cd ${.CURDIR}; rm -rf obj; \
164afe61c15SRodney W. Grimes	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
165afe61c15SRodney W. Grimes	echo "$$here -> $$dest"; ln -s $$dest obj; \
166afe61c15SRodney W. Grimes	if test -d /usr/obj -a ! -d $$dest; then \
167afe61c15SRodney W. Grimes		mkdir -p $$dest; \
168afe61c15SRodney W. Grimes	else \
169afe61c15SRodney W. Grimes		true; \
170afe61c15SRodney W. Grimes	fi;
171afe61c15SRodney W. Grimes.endif
172afe61c15SRodney W. Grimes.endif
173afe61c15SRodney W. Grimes
174afe61c15SRodney W. Grimes.if !target(objdir)
175afe61c15SRodney W. Grimes.if defined(NOOBJ)
176afe61c15SRodney W. Grimesobjdir: _PROGSUBDIR
177afe61c15SRodney W. Grimes.else
178afe61c15SRodney W. Grimesobjdir: _PROGSUBDIR
179afe61c15SRodney W. Grimes	@cd ${.CURDIR}; \
180afe61c15SRodney W. Grimes	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
181afe61c15SRodney W. Grimes	if test -d /usr/obj -a ! -d $$dest; then \
182afe61c15SRodney W. Grimes		mkdir -p $$dest; \
183afe61c15SRodney W. Grimes	else \
184afe61c15SRodney W. Grimes		true; \
185afe61c15SRodney W. Grimes	fi;
186afe61c15SRodney W. Grimes.endif
187afe61c15SRodney W. Grimes.endif
188afe61c15SRodney W. Grimes
189afe61c15SRodney W. Grimes.if !target(tags)
190afe61c15SRodney W. Grimestags: ${SRCS} _PROGSUBDIR
191afe61c15SRodney W. Grimes.if defined(PROG)
192afe61c15SRodney W. Grimes	-ctags -f /dev/stdout ${.ALLSRC} | \
193afe61c15SRodney W. Grimes	    sed "s;${.CURDIR}/;;" > ${.CURDIR}/tags
194afe61c15SRodney W. Grimes.endif
195afe61c15SRodney W. Grimes.endif
196afe61c15SRodney W. Grimes
197afe61c15SRodney W. Grimes.if !defined(NOMAN)
198afe61c15SRodney W. Grimes.include <bsd.man.mk>
199afe61c15SRodney W. Grimes.else
200afe61c15SRodney W. Grimesmaninstall:
201afe61c15SRodney W. Grimes.endif
202