Browse Source

Ensure good code practices by appropriate compiler warnings.
Compiler flags are mostly lifted from here: http://blog.httrack.com/blog/2014/03/09/what-are-your-gcc-flags/
Long-term goal should be -werror enabled (no warnings permitted at all).

Julius Pfrommer 11 years ago
parent
commit
f98634c0b1
5 changed files with 8 additions and 26 deletions
  1. 4 2
      Makefile.am
  2. 1 6
      examples/src/Makefile.am
  3. 1 6
      src/Makefile.am
  4. 1 6
      tests/Makefile.am
  5. 1 6
      tool/Makefile.am

+ 4 - 2
Makefile.am

@@ -1,10 +1,12 @@
 
 if DEBUG
-AM_CFLAGS = -g -O0
+AM_CFLAGS = -g -O0 -std=c99 -pedantic -pipe -fPIC -fno-exceptions -fstack-protector -Wl,-z,relro -Wl,-z,now -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security
 else
-AM_CFLAGS = -O2
+AM_CFLAGS = -O2 -std=c99 -pedantic -pipe -fPIC -fno-exceptions -fstack-protector -Wl,-z,relro -Wl,-z,now -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security
 endif
 
+export GLOBAL_AM_CFLAGS = $(AM_CFLAGS)
+
 if HAVE_CHECK
     SUBS=src tests tool
 

+ 1 - 6
examples/src/Makefile.am

@@ -5,9 +5,4 @@ __top_builddir__bin_exampleServer_CFLAGS = -I$(top_builddir)/src -I$(top_builddi
 __top_builddir__bin_exampleServer_SOURCES = opcuaServer.c
 __top_builddir__bin_exampleServer_LDADD= $(top_builddir)/lib/libopen62541.a
 
-#optimization levels depending on debug
-if DEBUG
-        AM_CFLAGS = -O0
-else
-        AM_CFLAGS = -O2
-endif
+AM_CFLAGS = $(GLOBAL_AM_CFLAGS)

+ 1 - 6
src/Makefile.am

@@ -72,9 +72,4 @@ all-local: convenience-link
 clean-local: clean-convenience-link
 
 #optimization levels depending on debug
-if DEBUG
-        AM_CFLAGS = -O0
-else
-        AM_CFLAGS = -O2
-endif
-
+AM_CFLAGS = $(GLOBAL_AM_CFLAGS)

+ 1 - 6
tests/Makefile.am

@@ -7,9 +7,4 @@ LDADD = $(top_builddir)/lib/libopen62541.a @CHECK_LIBS@
 check_PROGRAMS = $(TESTS)
 AM_LDFLAGS = $(LDADD)
 
-#optimization levels depending on debug
-if DEBUG
-        AM_CFLAGS = -O0 $(INCLUDE)
-else
-        AM_CFLAGS = -O2 $(INCLUDE)
-endif
+AM_CFLAGS = $(GLOBAL_AM_CFLAGS)

+ 1 - 6
tool/Makefile.am

@@ -17,9 +17,4 @@ clean-autogenerated:
 
 clean-local: clean-autogenerated
 
-#optimization levels depending on debug
-if DEBUG
-        AM_CFLAGS = -O0 $(INCLUDE)
-else
-        AM_CFLAGS = -O2 $(INCLUDE)
-endif
+AM_CFLAGS = $(GLOBAL_AM_CFLAGS)