Fix unrecognized option errors when building with older versions of GCC (Issue #23).

This approach suggested by ppannuto.
This commit is contained in:
Alex Halderman 2013-08-20 12:01:01 -04:00
parent 0b6494a3fb
commit 81f25a1848
2 changed files with 11 additions and 2 deletions

View File

@ -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 $*

7
src/zopt_compat.c Normal file
View File

@ -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"