I find myself adding the following to many ports files nowadays
.include <bsd.port.arch.mk>
.if !${PROPERTIES:Mclang}
CFLAGS += -std=gnu99
.endif
Rather than continue this, I'd like to propose adding BASE_C99 to bsd.port.mk
When BASE_C99= Yes, if on a non-base-clang arch, it will add the same to
CFLAGS, but without including bsd.port.arch.mk by hand.
Included are patches to add this to bsd.port.mk and a diff for bsd.port.mk(5)
to include it in the man page.
Once this is in, I'll sweep the tree for the boilerplate and replace it all
with this.
ok?
--Kurt
Index: bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.1564
diff -u -p -r1.1564 bsd.port.mk
--- bsd.port.mk 14 Dec 2021 14:21:41 -0000 1.1564
+++ bsd.port.mk 23 Dec 2021 16:34:42 -0000
@@ -736,6 +736,13 @@ CFLAGS += ${CDIAGFLAGS}
CXXFLAGS += ${CXXDIAGFLAGS}
.endif
+# Add -std=gnu99 to CFLAGS if requested and arch is base-gcc
+BASE_C99 ?= no
+.if !${PROPERTIES:Mclang} && ${BASE_C99:L} == "yes"
+CFLAGS += -std=gnu99
+.endif
+
+
# XXX trick ports into trying to write into / instead of the current user's
# homedir.
PORTHOME ?= /${PKGNAME}_writes_to_HOME
Index: bsd.port.mk.5
===================================================================
RCS file: /cvs/src/share/man/man5/bsd.port.mk.5,v
retrieving revision 1.550
diff -u -p -r1.550 bsd.port.mk.5
--- bsd.port.mk.5 22 Nov 2021 11:17:39 -0000 1.550
+++ bsd.port.mk.5 28 Dec 2021 02:34:51 -0000
@@ -966,6 +966,21 @@ Can be set to
.Sq autogen.sh
if such a script is available.
Defaults to autoreconf --force --install.
+.It Ev BASE_C99
+Defaults to
+.Sq \&No .
+Set to
+.Sq Yes
+for ports needing c99 constructs while using base-gcc.
+.Pp
+When
+.Ev BASE_C99
+is set to
+.Sq Yes ,
+.Ev CFLAGS
+has
+.Sq -std=gnu99
+added to it if building on a base-gcc architecture.
.It Ev BASE_PKGPATH
Full
.Xr pkgpath 7