SINGA-69 Add debug option in compilation configuration
Two updates:
1.User can use "--enable-singatest" option while running configure script to 
generate test binary file and corresponding library.
2.User can use "--enable-debug" option while running configure script to 
compile with "-g" parameter. The optimization level is adapted to "-O2".


Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/e0de439e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/e0de439e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/e0de439e

Branch: refs/heads/tutorial
Commit: e0de439ea797b3276bf6e59e01a3c243cea57ece
Parents: bc400a7
Author: xiezl <[email protected]>
Authored: Sat Sep 12 21:07:27 2015 +0800
Committer: xiezl <[email protected]>
Committed: Sat Sep 12 21:07:27 2015 +0800

----------------------------------------------------------------------
 Makefile.am  | 55 ++++++++++++++++++++++++++++++++-----------------------
 configure.ac | 27 ++++++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/e0de439e/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 732b84e..baff947 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,9 +4,12 @@ AUTOMAKE_OPTIONS = foreign subdir-objects
 AM_CPPFLAGS = -I$(top_srcdir)/src
 
 MSHADOW_FLAGS = -DMSHADOW_USE_CUDA=0 -DMSHADOW_USE_CBLAS=1 -DMSHADOW_USE_MKL=0
+DEFAULT_FLAGS = -Wall -pthread -fPIC -std=c++11 -Wno-unknown-pragmas \
+              $(MSHADOW_FLAGS) -DCPU_ONLY=1 -funroll-loops -DTHREADED
 
-AC_CXXFLAGS = -O3 -Wall -pthread -fPIC -std=c++11 -Wno-unknown-pragmas \
-              $(MSHADOW_FLAGS) -DCPU_ONLY=1 -funroll-loops
+CFLAGS = -O2 $(DEBUG)
+CXXFLAGS = -O2 $(DEBUG) 
+AC_CXXFLAGS = -O2 $(DEBUG)
 
 INCLUDES = -I$(top_srcdir)/include
 
@@ -87,31 +90,28 @@ TEST_SRCS := include/gtest/gtest_main.cc \
                         src/test/test_paramslicer.cc \
                         src/test/test_shard.cc
 
-lib_LTLIBRARIES = libsinga.la
+#EXTRA_PROGRAMS = $(PROGS)
+EXTRA_PROGRAMS = singatest
+#EXTRA_LTLIBRARIES = $(LTLIBS)
+EXTRA_LTLIBRARIES = libgtest.la
+
+lib_LTLIBRARIES = libsinga.la $(LTLIBS)
+bin_PROGRAMS = singa singatool $(PROGS)
+
+#lib_LTLIBRARIES = libsinga.la
 libsinga_la_SOURCES = $(PROTO_HDRS) $(PROTO_SRCS) $(SINGA_HDRS) $(SINGA_SRCS)
-libsinga_la_CXXFLAGS = -O3 -Wall -pthread -fPIC -std=c++11 
-Wno-unknown-pragmas \
-                       $(MSHADOW_FLAGS) -DCPU_ONLY=1 -funroll-loops -gdwarf-2 
-msse3 \
-                       -gstrict-dwarf -Woverloaded-virtual -DTHREADED 
-fpermissive
+libsinga_la_CXXFLAGS = $(DEFAULT_FLAGS) -gdwarf-2 -msse3 \
+                       -gstrict-dwarf -Woverloaded-virtual -fpermissive
 if LMDB
 libsinga_la_CXXFLAGS += -DUSE_LMDB
 endif
 libsinga_la_LDFLAGS = -I./include
 
-lib_LTLIBRARIES += libgtest.la
-libgtest_la_SOURCES = $(GTEST_HDRS) $(GTEST_SRCS)
-libgtest_la_CXXFLAGS = -O3 -Wall -pthread -fPIC -std=c++11 
-Wno-unknown-pragmas \
-                       $(MSHADOW_FLAGS) -DCPU_ONLY=1 -funroll-loops -gdwarf-2 
-msse3 \
-                       -gstrict-dwarf -Woverloaded-virtual -DTHREADED 
-fpermissive
-if LMDB
-libgtest_la_CXXFLAGS += -DUSE_LMDB
-endif
-libgtest_la_LDFLAGS = -I./include
 
 
-bin_PROGRAMS = singa
+#bin_PROGRAMS = singa
 singa_SOURCES = src/main.cc
-singa_CXXFLAGS = -O3 -Wall -pthread -fPIC -std=c++11 -MMD -Wno-unknown-pragmas 
\
-                 $(MSHADOW_FLAGS) -DCPU_ONLY=1 -funroll-loops -DTHREADED
+singa_CXXFLAGS = $(DEFAULT_FLAGS) -MMD 
 singa_LDFLAGS = -I./include \
                 -lsinga \
                 -lglog  \
@@ -125,9 +125,9 @@ if LMDB
 singa_LDFLAGS += -llmdb
 endif
 
-bin_PROGRAMS += singatool
+#bin_PROGRAMS += singatool
 singatool_SOURCES = src/utils/tool.cc
-singatool_CXXFLAGS = -O3 -Wall -pthread -fPIC -std=c++11 -MMD 
-Wno-unknown-pragmas \
+singatool_CXXFLAGS = -Wall -pthread -fPIC -std=c++11 -MMD -Wno-unknown-pragmas 
\
                      -funroll-loops -DTHREADED
 singatool_LDFLAGS = -I./include \
                     -lsinga \
@@ -135,10 +135,19 @@ singatool_LDFLAGS = -I./include \
                     -lprotobuf \
                     -lzookeeper_mt
 
-bin_PROGRAMS += singatest
+#lib_LTLIBRARIES += libgtest.la
+libgtest_la_SOURCES = $(GTEST_HDRS) $(GTEST_SRCS)
+libgtest_la_CXXFLAGS = $(DEFAULT_FLAGS) -gdwarf-2 -msse3 \
+                                       -gstrict-dwarf -Woverloaded-virtual 
-fpermissive
+if LMDB
+libgtest_la_CXXFLAGS += -DUSE_LMDB
+endif
+libgtest_la_LDFLAGS = -I./include
+
+#bin_PROGRAMS += singatest
+
 singatest_SOURCES = $(GTEST_HDRS) $(TEST_SRCS)
-singatest_CXXFLAGS = -O3 -Wall -pthread -fPIC -std=c++11 -MMD 
-Wno-unknown-pragmas \
-                 $(MSHADOW_FLAGS) -DCPU_ONLY=1 -funroll-loops -DTHREADED
+singatest_CXXFLAGS = $(DEFAULT_FLAGS) 
 singatest_LDFLAGS = -I./include \
                 -lsinga \
                 -lglog  \

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/e0de439e/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 569c406..1ff528f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,7 +8,7 @@ AC_CONFIG_MACRO_DIR(config)
 AC_CONFIG_SRCDIR([src/utils/common.cc])
 AC_CONFIG_HEADER([config.h])
 AM_INIT_AUTOMAKE([subdir-objects foreign])
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+#m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 ACLOCAL_AMFLAGS = -I m4 --install
 
 # Checks for programs.
@@ -44,6 +44,31 @@ if test x"$enable_lmdb" = x"yes"; then
        AC_DEFINE(LMDB, 1, [Enable Option layer])
 fi
 
+AC_ARG_ENABLE(singatest,
+       AS_HELP_STRING([--enable-singatest],[enable singa test]),
+       [enable_singatest=yes],[enable_singatest=no])
+AM_CONDITIONAL(SINGATEST, test "$enable_singatest" = yes)
+if test x"$enable_singatest" != x"no"; then
+       PROGS='singatest'
+       LTLIBS='libgtest.la'
+else
+       PROGS=''
+       LTLIBS=''
+fi
+AC_SUBST([PROGS])
+AC_SUBST([LTLIBS])
+
+AC_ARG_ENABLE(debug,
+       AS_HELP_STRING([--enable-debug],[enable debug mode]),
+       [enable_debug=yes],[enable_debug=no])
+AM_CONDITIONAL(DEBUG, test "$enable_debug" = yes)
+if test x"$enable_debug" != x"no"; then
+       DEBUG='-g'
+else
+       DEBUG=''
+fi
+AC_SUBST([DEBUG])
+
 #AC_CHECK_LIB([opencv_imgproc], [main], [], [
 #  AC_MSG_ERROR([unable to find opencv_imgproc lib])
 #  ])

Reply via email to