<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39661 >

On 03/09/07, I wrote:
>
>  I have been compiling this with quite recent gcc versions only. I'm
> not sure how long that particular option has been around. Have to
> check that.

 It was not enough to check if compiler is gcc or not, as version does
matter. Attached version adds macros to check if compiler supports
certain flags, and uses that for parameter suppressing lua warnings.


 - ML

diff -Nurd -X.diff_ignore freeciv/configure.ac freeciv/configure.ac
--- freeciv/configure.ac	2007-08-26 22:11:42.000000000 +0300
+++ freeciv/configure.ac	2007-09-03 18:53:47.000000000 +0300
@@ -696,10 +696,16 @@
    fi]],[[]])
 
 if test -n "$GCC"; then
-  CFLAGS="$EXTRA_GCC_DEBUG_CFLAGS $CFLAGS"
-  CXXFLAGS="$EXTRA_GCC_DEBUG_CXXFLAGS $CXXFLAGS"
+  FC_CFLAGS="$EXTRA_GCC_DEBUG_CFLAGS $FC_CFLAGS"
+  FC_CXXFLAGS="$EXTRA_GCC_DEBUG_CXXFLAGS $FC_CXXFLAGS"
 fi
 
+dnl Add parameter to override -Werror in lua compilation, if compiler
+dnl supports it.
+dnl TODO: Remove when lua updated, or otherwise fixed
+FC_C_FLAG([-Wno-pointer-to-int-cast], [], [lualib_CFLAGS])
+AC_SUBST([lualib_CFLAGS], [$lualib_CFLAGS])
+
 dnl Rebuild 'configure' whenever version.in changes, if maintainer mode enabled.
 AC_SUBST([CONFIGURE_DEPENDENCIES], ["$CONFIGURE_DEPENDENCIES \$(top_srcdir)/version.in"])
 
@@ -711,6 +717,18 @@
 AC_DEFINE_UNQUOTED([FC_STORE_CPPFLAGS], ['$CPPFLAGS'], [These are the CPPFLAGS used in compilation])
 AC_DEFINE_UNQUOTED([FC_STORE_CFLAGS], ['$CFLAGS'], [These are the CFLAGS used in compilation])
 AC_DEFINE_UNQUOTED([FC_STORE_CXXFLAGS], ['$CXXFLAGS'], [These are the CXXFLAGS used in compilation])
+AC_DEFINE_UNQUOTED([FC_STORE_FC_CFLAGS], ['$FC_CFLAGS'], [These are the FC_CFLAGS used in compilation])
+AC_DEFINE_UNQUOTED([FC_STORE_FC_CXXFLAGS], ['$FC_CXXFLAGS'], [These are the FC_CXXFLAGS used in compilation])
+
+dnl We set AM_CFLAGS and AM_CXXFLAGS globally for all Makefiles to use.
+dnl Only lua Makefile currently adjust these (AM_CFLAGS).
+dnl We use FC_ -variants upto this point for a reason instead of modifying
+dnl AM_ -variants directly. aclocal thinks that everything starting with AM_
+dnl is meant to be m4 macro call and warns about these if not used carefully.
+dnl I'm undecided if it would be better style to just store FC_ -variants
+dnl here and set AM_ -variants to use them in every Makefile.
+AC_SUBST([AM_CFLAGS], [$FC_CFLAGS])
+AC_SUBST([AM_CXXFLAGS], [$FC_CXXFLAGS])
 
 AC_CONFIG_FILES([Makefile
           data/Makefile
diff -Nurd -X.diff_ignore freeciv/dependencies/lua/src/Makefile.am freeciv/dependencies/lua/src/Makefile.am
--- freeciv/dependencies/lua/src/Makefile.am	2007-03-05 19:13:42.000000000 +0200
+++ freeciv/dependencies/lua/src/Makefile.am	2007-09-03 18:52:33.000000000 +0300
@@ -1,6 +1,10 @@
 SUBDIRS = lib
 noinst_LIBRARIES = liblua.a
 AM_CPPFLAGS = -I$(srcdir)/../include -I.
+
+# Override possible -Werror from AM_CFLAGS
+liblua_a_CFLAGS = @lualib_CFLAGS@
+
 EXTRA_DIST= README
 liblua_a_SOURCES = \
 	../include/lauxlib.h \
@@ -45,4 +49,3 @@
 	lvm.h \
 	lzio.c \
 	lzio.h
-
diff -Nurd -X.diff_ignore freeciv/m4/compiler.m4 freeciv/m4/compiler.m4
--- freeciv/m4/compiler.m4	1970-01-01 02:00:00.000000000 +0200
+++ freeciv/m4/compiler.m4	2007-09-03 19:02:32.000000000 +0300
@@ -0,0 +1,37 @@
+# Macros to check compiler options
+#
+
+#
+# FC_C_FLAG and FC_CXX_FLAG are identical tests for C and C++ compilers
+# They test if compiler accepts given parameter in CFLAGS/CXXFLAGS and if it
+# does, will catenate parameter to variable.
+#
+# $1 - Parameter to test
+# $2 - Additional parameters
+# $3 - Variable where to add
+#
+
+AC_DEFUN([FC_C_FLAG],
+[
+  AC_LANG_PUSH([C])
+
+  cflags_save=$CFLAGS
+  CFLAGS="$CFLAGS $1 $2"
+  AC_COMPILE_IFELSE([int a;], [$3="$$3 $1"])
+  CFLAGS=$cflags_save
+
+  AC_LANG_POP([C])
+])
+
+
+AC_DEFUN([FC_CXX_FLAG],
+[
+  AC_LANG_PUSH([C++])
+
+  cxxflags_save=$CXXFLAGS
+  CXXFLAGS="$CXXFLAGS $1 $2"
+  AC_COMPILE_IFELSE([int a;], [$3="$$3 $1"])
+  CXXFLAGS=$cxxflags_save
+
+  AC_LANG_POP([C++])
+])
diff -Nurd -X.diff_ignore freeciv/configure.ac freeciv/configure.ac
--- freeciv/configure.ac	2007-08-26 22:07:41.000000000 +0300
+++ freeciv/configure.ac	2007-09-03 19:11:06.000000000 +0300
@@ -713,10 +713,16 @@
    fi]],[[]])
 
 if test -n "$GCC"; then
-  CFLAGS="$EXTRA_GCC_DEBUG_CFLAGS $CFLAGS"
-  CXXFLAGS="$EXTRA_GCC_DEBUG_CXXFLAGS $CXXFLAGS"
+  FC_CFLAGS="$EXTRA_GCC_DEBUG_CFLAGS $FC_CFLAGS"
+  FC_CXXFLAGS="$EXTRA_GCC_DEBUG_CXXFLAGS $FC_CXXFLAGS"
 fi
 
+dnl Add parameter to override -Werror in lua compilation, if compiler
+dnl supports it.
+dnl TODO: Remove when lua updated, or otherwise fixed
+FC_C_FLAG([-Wno-pointer-to-int-cast], [], [lualib_CFLAGS])
+AC_SUBST([lualib_CFLAGS], [$lualib_CFLAGS])
+
 dnl Rebuild 'configure' whenever version.in changes, if maintainer mode enabled.
 AC_SUBST([CONFIGURE_DEPENDENCIES], ["$CONFIGURE_DEPENDENCIES \$(top_srcdir)/version.in"])
 
@@ -732,6 +738,20 @@
                    [These are the CFLAGS used in compilation])
 AC_DEFINE_UNQUOTED([FC_STORE_CXXFLAGS], ['$CXXFLAGS'],
                    [These are the CXXFLAGS used in compilation])
+AC_DEFINE_UNQUOTED([FC_STORE_FC_CFLAGS], ['$FC_CFLAGS'],
+                   [These are the FC_CFLAGS used in compilation])
+AC_DEFINE_UNQUOTED([FC_STORE_FC_CXXFLAGS], ['$FC_CXXFLAGS'],
+                   [These are the FC_CXXFLAGS used in compilation])
+
+dnl We set AM_CFLAGS and AM_CXXFLAGS globally for all Makefiles to use.
+dnl Only lua Makefile currently adjust these (AM_CFLAGS).
+dnl We use FC_ -variants upto this point for a reason instead of modifying
+dnl AM_ -variants directly. aclocal thinks that everything starting with AM_
+dnl is meant to be m4 macro call and warns about these if not used carefully.
+dnl I'm undecided if it would be better style to just store FC_ -variants
+dnl here and set AM_ -variants to use them in every Makefile.
+AC_SUBST([AM_CFLAGS], [$FC_CFLAGS])
+AC_SUBST([AM_CXXFLAGS], [$FC_CXXFLAGS])
 
 AC_CONFIG_FILES([Makefile
           data/Makefile
diff -Nurd -X.diff_ignore freeciv/dependencies/lua/src/Makefile.am freeciv/dependencies/lua/src/Makefile.am
--- freeciv/dependencies/lua/src/Makefile.am	2007-08-04 18:36:08.000000000 +0300
+++ freeciv/dependencies/lua/src/Makefile.am	2007-09-03 19:10:19.000000000 +0300
@@ -1,6 +1,10 @@
 SUBDIRS = lib
 noinst_LIBRARIES = liblua.a
 AM_CPPFLAGS = -I$(srcdir)/../include -I.
+
+# Override possible -Werror from AM_CFLAGS
+liblua_a_CFLAGS = @lualib_CFLAGS@
+
 EXTRA_DIST= README
 liblua_a_SOURCES = \
 	../include/lauxlib.h \
@@ -45,4 +49,3 @@
 	lvm.h \
 	lzio.c \
 	lzio.h
-
diff -Nurd -X.diff_ignore freeciv/m4/compiler.m4 freeciv/m4/compiler.m4
--- freeciv/m4/compiler.m4	1970-01-01 02:00:00.000000000 +0200
+++ freeciv/m4/compiler.m4	2007-09-03 19:10:19.000000000 +0300
@@ -0,0 +1,37 @@
+# Macros to check compiler options
+#
+
+#
+# FC_C_FLAG and FC_CXX_FLAG are identical tests for C and C++ compilers
+# They test if compiler accepts given parameter in CFLAGS/CXXFLAGS and if it
+# does, will catenate parameter to variable.
+#
+# $1 - Parameter to test
+# $2 - Additional parameters
+# $3 - Variable where to add
+#
+
+AC_DEFUN([FC_C_FLAG],
+[
+  AC_LANG_PUSH([C])
+
+  cflags_save=$CFLAGS
+  CFLAGS="$CFLAGS $1 $2"
+  AC_COMPILE_IFELSE([int a;], [$3="$$3 $1"])
+  CFLAGS=$cflags_save
+
+  AC_LANG_POP([C])
+])
+
+
+AC_DEFUN([FC_CXX_FLAG],
+[
+  AC_LANG_PUSH([C++])
+
+  cxxflags_save=$CXXFLAGS
+  CXXFLAGS="$CXXFLAGS $1 $2"
+  AC_COMPILE_IFELSE([int a;], [$3="$$3 $1"])
+  CXXFLAGS=$cxxflags_save
+
+  AC_LANG_POP([C++])
+])
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to