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