bsd.prog.mk revision 17819
1#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2#	$Id: bsd.prog.mk,v 1.35 1996/06/29 03:12:49 phk 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
66LIBTCL?=	${DESTDIR}/usr/lib/libtcl.a
67LIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
68LIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
69LIBTERMLIB?=	"don't use LIBTERMLIB, use LIBTERMCAP"
70LIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
71LIBXPG4?=	${DESTDIR}/usr/lib/libxpg4.a
72LIBY?=		${DESTDIR}/usr/lib/liby.a
73
74.if defined(NOSHARED)
75LDFLAGS+= -static
76.endif
77
78.if defined(DESTDIR)
79LDDESTDIR+=	-L${DESTDIR}/usr/lib
80.endif
81
82.if defined(PROG)
83.if defined(SRCS)
84
85DPSRCS+= ${SRCS:M*.h}
86.if !defined(NOOBJ)
87OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
88.endif
89
90.if defined(LDONLY)
91
92${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD} 
93	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
94		${LDADD}
95
96.else defined(LDONLY)
97
98${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
99	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
100
101.endif
102
103.else !defined(SRCS)
104
105SRCS=	${PROG}.c
106
107.if 0
108${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
109	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
110		${LDDESTDIR} ${LDADD}
111
112MKDEP=	-p
113.else
114# Always make an intermediate object file because:
115# - it saves time rebuilding when only the library has changed
116# - the name of the object gets put into the executable symbol table instead of
117#   the name of a variable temporary object.
118# - it's useful to keep objects around for crunching.
119OBJS=	${PROG}.o
120${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
121	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
122.endif
123
124.endif
125
126.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
127	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
128	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
129MAN1=	${PROG}.1
130.endif
131.endif
132
133# XXX I think MANDEPEND is only used for groff.  It should be named more
134# generally and perhaps not be in the maninstall dependencies now it is
135# here (or does maninstall always work when nothing is made?),
136
137.MAIN: all
138all: ${PROG} all-man _SUBDIR
139
140.if !target(clean)
141clean: _SUBDIR
142	rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES} 
143.if defined(CLEANDIRS) && !empty(CLEANDIRS)
144	rm -rf ${CLEANDIRS}
145.endif
146.endif
147
148.if !target(install)
149.if !target(beforeinstall)
150beforeinstall:
151.endif
152
153realinstall: beforeinstall
154.if defined(PROG)
155	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
156	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
157.endif
158.if defined(HIDEGAME)
159	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
160	    chown games.bin ${PROG})
161.endif
162.if defined(LINKS) && !empty(LINKS)
163	@set ${LINKS}; \
164	while test $$# -ge 2; do \
165		l=${DESTDIR}$$1; \
166		shift; \
167		t=${DESTDIR}$$1; \
168		shift; \
169		${ECHO} $$t -\> $$l; \
170		rm -f $$t; \
171		ln ${LN_FLAGS} $$l $$t; \
172	done; true
173.endif
174
175install: afterinstall _SUBDIR
176.if !defined(NOMAN)
177afterinstall: realinstall maninstall
178.else
179afterinstall: realinstall
180.endif
181.endif
182
183DISTRIBUTION?=	bin
184.if !target(distribute)
185distribute: _SUBDIR
186	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
187.endif
188
189.if !target(lint)
190lint: ${SRCS} _SUBDIR
191.if defined(PROG)
192	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
193.endif
194.endif
195
196.if !target(tags)
197tags: ${SRCS} _SUBDIR
198.if defined(PROG)
199	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
200	    sed "s;\${.CURDIR}/;;" > tags
201.endif
202.endif
203
204.if !defined(NOMAN)
205.include <bsd.man.mk>
206.elif !target(maninstall)
207maninstall:
208all-man:
209.endif
210
211.include <bsd.dep.mk>
212.include <bsd.obj.mk>
213