Explorar el Código

improved debugging infrastructure

./configure can be now run with --enable-debug (default: false)

if debug is off -- compile with -g -O2
if debug is on -- compile with -g -O0 and DEBUG symbol is accessble from precompiler
Stasik0 hace 11 años
padre
commit
2bca27736b
Se han modificado 5 ficheros con 28 adiciones y 33 borrados
  1. 1 1
      README.md
  2. 6 1
      configure.ac
  3. 7 1
      examples/src/Makefile.am
  4. 7 30
      src/Makefile.am
  5. 7 0
      tests/Makefile.am

+ 1 - 1
README.md

@@ -58,7 +58,7 @@ $ git clone https://github.com/acplt/open62541.git
 ```bash
 $ cd open62541
 $ ./autogen.sh
-$ ./configure
+$ ./configure --enable-debug
 $ make
 $ make check
 ```

+ 6 - 1
configure.ac

@@ -7,8 +7,10 @@ AC_INIT(OPCUAServer, 1.0)
 AC_CANONICAL_SYSTEM
 AM_INIT_AUTOMAKE()
 AC_PROG_MAKE_SET
+#default CFLAGS is -g -02
+#reset it just to -g and make optimization dependend on --enable-debug
 if test -z $CFLAGS; then
-    CFLAGS='-O0'
+    CFLAGS='-g'
 fi
 AC_PROG_CC
 AC_PROG_LN_S
@@ -37,6 +39,9 @@ esac],
 [debug=false])
 
 AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")
+AM_COND_IF([DEBUG],
+    AC_DEFINE([DEBUG])) #define DEBUG is accessible from pre-processor
+
    
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL

+ 7 - 1
examples/src/Makefile.am

@@ -1,5 +1,11 @@
-
 bin_PROGRAMS= $(top_builddir)/bin/exampleServer
 __top_builddir__bin_exampleServer_LDFLAGS = -all-static
 __top_builddir__bin_exampleServer_SOURCES = opcuaServer.c
 __top_builddir__bin_exampleServer_LDADD= ../../lib/libopen62541.a
+
+#optimization levels depending on debug
+if DEBUG
+        AM_CFLAGS = -O0
+else
+        AM_CFLAGS = -O2
+endif

+ 7 - 30
src/Makefile.am

@@ -1,21 +1,3 @@
-
-#__top_builddir__bin_stackTest_out_SOURCES =	opcuaServer.c\
-#											opcua_builtInDatatypes.c\
-#											opcua_binaryEncDec.c\
-#											opcua_transportLayer.c\
-#											opcua_builtInDatatypes.h\
-#											opcua_binaryEncDec.h\
-#											opcua_transportLayer.h\
-#											opcua_advancedDatatypes.h\
-#											opcua_types.h\
-#											opcua_connectionHelper.h\
-#											tcp_layer.h
-
-#lib_LTLIBRARIES = libstack.la
-#libstack_la_SOURCES = opcua_transportLayer.c\
-#					  opcua_transportLayer.h\
-#					  opcua_advancedDatatypes.h\
-#					  opcua_connectionHelper.h	
 lib_LTLIBRARIES = libopen62541.la
 libopen62541_la_LDFLAGS = -avoid-version -no-undefined
 libopen62541_la_SOURCES = opcua_builtInDatatypes.c\
@@ -38,18 +20,6 @@ libopen62541_la_SOURCES = opcua_builtInDatatypes.c\
 						opcua_time.h\
 						tcp_layer.h						
 
-#bin_PROGRAMS= $(top_builddir)/bin/open62541.out
-#__top_builddir__bin_libOpen62541_out_SOURCES = opcuaServer.c
-#libOpen62541_la_LIBADD = ../lib/libOpen62541.la		  										
-
-if DEBUG
-AM_CFLAGS = -g -O0
-AM_CXXFLAGS = -g -O0
-else
-AM_CFLAGS = -O2
-AM_CXXFLAGS = -O2
-endif
-
 .PHONY: convenience-link clean-convenience-link
 
 convenience-link: $(lib_LTLIBRARIES)
@@ -76,3 +46,10 @@ all-local: convenience-link
 
 clean-local: clean-convenience-link
 
+#optimization levels depending on debug
+if DEBUG
+        AM_CFLAGS = -O0
+else
+        AM_CFLAGS = -O2
+endif
+

+ 7 - 0
tests/Makefile.am

@@ -4,3 +4,10 @@ check_stack_SOURCES = check_stack.c
 
 check_stack_CFLAGS = @CHECK_CFLAGS@
 check_stack_LDADD = $(top_builddir)/src/libopen62541.la @CHECK_LIBS@
+
+#optimization levels depending on debug
+if DEBUG
+        AM_CFLAGS = -O0
+else
+        AM_CFLAGS = -O2
+endif