xref: /freebsd/contrib/bmake/Makefile (revision 3df058ffaf72b8715c9a5a6a4cbaf1eac1910e43)
1#	$Id: Makefile,v 1.39 2015/06/07 15:54:37 sjg Exp $
2
3# Base version on src date
4MAKE_VERSION= 20150606
5
6PROG=	bmake
7
8SRCS= \
9	arch.c \
10	buf.c \
11	compat.c \
12	cond.c \
13	dir.c \
14	for.c \
15	hash.c \
16	job.c \
17	main.c \
18	make.c \
19	make_malloc.c \
20	meta.c \
21	parse.c \
22	str.c \
23	strlist.c \
24	suff.c \
25	targ.c \
26	trace.c \
27	util.c \
28	var.c
29
30# from lst.lib/
31SRCS+= \
32	lstAppend.c \
33	lstAtEnd.c \
34	lstAtFront.c \
35	lstClose.c \
36	lstConcat.c \
37	lstDatum.c \
38	lstDeQueue.c \
39	lstDestroy.c \
40	lstDupl.c \
41	lstEnQueue.c \
42	lstFind.c \
43	lstFindFrom.c \
44	lstFirst.c \
45	lstForEach.c \
46	lstForEachFrom.c \
47	lstInit.c \
48	lstInsert.c \
49	lstIsAtEnd.c \
50	lstIsEmpty.c \
51	lstLast.c \
52	lstMember.c \
53	lstNext.c \
54	lstOpen.c \
55	lstPrev.c \
56	lstRemove.c \
57	lstReplace.c \
58	lstSucc.c
59
60# this file gets generated by configure
61.-include "Makefile.config"
62
63.if !empty(LIBOBJS)
64SRCS+= ${LIBOBJS:T:.o=.c}
65.endif
66
67# just in case
68prefix?= /usr
69srcdir?= ${.CURDIR}
70
71DEFAULT_SYS_PATH?= ${prefix}/share/mk
72
73CPPFLAGS+= -DUSE_META
74CFLAGS+= ${CPPFLAGS}
75CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
76CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
77CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
78COPTS.main.c+= "-DMAKE_VERSION=\"${MAKE_VERSION}\""
79
80# meta mode can be useful even without filemon
81FILEMON_H ?= /usr/include/dev/filemon/filemon.h
82.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
83COPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
84.endif
85
86.PATH:	${srcdir}
87.PATH:	${srcdir}/lst.lib
88
89.if make(obj) || make(clean)
90SUBDIR+= unit-tests
91.endif
92
93# start-delete1 for bsd.after-import.mk
94# we skip a lot of this when building as part of FreeBSD etc.
95
96# list of OS's which are derrived from BSD4.4
97BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig
98# we are...
99OS!= uname -s
100# are we 4.4BSD ?
101isBSD44:=${BSD44_LIST:M${OS}}
102
103.if ${isBSD44} == ""
104MANTARGET= cat
105INSTALL?=${srcdir}/install-sh
106.if (${MACHINE} == "sun386")
107# even I don't have one of these anymore :-)
108CFLAGS+= -DPORTAR
109.elif (${MACHINE} != "sunos")
110SRCS+= sigcompat.c
111CFLAGS+= -DSIGNAL_FLAGS=SA_RESTART
112.endif
113.else
114MANTARGET?= man
115.endif
116
117# turn this on by default - ignored if we are root
118WITH_INSTALL_AS_USER=
119
120# suppress with -DWITHOUT_*
121OPTIONS_DEFAULT_YES+= \
122	AUTOCONF_MK \
123	INSTALL_MK \
124	PROG_LINK
125
126OPTIONS_DEFAULT_NO+= \
127	PROG_VERSION
128
129# process options now
130.include <own.mk>
131
132.if ${MK_PROG_VERSION} == "yes"
133PROG_NAME= ${PROG}-${MAKE_VERSION}
134.if ${MK_PROG_LINK} == "yes"
135SYMLINKS+= ${PROG}-${MAKE_VERSION} ${BINDIR}/${PROG}
136.endif
137.endif
138
139EXTRACT_MAN=no
140# end-delete1
141
142MAN= ${PROG}.1
143MAN1= ${MAN}
144
145.if (${PROG} != "make")
146CLEANFILES+= my.history
147.if make(${MAN}) || !exists(${srcdir}/${MAN})
148my.history: ${MAKEFILE}
149	@(echo ".Nm"; \
150	echo "is derived from NetBSD"; \
151	echo ".Xr make 1 ."; \
152	echo "It uses autoconf to facilitate portability to other platforms."; \
153	echo ".Pp") > $@
154
155.NOPATH: ${MAN}
156${MAN}:	make.1 my.history
157	@echo making $@
158	@sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \
159	-e '/^.Sh HISTORY/rmy.history' \
160	-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
161
162all beforeinstall: ${MAN}
163_mfromdir=.
164.endif
165.endif
166
167MANTARGET?= cat
168MANDEST?= ${MANDIR}/${MANTARGET}1
169
170.if ${MANTARGET} == "cat"
171_mfromdir=${srcdir}
172.endif
173
174.include <prog.mk>
175
176CPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H
177COPTS.var.c += -Wno-cast-qual
178COPTS.job.c += -Wno-format-nonliteral
179COPTS.parse.c += -Wno-format-nonliteral
180COPTS.var.c += -Wno-format-nonliteral
181
182# Force these
183SHAREDIR= ${SHAREDIR.bmake:U${prefix}/share}
184BINDIR= ${BINDIR.bmake:U${prefix}/bin}
185MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man}
186
187.if !exists(.depend)
188${OBJS}: config.h
189.endif
190
191# make sure that MAKE_VERSION gets updated.
192main.o: ${SRCS} ${MAKEFILE}
193
194# start-delete2 for bsd.after-import.mk
195.if ${MK_AUTOCONF_MK} == "yes"
196.include <autoconf.mk>
197.endif
198SHARE_MK?=${SHAREDIR}/mk
199MKSRC=${srcdir}/mk
200INSTALL?=${srcdir}/install-sh
201
202.if ${MK_INSTALL_MK} == "yes"
203install: install-mk
204.endif
205
206beforeinstall:
207	test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR}
208	test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST}
209
210install-mk:
211.if exists(${MKSRC}/install-mk)
212	test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK}
213	sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK}
214.else
215	@echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
216.endif
217# end-delete2
218
219# A simple unit-test driver to help catch regressions
220accept test:
221	cd ${.CURDIR}/unit-tests && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
222