git: d7511b9d0074 - main - Mk/bsd.port.mk: Add __MAKE_CONF=${NONEXISTENT} to WRK_ENV

From: Tijl Coosemans <tijl_at_FreeBSD.org>
Date: Sat, 23 Mar 2024 11:29:48 UTC
The branch main has been updated by tijl:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d7511b9d00742c3e2d57c6c03718c4a6f4cd3e72

commit d7511b9d00742c3e2d57c6c03718c4a6f4cd3e72
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2024-02-29 21:11:00 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2024-03-23 11:19:32 +0000

    Mk/bsd.port.mk: Add __MAKE_CONF=${NONEXISTENT} to WRK_ENV
    
    And remove it from individual ports.  Use WRK_ENV in custom build
    commands where necessary.
    
    FreeBSD make(1) includes /usr/share/mk/sys.mk and that includes
    /etc/make.conf if it exists.  This happens when you run make in a port
    directory but it also happens when the upstream build system uses make.
    This commit disables make.conf inclusion in the latter case because
    users can define variables like CFLAGS in make.conf that override ports
    framework variables and this can cause problems that are difficult to
    diagnose.
    
    If there are any build customisations made through make.conf that stop
    working because of this commit then they should be made available by the
    ports tree through some mechanism, e.g. an option in a port.
    
    Some ports were picking up variables from Poudriere make.conf and
    required fixes:
    
    - astro/wmspaceweather x11-clocks/wmcalclock: Add OPSYS to MAKE_ENV.
    - games/zhlt: Add ARCH to MAKE_ENV.
    - graphics/tachyon: Upstream ARCH is not ports tree ARCH.
      Set ALL_TARGET=bsd so upstream ARCH is defined correctly.
      Enable multi-threading support while here.
    
    PR:             277455
    Exp-run by:     antoine
---
 Mk/bsd.port.mk                              |  3 ++-
 archivers/libcabinet/Makefile               |  2 +-
 astro/wmspaceweather/Makefile               |  1 +
 devel/libpdel/Makefile                      |  2 +-
 devel/libshhmsg/Makefile                    |  2 +-
 devel/libxalloc/Makefile                    |  2 +-
 devel/linux_libusb/Makefile                 | 14 +++++++-------
 emulators/vmw/Makefile                      |  2 +-
 finance/libstocks/Makefile                  |  6 +++---
 games/libshhcards/Makefile                  |  2 +-
 games/zhlt/Makefile                         |  1 +
 graphics/tachyon/Makefile                   | 10 ++++++----
 graphics/tachyon/files/patch-Makefile       | 11 -----------
 graphics/tachyon/files/patch-src_threads.c  | 11 +++++++++++
 graphics/tachyon/files/patch-src_threads.h  | 11 +++++++++++
 graphics/tachyon/files/patch-src_trace.c    | 11 +++++++++++
 graphics/tachyon/files/patch-unix_Make-arch | 18 ++++++++++++++++++
 lang/lua51/Makefile                         |  8 --------
 lang/lua52/Makefile                         |  8 --------
 lang/lua53/Makefile                         |  8 --------
 lang/lua54/Makefile                         |  8 --------
 mail/dma/Makefile                           |  3 +--
 mail/spamilter/Makefile                     |  1 -
 math/libmissing/Makefile                    |  9 +++++----
 math/linpack/Makefile                       |  2 +-
 ports-mgmt/dialog4ports/Makefile            |  2 +-
 sysutils/dirdiff/Makefile                   |  5 -----
 sysutils/pfstat/Makefile                    |  1 -
 sysutils/pftop/Makefile                     |  1 -
 x11-clocks/wmcalclock/Makefile              |  1 +
 30 files changed, 86 insertions(+), 80 deletions(-)

diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index bd2b50a0d4a6..8803c0d80f88 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1633,7 +1633,8 @@ PKG_NOTE_flavor=	${FLAVOR}
 .    endif
 
 WRK_ENV+=		HOME=${WRKDIR} \
-				PWD="$${PWD}"
+				PWD="$${PWD}" \
+				__MAKE_CONF=${NONEXISTENT}
 .    for e in OSVERSION PATH TERM TMPDIR \
 				UNAME_b UNAME_i UNAME_K UNAME_m UNAME_n \
 				UNAME_p UNAME_r UNAME_s UNAME_U UNAME_v
diff --git a/archivers/libcabinet/Makefile b/archivers/libcabinet/Makefile
index 9d5e0ae7039f..a96bba8f6930 100644
--- a/archivers/libcabinet/Makefile
+++ b/archivers/libcabinet/Makefile
@@ -11,7 +11,7 @@ USES=		uidfix
 USE_LDCONFIG=	yes
 SRCFILE=	${WRKSRC}/listcab.cpp
 PROGFILE=	${SRCFILE:S/.cpp$//}
-MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
+MAKE_ENV=	WITHOUT_PROFILE=yes SRCCONF=/dev/null
 
 post-build:
 	${CXX} ${CXXFLAGS} -o ${PROGFILE} ${SRCFILE} -L${WRKSRC} -lcabinet -lz
diff --git a/astro/wmspaceweather/Makefile b/astro/wmspaceweather/Makefile
index 44a55987e1ac..31a89888ae0c 100644
--- a/astro/wmspaceweather/Makefile
+++ b/astro/wmspaceweather/Makefile
@@ -20,6 +20,7 @@ WRKSRC=		${WRKDIR}/${DISTNAME}/wmSpaceWeather
 SHEBANG_FILES=	GetKp
 USE_XORG=	x11 xext xpm
 ALL_TARGET=	clean all
+MAKE_ENV=	OPSYS=${OPSYS}
 MAKE_JOBS_UNSAFE=	yes
 
 PLIST_FILES=	bin/GetKp bin/wmSpaceWeather \
diff --git a/devel/libpdel/Makefile b/devel/libpdel/Makefile
index bf220ac3d490..3c9c4b59a95e 100644
--- a/devel/libpdel/Makefile
+++ b/devel/libpdel/Makefile
@@ -17,7 +17,7 @@ LIB_DEPENDS=	libexpat.so:textproc/expat2
 USES=		tar:bz2
 USE_LDCONFIG=	yes
 
-MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
+MAKE_ENV=	WITHOUT_PROFILE=yes SRCCONF=/dev/null
 
 WRKSRC_SUBDIR=	pdel
 
diff --git a/devel/libshhmsg/Makefile b/devel/libshhmsg/Makefile
index 2ef068782fe9..26a8a30f59d0 100644
--- a/devel/libshhmsg/Makefile
+++ b/devel/libshhmsg/Makefile
@@ -13,7 +13,7 @@ LICENSE=	ART10
 USES=		uidfix
 MAKEFILE=	${FILESDIR}/Makefile.lib
 USE_LDCONFIG=	yes
-MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
+MAKE_ENV=	WITHOUT_PROFILE=yes SRCCONF=/dev/null
 
 OPTIONS_DEFINE=		DOCS
 
diff --git a/devel/libxalloc/Makefile b/devel/libxalloc/Makefile
index 8e0b08a717d7..0e36a79709c0 100644
--- a/devel/libxalloc/Makefile
+++ b/devel/libxalloc/Makefile
@@ -14,7 +14,7 @@ USES=		uidfix
 
 MAKEFILE=	${FILESDIR}/Makefile.lib
 USE_LDCONFIG=	yes
-MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
+MAKE_ENV=	WITHOUT_PROFILE=yes SRCCONF=/dev/null
 
 post-install:
 	@${MKDIR} ${STAGEDIR}${DOCSDIR}
diff --git a/devel/linux_libusb/Makefile b/devel/linux_libusb/Makefile
index 851f6809c29a..a594ecc69110 100644
--- a/devel/linux_libusb/Makefile
+++ b/devel/linux_libusb/Makefile
@@ -34,7 +34,6 @@ MAKE_ARGS+=	LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h
 MAKE_ARGS+=	WITHOUT_PROFILE=yes
 MAKE_ARGS+=	WITHOUT_SSP=yes
 MAKE_ARGS+=	WITHOUT_WERROR=yes
-MAKE_ARGS+=	__MAKE_CONF=""
 MAKE_ENV+=	LDADD="-lrt"
 
 .include <bsd.port.pre.mk>
@@ -49,14 +48,15 @@ PLIST_FILES+=	usr/lib/libusb.so.3 \
 
 do-build:
 	${MKDIR} ${WRKSRC}/${LIBDIR_${ARCH}}
-	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} MAKEOBJDIR=${LIBDIR_${ARCH}} \
-		${MAKE_CMD} ${MAKE_FLAGS} ${MAKEFILE} ${_MAKE_JOBS} \
-		${MAKE_ARGS:N${DESTDIRNAME}=*}
+	cd ${WRKSRC} && ${SETENVI} ${WRK_ENV} ${MAKE_ENV} \
+		MAKEOBJDIR=${LIBDIR_${ARCH}} ${MAKE_CMD} ${MAKE_FLAGS} \
+		${MAKEFILE} ${_MAKE_JOBS} ${MAKE_ARGS:N${DESTDIRNAME}=*}
 .if ${ARCH} == amd64
 	${MKDIR} ${WRKSRC}/lib
-	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV:NCC=*} CC="${CC} -m32" \
-		MAKEOBJDIR=lib ${MAKE_CMD} ${MAKE_FLAGS} ${MAKEFILE} \
-		${_MAKE_JOBS} ${MAKE_ARGS:N${DESTDIRNAME}=*} COMPAT_32BIT=yes
+	cd ${WRKSRC} && ${SETENVI} ${WRK_ENV} ${MAKE_ENV:NCC=*} \
+		CC="${CC} -m32" MAKEOBJDIR=lib ${MAKE_CMD} ${MAKE_FLAGS} \
+		${MAKEFILE} ${_MAKE_JOBS} ${MAKE_ARGS:N${DESTDIRNAME}=*} \
+		COMPAT_32BIT=yes
 .endif
 
 do-install:
diff --git a/emulators/vmw/Makefile b/emulators/vmw/Makefile
index 79fa5e4ffce0..9f71e6c574f2 100644
--- a/emulators/vmw/Makefile
+++ b/emulators/vmw/Makefile
@@ -14,7 +14,7 @@ BUILD_DEPENDS=	as:devel/binutils
 
 WRKSRC=		${WRKDIR}/${PORTNAME}/src
 USES=		iconv
-MAKE_ENV+=	__MAKE_CONF=/dev/null ASFLAGS="${ASFLAGS}"
+MAKE_ENV+=	ASFLAGS="${ASFLAGS}"
 MAKE_ENV+=	LD="${CC}"
 
 SBINS=		vmw vmshrink vmftp
diff --git a/finance/libstocks/Makefile b/finance/libstocks/Makefile
index 557a4eda7401..158939dcd1fa 100644
--- a/finance/libstocks/Makefile
+++ b/finance/libstocks/Makefile
@@ -9,7 +9,7 @@ WWW=		https://libstocks.sourceforge.net/
 
 USE_LDCONFIG=	yes
 REINPLACE_ARGS=	-i ""
-MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
+MAKE_ENV=	WITHOUT_PROFILE=yes SRCCONF=/dev/null
 MAKE_ENV+=	STAGEDIR="${STAGEDIR}"
 USES=		uidfix
 
@@ -23,8 +23,8 @@ post-patch:
 
 do-build do-install:
 .for d in lib client
-	cd ${WRKSRC}/$d && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKEFLAGS} -j2 \
-		-f ${FILESDIR}/Makefile.$d ${.TARGET:S/do-//}
+	cd ${WRKSRC}/$d && ${SETENVI} ${WRK_ENV} ${MAKE_ENV} ${MAKE_CMD} \
+		${MAKEFLAGS} -j2 -f ${FILESDIR}/Makefile.$d ${.TARGET:S/do-//}
 .endfor
 
 post-install:
diff --git a/games/libshhcards/Makefile b/games/libshhcards/Makefile
index 8f84bf881958..fcd8d193c513 100644
--- a/games/libshhcards/Makefile
+++ b/games/libshhcards/Makefile
@@ -14,7 +14,7 @@ USES=		xorg
 USE_XORG=	xpm
 MAKEFILE=	${FILESDIR}/Makefile.lib
 USE_LDCONFIG=	yes
-MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
+MAKE_ENV=	WITHOUT_PROFILE=yes SRCCONF=/dev/null
 
 OPTIONS_DEFINE=	DOCS
 
diff --git a/games/zhlt/Makefile b/games/zhlt/Makefile
index 10b8d0e63d06..b32de8f6e8fa 100644
--- a/games/zhlt/Makefile
+++ b/games/zhlt/Makefile
@@ -18,6 +18,7 @@ DOS2UNIX_FILES=	common/bspfile.h common/cmdlib.cpp common/mathlib.h \
 		hlvis/flow.cpp hlvis/vis.cpp hlvis/vis.h
 
 MAKEFILE=	${FILESDIR}/Makefile
+MAKE_ENV=	ARCH=${ARCH}
 NO_WRKSUBDIR=	yes
 
 PLIST_FILES=	bin/hlbsp bin/hlcsg bin/hlrad bin/hlvis bin/ripent
diff --git a/graphics/tachyon/Makefile b/graphics/tachyon/Makefile
index 84520a37673a..a011a732c14c 100644
--- a/graphics/tachyon/Makefile
+++ b/graphics/tachyon/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	tachyon
 DISTVERSION=	0.98.9
+PORTREVISION=	1
 CATEGORIES=	graphics science
 MASTER_SITES=	http://jedi.ks.uiuc.edu/~johns/raytracer/files/${DISTVERSION}/
 
@@ -8,10 +9,11 @@ COMMENT=	Multiproccess ray tracing system
 WWW=		http://jedi.ks.uiuc.edu/~johns/raytracer/
 
 LICENSE=	BSD3CLAUSE
-LICENSE_FILE=	${WRKSRC}/../Copyright
+LICENSE_FILE=	${WRKSRC}/Copyright
 
+ALL_TARGET=	bsd
+BUILD_WRKSRC=	${WRKSRC}/unix
 WRKSRC=		${WRKDIR}/${PORTNAME}
-WRKSRC_SUBDIR=	unix
 
 PLIST_FILES=	bin/tachyon \
 		lib/libtachyon.a
@@ -19,7 +21,7 @@ PLIST_FILES=	bin/tachyon \
 .include <bsd.port.pre.mk>
 
 do-install:
-	${INSTALL_PROGRAM} ${WRKSRC}/../compile/${ARCH}/tachyon ${STAGEDIR}${PREFIX}/bin
-	${INSTALL_LIB} ${WRKSRC}/../compile/${ARCH}/libtachyon.a ${STAGEDIR}${PREFIX}/lib
+	${INSTALL_PROGRAM} ${WRKSRC}/compile/bsd/tachyon ${STAGEDIR}${PREFIX}/bin
+	${INSTALL_LIB} ${WRKSRC}/compile/bsd/libtachyon.a ${STAGEDIR}${PREFIX}/lib
 
 .include <bsd.port.post.mk>
diff --git a/graphics/tachyon/files/patch-Makefile b/graphics/tachyon/files/patch-Makefile
deleted file mode 100644
index 17a22c27800a..000000000000
--- a/graphics/tachyon/files/patch-Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
---- Makefile.orig	2009-04-23 15:11:55 UTC
-+++ Makefile
-@@ -18,6 +18,8 @@ include Make-distrib
- COMPILEDIR=../compile
- ARCHDIR=../compile/${ARCH}
- OBJDIR=${ARCHDIR}/libtachyon
-+LIBS=-L. -ltachyon -lm
-+STRIP=strip
- 
- #
- # Name of raytracing library file to create
diff --git a/graphics/tachyon/files/patch-src_threads.c b/graphics/tachyon/files/patch-src_threads.c
new file mode 100644
index 000000000000..fbbaf05e1bb9
--- /dev/null
+++ b/graphics/tachyon/files/patch-src_threads.c
@@ -0,0 +1,11 @@
+--- src/threads.c.orig	2009-04-23 15:01:01 UTC
++++ src/threads.c
+@@ -13,7 +13,7 @@
+ #include <winbase.h> /* system services headers */
+ #endif
+ 
+-#if defined(SunOS) || defined(Irix) || defined(Linux) || defined(_CRAY) || defined(__osf__) || defined(AIX)
++#if defined(SunOS) || defined(Irix) || defined(Linux) || defined(Bsd) || defined(_CRAY) || defined(__osf__) || defined(AIX)
+ #include<unistd.h>  /* sysconf() headers, used by most systems */
+ #endif
+ 
diff --git a/graphics/tachyon/files/patch-src_threads.h b/graphics/tachyon/files/patch-src_threads.h
new file mode 100644
index 000000000000..d4fd3a7775c4
--- /dev/null
+++ b/graphics/tachyon/files/patch-src_threads.h
@@ -0,0 +1,11 @@
+--- src/threads.h.orig	2009-04-22 15:43:14 UTC
++++ src/threads.h
+@@ -13,7 +13,7 @@
+ #endif
+ 
+ /* POSIX Threads */
+-#if defined(HPUX) || defined(__PARAGON__) || defined(Irix) || defined(Linux) ||     defined(_CRAY) || defined(__osf__) || defined(AIX) || defined(__APPLE__)
++#if defined(HPUX) || defined(__PARAGON__) || defined(Irix) || defined(Linux) || defined(Bsd) || defined(_CRAY) || defined(__osf__) || defined(AIX) || defined(__APPLE__)
+ #if !defined(USEUITHREADS) && !defined(USEPOSIXTHREADS)
+ #define USEPOSIXTHREADS
+ #endif
diff --git a/graphics/tachyon/files/patch-src_trace.c b/graphics/tachyon/files/patch-src_trace.c
new file mode 100644
index 000000000000..76ecce1fcb29
--- /dev/null
+++ b/graphics/tachyon/files/patch-src_trace.c
@@ -0,0 +1,11 @@
+--- src/trace.c.orig	2010-01-18 06:13:18 UTC
++++ src/trace.c
+@@ -88,7 +88,7 @@ void * thread_trace(thr_parms * t) {
+    * wraparound in _anyone's_ lifetime, so no need to even check....
+    * On lesser-bit platforms, we're not quite so lucky, so we have to check.
+    */
+-#if !defined(LP64)
++#if !defined(LP64) && !defined(_LP64)
+   if (local_mbox != NULL) {
+     if (t->serialno > (((unsigned long) 1) << ((sizeof(unsigned long) * 8) - 3))) {
+       memset(local_mbox, 0, sizeof(unsigned long) * scene->objgroup.numobjects);
diff --git a/graphics/tachyon/files/patch-unix_Make-arch b/graphics/tachyon/files/patch-unix_Make-arch
new file mode 100644
index 000000000000..81d9bbd7b8f2
--- /dev/null
+++ b/graphics/tachyon/files/patch-unix_Make-arch
@@ -0,0 +1,18 @@
+--- unix/Make-arch.orig	2010-01-18 19:13:41 UTC
++++ unix/Make-arch
+@@ -954,13 +954,12 @@ bsd:
+ bsd:
+ 	$(MAKE) all \
+ 	"ARCH = bsd" \
+-	"CC = gcc" \
+-	"CFLAGS = -O3 -fomit-frame-pointer -ffast-math -DBsd  $(MISCFLAGS)" \
++	"CFLAGS = $(CFLAGS) -DBsd -DTHR $(MISCFLAGS)" \
+ 	"AR = ar" \
+ 	"ARFLAGS = r" \
+ 	"STRIP = strip" \
+ 	"RANLIB = ranlib" \
+-	"LIBS = -L. -ltachyon $(MISCLIB) -lm"
++	"LIBS = -L. -ltachyon $(MISCLIB) -lm -lpthread"
+ 
+ bsd-sparc:
+ 	$(MAKE) all \
diff --git a/lang/lua51/Makefile b/lang/lua51/Makefile
index 245ae8eeb36c..3455a68dbf0b 100644
--- a/lang/lua51/Makefile
+++ b/lang/lua51/Makefile
@@ -14,14 +14,6 @@ LICENSE=	MIT
 USES=		cpe libedit lua:core,51
 USE_LDCONFIG=	yes
 
-# Overriding __MAKE_CONF makes sure that we don't re-parse
-# /etc/make.conf during do-build, which would jeopardize the build
-# if, for instance, the user set CFLAGS=mumble
-# NOTE: /etc/make.conf is read BEFORE Makefile, so we already
-# have its settings when we get here.
-# See http://wiki.freebsd.org/MatthiasAndree/LuaLessonsLearnt
-MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
-
 # liblua.so requires libm, so make sure it has an explicit dependency
 # so that applications need not second-guess lua's dependencies.
 CPPFLAGS+=	-I${LOCALBASE}/include
diff --git a/lang/lua52/Makefile b/lang/lua52/Makefile
index 668565afb4ad..6b1c8c2f4da5 100644
--- a/lang/lua52/Makefile
+++ b/lang/lua52/Makefile
@@ -14,14 +14,6 @@ LICENSE=	MIT
 USES=		cpe libedit lua:core,52
 USE_LDCONFIG=	yes
 
-# Overriding __MAKE_CONF makes sure that we don't re-parse
-# /etc/make.conf during do-build, which would jeopardize the build
-# if, for instance, the user set CFLAGS=mumble
-# NOTE: /etc/make.conf is read BEFORE Makefile, so we already
-# have its settings when we get here.
-# See http://wiki.freebsd.org/MatthiasAndree/LuaLessonsLearnt
-MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
-
 # liblua.so requires libm, so make sure it has an explicit dependency
 # so that applications need not second-guess lua's dependencies.
 CPPFLAGS+=	-I${LOCALBASE}/include
diff --git a/lang/lua53/Makefile b/lang/lua53/Makefile
index 68ef4eb54e84..b9238f337bf1 100644
--- a/lang/lua53/Makefile
+++ b/lang/lua53/Makefile
@@ -14,14 +14,6 @@ LICENSE=	MIT
 USES=		cpe lua:core,53
 USE_LDCONFIG=	yes
 
-# Overriding __MAKE_CONF makes sure that we don't re-parse
-# /etc/make.conf during do-build, which would jeopardize the build
-# if, for instance, the user set CFLAGS=mumble
-# NOTE: /etc/make.conf is read BEFORE Makefile, so we already
-# have its settings when we get here.
-# See http://wiki.freebsd.org/MatthiasAndree/LuaLessonsLearnt
-MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
-
 # using the "bsd" target rather than "freebsd" saves patching out the
 # assumption of using base libedit in order to make it configurable. "bsd"
 # is "generic" plus the POSIX and DLOPEN options, plus -Wl,-E at link time;
diff --git a/lang/lua54/Makefile b/lang/lua54/Makefile
index 0f26b76890c3..c0a91f315034 100644
--- a/lang/lua54/Makefile
+++ b/lang/lua54/Makefile
@@ -14,14 +14,6 @@ LICENSE=	MIT
 USES=		cpe lua:core,54
 USE_LDCONFIG=	yes
 
-# Overriding __MAKE_CONF makes sure that we don't re-parse
-# /etc/make.conf during do-build, which would jeopardize the build
-# if, for instance, the user set CFLAGS=mumble
-# NOTE: /etc/make.conf is read BEFORE Makefile, so we already
-# have its settings when we get here.
-# See http://wiki.freebsd.org/MatthiasAndree/LuaLessonsLearnt
-MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
-
 # using the "bsd" target rather than "freebsd" saves patching out the
 # assumption of using base libedit in order to make it configurable. "bsd"
 # is "generic" plus the POSIX and DLOPEN options, plus -Wl,-E at link time;
diff --git a/mail/dma/Makefile b/mail/dma/Makefile
index 9ebbce70c586..417eff266a6a 100644
--- a/mail/dma/Makefile
+++ b/mail/dma/Makefile
@@ -18,8 +18,7 @@ GH_ACCOUNT=	corecode
 GH_TAGNAME=	92937587bbfeab53653b841afe76af2fa6dad345
 USE_RC_SUBR=	dma_flushq
 
-MAKE_ENV=	__MAKE_CONF=/dev/null \
-		MANDIR=${PREFIX}/share/man/man \
+MAKE_ENV=	MANDIR=${PREFIX}/share/man/man \
 		MK_WERROR=no \
 		SRCCONF=/dev/null
 
diff --git a/mail/spamilter/Makefile b/mail/spamilter/Makefile
index cd9a6bc06e04..dd625e6ed9f5 100644
--- a/mail/spamilter/Makefile
+++ b/mail/spamilter/Makefile
@@ -17,7 +17,6 @@ CONFIGURE_ARGS=	--have-resn
 USE_RC_SUBR=	spamilter
 
 LDFLAGS+=	-lpthread
-MAKE_ENV+=	__MAKE_CONF=/dev/null
 
 BINFILES=	spamilter-system-report spamilter-user-report
 SHEBANG_FILES=	${BINFILES}
diff --git a/math/libmissing/Makefile b/math/libmissing/Makefile
index ea6f7e60ce27..ae54be1d924c 100644
--- a/math/libmissing/Makefile
+++ b/math/libmissing/Makefile
@@ -15,7 +15,7 @@ USE_LDCONFIG=	yes
 USES=		tar:xz uidfix
 
 MAKE_ENV=	LDADD=-lmpc LIB=missing SHLIB_MAJOR="${SHLIB_MAJOR}" \
-		SRCCONF=/dev/null SRCS="${SRCS}" __MAKE_CONF=/dev/null
+		SRCCONF=/dev/null SRCS="${SRCS}"
 
 OPTIONS_DEFINE=	PROFILE EXAMPLES
 
@@ -61,10 +61,11 @@ post-patch:
 		${WRKSRC}/c/sp/Makefile
 
 do-test:
-	@cd ${WRKSRC}/c; ${SETENV} ${MAKE_ENV} XCFLAGS="${CFLAGS} -frounding-math" \
-		XINCLUDES="-I${WRKSRC}" XLDFLAGS="${LDFLAGS}" XLIBS="-L${WRKSRC} -lmissing" \
+	@cd ${WRKSRC}/c; ${SETENVI} ${WRK_ENV} ${MAKE_ENV} \
+		XCFLAGS="${CFLAGS} -frounding-math" XINCLUDES="-I${WRKSRC}" \
+		XLDFLAGS="${LDFLAGS}" XLIBS="-L${WRKSRC} -lmissing" \
 		LD_LIBRARY_PATH="/lib:/usr/lib:${LOCALBASE}/lib:${WRKSRC}" \
-		${MAKE} ${_MAKE_JOBS} ${MAKE_ARGS} all3
+		${MAKE_CMD} ${_MAKE_JOBS} ${MAKE_ARGS} all3
 .for t in d q s
 	@${PRINTF} "\n\n\n\t\t%s\n\n\n" "REPORT OF ${t:tu}. PRECISION TEST RESULTS:"
 	@${CAT} ${WRKSRC}/c/${t}p/tall${t}p.lst-xxx
diff --git a/math/linpack/Makefile b/math/linpack/Makefile
index af1d2ea896f0..e75a93be1f8a 100644
--- a/math/linpack/Makefile
+++ b/math/linpack/Makefile
@@ -11,7 +11,7 @@ WWW=		https://www.netlib.org/linpack/
 
 LIB_DEPENDS=	libblas.so:math/blas
 
-MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
+MAKE_ENV=	WITHOUT_PROFILE=yes SRCCONF=/dev/null
 MAKEFILE=	${FILESDIR}/Makefile.lib
 
 USES=		fortran uidfix
diff --git a/ports-mgmt/dialog4ports/Makefile b/ports-mgmt/dialog4ports/Makefile
index 3858acd7b3ab..91773a2e1f67 100644
--- a/ports-mgmt/dialog4ports/Makefile
+++ b/ports-mgmt/dialog4ports/Makefile
@@ -21,7 +21,7 @@ MAKE_ARGS+=	MAN1DIR=${PREFIX}/share/man/man1
 # CCACHE has options, so may need d4p, make d4p not ccache friendly
 # to avoid circular dependency
 NO_CCACHE=	yes
-MAKE_ENV+=	__MAKE_CONF=/dev/null SRCCONF=/dev/null
+MAKE_ENV+=	SRCCONF=/dev/null
 
 .if !exists(/usr/lib/libdialog.so)
 BROKEN=		Requires libdialog in base
diff --git a/sysutils/dirdiff/Makefile b/sysutils/dirdiff/Makefile
index 61d313b8c6b1..7d2b2680becf 100644
--- a/sysutils/dirdiff/Makefile
+++ b/sysutils/dirdiff/Makefile
@@ -18,11 +18,6 @@ PLIST_FILES=	bin/dirdiff lib/libfilecmp.so.0.0
 
 CFLAGS+=	-fPIC -I${TCL_INCLUDEDIR}
 
-# When bsdmake is used to build the port, the ports infrastructure should call
-# it with MAKE_ENV+=  __MAKE_CONF=/dev/null to avoid sourcing make.conf twice.
-# This is a workaround to make sure CFLAGS are passed through.
-MAKE_ARGS=	CFLAGS="${CFLAGS}"
-
 post-patch:
 	@${REINPLACE_CMD} -e \
 		's|.0.0|.0|g ; \
diff --git a/sysutils/pfstat/Makefile b/sysutils/pfstat/Makefile
index 423de38bec55..a89e00609971 100644
--- a/sysutils/pfstat/Makefile
+++ b/sysutils/pfstat/Makefile
@@ -18,7 +18,6 @@ USES=		iconv jpeg
 USE_RC_SUBR=	pfstatd
 
 MAKE_ARGS=	"LD_GD=gd"
-MAKE_ENV+=	__MAKE_CONF=/dev/null
 
 PLIST_FILES=	bin/pfstat \
 		bin/pfstatd \
diff --git a/sysutils/pftop/Makefile b/sysutils/pftop/Makefile
index 13f7bf3f98a5..3d3e9b75ae0f 100644
--- a/sysutils/pftop/Makefile
+++ b/sysutils/pftop/Makefile
@@ -30,7 +30,6 @@ CFLAGS+=	-DHAVE_ALTQ=1
 .endif
 
 MAKE_ARGS+=	CSTD=gnu89
-MAKE_ENV+=	__MAKE_CONF=/dev/null
 
 PLIST_FILES=	sbin/pftop \
 		share/man/man8/pftop.8.gz
diff --git a/x11-clocks/wmcalclock/Makefile b/x11-clocks/wmcalclock/Makefile
index 4fb767e1aa1a..660d3bcfcc8a 100644
--- a/x11-clocks/wmcalclock/Makefile
+++ b/x11-clocks/wmcalclock/Makefile
@@ -13,6 +13,7 @@ LICENSE_FILE=	${WRKSRC}/../COPYING
 
 USES=		xorg
 USE_XORG=	x11 xext xpm
+MAKE_ENV=	OPSYS=${OPSYS}
 WRKSRC=		${WRKDIR}/${DISTNAME}/Src
 PLIST_FILES=	bin/wmCalClock man/man1/${PORTNAME}.1.gz
 PORTDOCS=	BUGS CHANGES HINTS INSTALL README TODO