1*548bfc56SSimon J. Gerraty# $Id: Makefile,v 1.127 2024/03/19 16:03:23 sjg Exp $ 23cbdda60SSimon J. Gerraty 33cbdda60SSimon J. GerratyPROG= bmake 43cbdda60SSimon J. Gerraty 53cbdda60SSimon J. GerratySRCS= \ 63cbdda60SSimon J. Gerraty arch.c \ 73cbdda60SSimon J. Gerraty buf.c \ 83cbdda60SSimon J. Gerraty compat.c \ 93cbdda60SSimon J. Gerraty cond.c \ 103cbdda60SSimon J. Gerraty dir.c \ 113cbdda60SSimon J. Gerraty for.c \ 123cbdda60SSimon J. Gerraty hash.c \ 133cbdda60SSimon J. Gerraty job.c \ 142c3632d1SSimon J. Gerraty lst.c \ 153cbdda60SSimon J. Gerraty main.c \ 163cbdda60SSimon J. Gerraty make.c \ 173cbdda60SSimon J. Gerraty make_malloc.c \ 183cbdda60SSimon J. Gerraty meta.c \ 194c620fe5SSimon J. Gerraty metachar.c \ 203cbdda60SSimon J. Gerraty parse.c \ 213cbdda60SSimon J. Gerraty str.c \ 223cbdda60SSimon J. Gerraty suff.c \ 233cbdda60SSimon J. Gerraty targ.c \ 243cbdda60SSimon J. Gerraty trace.c \ 253cbdda60SSimon J. Gerraty util.c \ 263cbdda60SSimon J. Gerraty var.c 273cbdda60SSimon J. Gerraty 28e22fef7dSSimon J. Gerraty.-include "VERSION" 2949caa483SSimon J. Gerraty.-include "Makefile.inc" 30e22fef7dSSimon J. Gerraty 313cbdda60SSimon J. Gerraty# this file gets generated by configure 323cbdda60SSimon J. Gerraty.-include "Makefile.config" 333cbdda60SSimon J. Gerraty 343cbdda60SSimon J. Gerraty.if !empty(LIBOBJS) 353cbdda60SSimon J. GerratySRCS+= ${LIBOBJS:T:.o=.c} 363cbdda60SSimon J. Gerraty.endif 373cbdda60SSimon J. Gerraty 383cbdda60SSimon J. Gerraty# just in case 393cbdda60SSimon J. Gerratyprefix?= /usr 403cbdda60SSimon J. Gerratysrcdir?= ${.CURDIR} 413cbdda60SSimon J. Gerraty 420dede8b0SSimon J. GerratyDEFAULT_SYS_PATH?= ${prefix}/share/mk 433cbdda60SSimon J. Gerraty 443cbdda60SSimon J. GerratyCPPFLAGS+= -DUSE_META 453cbdda60SSimon J. GerratyCFLAGS+= ${CPPFLAGS} 463cbdda60SSimon J. GerratyCFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\" 473cbdda60SSimon J. GerratyCFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE 483cbdda60SSimon J. GerratyCFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}} 493bebe729SSimon J. GerratyCOPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\"" 503cbdda60SSimon J. Gerraty 51*548bfc56SSimon J. Gerraty.for x in FORCE_MAKE_OS FORCE_MACHINE FORCE_MACHINE_ARCH 52e2eeea75SSimon J. Gerraty.ifdef $x 53e2eeea75SSimon J. GerratyCOPTS.main.c+= "-D$x=\"${$x}\"" 54e2eeea75SSimon J. Gerraty.endif 55e2eeea75SSimon J. Gerraty.endfor 56e2eeea75SSimon J. Gerraty 573cbdda60SSimon J. Gerraty# meta mode can be useful even without filemon 5849caa483SSimon J. Gerraty# should be set by now 5949caa483SSimon J. GerratyUSE_FILEMON ?= no 6049caa483SSimon J. Gerraty.if ${USE_FILEMON:tl} != "no" 61ef0b2538SSimon J. Gerraty.PATH: ${srcdir}/filemon 6249caa483SSimon J. GerratySRCS+= filemon_${USE_FILEMON}.c 6349caa483SSimon J. GerratyCOPTS.meta.c+= -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu} 6449caa483SSimon J. GerratyCOPTS.job.c+= ${COPTS.meta.c} 6549caa483SSimon J. Gerraty 6649caa483SSimon J. Gerraty.if ${USE_FILEMON} == "dev" 673cbdda60SSimon J. GerratyFILEMON_H ?= /usr/include/dev/filemon/filemon.h 683cbdda60SSimon J. Gerraty.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h" 6949caa483SSimon J. GerratyCOPTS.filemon_dev.c += -DHAVE_FILEMON_H -I${FILEMON_H:H} 703cbdda60SSimon J. Gerraty.endif 71148ee845SSimon J. Gerraty.elif ${USE_FILEMON} == "ktrace" 72148ee845SSimon J. GerratyCOPTS.filemon_ktrace.c += -Wno-error=unused-parameter 73148ee845SSimon J. Gerraty.endif 7449caa483SSimon J. Gerraty 7549caa483SSimon J. Gerraty.endif # USE_FILEMON 763cbdda60SSimon J. Gerraty 773cbdda60SSimon J. Gerraty.PATH: ${srcdir} 783cbdda60SSimon J. Gerraty 793cbdda60SSimon J. Gerraty.if make(obj) || make(clean) 803cbdda60SSimon J. GerratySUBDIR+= unit-tests 813cbdda60SSimon J. Gerraty.endif 823cbdda60SSimon J. Gerraty 833cbdda60SSimon J. Gerraty# start-delete1 for bsd.after-import.mk 843cbdda60SSimon J. Gerraty# we skip a lot of this when building as part of FreeBSD etc. 853cbdda60SSimon J. Gerraty 863cbdda60SSimon J. Gerraty# list of OS's which are derrived from BSD4.4 8728a6bc81SSimon J. GerratyBSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig 883cbdda60SSimon J. Gerraty# we are... 892c3632d1SSimon J. GerratyOS := ${.MAKE.OS:U${uname -s:L:sh}} 903cbdda60SSimon J. Gerraty# are we 4.4BSD ? 913cbdda60SSimon J. GerratyisBSD44:=${BSD44_LIST:M${OS}} 923cbdda60SSimon J. Gerraty 93*548bfc56SSimon J. Gerraty.if ${isBSD44} == "" && ${OS:NCygwin:NDarwin:NLinux} != "" 94c59c3bf3SSimon J. GerratyMANTARGET?= cat 9512904384SSimon J. Gerraty.if ${MACHINE} == "sun386" 963cbdda60SSimon J. Gerraty# even I don't have one of these anymore :-) 973cbdda60SSimon J. GerratyCFLAGS+= -DPORTAR 9812904384SSimon J. Gerraty.elif ${OS} != "SunOS" 9912904384SSimon J. Gerraty# assume the worst 1003cbdda60SSimon J. GerratySRCS+= sigcompat.c 1013cbdda60SSimon J. GerratyCFLAGS+= -DSIGNAL_FLAGS=SA_RESTART 1023cbdda60SSimon J. Gerraty.endif 1033cbdda60SSimon J. Gerraty.else 1043cbdda60SSimon J. GerratyMANTARGET?= man 1053cbdda60SSimon J. Gerraty.endif 1063cbdda60SSimon J. Gerraty 1073cbdda60SSimon J. Gerraty# turn this on by default - ignored if we are root 1083cbdda60SSimon J. GerratyWITH_INSTALL_AS_USER= 1093cbdda60SSimon J. Gerraty 1105bcb7424SSimon J. Gerraty# suppress with -DWITHOUT_* 1113cbdda60SSimon J. GerratyOPTIONS_DEFAULT_YES+= \ 1123cbdda60SSimon J. Gerraty AUTOCONF_MK \ 1133cbdda60SSimon J. Gerraty INSTALL_MK \ 1143cbdda60SSimon J. Gerraty PROG_LINK 1153cbdda60SSimon J. Gerraty 1163cbdda60SSimon J. GerratyOPTIONS_DEFAULT_NO+= \ 1173cbdda60SSimon J. Gerraty PROG_VERSION 1183cbdda60SSimon J. Gerraty 1193cbdda60SSimon J. Gerraty# process options now 1203cbdda60SSimon J. Gerraty.include <own.mk> 1213cbdda60SSimon J. Gerraty 1223cbdda60SSimon J. Gerraty.if ${MK_PROG_VERSION} == "yes" 123e48f47ddSSimon J. GerratyPROG_NAME= ${PROG}-${_MAKE_VERSION} 1243cbdda60SSimon J. Gerraty.if ${MK_PROG_LINK} == "yes" 125e48f47ddSSimon J. GerratySYMLINKS+= ${PROG_NAME} ${BINDIR}/${PROG} 1263cbdda60SSimon J. Gerraty.endif 1273cbdda60SSimon J. Gerraty.endif 1283cbdda60SSimon J. Gerraty 1293cbdda60SSimon J. GerratyEXTRACT_MAN=no 1303cbdda60SSimon J. Gerraty# end-delete1 1313cbdda60SSimon J. Gerraty 1323cbdda60SSimon J. GerratyMAN= ${PROG}.1 1333cbdda60SSimon J. GerratyMAN1= ${MAN} 1343cbdda60SSimon J. Gerraty 13512904384SSimon J. Gerraty.if ${PROG} != "make" 1363cbdda60SSimon J. GerratyCLEANFILES+= my.history 1373cbdda60SSimon J. Gerraty.if make(${MAN}) || !exists(${srcdir}/${MAN}) 138ef0b2538SSimon J. Gerratymy.history: 1393cbdda60SSimon J. Gerraty @(echo ".Nm"; \ 1403cbdda60SSimon J. Gerraty echo "is derived from NetBSD"; \ 1413cbdda60SSimon J. Gerraty echo ".Xr make 1 ."; \ 1423cbdda60SSimon J. Gerraty echo "It uses autoconf to facilitate portability to other platforms."; \ 1433cbdda60SSimon J. Gerraty echo ".Pp") > $@ 1443cbdda60SSimon J. Gerraty 1453cbdda60SSimon J. Gerraty.NOPATH: ${MAN} 1463cbdda60SSimon J. Gerraty${MAN}: make.1 my.history 1473cbdda60SSimon J. Gerraty @echo making $@ 14845447996SSimon J. Gerraty @sed \ 14945447996SSimon J. Gerraty -e '/^.Dt/s/MAKE/${PROG:tu}/' \ 15045447996SSimon J. Gerraty -e 's/^.Nx/NetBSD/' \ 15145447996SSimon J. Gerraty -e '/^.Nm/s/make/${PROG}/' \ 1523cbdda60SSimon J. Gerraty -e '/^.Sh HISTORY/rmy.history' \ 1533cbdda60SSimon J. Gerraty -e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@ 1543cbdda60SSimon J. Gerraty 1553cbdda60SSimon J. Gerratyall beforeinstall: ${MAN} 1563cbdda60SSimon J. Gerraty_mfromdir=. 1573cbdda60SSimon J. Gerraty.endif 1583cbdda60SSimon J. Gerraty.endif 1593cbdda60SSimon J. Gerraty 1603cbdda60SSimon J. GerratyMANTARGET?= cat 1613cbdda60SSimon J. GerratyMANDEST?= ${MANDIR}/${MANTARGET}1 1623cbdda60SSimon J. Gerraty 1633cbdda60SSimon J. Gerraty.if ${MANTARGET} == "cat" 1643cbdda60SSimon J. Gerraty_mfromdir=${srcdir} 1653cbdda60SSimon J. Gerraty.endif 1663cbdda60SSimon J. Gerraty 1673cbdda60SSimon J. Gerraty.include <prog.mk> 1683cbdda60SSimon J. Gerraty 1693cbdda60SSimon J. GerratyCPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H 1703cbdda60SSimon J. GerratyCOPTS.var.c += -Wno-cast-qual 1713cbdda60SSimon J. GerratyCOPTS.job.c += -Wno-format-nonliteral 1723cbdda60SSimon J. GerratyCOPTS.parse.c += -Wno-format-nonliteral 1733cbdda60SSimon J. GerratyCOPTS.var.c += -Wno-format-nonliteral 1743cbdda60SSimon J. Gerraty 1753cbdda60SSimon J. Gerraty# Force these 176db29cad8SSimon J. GerratySHAREDIR= ${SHAREDIR.bmake:U${prefix}/share} 177db29cad8SSimon J. GerratyBINDIR= ${BINDIR.bmake:U${prefix}/bin} 178db29cad8SSimon J. GerratyMANDIR= ${MANDIR.bmake:U${SHAREDIR}/man} 1793cbdda60SSimon J. Gerraty 1803cbdda60SSimon J. Gerraty${OBJS}: config.h 1813cbdda60SSimon J. Gerraty 1823cbdda60SSimon J. Gerraty# start-delete2 for bsd.after-import.mk 183e22fef7dSSimon J. Gerraty 184e22fef7dSSimon J. Gerraty# make sure that MAKE_VERSION gets updated. 185ef0b2538SSimon J. Gerratymain.o: ${srcdir}/VERSION 186e22fef7dSSimon J. Gerraty 1871748de26SSimon J. Gerraty.if ${MK_AUTOCONF_MK} == "yes" 188e22fef7dSSimon J. GerratyCONFIGURE_DEPS += ${.CURDIR}/VERSION 18949caa483SSimon J. Gerraty# we do not need or want the generated makefile 19049caa483SSimon J. GerratyCONFIGURE_ARGS += --without-makefile 19112904384SSimon J. GerratyAUTOCONF_GENERATED_MAKEFILE = Makefile.config 1921748de26SSimon J. Gerraty.include <autoconf.mk> 1931748de26SSimon J. Gerraty.endif 1943cbdda60SSimon J. GerratySHARE_MK ?= ${SHAREDIR}/mk 1953cbdda60SSimon J. GerratyMKSRC = ${srcdir}/mk 1963cbdda60SSimon J. GerratyINSTALL ?= ${srcdir}/install-sh 1973cbdda60SSimon J. Gerraty 1983cbdda60SSimon J. Gerraty.if ${MK_INSTALL_MK} == "yes" 1993cbdda60SSimon J. Gerratyinstall: install-mk 2003cbdda60SSimon J. Gerraty.endif 2013cbdda60SSimon J. Gerraty 2023cbdda60SSimon J. Gerratybeforeinstall: 203dc1b8c9aSSimon J. Gerraty test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${BINDIR} 204dc1b8c9aSSimon J. Gerraty test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${MANDEST} 2053cbdda60SSimon J. Gerraty 2063cbdda60SSimon J. Gerratyinstall-mk: 2073cbdda60SSimon J. Gerraty.if exists(${MKSRC}/install-mk) 208dc1b8c9aSSimon J. Gerraty test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${SHARE_MK} 209dc1b8c9aSSimon J. Gerraty sh ${MKSRC}/install-mk -v -m ${NONBINMODE} ${DESTDIR}${SHARE_MK} 2103cbdda60SSimon J. Gerraty.else 2113cbdda60SSimon J. Gerraty @echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false 2123cbdda60SSimon J. Gerraty.endif 2133cbdda60SSimon J. Gerraty# end-delete2 2143cbdda60SSimon J. Gerraty 2153cbdda60SSimon J. Gerraty# A simple unit-test driver to help catch regressions 2162c3632d1SSimon J. GerratyTEST_MAKE ?= ${.OBJDIR}/${PROG:T} 217532d4fbfSSimon J. Gerratyaccept test: .NOMETA 2182c3632d1SSimon J. Gerraty cd ${.CURDIR}/unit-tests && \ 2192c3632d1SSimon J. Gerraty MAKEFLAGS= ${TEST_MAKE} -r -m / ${.TARGET} ${TESTS:DTESTS=${TESTS:Q}} 2202c3632d1SSimon J. Gerraty 221532d4fbfSSimon J. Gerraty 222532d4fbfSSimon J. Gerraty.if make(test) && ${MK_AUTO_OBJ} == "yes" 223532d4fbfSSimon J. Gerraty# The test target above visits unit-tests with -r -m / 224532d4fbfSSimon J. Gerraty# which prevents MK_AUTO_OBJ doing its job 225532d4fbfSSimon J. Gerraty# so do it here 226532d4fbfSSimon J. Gerraty.if defined(MAKEOBJDIRPREFIX) || ${MAKEOBJDIR:U:M*/*} != "" 227532d4fbfSSimon J. Gerraty_utobj = ${.OBJDIR}/unit-tests 228532d4fbfSSimon J. Gerraty.else 229532d4fbfSSimon J. Gerraty_utobj = ${.CURDIR}/unit-tests/${MAKEOBJDIR:Uobj} 230532d4fbfSSimon J. Gerraty.endif 231532d4fbfSSimon J. Gerratyutobj: .NOMETA 232532d4fbfSSimon J. Gerraty @test -d ${_utobj} && exit 0; \ 233532d4fbfSSimon J. Gerraty echo "[Creating ${_utobj}...]"; \ 234532d4fbfSSimon J. Gerraty umask ${OBJDIR_UMASK:U002}; \ 235532d4fbfSSimon J. Gerraty mkdir -p ${_utobj} 236532d4fbfSSimon J. Gerratytest: utobj 237532d4fbfSSimon J. Gerraty.endif 238