summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2011-09-02 11:22:50 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2011-09-02 11:22:50 +0200
commit1e78a7fe81d7d6140a0f7ecaa428a31170d62d72 (patch)
tree5abaf025b2626ea4faeae6a83b05661d1405b244
parent286207a4d243f9553157fcffa28650132779912d (diff)
autotools: added --enable-warnings
Use --enable-warnings=fatal to compile with warnings enabled which the code needs to pass and these warnings turned into errors. Easier than having to remember and set the right CFLAGS/CXXFLAGS.
-rwxr-xr-xautogen.sh2
-rw-r--r--configure.in6
-rw-r--r--m4/dk-warn.m4114
-rw-r--r--src/Makefile.am.in5
4 files changed, 124 insertions, 3 deletions
diff --git a/autogen.sh b/autogen.sh
index 1779d45..f08c81c 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -9,7 +9,7 @@ rm -rf aclocal.m4 autom4te.cache config.guess config.sub config.h.in configure d
(cd src && ./gen-makefile-am.sh)
libtoolize -c
-aclocal
+aclocal -I m4
autoheader
automake -a -c
autoconf
diff --git a/configure.in b/configure.in
index 652ea0c..2bdc3da 100644
--- a/configure.in
+++ b/configure.in
@@ -14,6 +14,12 @@ AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
AM_PROG_CC_C_O
+# --enable-warning=min/max/fatal/none
+DK_ARG_ENABLE_WARNINGS([SYNTHESIS_WFLAGS],
+ [-Wall],
+ [-Wall -Wno-unknown-pragmas],
+ [])
+
dnl Extract PIC flags from libtool configure for libsynthesissdk.a
dnl (makes assumptions about libtool var naming!). Some versions
dnl of libtool use PIC mode automatically for static libraries,
diff --git a/m4/dk-warn.m4 b/m4/dk-warn.m4
new file mode 100644
index 0000000..90243bd
--- /dev/null
+++ b/m4/dk-warn.m4
@@ -0,0 +1,114 @@
+## Copyright (c) 2004-2007 Daniel Elstner <daniel.kitta@gmail.com>
+##
+## This file is part of danielk's Autostuff.
+##
+## danielk's Autostuff is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License as published
+## by the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## danielk's Autostuff is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+## for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with danielk's Autostuff; if not, write to the Free Software Foundation,
+## Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#serial 20070116
+
+## DK_ARG_ENABLE_WARNINGS(variable, min-flags, max-flags, [deprecation-prefixes])
+##
+## Provide the --enable-warnings configure argument, set to "min" by default.
+## <min-flags> and <max-flags> should be space-separated lists of compiler
+## warning flags to use with --enable-warnings=min or --enable-warnings=max,
+## respectively. Warning level "fatal" is the same as "max" but in addition
+## enables -Werror mode.
+##
+## If not empty, <deprecation-prefixes> should be a list of module prefixes
+## which is expanded to -D<module>_DISABLE_DEPRECATED flags if fatal warnings
+## are enabled, too.
+##
+AC_DEFUN([DK_ARG_ENABLE_WARNINGS],
+[dnl
+m4_if([$3],, [AC_FATAL([3 arguments expected])])[]dnl
+dnl
+AC_ARG_ENABLE([warnings], [AS_HELP_STRING(
+ [--enable-warnings=@<:@min|max|fatal|no@:>@],
+ [control compiler pickyness @<:@min@:>@])],
+ [dk_enable_warnings=$enableval],
+ [dk_enable_warnings=min])[]dnl
+
+dk_lang=
+case $ac_compile in
+ *'$CXXFLAGS '*)
+ dk_lang='C++'
+ dk_cc=$CXX
+ dk_conftest=conftest.${ac_ext-cc}
+ ;;
+ *'$CFLAGS '*)
+ dk_lang=C
+ dk_cc=$CC
+ dk_conftest=conftest.${ac_ext-c}
+ ;;
+esac
+
+AS_IF([test "x$dk_lang" != x],
+[
+ AC_MSG_CHECKING([which $dk_lang compiler warning flags to use])
+
+ case $dk_enable_warnings in
+ no) dk_warning_flags=;;
+ max) dk_warning_flags="$3";;
+ fatal) dk_warning_flags="$3 -Werror";;
+ *) dk_warning_flags="$2";;
+ esac
+
+ dk_deprecation_flags=
+m4_if([$4],,, [
+ AS_IF([test "x$dk_enable_warnings" = xfatal],
+ [
+ dk_deprecation_prefixes="$4"
+ for dk_prefix in $dk_deprecation_prefixes
+ do
+ dk_deprecation_flags="${dk_deprecation_flags}-D${dk_prefix}_DISABLE_DEPRECATED "
+ done
+ ])
+])[]dnl
+ dk_tested_flags=
+
+ AS_IF([test "x$dk_warning_flags" != x],
+ [
+ # Keep in mind that the dummy source must be devoid of any
+ # problems that might cause diagnostics.
+ AC_LANG_CONFTEST([AC_LANG_SOURCE(
+ [[int main(int argc, char** argv) { return (argv != 0) ? argc : 0; }]])])
+
+ for dk_flag in $dk_warning_flags
+ do
+ # Test whether the compiler accepts the flag. GCC doesn't bail
+ # out when given an unsupported flag but prints a warning, so
+ # check the compiler output instead.
+ dk_cc_out=`$dk_cc $dk_tested_flags $dk_flag -c "$dk_conftest" 2>&1 || echo failed`
+ rm -f "conftest.${OBJEXT-o}"
+
+ AS_IF([test "x$dk_cc_out" = x],
+ [
+ AS_IF([test "x$dk_tested_flags" = x],
+ [dk_tested_flags=$dk_flag],
+ [dk_tested_flags="$dk_tested_flags $dk_flag"])
+ ], [
+ echo "$dk_cc_out" >&AS_MESSAGE_LOG_FD
+ ])
+ done
+
+ rm -f "$dk_conftest"
+ ])
+ dk_all_flags=$dk_deprecation_flags$dk_tested_flags
+ AC_SUBST([$1], [$dk_all_flags])
+
+ test "x$dk_all_flags" != x || dk_all_flags=none
+ AC_MSG_RESULT([$dk_all_flags])
+])
+])
diff --git a/src/Makefile.am.in b/src/Makefile.am.in
index 3e4fc48..4d3e39d 100644
--- a/src/Makefile.am.in
+++ b/src/Makefile.am.in
@@ -46,6 +46,7 @@ libsynthesis_la_SOURCES = @LIBSYNTHESIS_SOURCES@ \
$(XMLPARSE_SOURCES)
libsynthesis_la_CPPFLAGS = -I$(srcdir)/sysync_SDK/Sources
libsynthesis_la_CFLAGS = \
+ $(SYNTHESIS_WFLAGS) \
-include $(top_builddir)/config.h \
-include $(srcdir)/Targets/ReleasedProducts/combiEngine_opensource_linux/combiengine_opensource_linux_prefix.h \
-I$(srcdir)/Targets/ReleasedProducts/clientEngine_autotools/ \
@@ -109,8 +110,8 @@ endif
libsynthesissdk_la_LIBADD = libsmltk.la # san.cpp calls sml* functions directly
libsynthesissdk_la_LDFLAGS = -static
-libsynthesissdk_la_CFLAGS = $(PIC_CXXFLAGS)
-libsynthesissdk_la_CXXFLAGS = $(PIC_CXXFLAGS)
+libsynthesissdk_la_CFLAGS = $(PIC_CXXFLAGS) $(SYNTHESIS_WFLAGS)
+libsynthesissdk_la_CXXFLAGS = $(PIC_CXXFLAGS) $(SYNTHESIS_WFLAGS)
libsynthesissdk_la_SOURCES = @LIBSYNTHESISSDK_HEADERS@
if COND_STATIC
libsynthesissdk_la_SOURCES += @LIBSYNTHESISSDK_SOURCES_SDK_ONLY@