build: add --disable-optimizations option
authorDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 6 Aug 2012 13:27:53 +0000 (15:27 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 6 Aug 2012 13:27:53 +0000 (15:27 +0200)
We are in a state where redrawing the console can take a significant
amount of time on slower machines. Therefore, we definitely need gcc code
optimizations which help here a _lot_. However, they are currently bundled
to the debug flags.

This splits this into two options. We still need this flag to get getter
backtraces. Otherwise, those inlined functions are horrible to track done.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Makefile.am
configure.ac

index 6ac9e63..324c4ee 100644 (file)
@@ -49,8 +49,9 @@ lib_LTLIBRARIES = \
 # Also make the linker discard all unused symbols as we are not building a
 # shared library.
 #
-# When compiling in debug mode, we disable optimization and enable debug symbols
-# so debugging with gdb is easier.
+# When compiling in debug mode, we enable debug symbols so debugging with gdb
+# is easier. If optimizations are disabled, we pass -O0 to the compiler.
+# Otherwise, we use standard optimizations -O2.
 #
 
 AM_CFLAGS = \
@@ -63,9 +64,13 @@ AM_LDFLAGS = \
        -Wl,--as-needed
 
 if DEBUG
-AM_CFLAGS += -O0 -g
-else
+AM_CFLAGS += -g
+endif
+
+if OPTIMIZATIONS
 AM_CFLAGS += -O2
+else
+AM_CFLAGS += -O0
 endif
 
 #
index 3e0990b..8c9f7a4 100644 (file)
@@ -154,10 +154,16 @@ AC_ARG_ENABLE([debug],
                               [whether to build with debugging on])])
 AC_MSG_RESULT([ok])
 
+AC_MSG_CHECKING([whether to disable code optimizations])
+AC_ARG_ENABLE([optimizations],
+              [AS_HELP_STRING([--disable-optimizations],
+                              [whether to disable code optimizations])])
+AC_MSG_RESULT([ok])
+
 #
-# Debug mode
-# In debug mode we use -g -O0 for compilation and set several flags so verbose
-# logging is possible.
+# Debug mode and code optimizations
+# In debug mode we compile with -g and enable several debug-messages and flags.
+# With optimizations (default), we add -O2 to compile-flags.
 #
 
 debug_enabled=no
@@ -165,6 +171,11 @@ if test x$enable_debug = xyes ; then
         debug_enabled=yes
 fi
 
+optimizations_enabled=no
+if test ! x$enable_optimizations = xno ; then
+        optimizations_enabled=yes
+fi
+
 if test x$debug_enabled = xyes ; then
         AC_DEFINE([KMSCON_ENABLE_DEBUG], [1],
                   [Enable debug for kmscon])
@@ -177,6 +188,7 @@ else
 fi
 
 AM_CONDITIONAL([DEBUG], [test x$debug_enabled = xyes])
+AM_CONDITIONAL([OPTIMIZATIONS], [test x$optimizations_enabled = xyes])
 
 #
 # Main dependencies
@@ -464,6 +476,7 @@ AC_OUTPUT([src/genshader.c])
 AC_MSG_NOTICE([Build configuration:
 
                debug: $debug_enabled
+       optimizations: $optimizations_enabled
 
              systemd: $systemd_enabled
                 udev: $udev_enabled