xref: /original-bsd/share/mk/bsd.prog.mk (revision 3b6250d9)
1#	@(#)bsd.prog.mk	5.31 (Berkeley) 04/08/92
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 -man ${.IMPSRC} > ${.TARGET}
11
12CFLAGS+=${COPTS}
13
14STRIP?=	-s
15
16BINGRP?=	bin
17BINOWN?=	bin
18BINMODE?=	555
19
20LIBC?=		/usr/lib/libc.a
21LIBCOMPAT?=	/usr/lib/libcompat.a
22LIBCURSES?=	/usr/lib/libcurses.a
23LIBDBM?=	/usr/lib/libdbm.a
24LIBDES?=	/usr/lib/libdes.a
25LIBL?=		/usr/lib/libl.a
26LIBKDB?=	/usr/lib/libkdb.a
27LIBKRB?=	/usr/lib/libkrb.a
28LIBKVM?=	/usr/lib/libkvm.a
29LIBM?=		/usr/lib/libm.a
30LIBMP?=		/usr/lib/libmp.a
31LIBPC?=		/usr/lib/libpc.a
32LIBPLOT?=	/usr/lib/libplot.a
33LIBRESOLV?=	/usr/lib/libresolv.a
34LIBRPC?=	/usr/lib/sunrpc.a
35LIBTERM?=	/usr/lib/libterm.a
36LIBUTIL?=	/usr/lib/libutil.a
37
38.if defined(SHAREDSTRINGS)
39CLEANFILES+=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
49OBJS+=  ${SRCS:R:S/$/.o/g}
50
51${PROG}: ${OBJS} ${LIBC} ${DPADD}
52	${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
53
54.else defined(SRCS)
55
56SRCS= ${PROG}.c
57
58${PROG}: ${SRCS} ${LIBC} ${DPADD}
59	${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
60
61MKDEP=	-p
62
63.endif
64
65.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
66	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
67	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
68MAN1=	${PROG}.0
69.endif
70.endif
71MANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
72manpages: ${MANALL}
73
74_PROGSUBDIR: .USE
75.if defined(SUBDIR) && !empty(SUBDIR)
76	@for entry in ${SUBDIR}; do \
77		(echo "===> $$entry"; \
78		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
79			cd ${.CURDIR}/$${entry}.${MACHINE}; \
80		else \
81			cd ${.CURDIR}/$${entry}; \
82		fi; \
83		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
84	done
85.endif
86
87.if !target(all)
88.MAIN: all
89all: ${PROG} ${MANALL} _PROGSUBDIR
90.endif
91
92.if !target(clean)
93clean: _PROGSUBDIR
94	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
95.endif
96
97.if !target(cleandir)
98cleandir: _PROGSUBDIR
99	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
100	rm -f .depend ${MANALL}
101.endif
102
103# some of the rules involve .h sources, so remove them from mkdep line
104.if !target(depend)
105depend: .depend _PROGSUBDIR
106.depend: ${SRCS}
107.if defined(PROG)
108	mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
109.endif
110.endif
111
112.if !target(install)
113.if !target(beforeinstall)
114beforeinstall:
115.endif
116.if !target(afterinstall)
117afterinstall:
118.endif
119
120realinstall: _PROGSUBDIR
121.if defined(PROG)
122	install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
123	    ${PROG} ${DESTDIR}${BINDIR}
124.endif
125.if defined(HIDEGAME)
126	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
127	    chown games.bin ${PROG})
128.endif
129.if defined(LINKS) && !empty(LINKS)
130	@set ${LINKS}; \
131	while test $$# -ge 2; do \
132		l=${DESTDIR}$$1; \
133		shift; \
134		t=${DESTDIR}$$1; \
135		shift; \
136		echo $$t -\> $$l; \
137		rm -f $$t; \
138		ln $$l $$t; \
139	done; true
140.endif
141
142install: afterinstall maninstall
143afterinstall: realinstall
144realinstall: beforeinstall
145.endif
146
147.if !target(lint)
148lint: ${SRCS} _PROGSUBDIR
149.if defined(PROG)
150	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
151.endif
152.endif
153
154.if !target(obj)
155.if defined(NOOBJ)
156obj: _PROGSUBDIR
157.else
158obj: _PROGSUBDIR
159	@cd ${.CURDIR}; rm -rf obj; \
160	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
161	echo "$$here -> $$dest"; ln -s $$dest obj; \
162	if test -d /usr/obj -a ! -d $$dest; then \
163		mkdir -p $$dest; \
164	else \
165		true; \
166	fi;
167.endif
168.endif
169
170.if !target(objdir)
171.if defined(NOOBJ)
172objdir: _PROGSUBDIR
173.else
174objdir: _PROGSUBDIR
175	@cd ${.CURDIR}; \
176	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
177	if test -d /usr/obj -a ! -d $$dest; then \
178		mkdir -p $$dest; \
179	else \
180		true; \
181	fi;
182.endif
183.endif
184
185.if !target(tags)
186tags: ${SRCS} _PROGSUBDIR
187.if defined(PROG)
188	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
189	    sed "s;\${.CURDIR}/;;" > tags
190.endif
191.endif
192
193.if !defined(NOMAN)
194.include <bsd.man.mk>
195.else
196maninstall:
197.endif
198