diff --git a/Makefile.am b/Makefile.am index 7771a6e3..4a8ee4af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,18 +43,7 @@ AM_CXXFLAGS += -I$(top_srcdir)/src/common/android/include AM_CXXFLAGS += -I$(top_srcdir)/src/common/android/testing/include endif -if GCC -# These are good warnings to be treated as errors -AM_CXXFLAGS += \ - -Werror \ - -Werror=missing-braces \ - -Werror=non-virtual-dtor \ - -Werror=overloaded-virtual \ - -Werror=reorder \ - -Werror=sign-compare \ - -Werror=unused-variable \ - -Werror=vla -endif +AM_CXXFLAGS += $(WARN_CXXFLAGS) if LINUX_HOST # Build as PIC on Linux, for linux_client_unittest_shlib diff --git a/Makefile.in b/Makefile.in index 2de8fd3e..84206074 100644 --- a/Makefile.in +++ b/Makefile.in @@ -129,53 +129,41 @@ host_triplet = @host@ @ANDROID_HOST_TRUE@ -I$(top_srcdir)/src/common/android/include \ @ANDROID_HOST_TRUE@ -I$(top_srcdir)/src/common/android/testing/include -# These are good warnings to be treated as errors -@GCC_TRUE@am__append_2 = \ -@GCC_TRUE@ -Werror \ -@GCC_TRUE@ -Werror=missing-braces \ -@GCC_TRUE@ -Werror=non-virtual-dtor \ -@GCC_TRUE@ -Werror=overloaded-virtual \ -@GCC_TRUE@ -Werror=reorder \ -@GCC_TRUE@ -Werror=sign-compare \ -@GCC_TRUE@ -Werror=unused-variable \ -@GCC_TRUE@ -Werror=vla - - # Build as PIC on Linux, for linux_client_unittest_shlib +@LINUX_HOST_TRUE@am__append_2 = -fPIC @LINUX_HOST_TRUE@am__append_3 = -fPIC -@LINUX_HOST_TRUE@am__append_4 = -fPIC bin_PROGRAMS = $(am__EXEEXT_2) $(am__EXEEXT_3) $(am__EXEEXT_4) check_PROGRAMS = $(am__EXEEXT_5) $(am__EXEEXT_6) $(am__EXEEXT_7) \ $(am__EXEEXT_8) $(am__EXEEXT_9) EXTRA_PROGRAMS = $(am__EXEEXT_1) -@DISABLE_PROCESSOR_FALSE@am__append_5 = src/libbreakpad.a -@DISABLE_PROCESSOR_FALSE@am__append_6 = breakpad.pc -@DISABLE_PROCESSOR_FALSE@am__append_7 = src/third_party/libdisasm/libdisasm.a -@LINUX_HOST_TRUE@am__append_8 = src/client/linux/libbreakpad_client.a -@LINUX_HOST_TRUE@am__append_9 = breakpad-client.pc -@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_10 = \ +@DISABLE_PROCESSOR_FALSE@am__append_4 = src/libbreakpad.a +@DISABLE_PROCESSOR_FALSE@am__append_5 = breakpad.pc +@DISABLE_PROCESSOR_FALSE@am__append_6 = src/third_party/libdisasm/libdisasm.a +@LINUX_HOST_TRUE@am__append_7 = src/client/linux/libbreakpad_client.a +@LINUX_HOST_TRUE@am__append_8 = breakpad-client.pc +@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_9 = \ @ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@ src/common/android/breakpad_getcontext.S -@DISABLE_PROCESSOR_FALSE@am__append_11 = \ +@DISABLE_PROCESSOR_FALSE@am__append_10 = \ @DISABLE_PROCESSOR_FALSE@ src/processor/microdump_stackwalk \ @DISABLE_PROCESSOR_FALSE@ src/processor/minidump_dump \ @DISABLE_PROCESSOR_FALSE@ src/processor/minidump_stackwalk +@LINUX_HOST_TRUE@am__append_11 = src/client/linux/linux_dumper_unittest_helper \ +@LINUX_HOST_TRUE@ src/client/linux/linux_client_unittest_shlib @LINUX_HOST_TRUE@am__append_12 = src/client/linux/linux_dumper_unittest_helper \ @LINUX_HOST_TRUE@ src/client/linux/linux_client_unittest_shlib -@LINUX_HOST_TRUE@am__append_13 = src/client/linux/linux_dumper_unittest_helper \ -@LINUX_HOST_TRUE@ src/client/linux/linux_client_unittest_shlib -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am__append_14 = \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am__append_13 = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/core2md/core2md \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/dump_syms/dump_syms \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/md2core/minidump-2-core \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/symupload/minidump_upload \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/symupload/sym_upload -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@@X86_HOST_TRUE@am__append_15 = \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@@X86_HOST_TRUE@am__append_14 = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@@X86_HOST_TRUE@ src/tools/mac/dump_syms/dump_syms_mac -@DISABLE_PROCESSOR_FALSE@am__append_16 = \ +@DISABLE_PROCESSOR_FALSE@am__append_15 = \ @DISABLE_PROCESSOR_FALSE@ src/common/test_assembler_unittest \ @DISABLE_PROCESSOR_FALSE@ src/processor/address_map_unittest \ @DISABLE_PROCESSOR_FALSE@ src/processor/basic_source_line_resolver_unittest \ @@ -206,36 +194,41 @@ EXTRA_PROGRAMS = $(am__EXEEXT_1) @DISABLE_PROCESSOR_FALSE@ src/processor/stackwalker_x86_unittest \ @DISABLE_PROCESSOR_FALSE@ src/processor/synth_minidump_unittest -@LINUX_HOST_TRUE@am__append_17 = \ +@LINUX_HOST_TRUE@am__append_16 = \ @LINUX_HOST_TRUE@ src/client/linux/linux_client_unittest -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am__append_18 = \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am__append_17 = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/dumper_unittest \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/md2core/minidump_2_core_unittest -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@@X86_HOST_TRUE@am__append_19 = \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@@X86_HOST_TRUE@am__append_18 = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@@X86_HOST_TRUE@ src/common/mac/macho_reader_unittest -@DISABLE_PROCESSOR_FALSE@@SELFTEST_TRUE@am__append_20 = \ +@DISABLE_PROCESSOR_FALSE@@SELFTEST_TRUE@am__append_19 = \ @DISABLE_PROCESSOR_FALSE@@SELFTEST_TRUE@ src/processor/stackwalker_selftest -@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_21 = \ +@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_20 = \ @ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@ src/common/android/breakpad_getcontext.S -@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_22 = \ +@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_21 = \ @ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@ src/common/android/breakpad_getcontext_unittest.cc -@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_23 = \ +@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_22 = \ @ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@ -llog -lm -@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_24 = \ +@ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@am__append_23 = \ @ANDROID_HOST_TRUE@@LINUX_HOST_TRUE@ -llog noinst_PROGRAMS = subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ - $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \ + $(top_srcdir)/m4/ax_append_flag.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_pthread.m4 \ + $(top_srcdir)/m4/ax_require_defined.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ @@ -1963,6 +1956,7 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -2019,8 +2013,8 @@ top_srcdir = @top_srcdir@ # This allows #includes to be relative to src/ AM_CPPFLAGS = -I$(top_srcdir)/src -AM_CFLAGS = $(am__append_3) -AM_CXXFLAGS = $(am__append_1) $(am__append_2) $(am__append_4) +AM_CFLAGS = $(am__append_2) +AM_CXXFLAGS = $(am__append_1) $(WARN_CXXFLAGS) $(am__append_3) # Specify include paths for ac macros ACLOCAL_AMFLAGS = -I m4 @@ -2054,7 +2048,7 @@ includec_HEADERS = $(top_srcdir)/src/common/*.h includepdir = $(includedir)/$(PACKAGE)/processor includep_HEADERS = $(top_srcdir)/src/processor/*.h pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = $(am__append_6) $(am__append_9) +pkgconfig_DATA = $(am__append_5) $(am__append_8) @SYSTEM_TEST_LIBS_FALSE@TEST_CFLAGS = \ @SYSTEM_TEST_LIBS_FALSE@ -I$(top_srcdir)/src/testing/include \ @SYSTEM_TEST_LIBS_FALSE@ -I$(top_srcdir)/src/testing/googletest/include \ @@ -2069,9 +2063,9 @@ pkgconfig_DATA = $(am__append_6) $(am__append_9) @SYSTEM_TEST_LIBS_FALSE@TEST_DEPS = $(TEST_LIBS) @SYSTEM_TEST_LIBS_TRUE@TEST_DEPS = check_LIBRARIES = src/testing/libtesting.a -noinst_LIBRARIES = $(am__append_7) -lib_LIBRARIES = $(am__append_5) $(am__append_8) -CLEANFILES = $(am__append_13) +noinst_LIBRARIES = $(am__append_6) +lib_LIBRARIES = $(am__append_4) $(am__append_7) +CLEANFILES = $(am__append_12) @SYSTEM_TEST_LIBS_FALSE@src_testing_libtesting_a_SOURCES = \ @SYSTEM_TEST_LIBS_FALSE@ src/breakpad_googletest_includes.h \ @SYSTEM_TEST_LIBS_FALSE@ src/testing/googletest/src/gtest-all.cc \ @@ -2115,7 +2109,7 @@ CLEANFILES = $(am__append_13) @LINUX_HOST_TRUE@ src/common/linux/linux_libc_support.cc \ @LINUX_HOST_TRUE@ src/common/linux/memory_mapped_file.cc \ @LINUX_HOST_TRUE@ src/common/linux/safe_readlink.cc \ -@LINUX_HOST_TRUE@ $(am__append_10) +@LINUX_HOST_TRUE@ $(am__append_9) @DISABLE_PROCESSOR_FALSE@src_libbreakpad_a_SOURCES = \ @DISABLE_PROCESSOR_FALSE@ src/google_breakpad/common/breakpad_types.h \ @DISABLE_PROCESSOR_FALSE@ src/google_breakpad/common/minidump_format.h \ @@ -2312,15 +2306,15 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @LINUX_HOST_TRUE@ src/processor/minidump.cc \ @LINUX_HOST_TRUE@ src/processor/pathname_stripper.cc \ @LINUX_HOST_TRUE@ src/processor/proc_maps_linux.cc \ -@LINUX_HOST_TRUE@ $(am__append_21) \ +@LINUX_HOST_TRUE@ $(am__append_20) \ @LINUX_HOST_TRUE@ src/client/linux/microdump_writer/microdump_writer_unittest.cc \ -@LINUX_HOST_TRUE@ $(am__append_22) +@LINUX_HOST_TRUE@ $(am__append_21) @LINUX_HOST_TRUE@src_client_linux_linux_client_unittest_shlib_CPPFLAGS = \ @LINUX_HOST_TRUE@ $(AM_CPPFLAGS) $(TEST_CFLAGS) @LINUX_HOST_TRUE@src_client_linux_linux_client_unittest_shlib_LDFLAGS = \ @LINUX_HOST_TRUE@ -shared -Wl,-h,linux_client_unittest_shlib \ -@LINUX_HOST_TRUE@ $(am__append_23) +@LINUX_HOST_TRUE@ $(am__append_22) @LINUX_HOST_TRUE@src_client_linux_linux_client_unittest_shlib_LDADD = \ @LINUX_HOST_TRUE@ src/client/linux/crash_generation/crash_generation_client.o \ @LINUX_HOST_TRUE@ src/client/linux/dump_writer_common/thread_info.o \ @@ -2356,7 +2350,7 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @LINUX_HOST_TRUE@src_client_linux_linux_client_unittest_LDFLAGS = \ @LINUX_HOST_TRUE@ -Wl,-rpath,'$$ORIGIN' \ @LINUX_HOST_TRUE@ -Wl,--build-id=0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f \ -@LINUX_HOST_TRUE@ $(am__append_24) +@LINUX_HOST_TRUE@ $(am__append_23) @LINUX_HOST_TRUE@src_client_linux_linux_client_unittest_LDADD = \ @LINUX_HOST_TRUE@ src/client/linux/linux_client_unittest_shlib \ @LINUX_HOST_TRUE@ $(TEST_LIBS) diff --git a/aclocal.m4 b/aclocal.m4 index 9b17609b..16992bfd 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1295,5 +1295,9 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +m4_include([m4/ax_append_compile_flags.m4]) +m4_include([m4/ax_append_flag.m4]) +m4_include([m4/ax_check_compile_flag.m4]) m4_include([m4/ax_cxx_compile_stdcxx.m4]) m4_include([m4/ax_pthread.m4]) +m4_include([m4/ax_require_defined.m4]) diff --git a/configure b/configure index 3de6e284..8d92159f 100755 --- a/configure +++ b/configure @@ -648,6 +648,7 @@ ANDROID_HOST_FALSE ANDROID_HOST_TRUE LINUX_HOST_FALSE LINUX_HOST_TRUE +WARN_CXXFLAGS HAVE_CXX11 PTHREAD_CFLAGS PTHREAD_LIBS @@ -655,8 +656,6 @@ PTHREAD_CC ax_pthread_config EGREP GREP -GCC_FALSE -GCC_TRUE RANLIB am__fastdepCXX_FALSE am__fastdepCXX_TRUE @@ -5737,14 +5736,6 @@ else RANLIB="$ac_cv_prog_RANLIB" fi - if test "$GCC" = yes; then - GCC_TRUE= - GCC_FALSE='#' -else - GCC_TRUE='#' - GCC_FALSE= -fi - # let the Makefile know if we're gcc # Check whether --enable-m32 was given. if test "${enable_m32+set}" = set; then : @@ -7254,6 +7245,136 @@ $as_echo "#define HAVE_CXX11 1" >>confdefs.h fi +WARN_CXXFLAGS= +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts -Werror=unknown-warning-option" >&5 +$as_echo_n "checking whether C++ compiler accepts -Werror=unknown-warning-option... " >&6; } +if ${ax_cv_check_cxxflags___Werror_unknown_warning_option+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -Werror=unknown-warning-option" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_check_cxxflags___Werror_unknown_warning_option=yes +else + ax_cv_check_cxxflags___Werror_unknown_warning_option=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cxxflags___Werror_unknown_warning_option" >&5 +$as_echo "$ax_cv_check_cxxflags___Werror_unknown_warning_option" >&6; } +if test "x$ax_cv_check_cxxflags___Werror_unknown_warning_option" = xyes; then : + + ax_compiler_flags_test="-Werror=unknown-warning-option" + +else + + ax_compiler_flags_test="" + +fi + + + + + +for flag in -Wmissing-braces -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-compare -Wunused-variable -Wvla ; do + as_CACHEVAR=`$as_echo "ax_cv_check_cxxflags_${ax_compiler_flags_test}_$flag" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts $flag" >&5 +$as_echo_n "checking whether C++ compiler accepts $flag... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS ${ax_compiler_flags_test} $flag" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$as_CACHEVAR=yes" +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + +if ${WARN_CXXFLAGS+:} false; then : + + case " $WARN_CXXFLAGS " in #( + *" $flag "*) : + { { $as_echo "$as_me:${as_lineno-$LINENO}: : WARN_CXXFLAGS already contains \$flag"; } >&5 + (: WARN_CXXFLAGS already contains $flag) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } ;; #( + *) : + + as_fn_append WARN_CXXFLAGS " $flag" + { { $as_echo "$as_me:${as_lineno-$LINENO}: : WARN_CXXFLAGS=\"\$WARN_CXXFLAGS\""; } >&5 + (: WARN_CXXFLAGS="$WARN_CXXFLAGS") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + ;; +esac + +else + + WARN_CXXFLAGS=$flag + { { $as_echo "$as_me:${as_lineno-$LINENO}: : WARN_CXXFLAGS=\"\$WARN_CXXFLAGS\""; } >&5 + (: WARN_CXXFLAGS="$WARN_CXXFLAGS") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + +fi + +else + : +fi + +done + +as_fn_append WARN_CXXFLAGS " -Werror" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + # Only build Linux client libs when compiling for Linux case $host in *-*-linux* | *-android* ) @@ -7780,10 +7901,6 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${GCC_TRUE}" && test -z "${GCC_FALSE}"; then - as_fn_error $? "conditional \"GCC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${LINUX_HOST_TRUE}" && test -z "${LINUX_HOST_FALSE}"; then as_fn_error $? "conditional \"LINUX_HOST\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index c2dc7b3f..8dd855d9 100644 --- a/configure.ac +++ b/configure.ac @@ -28,7 +28,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -AC_PREREQ(2.57) +AC_PREREQ(2.64) AC_INIT(breakpad, 0.1, google-breakpad-dev@googlegroups.com) dnl Sanity check: the argument is just a file that should exist. @@ -48,7 +48,6 @@ AM_PROG_CC_C_O AC_PROG_CPP AC_PROG_CXX AC_PROG_RANLIB -AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc dnl This must come before all the feature tests below. AC_ARG_ENABLE(m32, @@ -77,6 +76,29 @@ AC_CHECK_HEADERS([a.out.h]) AX_CXX_COMPILE_STDCXX(11, noext, mandatory) +dnl Test supported warning flags. +WARN_CXXFLAGS= +dnl This warning flag is used by clang. Its default behavior is to warn when +dnl given an unknown flag rather than error out. +AC_LANG_PUSH([C++]) +AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[ + ax_compiler_flags_test="-Werror=unknown-warning-option" +],[ + ax_compiler_flags_test="" +]) +AX_APPEND_COMPILE_FLAGS(m4_flatten([ + -Wmissing-braces + -Wnon-virtual-dtor + -Woverloaded-virtual + -Wreorder + -Wsign-compare + -Wunused-variable + -Wvla +]), [WARN_CXXFLAGS], [${ax_compiler_flags_test}]) +AS_VAR_APPEND([WARN_CXXFLAGS], " -Werror") +AC_LANG_POP([C++]) +AC_SUBST([WARN_CXXFLAGS]) + # Only build Linux client libs when compiling for Linux case $host in *-*-linux* | *-android* ) diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4 new file mode 100644 index 00000000..2bb27ef2 --- /dev/null +++ b/m4/ax_append_compile_flags.m4 @@ -0,0 +1,67 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# For every FLAG1, FLAG2 it is checked whether the compiler works with the +# flag. If it does, the flag is added FLAGS-VARIABLE +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. During the check the flag is always added to the +# current language's flags. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: This macro depends on the AX_APPEND_FLAG and +# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with +# AX_APPEND_LINK_FLAGS. +# +# LICENSE +# +# Copyright (c) 2011 Maarten Bosmans +# +# This program 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 3 of the License, or (at your +# option) any later version. +# +# This program 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 this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 5 + +AC_DEFUN([AX_APPEND_COMPILE_FLAGS], +[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) +AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) +for flag in $1; do + AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4]) +done +])dnl AX_APPEND_COMPILE_FLAGS diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4 new file mode 100644 index 00000000..08f2e07e --- /dev/null +++ b/m4/ax_append_flag.m4 @@ -0,0 +1,71 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) +# +# DESCRIPTION +# +# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space +# added in between. +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains +# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly +# FLAG. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program 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 3 of the License, or (at your +# option) any later version. +# +# This program 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 this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 6 + +AC_DEFUN([AX_APPEND_FLAG], +[dnl +AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF +AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) +AS_VAR_SET_IF(FLAGS,[ + AS_CASE([" AS_VAR_GET(FLAGS) "], + [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], + [ + AS_VAR_APPEND(FLAGS,[" $1"]) + AC_RUN_LOG([: FLAGS="$FLAGS"]) + ]) + ], + [ + AS_VAR_SET(FLAGS,[$1]) + AC_RUN_LOG([: FLAGS="$FLAGS"]) + ]) +AS_VAR_POPDEF([FLAGS])dnl +])dnl AX_APPEND_FLAG diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 00000000..ca363971 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -0,0 +1,74 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program 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 3 of the License, or (at your +# option) any later version. +# +# This program 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 this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 4 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4 new file mode 100644 index 00000000..cae11112 --- /dev/null +++ b/m4/ax_require_defined.m4 @@ -0,0 +1,37 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_REQUIRE_DEFINED(MACRO) +# +# DESCRIPTION +# +# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have +# been defined and thus are available for use. This avoids random issues +# where a macro isn't expanded. Instead the configure script emits a +# non-fatal: +# +# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found +# +# It's like AC_REQUIRE except it doesn't expand the required macro. +# +# Here's an example: +# +# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) +# +# LICENSE +# +# Copyright (c) 2014 Mike Frysinger +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 1 + +AC_DEFUN([AX_REQUIRE_DEFINED], [dnl + m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) +])dnl AX_REQUIRE_DEFINED