From 7aad159464b3a31a42789594e6efd4bd2fceb644 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sat, 2 Jun 2018 22:00:32 -0300 Subject: [PATCH] build: append -std=gnu99 after SNMP_CFLAGS Programs that link to libnetsnmp must be compiled using a special set of flags as specified by the "net-snmp-config --base-cflags" command (whose output is stored in the SNMP_CFLAGS variable). The problem is that "net-snmp-config --base-cflags" can output -std=c99 in addition to other compiler flags in some platforms, and this breaks the build since FRR souce code makes use of some GNU compiler extensions (e.g. allow trailing commas in function parameter lists). In order to solve this problem, append -std=gnu99 after SNMP_CFLAGS in all makefiles where this variable is used. This way the -std=c99 flag will be overwritten when it's present. Source files that don't link to libnetsnmp will be compiled using either -std=gnu99 or -std=gnu11 depending on the compiler availability. Fixes #1617. Signed-off-by: Renato Westphal --- bgpd/Makefile.am | 2 +- lib/subdir.am | 2 +- ospf6d/subdir.am | 2 +- ospfd/subdir.am | 2 +- ripd/subdir.am | 2 +- zebra/subdir.am | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am index 8a410adca1..6761389100 100644 --- a/bgpd/Makefile.am +++ b/bgpd/Makefile.am @@ -116,7 +116,7 @@ module_LTLIBRARIES += bgpd_snmp.la endif bgpd_snmp_la_SOURCES = bgp_snmp.c -bgpd_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) +bgpd_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99 bgpd_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic bgpd_snmp_la_LIBADD = ../lib/libfrrsnmp.la diff --git a/lib/subdir.am b/lib/subdir.am index c5719786d6..1c3d31b927 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -190,7 +190,7 @@ if SNMP lib_LTLIBRARIES += lib/libfrrsnmp.la endif -lib_libfrrsnmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) +lib_libfrrsnmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99 lib_libfrrsnmp_la_LDFLAGS = -version-info 0:0:0 lib_libfrrsnmp_la_LIBADD = lib/libfrr.la $(SNMP_LIBS) lib_libfrrsnmp_la_SOURCES = \ diff --git a/ospf6d/subdir.am b/ospf6d/subdir.am index 76a64cd637..8a6c4a5ccf 100644 --- a/ospf6d/subdir.am +++ b/ospf6d/subdir.am @@ -61,6 +61,6 @@ ospf6d_ospf6d_SOURCES = \ # end ospf6d_ospf6d_snmp_la_SOURCES = ospf6d/ospf6_snmp.c -ospf6d_ospf6d_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) +ospf6d_ospf6d_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99 ospf6d_ospf6d_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic ospf6d_ospf6d_snmp_la_LIBADD = lib/libfrrsnmp.la diff --git a/ospfd/subdir.am b/ospfd/subdir.am index 9f04260366..f2e292e186 100644 --- a/ospfd/subdir.am +++ b/ospfd/subdir.am @@ -89,7 +89,7 @@ ospfd_ospfd_LDADD = ospfd/libfrrospf.a lib/libfrr.la @LIBCAP@ @LIBM@ ospfd_ospfd_SOURCES = ospfd/ospf_main.c ospfd_ospfd_snmp_la_SOURCES = ospfd/ospf_snmp.c -ospfd_ospfd_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) +ospfd_ospfd_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99 ospfd_ospfd_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic ospfd_ospfd_snmp_la_LIBADD = lib/libfrrsnmp.la diff --git a/ripd/subdir.am b/ripd/subdir.am index 7a8f2185ba..1c5167ef4a 100644 --- a/ripd/subdir.am +++ b/ripd/subdir.am @@ -35,7 +35,7 @@ ripd_ripd_SOURCES = \ # end ripd_ripd_snmp_la_SOURCES = ripd/rip_snmp.c -ripd_ripd_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) +ripd_ripd_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99 ripd_ripd_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic ripd_ripd_snmp_la_LIBADD = lib/libfrrsnmp.la diff --git a/zebra/subdir.am b/zebra/subdir.am index 45e285a9e7..d3abcef6d5 100644 --- a/zebra/subdir.am +++ b/zebra/subdir.am @@ -127,7 +127,7 @@ zebra_zebra_irdp_la_SOURCES = \ zebra_zebra_irdp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic zebra_zebra_snmp_la_SOURCES = zebra/zebra_snmp.c -zebra_zebra_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) +zebra_zebra_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99 zebra_zebra_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic zebra_zebra_snmp_la_LIBADD = lib/libfrrsnmp.la -- 2.39.5