bsd.prog.mk revision 16437
1#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2#	$Id: bsd.prog.mk,v 1.31 1996/06/17 12:31:02 jkh Exp $
3
4.if exists(${.CURDIR}/../Makefile.inc)
5.include "${.CURDIR}/../Makefile.inc"
6.endif
7
8.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
9
10CFLAGS+=${COPTS} ${DEBUG_FLAGS}
11.if defined(DESTDIR)
12CFLAGS+= -I${DESTDIR}/usr/include
13CXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
14.endif
15
16.if !defined(DEBUG_FLAGS)
17STRIP?=	-s
18.endif
19
20
21LIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
22LIBKZHEAD?=	${DESTDIR}/usr/lib/kzhead.o
23LIBKZTAIL?=	${DESTDIR}/usr/lib/kztail.o
24
25LIBC?=		${DESTDIR}/usr/lib/libc.a
26LIBC_PIC=	${DESTDIR}/usr/lib/libc_pic.a
27LIBCOM_ERR=	${DESTDIR}/usr/lib/libcom_err.a
28LIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
29LIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
30LIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
31LIBDES?=	${DESTDIR}/usr/lib/libdes.a	# XXX doesn't exist
32LIBDIALOG?=	${DESTDIR}/usr/lib/libdialog.a
33LIBDISK?=	${DESTDIR}/usr/lib/libdisk.a
34LIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
35LIBF2C?=	${DESTDIR}/usr/lib/libf2c.a
36LIBFL?=		"don't use LIBFL, use LIBL"
37LIBFORMS?=	${DESTDIR}/usr/lib/libforms.a
38LIBFTPIO?=	${DESTDIR}/usr/lib/libftpio.a
39LIBGPLUSPLUS?=	${DESTDIR}/usr/lib/libg++.a
40LIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
41LIBGCC_PIC?=	${DESTDIR}/usr/lib/libgcc_pic.a
42LIBGMP?=	${DESTDIR}/usr/lib/libgmp.a
43LIBGNUREGEX?=	${DESTDIR}/usr/lib/libgnuregex.a
44LIBIPX?=	${DESTDIR}/usr/lib/libipx.a
45LIBKDB?=	${DESTDIR}/usr/lib/libkdb.a	# XXX doesn't exist
46LIBKRB?=	${DESTDIR}/usr/lib/libkrb.a	# XXX doesn't exist
47LIBKEYCAP?=	${DESTDIR}/usr/lib/libkeycap.a
48LIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
49LIBL?=		${DESTDIR}/usr/lib/libl.a
50LIBLN?=		"don't use, LIBLN, use LIBL"
51LIBM?=		${DESTDIR}/usr/lib/libm.a
52LIBMD?=		${DESTDIR}/usr/lib/libmd.a
53LIBMP?=		${DESTDIR}/usr/lib/libmp.a
54LIBMYTINFO?=	${DESTDIR}/usr/lib/libmytinfo.a
55LIBNCURSES?=	${DESTDIR}/usr/lib/libncurses.a
56LIBPC?=		${DESTDIR}/usr/lib/libpc.a	# XXX doesn't exist
57LIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
58LIBPLOT?=	${DESTDIR}/usr/lib/libplot.a	# XXX doesn't exist
59LIBREADLINE?=	${DESTDIR}/usr/lib/libreadline.a
60LIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
61LIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
62LIBSCRYPT?=	"don't use LIBSCRYPT, use LIBCRYPT"
63LIBSCSI?=	${DESTDIR}/usr/lib/libscsi.a
64LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
65LIBSS?=		${DESTDIR}/usr/lib/libss.a
66LIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
67LIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
68LIBTERMLIB?=	"don't use LIBTERMLIB, use LIBTERMCAP"
69LIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
70LIBXPG4?=	${DESTDIR}/usr/lib/libxpg4.a
71LIBY?=		${DESTDIR}/usr/lib/liby.a
72
73.if defined(NOSHARED)
74LDFLAGS+= -static
75.endif
76
77.if defined(DESTDIR)
78LDDESTDIR+=	-L${DESTDIR}/usr/lib
79.endif
80
81.if defined(PROG)
82.if defined(SRCS)
83
84DPSRCS+= ${SRCS:M*.h}
85.if !defined(NOOBJ)
86OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
87.endif
88
89.if defined(LDONLY)
90
91${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD} 
92	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
93		${LDADD}
94
95.else defined(LDONLY)
96
97${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
98	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
99
100.endif
101
102.else !defined(SRCS)
103
104SRCS=	${PROG}.c
105
106.if 0
107${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
108	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
109		${LDDESTDIR} ${LDADD}
110
111MKDEP=	-p
112.else
113# Always make an intermediate object file because:
114# - it saves time rebuilding when only the library has changed
115# - the name of the object gets put into the executable symbol table instead of
116#   the name of a variable temporary object.
117# - it's useful to keep objects around for crunching.
118OBJS=	${PROG}.o
119${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
120	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
121.endif
122
123.endif
124
125.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
126	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
127	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
128MAN1=	${PROG}.1
129.endif
130.endif
131
132_PROGSUBDIR: .USE
133.if defined(SUBDIR) && !empty(SUBDIR)
134	@for entry in ${SUBDIR}; do \
135		(${ECHODIR} "===> ${DIRPRFX}$$entry"; \
136		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
137			cd ${.CURDIR}/$${entry}.${MACHINE}; \
138		else \
139			cd ${.CURDIR}/$${entry}; \
140		fi; \
141		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \
142	done
143.endif
144
145# XXX I think MANDEPEND is only used for groff.  It should be named more
146# generally and perhaps not be in the maninstall dependencies now it is
147# here (or does maninstall always work when nothing is made?),
148
149.MAIN: all
150all: ${PROG} all-man _PROGSUBDIR
151
152.if !target(clean)
153clean: _PROGSUBDIR
154	rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES} 
155.if defined(CLEANDIRS)
156	rm -rf ${CLEANDIRS}
157.endif
158.endif
159
160.if !target(cleandir)
161cleandir: _PROGSUBDIR
162	rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES}
163	rm -f ${.CURDIR}/tags .depend
164.if defined(CLEANDIRS)
165	rm -rf ${CLEANDIRS}
166.endif
167	cd ${.CURDIR}; rm -rf obj;
168.endif
169
170.if !target(install)
171.if !target(beforeinstall)
172beforeinstall:
173.endif
174.if !target(afterinstall)
175afterinstall:
176.endif
177
178realinstall: _PROGSUBDIR
179.if defined(PROG)
180	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
181	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
182.endif
183.if defined(HIDEGAME)
184	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
185	    chown games.bin ${PROG})
186.endif
187.if defined(LINKS) && !empty(LINKS)
188	@set ${LINKS}; \
189	while test $$# -ge 2; do \
190		l=${DESTDIR}$$1; \
191		shift; \
192		t=${DESTDIR}$$1; \
193		shift; \
194		${ECHO} $$t -\> $$l; \
195		rm -f $$t; \
196		ln ${LN_FLAGS} $$l $$t; \
197	done; true
198.endif
199
200install: afterinstall
201.if !defined(NOMAN)
202afterinstall: realinstall maninstall
203.else
204afterinstall: realinstall
205.endif
206realinstall: beforeinstall
207.endif
208
209DISTRIBUTION?=	bin
210.if !target(distribute)
211distribute:
212	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
213.endif
214
215.if !target(lint)
216lint: ${SRCS} _PROGSUBDIR
217.if defined(PROG)
218	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
219.endif
220.endif
221
222.if !target(obj)
223.if defined(NOOBJ)
224obj: _PROGSUBDIR
225.else
226obj: _PROGSUBDIR
227	@cd ${.CURDIR}; rm -rf obj; \
228	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
229	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
230	if test -d /usr/obj -a ! -d $$dest; then \
231		mkdir -p $$dest; \
232	else \
233		true; \
234	fi;
235.endif
236.endif
237
238.if !target(tags)
239tags: ${SRCS} _PROGSUBDIR
240.if defined(PROG)
241	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
242	    sed "s;\${.CURDIR}/;;" > tags
243.endif
244.endif
245
246.if !defined(NOMAN)
247.include <bsd.man.mk>
248.elif !target(maninstall)
249maninstall:
250all-man:
251.endif
252
253_DEPSUBDIR=	_PROGSUBDIR
254.include <bsd.dep.mk>
255