summaryrefslogtreecommitdiff
path: root/Build/source/m4
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2009-06-15 15:10:25 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2009-06-15 15:10:25 +0000
commit273ed9c5b194dca51ed972db8071522d60733284 (patch)
tree5756fca71150fed35117a3b02a8648a3ec5e367f /Build/source/m4
parentca19ba96de1003493b769ea8b13d12ebc0c883ca (diff)
implement compiler warnings
git-svn-id: svn://tug.org/texlive/trunk@13751 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/m4')
-rw-r--r--Build/source/m4/kpse-common.m44
-rw-r--r--Build/source/m4/kpse-setup.m417
-rw-r--r--Build/source/m4/kpse-warnings.m4111
3 files changed, 128 insertions, 4 deletions
diff --git a/Build/source/m4/kpse-common.m4 b/Build/source/m4/kpse-common.m4
index 2a0d0d66e0f..926d6cbef7c 100644
--- a/Build/source/m4/kpse-common.m4
+++ b/Build/source/m4/kpse-common.m4
@@ -260,6 +260,9 @@ if test "$kb_cv_var_program_inv_name" = yes; then
[Define to 1 if you are using GNU libc or otherwise have global variables
`program_invocation_name' and `program_invocation_short_name'.])
fi
+dnl
+dnl Enable flags for compiler warnings
+KPSE_COMPILER_WARNINGS
]) # KPSE_COMMON
# KPSE_MSG_ERROR(PACKAGE, ERROR, [EXIT-STATUS = 1])
@@ -285,3 +288,4 @@ AC_DEFUN([_KPSE_CHECK_PKG_CONFIG],
[AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
AC_CHECK_TOOL([PKG_CONFIG], [pkg-config], [false])[]dnl
]) # _KPSE_CHECK_PKG_CONFIG
+
diff --git a/Build/source/m4/kpse-setup.m4 b/Build/source/m4/kpse-setup.m4
index 5b477196aec..9321f9a0a76 100644
--- a/Build/source/m4/kpse-setup.m4
+++ b/Build/source/m4/kpse-setup.m4
@@ -39,11 +39,19 @@ if test "x$enable_native_texlive_build" = xyes; then
[yes | no], [:],
[enable_cxx_runtime_hack=yes
ac_configure_args="$ac_configure_args '--enable-cxx-runtime-hack'"])
- AS_CASE([$enable_shared],
- [yes | no], [:],
- [enable_shared=no
- ac_configure_args="$ac_configure_args '--disable-shared'"])
fi
+AS_CASE([$enable_shared],
+ [no], [:],
+ [yes ], [AS_IF([test "x$enable_native_texlive_build" = xyes],
+ [AC_MSG_ERROR([you can not use a shared Kpathsea library for a native TeX Live build])])],
+ [enable_shared=no
+ ac_configure_args="$ac_configure_args '--disable-shared'"])
+dnl Automatically pass this option to all subdirectories.
+AS_CASE([$enable_texlive_build],
+ [yes], [:],
+ [no], [AC_MSG_ERROR([you can not configure the TeX Live tree with `--disable-texlive-build'])],
+ [enable_texlive_build=yes
+ ac_configure_args="$ac_configure_args '--enable-texlive-build'"])
KPSE_OPTIONS
KPSE_ENABLE_CXX_HACK
KPSE_LIBS_PREPARE
@@ -156,6 +164,7 @@ AC_DEFUN([KPSE_CHECK_LIB],
LIBS="$AS_TR_CPP($1)_LIBS $LIBS"
AC_CHECK_FUNCS([$2], , [syslib_status=no])
AC_CHECK_HEADERS([$3], , [syslib_status=no])
+ syslib_used=yes
fi
]) # KPSE_CHECK_LIB
diff --git a/Build/source/m4/kpse-warnings.m4 b/Build/source/m4/kpse-warnings.m4
new file mode 100644
index 00000000000..545bcb6d3af
--- /dev/null
+++ b/Build/source/m4/kpse-warnings.m4
@@ -0,0 +1,111 @@
+# Public macros for the TeX Live (TL) tree.
+# Copyright (C) 2009 Peter Breitenlohner <tex-live@tug.org>
+#
+# This file is free software; the copyright holders
+# give unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 0
+
+# KPSE_COMPILER_WARNINGS
+# ----------------------
+# Set up compiler warnings for C and C++.
+# This macro determines and substitutes WARNING_CFLAGS for the C compiler
+# and, if applicable, WARNING_CXXFLAGS for the C++ compiler. To activate
+# them a Makefile.am must use them, e.g., in AM_CFLAGS or AM_CXXFLAGS.
+AC_DEFUN([KPSE_COMPILER_WARNINGS],
+[AC_REQUIRE([_KPSE_COMPILER_WARNINGS_OPTION])[]dnl
+KPSE_WARNING_CFLAGS
+dnl arrange that AC_PROG_CXX uses _KPSE_WARNING_CXXFLAGS.
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [_KPSE_WARNING_CXXFLAGS],
+ [m4_define([AC_PROG_CXX],
+ m4_defn([AC_PROG_CXX])[_KPSE_WARNING_CXXFLAGS])])
+]) # KPSE_COMPILER_WARNINGS
+
+KPSE_WARNING_CFLAGS
+# -----------------
+# Determine and substitute WARNING_CFLAGS for C compiler.
+AC_DEFUN([KPSE_WARNING_CFLAGS],
+[AC_REQUIRE([_KPSE_COMPILER_WARNINGS_OPTION])[]dnl
+AC_REQUIRE([AC_PROG_CC])[]dnl
+AC_CACHE_CHECK([what warning flags to pass to the C compiler],
+ [kpse_cv_warning_cflags],
+ [dnl
+if test "x$enable_compiler_warnings" = xno; then
+ kpse_cv_warning_cflags=
+elif test "x$GCC" = xyes; then
+ kpse_cv_warning_cflags="-Wall -Wunused"
+ if test "x$enable_compiler_warnings" != xmin; then
+ kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wmissing-prototypes -Wmissing-declarations"
+ AS_CASE([`$CC -dumpversion`],
+ [3.4.* | 4.*],
+ [kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement"])
+ if test "x$enable_compiler_warnings" != xyes; then
+ kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wimplicit -Wparentheses -Wreturn-type"
+ kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wswitch -Wtrigraphs -Wshadow -Wpointer-arith"
+ kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings"
+ AS_CASE([`$CC -dumpversion`],
+ [3.4.* | 4.*],
+ [kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition"])
+ fi
+ fi
+else
+ : # FIXME: warning flags for non-gcc compilers
+fi])
+WARNING_CFLAGS=$kpse_cv_warning_cflags
+AC_SUBST([WARNING_CFLAGS])
+]) # KPSE_WARNING_CFLAGS
+
+# KPSE_WARNING_CXXFLAGS
+# ---------------------
+# Determine and substitute WARNING_CXXFLAGS for C++ compiler.
+AC_DEFUN([KPSE_WARNING_CXXFLAGS],
+[AC_REQUIRE([_KPSE_COMPILER_WARNINGS_OPTION])[]dnl
+AC_REQUIRE([AC_PROG_CXX])[]dnl
+_KPSE_WARNING_CXXFLAGS
+]) # KPSE_WARNING_CXXFLAGS
+
+# _KPSE_COMPILER_WARNINGS_OPTION
+# ------------------------------
+# Internal subroutine.
+# Provide configure option `--enable-compiler-warnings=[no|min|yes|max]'
+# to enable various degrees of compiler warnings.
+AC_DEFUN([_KPSE_COMPILER_WARNINGS_OPTION],
+[AC_ARG_ENABLE([compiler-warnings],
+ AS_HELP_STRING([--enable-compiler-warnings=@<:@no|min|yes|max@:>@],
+ [Turn on compiler warnings @<:@default: yes if maintainer-mode,
+ min otherwise@:>@]))[]dnl
+AS_CASE([$enable_compiler_warnings],
+ [no | min | yes | max], [],
+ [AS_IF([test "x$enable_maintainer_mode" = xyes],
+ [enable_compiler_warnings=yes],
+ [enable_compiler_warnings=min])])
+]) # _KPSE_COMPILER_WARNINGS_OPTION
+
+# _KPSE_WARNING_CXXFLAGS
+# ----------------------
+# Internal subroutine.
+# Determine and substitute WARNING_CXXFLAGS for C++ compiler.
+m4_define([_KPSE_WARNING_CXXFLAGS],
+[AC_CACHE_CHECK([what warning flags to pass to the C++ compiler],
+ [kpse_cv_warning_cxxflags],
+ [dnl
+if test "x$enable_compiler_warnings" = xno; then
+ kpse_cv_warning_cxxflags=
+elif test "x$GXX" = xyes; then
+ kpse_cv_warning_cxxflags="-Wall -Wunused"
+ if test "x$enable_compiler_warnings" != xmin; then
+ if test "x$enable_compiler_warnings" != xyes; then
+ kpse_cv_warning_cxxflags="$kpse_cv_warning_cxxflags -Wimplicit -Wparentheses -Wreturn-type"
+ kpse_cv_warning_cxxflags="$kpse_cv_warning_cxxflags -Wswitch -Wtrigraphs -Wshadow -Wpointer-arith"
+ kpse_cv_warning_cxxflags="$kpse_cv_warning_cxxflags -Wcast-qual -Wcast-align -Wwrite-strings"
+ fi
+ fi
+else
+ : # FIXME: warning flags for non-g++ compilers
+fi])
+WARNING_CXXFLAGS=$kpse_cv_warning_cxxflags
+AC_SUBST([WARNING_CXXFLAGS])
+]) # _KPSE_WARNING_CXXFLAGS
+