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