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