xref: /freebsd/contrib/bmake/Makefile (revision 78373a5faa3bab46d247c10a7059e484bc634504)
1#	$Id: Makefile,v 1.99 2017/08/13 20:12:53 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
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_NAME} ${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 \
159	-e '/^.Dt/s/MAKE/${PROG:tu}/' \
160	-e 's/^.Nx/NetBSD/' \
161	-e '/^.Nm/s/make/${PROG}/' \
162	-e '/^.Sh HISTORY/rmy.history' \
163	-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
164
165all beforeinstall: ${MAN}
166_mfromdir=.
167.endif
168.endif
169
170MANTARGET?= cat
171MANDEST?= ${MANDIR}/${MANTARGET}1
172
173.if ${MANTARGET} == "cat"
174_mfromdir=${srcdir}
175.endif
176
177.include <prog.mk>
178
179CPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H
180COPTS.var.c += -Wno-cast-qual
181COPTS.job.c += -Wno-format-nonliteral
182COPTS.parse.c += -Wno-format-nonliteral
183COPTS.var.c += -Wno-format-nonliteral
184
185# Force these
186SHAREDIR= ${SHAREDIR.bmake:U${prefix}/share}
187BINDIR= ${BINDIR.bmake:U${prefix}/bin}
188MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man}
189
190.if !exists(.depend)
191${OBJS}: config.h
192.endif
193
194# start-delete2 for bsd.after-import.mk
195
196# make sure that MAKE_VERSION gets updated.
197main.o: ${SRCS} ${.CURDIR}/VERSION
198
199.if ${MK_AUTOCONF_MK} == "yes"
200CONFIGURE_DEPS += ${.CURDIR}/VERSION
201.include <autoconf.mk>
202.endif
203SHARE_MK?=${SHAREDIR}/mk
204MKSRC=${srcdir}/mk
205INSTALL?=${srcdir}/install-sh
206
207.if ${MK_INSTALL_MK} == "yes"
208install: install-mk
209.endif
210
211beforeinstall:
212	test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR}
213	test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST}
214
215install-mk:
216.if exists(${MKSRC}/install-mk)
217	test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK}
218	sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK}
219.else
220	@echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
221.endif
222# end-delete2
223
224# A simple unit-test driver to help catch regressions
225accept test:
226	cd ${.CURDIR}/unit-tests && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
227