Makefile revision 300313
1300313Ssjg#	$Id: Makefile,v 1.63 2016/05/12 20:34:46 sjg Exp $
2246149Ssjg
3246149Ssjg# Base version on src date
4300313Ssjg_MAKE_VERSION= 20160512
5246149Ssjg
6246149SsjgPROG=	bmake
7246149Ssjg
8246149SsjgSRCS= \
9246149Ssjg	arch.c \
10246149Ssjg	buf.c \
11246149Ssjg	compat.c \
12246149Ssjg	cond.c \
13246149Ssjg	dir.c \
14246149Ssjg	for.c \
15246149Ssjg	hash.c \
16246149Ssjg	job.c \
17246149Ssjg	main.c \
18246149Ssjg	make.c \
19246149Ssjg	make_malloc.c \
20246149Ssjg	meta.c \
21289842Ssjg	metachar.c \
22246149Ssjg	parse.c \
23246149Ssjg	str.c \
24246149Ssjg	strlist.c \
25246149Ssjg	suff.c \
26246149Ssjg	targ.c \
27246149Ssjg	trace.c \
28246149Ssjg	util.c \
29246149Ssjg	var.c
30246149Ssjg
31246149Ssjg# from lst.lib/
32246149SsjgSRCS+= \
33246149Ssjg	lstAppend.c \
34246149Ssjg	lstAtEnd.c \
35246149Ssjg	lstAtFront.c \
36246149Ssjg	lstClose.c \
37246149Ssjg	lstConcat.c \
38246149Ssjg	lstDatum.c \
39246149Ssjg	lstDeQueue.c \
40246149Ssjg	lstDestroy.c \
41246149Ssjg	lstDupl.c \
42246149Ssjg	lstEnQueue.c \
43246149Ssjg	lstFind.c \
44246149Ssjg	lstFindFrom.c \
45246149Ssjg	lstFirst.c \
46246149Ssjg	lstForEach.c \
47246149Ssjg	lstForEachFrom.c \
48246149Ssjg	lstInit.c \
49246149Ssjg	lstInsert.c \
50246149Ssjg	lstIsAtEnd.c \
51246149Ssjg	lstIsEmpty.c \
52246149Ssjg	lstLast.c \
53246149Ssjg	lstMember.c \
54246149Ssjg	lstNext.c \
55246149Ssjg	lstOpen.c \
56246149Ssjg	lstPrev.c \
57246149Ssjg	lstRemove.c \
58246149Ssjg	lstReplace.c \
59246149Ssjg	lstSucc.c
60246149Ssjg
61246149Ssjg# this file gets generated by configure
62246149Ssjg.-include "Makefile.config"
63246149Ssjg
64246149Ssjg.if !empty(LIBOBJS)
65246149SsjgSRCS+= ${LIBOBJS:T:.o=.c}
66246149Ssjg.endif
67246149Ssjg
68246149Ssjg# just in case
69246149Ssjgprefix?= /usr
70246149Ssjgsrcdir?= ${.CURDIR}
71246149Ssjg
72261212SsjgDEFAULT_SYS_PATH?= ${prefix}/share/mk
73246149Ssjg
74246149SsjgCPPFLAGS+= -DUSE_META
75246149SsjgCFLAGS+= ${CPPFLAGS}
76246149SsjgCFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
77246149SsjgCFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
78246149SsjgCFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
79297040SsjgCOPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\""
80246149Ssjg
81246149Ssjg# meta mode can be useful even without filemon 
82246149SsjgFILEMON_H ?= /usr/include/dev/filemon/filemon.h
83246149Ssjg.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
84246149SsjgCOPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
85246149Ssjg.endif
86246149Ssjg
87246149Ssjg.PATH:	${srcdir}
88246149Ssjg.PATH:	${srcdir}/lst.lib
89246149Ssjg
90246149Ssjg.if make(obj) || make(clean)
91246149SsjgSUBDIR+= unit-tests
92246149Ssjg.endif
93246149Ssjg
94246149Ssjg# start-delete1 for bsd.after-import.mk
95246149Ssjg# we skip a lot of this when building as part of FreeBSD etc.
96246149Ssjg
97246149Ssjg# list of OS's which are derrived from BSD4.4
98282740SsjgBSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig
99246149Ssjg# we are...
100246149SsjgOS!= uname -s
101246149Ssjg# are we 4.4BSD ?
102246149SsjgisBSD44:=${BSD44_LIST:M${OS}}
103246149Ssjg
104246149Ssjg.if ${isBSD44} == ""
105246149SsjgMANTARGET= cat
106246149SsjgINSTALL?=${srcdir}/install-sh
107246149Ssjg.if (${MACHINE} == "sun386")
108246149Ssjg# even I don't have one of these anymore :-)
109246149SsjgCFLAGS+= -DPORTAR
110246149Ssjg.elif (${MACHINE} != "sunos")
111246149SsjgSRCS+= sigcompat.c
112246149SsjgCFLAGS+= -DSIGNAL_FLAGS=SA_RESTART
113246149Ssjg.endif
114246149Ssjg.else
115246149SsjgMANTARGET?= man
116246149Ssjg.endif
117246149Ssjg
118246149Ssjg# turn this on by default - ignored if we are root
119246149SsjgWITH_INSTALL_AS_USER=
120246149Ssjg
121268437Ssjg# suppress with -DWITHOUT_*
122246149SsjgOPTIONS_DEFAULT_YES+= \
123246149Ssjg	AUTOCONF_MK \
124246149Ssjg	INSTALL_MK \
125246149Ssjg	PROG_LINK
126246149Ssjg
127246149SsjgOPTIONS_DEFAULT_NO+= \
128246149Ssjg	PROG_VERSION
129246149Ssjg
130246149Ssjg# process options now
131246149Ssjg.include <own.mk>
132246149Ssjg
133246149Ssjg.if ${MK_PROG_VERSION} == "yes"
134300313SsjgPROG_NAME= ${PROG}-${_MAKE_VERSION}
135246149Ssjg.if ${MK_PROG_LINK} == "yes"
136300313SsjgSYMLINKS+= ${PROG_NAME} ${BINDIR}/${PROG}
137246149Ssjg.endif
138246149Ssjg.endif
139246149Ssjg
140246149SsjgEXTRACT_MAN=no
141246149Ssjg# end-delete1
142246149Ssjg
143246149SsjgMAN= ${PROG}.1
144246149SsjgMAN1= ${MAN}
145246149Ssjg
146246149Ssjg.if (${PROG} != "make")
147246149SsjgCLEANFILES+= my.history
148246149Ssjg.if make(${MAN}) || !exists(${srcdir}/${MAN})
149246149Ssjgmy.history: ${MAKEFILE}
150246149Ssjg	@(echo ".Nm"; \
151246149Ssjg	echo "is derived from NetBSD"; \
152246149Ssjg	echo ".Xr make 1 ."; \
153246149Ssjg	echo "It uses autoconf to facilitate portability to other platforms."; \
154246149Ssjg	echo ".Pp") > $@
155246149Ssjg
156246149Ssjg.NOPATH: ${MAN}
157246149Ssjg${MAN}:	make.1 my.history
158246149Ssjg	@echo making $@
159246149Ssjg	@sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \
160246149Ssjg	-e '/^.Sh HISTORY/rmy.history' \
161246149Ssjg	-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
162246149Ssjg
163246149Ssjgall beforeinstall: ${MAN}
164246149Ssjg_mfromdir=.
165246149Ssjg.endif
166246149Ssjg.endif
167246149Ssjg
168246149SsjgMANTARGET?= cat
169246149SsjgMANDEST?= ${MANDIR}/${MANTARGET}1
170246149Ssjg
171246149Ssjg.if ${MANTARGET} == "cat"
172246149Ssjg_mfromdir=${srcdir}
173246149Ssjg.endif
174246149Ssjg
175246149Ssjg.include <prog.mk>
176246149Ssjg
177246149SsjgCPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H
178246149SsjgCOPTS.var.c += -Wno-cast-qual
179246149SsjgCOPTS.job.c += -Wno-format-nonliteral
180246149SsjgCOPTS.parse.c += -Wno-format-nonliteral
181246149SsjgCOPTS.var.c += -Wno-format-nonliteral
182246149Ssjg
183246149Ssjg# Force these
184281812SsjgSHAREDIR= ${SHAREDIR.bmake:U${prefix}/share}
185281812SsjgBINDIR= ${BINDIR.bmake:U${prefix}/bin}
186281812SsjgMANDIR= ${MANDIR.bmake:U${SHAREDIR}/man}
187246149Ssjg
188246149Ssjg.if !exists(.depend)
189246149Ssjg${OBJS}: config.h
190246149Ssjg.endif
191246149Ssjg
192246149Ssjg# make sure that MAKE_VERSION gets updated.
193246149Ssjgmain.o: ${SRCS} ${MAKEFILE}
194246149Ssjg
195246149Ssjg# start-delete2 for bsd.after-import.mk
196249033Ssjg.if ${MK_AUTOCONF_MK} == "yes"
197249033Ssjg.include <autoconf.mk>
198249033Ssjg.endif
199246149SsjgSHARE_MK?=${SHAREDIR}/mk
200246149SsjgMKSRC=${srcdir}/mk
201246149SsjgINSTALL?=${srcdir}/install-sh
202246149Ssjg
203246149Ssjg.if ${MK_INSTALL_MK} == "yes"
204246149Ssjginstall: install-mk
205246149Ssjg.endif
206246149Ssjg
207246149Ssjgbeforeinstall:
208246149Ssjg	test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR}
209246149Ssjg	test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST}
210246149Ssjg
211246149Ssjginstall-mk:
212246149Ssjg.if exists(${MKSRC}/install-mk)
213246149Ssjg	test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK}
214246149Ssjg	sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK}
215246149Ssjg.else
216246149Ssjg	@echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
217246149Ssjg.endif
218246149Ssjg# end-delete2
219246149Ssjg
220246149Ssjg# A simple unit-test driver to help catch regressions
221246149Ssjgaccept test:
222246149Ssjg	cd ${.CURDIR}/unit-tests && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
223