1# $Id: Makefile,v 1.120 2022/07/26 23:02:54 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 lst.c \ 15 main.c \ 16 make.c \ 17 make_malloc.c \ 18 meta.c \ 19 metachar.c \ 20 parse.c \ 21 str.c \ 22 suff.c \ 23 targ.c \ 24 trace.c \ 25 util.c \ 26 var.c 27 28.-include "VERSION" 29.-include "Makefile.inc" 30 31# this file gets generated by configure 32.-include "Makefile.config" 33 34.if !empty(LIBOBJS) 35SRCS+= ${LIBOBJS:T:.o=.c} 36.endif 37 38# just in case 39prefix?= /usr 40srcdir?= ${.CURDIR} 41 42DEFAULT_SYS_PATH?= ${prefix}/share/mk 43 44CPPFLAGS+= -DUSE_META 45CFLAGS+= ${CPPFLAGS} 46CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\" 47CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE 48CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}} 49COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\"" 50 51.for x in FORCE_MACHINE FORCE_MACHINE_ARCH 52.ifdef $x 53COPTS.main.c+= "-D$x=\"${$x}\"" 54.endif 55.endfor 56 57# meta mode can be useful even without filemon 58# should be set by now 59USE_FILEMON ?= no 60.if ${USE_FILEMON:tl} != "no" 61.PATH: ${srcdir}/filemon 62SRCS+= filemon_${USE_FILEMON}.c 63COPTS.meta.c+= -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu} 64COPTS.job.c+= ${COPTS.meta.c} 65 66.if ${USE_FILEMON} == "dev" 67FILEMON_H ?= /usr/include/dev/filemon/filemon.h 68.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h" 69COPTS.filemon_dev.c += -DHAVE_FILEMON_H -I${FILEMON_H:H} 70.endif 71.endif # USE_FILEMON == dev 72 73.endif # USE_FILEMON 74 75.PATH: ${srcdir} 76 77.if make(obj) || make(clean) 78SUBDIR+= unit-tests 79.endif 80 81# start-delete1 for bsd.after-import.mk 82# we skip a lot of this when building as part of FreeBSD etc. 83 84# list of OS's which are derrived from BSD4.4 85BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig 86# we are... 87OS := ${.MAKE.OS:U${uname -s:L:sh}} 88# are we 4.4BSD ? 89isBSD44:=${BSD44_LIST:M${OS}} 90 91.if ${isBSD44} == "" 92MANTARGET= cat 93INSTALL?=${srcdir}/install-sh 94.if ${MACHINE} == "sun386" 95# even I don't have one of these anymore :-) 96CFLAGS+= -DPORTAR 97.elif ${OS} != "SunOS" 98# assume the worst 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 192AUTOCONF_GENERATED_MAKEFILE = Makefile.config 193.include <autoconf.mk> 194.endif 195SHARE_MK ?= ${SHAREDIR}/mk 196MKSRC = ${srcdir}/mk 197INSTALL ?= ${srcdir}/install-sh 198 199.if ${MK_INSTALL_MK} == "yes" 200install: install-mk 201.endif 202 203beforeinstall: 204 test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR} 205 test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST} 206 207install-mk: 208.if exists(${MKSRC}/install-mk) 209 test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK} 210 sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK} 211.else 212 @echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false 213.endif 214# end-delete2 215 216# A simple unit-test driver to help catch regressions 217TEST_MAKE ?= ${.OBJDIR}/${PROG:T} 218accept test: .NOMETA 219 cd ${.CURDIR}/unit-tests && \ 220 MAKEFLAGS= ${TEST_MAKE} -r -m / ${.TARGET} ${TESTS:DTESTS=${TESTS:Q}} 221 222 223.if make(test) && ${MK_AUTO_OBJ} == "yes" 224# The test target above visits unit-tests with -r -m / 225# which prevents MK_AUTO_OBJ doing its job 226# so do it here 227.if defined(MAKEOBJDIRPREFIX) || ${MAKEOBJDIR:U:M*/*} != "" 228_utobj = ${.OBJDIR}/unit-tests 229.else 230_utobj = ${.CURDIR}/unit-tests/${MAKEOBJDIR:Uobj} 231.endif 232utobj: .NOMETA 233 @test -d ${_utobj} && exit 0; \ 234 echo "[Creating ${_utobj}...]"; \ 235 umask ${OBJDIR_UMASK:U002}; \ 236 mkdir -p ${_utobj} 237test: utobj 238.endif 239