Skip to content

Commit

Permalink
configure: Verify that the compiler understands warning cflags
Browse files Browse the repository at this point in the history
Older compilers don't understand all of the flags
  • Loading branch information
ocrete committed Dec 27, 2013
1 parent 951924a commit 574b59a
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 28 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ stamp-h1

# top level stuff
debian
m4

# address/ stuff
address/libaddress.la
Expand Down
2 changes: 1 addition & 1 deletion agent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include $(top_srcdir)/common.mk

AM_CFLAGS = \
-DG_LOG_DOMAIN=\"libnice\" \
$(ERROR_CFLAGS) \
$(LIBNICE_CFLAGS) \
$(GLIB_CFLAGS) \
$(GUPNP_CFLAGS) \
-I $(top_srcdir) \
Expand Down
18 changes: 0 additions & 18 deletions common.mk
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@

ERROR_CFLAGS = \
$(LIBNICE_CFLAGS) \
-fno-strict-aliasing \
-Wextra \
-Wundef \
-Wnested-externs \
-Wwrite-strings \
-Wpointer-arith \
-Wbad-function-cast \
-Wmissing-declarations \
-Wmissing-prototypes \
-Wstrict-prototypes \
-Wredundant-decls \
-Wno-unused-parameter \
-Wno-missing-field-initializers
# -Wold-style-definition -Winline -Wunreachable-code

CLEANFILES = *.gcno *.gcda

pkgincludedir = $(includedir)/nice
Expand Down
19 changes: 19 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ dnl if asked for, add -Werror if supported
if test "x$LIBNICE_RELEASE" != "xyes"; then
LIBNICE_CFLAGS="$LIBNICE_CFLAGS -Werror"
fi

AC_DEFUN([NICE_ADD_FLAG],
AS_COMPILER_FLAG([$1], LIBNICE_CFLAGS="$LIBNICE_CFLAGS $1", [])
)

NICE_ADD_FLAG([-fno-strict-aliasing])
NICE_ADD_FLAG([-Wextra])
NICE_ADD_FLAG([-Wundef])
NICE_ADD_FLAG([-Wnested-externs])
NICE_ADD_FLAG([-Wwrite-strings])
NICE_ADD_FLAG([-Wpointer-arith])
NICE_ADD_FLAG([-Wbad-function-cast])
NICE_ADD_FLAG([-Wmissing-declarations])
NICE_ADD_FLAG([-Wmissing-prototypes])
NICE_ADD_FLAG([-Wstrict-prototypes])
NICE_ADD_FLAG([-Wredundant-decls])
NICE_ADD_FLAG([-Wno-unused-parameter])
NICE_ADD_FLAG([-Wno-missing-field-initializers])

#
# Fixes for Solaris
#
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/libnice/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ expand_content_files=
# signals and properties.
# e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
AM_CFLAGS = $(ERROR_CFLAGS) \
AM_CFLAGS = $(LIBNICE_CFLAGS) \
$(GLIB_CFLAGS) \
-I $(top_srcdir) \
-I $(top_srcdir)/random \
Expand Down
2 changes: 1 addition & 1 deletion examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AM_CFLAGS = \
-I $(top_srcdir)/random \
-I $(top_srcdir)/socket \
-I $(top_srcdir)/stun \
$(ERROR_CFLAGS) \
$(LIBNICE_CFLAGS) \
$(GLIB_CFLAGS) \
$(GUPNP_CFLAGS)

Expand Down
64 changes: 64 additions & 0 deletions m4/as-compiler-flag.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
dnl as-compiler-flag.m4 0.1.0

dnl autostars m4 macro for detection of compiler flags

dnl David Schleef <[email protected]>
dnl Tim-Philipp Müller <tim centricular net>

dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.

AC_DEFUN([AS_COMPILER_FLAG],
[
AC_MSG_CHECKING([to see if compiler understands $1])
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
CFLAGS="$save_CFLAGS"
if test "X$flag_ok" = Xyes ; then
$2
true
else
$3
true
fi
AC_MSG_RESULT([$flag_ok])
])

dnl AS_CXX_COMPILER_FLAG(CPPFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CPPFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.

AC_DEFUN([AS_CXX_COMPILER_FLAG],
[
AC_REQUIRE([AC_PROG_CXX])
AC_MSG_CHECKING([to see if c++ compiler understands $1])
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $1"
AC_LANG_PUSH(C++)
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
CPPFLAGS="$save_CPPFLAGS"
if test "X$flag_ok" = Xyes ; then
$2
true
else
$3
true
fi
AC_LANG_POP(C++)
AC_MSG_RESULT([$flag_ok])
])

2 changes: 1 addition & 1 deletion nice/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ libnice_la_LDFLAGS = \


AM_CFLAGS = \
$(ERROR_CFLAGS) \
$(LIBNICE_CFLAGS) \
$(GLIB_CFLAGS) \
-I $(top_srcdir) \
-I $(top_srcdir)/agent \
Expand Down
2 changes: 1 addition & 1 deletion random/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

include $(top_srcdir)/common.mk

AM_CFLAGS = $(ERROR_CFLAGS) $(GLIB_CFLAGS)
AM_CFLAGS = $(LIBNICE_CFLAGS) $(GLIB_CFLAGS)

noinst_LTLIBRARIES = libnice-random.la

Expand Down
2 changes: 1 addition & 1 deletion socket/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include $(top_srcdir)/common.mk

AM_CFLAGS = \
-DG_LOG_DOMAIN=\"libnice-socket\" \
$(ERROR_CFLAGS) \
$(LIBNICE_CFLAGS) \
$(GLIB_CFLAGS) \
$(GUPNP_CFLAGS) \
-I $(top_srcdir)/random \
Expand Down
2 changes: 1 addition & 1 deletion stun/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SUBDIRS = . tools tests

include $(top_srcdir)/common.mk

AM_CFLAGS = -std=gnu99 -DG_LOG_DOMAIN=\"libnice-stun\" $(ERROR_CFLAGS)
AM_CFLAGS = -std=gnu99 -DG_LOG_DOMAIN=\"libnice-stun\" $(LIBNICE_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)

if WINDOWS
Expand Down
2 changes: 1 addition & 1 deletion stun/tools/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

include $(top_srcdir)/common.mk
AM_CFLAGS = -std=gnu99 $(ERROR_CFLAGS)
AM_CFLAGS = -std=gnu99 $(LIBNICE_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)

bin_PROGRAMS = stunbdc stund
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
include $(top_srcdir)/common.mk

AM_CFLAGS = \
$(ERROR_CFLAGS) \
$(LIBNICE_CFLAGS) \
$(GLIB_CFLAGS) \
$(GUPNP_CFLAGS) \
-I $(top_srcdir) \
Expand Down

0 comments on commit 574b59a

Please sign in to comment.