* make it compile on Debian/Sarge with a gcc-3.3.5
[olsrd.git] / Makefile.inc
index 32adc76..2704b13 100644 (file)
@@ -1,5 +1,5 @@
 # programs
-CCACHE        $(shell sh -c "type -path ccache")
+CCACHE ?=       $(shell sh -c "type -path ccache")
 CC ?=          $(CCACHE) gcc
 STRIP ?=       strip
 BISON ?=       bison
@@ -18,11 +18,34 @@ EXENAME ?= olsrd
 
 INCLUDES =     -Isrc -I$(TOPDIR)/src 
 
+GCC_VERSION := $(shell v=$$($(CC) -dumpversion); echo $${v//./ })
+
 # add gcc warnings and optimizations if CFLAGS not set
 ifndef CFLAGS
-CFLAGS +=      -Wall -Wmissing-prototypes -Wstrict-prototypes \
-               -Wmissing-declarations -Wsign-compare
-CFLAGS +=      -O2 -g
+CFLAGS +=      -Wall
+# gcc-3.3.5 on Debian sarge doesn't know the following warnings
+ifneq ("$(GCC_VERSION)","3 3 5")
+CFLAGS +=      -Wextra
+CFLAGS +=      -Wold-style-definition
+CFLAGS +=      -Wdeclaration-after-statement
+endif
+CFLAGS +=      -Wmissing-prototypes
+CFLAGS +=      -Wstrict-prototypes
+CFLAGS +=      -Wmissing-declarations
+CFLAGS +=      -Wsign-compare
+CFLAGS +=      -Waggregate-return
+CFLAGS +=      -Wmissing-noreturn
+CFLAGS +=      -Wmissing-format-attribute
+CFLAGS +=      -Wno-multichar
+CFLAGS +=      -Wno-deprecated-declarations
+#CFLAGS +=     -Wredundant-decls
+CFLAGS +=      -Wnested-externs
+#CFLAGS +=     -Wunreachable-code
+CFLAGS +=      -Winline
+CFLAGS +=      -Wdisabled-optimization
+CFLAGS +=      -O2
+CFLAGS +=      -g
+#CFLAGS +=     -Werror
 endif
 
 ifdef OLSRD_PLUGIN
@@ -44,7 +67,9 @@ HDRS +=               $(wildcard *.h)
 all: default_target
 
 # OS detection
-OS =           $(shell sh $(TOPDIR)/make/guess_os.sh)
+ifeq ($(OS),)
+OS :=          $(shell sh $(TOPDIR)/make/guess_os.sh)
+endif
 ifeq ($(OS),UNKNOWN)
 all: help
 else