1# $Id: Makefile,v 1.124 2023/02/25 20:27:44 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} == "" && ${OS:NDarwin:NLinux} != "" 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${OBJS}: config.h 180 181# start-delete2 for bsd.after-import.mk 182 183# make sure that MAKE_VERSION gets updated. 184main.o: ${srcdir}/VERSION 185 186.if ${MK_AUTOCONF_MK} == "yes" 187CONFIGURE_DEPS += ${.CURDIR}/VERSION 188# we do not need or want the generated makefile 189CONFIGURE_ARGS += --without-makefile 190AUTOCONF_GENERATED_MAKEFILE = Makefile.config 191.include <autoconf.mk> 192.endif 193SHARE_MK ?= ${SHAREDIR}/mk 194MKSRC = ${srcdir}/mk 195INSTALL ?= ${srcdir}/install-sh 196 197.if ${MK_INSTALL_MK} == "yes" 198install: install-mk 199.endif 200 201beforeinstall: 202 test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${BINDIR} 203 test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${MANDEST} 204 205install-mk: 206.if exists(${MKSRC}/install-mk) 207 test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${SHARE_MK} 208 sh ${MKSRC}/install-mk -v -m ${NONBINMODE} ${DESTDIR}${SHARE_MK} 209.else 210 @echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false 211.endif 212# end-delete2 213 214# A simple unit-test driver to help catch regressions 215TEST_MAKE ?= ${.OBJDIR}/${PROG:T} 216accept test: .NOMETA 217 cd ${.CURDIR}/unit-tests && \ 218 MAKEFLAGS= ${TEST_MAKE} -r -m / ${.TARGET} ${TESTS:DTESTS=${TESTS:Q}} 219 220 221.if make(test) && ${MK_AUTO_OBJ} == "yes" 222# The test target above visits unit-tests with -r -m / 223# which prevents MK_AUTO_OBJ doing its job 224# so do it here 225.if defined(MAKEOBJDIRPREFIX) || ${MAKEOBJDIR:U:M*/*} != "" 226_utobj = ${.OBJDIR}/unit-tests 227.else 228_utobj = ${.CURDIR}/unit-tests/${MAKEOBJDIR:Uobj} 229.endif 230utobj: .NOMETA 231 @test -d ${_utobj} && exit 0; \ 232 echo "[Creating ${_utobj}...]"; \ 233 umask ${OBJDIR_UMASK:U002}; \ 234 mkdir -p ${_utobj} 235test: utobj 236.endif 237