# 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 = \
-Wl,--as-needed
if DEBUG
-AM_CFLAGS += -O0 -g
-else
+AM_CFLAGS += -g
+endif
+
+if OPTIMIZATIONS
AM_CFLAGS += -O2
+else
+AM_CFLAGS += -O0
endif
#
[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
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])
fi
AM_CONDITIONAL([DEBUG], [test x$debug_enabled = xyes])
+AM_CONDITIONAL([OPTIMIZATIONS], [test x$optimizations_enabled = xyes])
#
# Main dependencies
AC_MSG_NOTICE([Build configuration:
debug: $debug_enabled
+ optimizations: $optimizations_enabled
systemd: $systemd_enabled
udev: $udev_enabled