From 81f25a1848cca07a744f684f95f98cff409ab606 Mon Sep 17 00:00:00 2001 From: Alex Halderman Date: Tue, 20 Aug 2013 12:01:01 -0400 Subject: [PATCH] Fix unrecognized option errors when building with older versions of GCC (Issue #23). This approach suggested by ppannuto. --- src/Makefile | 6 ++++-- src/zopt_compat.c | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/zopt_compat.c diff --git a/src/Makefile b/src/Makefile index 5848a66..14498af 100644 --- a/src/Makefile +++ b/src/Makefile @@ -16,7 +16,7 @@ bindir=$(PREFIX)/sbin GCCWARNINGS = -Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef \ -Wpointer-arith \ -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment \ --Wformat=2 -Wwrite-strings -Wredundant-decls -Wno-unused-but-set-variable \ +-Wformat=2 -Wwrite-strings -Wredundant-decls \ -Wnested-externs -Wbad-function-cast -Winit-self \ -Wmissing-field-initializers \ -Waddress -Wmissing-noreturn -Wnormalized=id \ @@ -33,7 +33,7 @@ LDFLAGS+=$(EXTRALDFLAGS) modules=module_tcp_synscan.o module_icmp_echo.o module_udp.o #ADD YOUR MODULE HERE -objects=constraint.o blacklist.o cyclic.o logger.o send.o recv.o state.o monitor.o zopt.o zmap.o random.o output_modules.o module_simple_file.o module_extended_file.o packet.o probe_modules.o ${modules} validate.o rijndael-alg-fst.o get_gateway.o aesrand.o +objects=constraint.o blacklist.o cyclic.o logger.o send.o recv.o state.o monitor.o zopt_compat.o zmap.o random.o output_modules.o module_simple_file.o module_extended_file.o packet.o probe_modules.o ${modules} validate.o rijndael-alg-fst.o get_gateway.o aesrand.o ifeq ($(REDIS), true) LDLIBS+=-lhiredis @@ -48,6 +48,8 @@ $(TARGETS): zmap: $(objects) +zopt_compat.o: zopt.c + zopt.c zopt.h: zopt.ggo gengetopt -C --no-help --no-version -i $^ -F $* diff --git a/src/zopt_compat.c b/src/zopt_compat.c new file mode 100644 index 0000000..3dfda9d --- /dev/null +++ b/src/zopt_compat.c @@ -0,0 +1,7 @@ +#if __GNUC__ < 4 +#error "gcc version >= 4 is required" +#elif __GNUC_MINOR__ >= 6 +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#endif + +#include "zopt.c"