1# $Id: Makefile,v 1.113 2020/10/26 17:55:09 sjg Exp $ 2 3PROG= bmake 4 5SRCS= \ 6 arch.c \ 7 buf.c \ 8 compat.c \ 9 cond.c \ 10 dir.c \ 11 enum.c \ 12 for.c \ 13 hash.c \ 14 job.c \ 15 lst.c \ 16 main.c \ 17 make.c \ 18 make_malloc.c \ 19 meta.c \ 20 metachar.c \ 21 parse.c \ 22 str.c \ 23 suff.c \ 24 targ.c \ 25 trace.c \ 26 util.c \ 27 var.c 28 29.-include "VERSION" 30.-include "Makefile.inc" 31 32# this file gets generated by configure 33.-include "Makefile.config" 34 35.if !empty(LIBOBJS) 36SRCS+= ${LIBOBJS:T:.o=.c} 37.endif 38 39# just in case 40prefix?= /usr 41srcdir?= ${.CURDIR} 42 43DEFAULT_SYS_PATH?= ${prefix}/share/mk 44 45CPPFLAGS+= -DUSE_META 46CFLAGS+= ${CPPFLAGS} 47CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\" 48CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE 49CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}} 50COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\"" 51 52# meta mode can be useful even without filemon 53# should be set by now 54USE_FILEMON ?= no 55.if ${USE_FILEMON:tl} != "no" 56.PATH: ${srcdir}/filemon 57SRCS+= filemon_${USE_FILEMON}.c 58COPTS.meta.c+= -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu} 59COPTS.job.c+= ${COPTS.meta.c} 60 61.if ${USE_FILEMON} == "dev" 62FILEMON_H ?= /usr/include/dev/filemon/filemon.h 63.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h" 64COPTS.filemon_dev.c += -DHAVE_FILEMON_H -I${FILEMON_H:H} 65.endif 66.endif # USE_FILEMON == dev 67 68.endif # USE_FILEMON 69 70.PATH: ${srcdir} 71 72.if make(obj) || make(clean) 73SUBDIR+= unit-tests 74.endif 75 76# start-delete1 for bsd.after-import.mk 77# we skip a lot of this when building as part of FreeBSD etc. 78 79# list of OS's which are derrived from BSD4.4 80BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig 81# we are... 82OS := ${.MAKE.OS:U${uname -s:L:sh}} 83# are we 4.4BSD ? 84isBSD44:=${BSD44_LIST:M${OS}} 85 86.if ${isBSD44} == "" 87MANTARGET= cat 88INSTALL?=${srcdir}/install-sh 89.if (${MACHINE} == "sun386") 90# even I don't have one of these anymore :-) 91CFLAGS+= -DPORTAR 92.elif (${MACHINE} != "sunos") 93SRCS+= sigcompat.c 94CFLAGS+= -DSIGNAL_FLAGS=SA_RESTART 95.endif 96.else 97MANTARGET?= man 98.endif 99 100# turn this on by default - ignored if we are root 101WITH_INSTALL_AS_USER= 102 103# suppress with -DWITHOUT_* 104OPTIONS_DEFAULT_YES+= \ 105 AUTOCONF_MK \ 106 INSTALL_MK \ 107 PROG_LINK 108 109OPTIONS_DEFAULT_NO+= \ 110 PROG_VERSION 111 112# process options now 113.include <own.mk> 114 115.if ${MK_PROG_VERSION} == "yes" 116PROG_NAME= ${PROG}-${_MAKE_VERSION} 117.if ${MK_PROG_LINK} == "yes" 118SYMLINKS+= ${PROG_NAME} ${BINDIR}/${PROG} 119.endif 120.endif 121 122EXTRACT_MAN=no 123# end-delete1 124 125MAN= ${PROG}.1 126MAN1= ${MAN} 127 128.if (${PROG} != "make") 129CLEANFILES+= my.history 130.if make(${MAN}) || !exists(${srcdir}/${MAN}) 131my.history: 132 @(echo ".Nm"; \ 133 echo "is derived from NetBSD"; \ 134 echo ".Xr make 1 ."; \ 135 echo "It uses autoconf to facilitate portability to other platforms."; \ 136 echo ".Pp") > $@ 137 138.NOPATH: ${MAN} 139${MAN}: make.1 my.history 140 @echo making $@ 141 @sed \ 142 -e '/^.Dt/s/MAKE/${PROG:tu}/' \ 143 -e 's/^.Nx/NetBSD/' \ 144 -e '/^.Nm/s/make/${PROG}/' \ 145 -e '/^.Sh HISTORY/rmy.history' \ 146 -e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@ 147 148all beforeinstall: ${MAN} 149_mfromdir=. 150.endif 151.endif 152 153MANTARGET?= cat 154MANDEST?= ${MANDIR}/${MANTARGET}1 155 156.if ${MANTARGET} == "cat" 157_mfromdir=${srcdir} 158.endif 159 160.include <prog.mk> 161 162CPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H 163COPTS.var.c += -Wno-cast-qual 164COPTS.job.c += -Wno-format-nonliteral 165COPTS.parse.c += -Wno-format-nonliteral 166COPTS.var.c += -Wno-format-nonliteral 167 168# Force these 169SHAREDIR= ${SHAREDIR.bmake:U${prefix}/share} 170BINDIR= ${BINDIR.bmake:U${prefix}/bin} 171MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man} 172 173.if !exists(.depend) 174${OBJS}: config.h 175.endif 176 177# start-delete2 for bsd.after-import.mk 178 179# make sure that MAKE_VERSION gets updated. 180main.o: ${srcdir}/VERSION 181 182.if ${MK_AUTOCONF_MK} == "yes" 183CONFIGURE_DEPS += ${.CURDIR}/VERSION 184# we do not need or want the generated makefile 185CONFIGURE_ARGS += --without-makefile 186.include <autoconf.mk> 187.endif 188SHARE_MK?=${SHAREDIR}/mk 189MKSRC=${srcdir}/mk 190INSTALL?=${srcdir}/install-sh 191 192.if ${MK_INSTALL_MK} == "yes" 193install: install-mk 194.endif 195 196beforeinstall: 197 test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR} 198 test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST} 199 200install-mk: 201.if exists(${MKSRC}/install-mk) 202 test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK} 203 sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK} 204.else 205 @echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false 206.endif 207# end-delete2 208 209# A simple unit-test driver to help catch regressions 210TEST_MAKE ?= ${.OBJDIR}/${PROG:T} 211accept test: 212 cd ${.CURDIR}/unit-tests && \ 213 MAKEFLAGS= ${TEST_MAKE} -r -m / ${.TARGET} ${TESTS:DTESTS=${TESTS:Q}} 214 215