Sfoglia il codice sorgente

build: better check for compiler flags; we no longer try to use

flags that autoconf hasn’t checked first.
legacy
Sam Hocevar sam 12 anni fa
parent
commit
face8cf61c
3 ha cambiato i file con 61 aggiunte e 8 eliminazioni
  1. +32
    -0
      build/autotools/m4/lol-misc.m4
  2. +21
    -5
      configure.ac
  3. +8
    -3
      src/bullet/Makefile.am

+ 32
- 0
build/autotools/m4/lol-misc.m4 Vedi File

@@ -0,0 +1,32 @@

dnl LOL_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl check if $CC supports a given set of cflags
AC_DEFUN([LOL_TRY_CFLAGS],
[AC_MSG_CHECKING([if $CC supports $1 flags])
save_CFLAGS="$CFLAGS"
CFLAGS="$1"
AC_TRY_COMPILE([],[],[ac_cv_try_cflags_ok=yes],[ac_cv_try_cflags_ok=no])
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT([$ac_cv_try_cflags_ok])
if test x"$ac_cv_try_cflags_ok" = x"yes"; then
ifelse([$2],[],[:],[$2])
else
ifelse([$3],[],[:],[$3])
fi])

dnl LOL_TRY_CXXFLAGS (CXXFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl check if $CXX supports a given set of cxxflags
AC_DEFUN([LOL_TRY_CXXFLAGS],
[AC_MSG_CHECKING([if $CXX supports $1 flags])
AC_LANG_PUSH(C++)
save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$1"
AC_TRY_COMPILE([],[],[ac_cv_try_cxxflags_ok=yes],[ac_cv_try_cxxflags_ok=no])
CXXFLAGS="$save_CXXFLAGS"
AC_MSG_RESULT([$ac_cv_try_cxxflags_ok])
if test x"$ac_cv_try_cxxflags_ok" = x"yes"; then
ifelse([$2],[],[:],[$2])
else
ifelse([$3],[],[:],[$3])
fi
AC_LANG_POP(C++)])

+ 21
- 5
configure.ac Vedi File

@@ -139,12 +139,28 @@ AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
AM_CONDITIONAL(USE_DOT, test "${DOT}" != "no")

dnl No exceptions
AM_CXXFLAGS="${AM_CXXFLAGS} -fno-exceptions -fno-rtti"
dnl Optimizations

dnl No exceptions
LOL_TRY_CXXFLAGS(-fno-exceptions, [AM_CXXFLAGS="${AM_CXXFLAGS} -fno-exceptions"])
LOL_TRY_CXXFLAGS(-fno-rtti, [AM_CXXFLAGS="${AM_CXXFLAGS} -fno-rtti"])

dnl Optimizations
AM_CXXFLAGS="${AM_CXXFLAGS} ${REL} ${OPT}"
dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
AM_CPPFLAGS="${AM_CPPFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"

dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
LOL_TRY_CXXFLAGS(-Wall, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wall"])
LOL_TRY_CXXFLAGS(-Wextra, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wextra"])
LOL_TRY_CXXFLAGS(-Wpointer-arith, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wpointer-arith"])
LOL_TRY_CXXFLAGS(-Wcast-align, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-align"])
LOL_TRY_CXXFLAGS(-Wcast-qual, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-qual"])
LOL_TRY_CXXFLAGS(-Wshadow, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wshadow"])
LOL_TRY_CXXFLAGS(-Wsign-compare, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wsign-compare"])

dnl Add these even though they're implicitly set, so that we can safely
dnl remove them from within a Makefile.
LOL_TRY_CXXFLAGS(-Wno-maybe-uninitialized, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wno-maybe-uninitialized"])
LOL_TRY_CXXFLAGS(-Wno-narrowing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wno-narrowing"])


AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")


+ 8
- 3
src/bullet/Makefile.am Vedi File

@@ -3,10 +3,15 @@ include $(top_srcdir)/build/autotools/common.am

noinst_LIBRARIES = liblolbullet.a

# Only remove flags that were actually set, because we don't know
# what the compiler actually accepts.
disable_cflags = $(filter $(AM_CPPFLAGS:-W%=-Wno-%), \
-Wno-shadow -Wno-unused -Wno-cast-qual -Wno-strict-aliasing \
-Wno-reorder -Wno-maybe-uninitialized, -Wno-narrowing \
-Wno-parentheses)

liblolbullet_a_SOURCES = $(bullet_sources)
liblolbullet_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir) \
-Wno-extra -Wno-shadow -Wno-unused -Wno-cast-qual -Wno-strict-aliasing \
-Wno-parentheses -Wno-reorder
liblolbullet_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir) $(disable_cflags)

bullet_sources =



Caricamento…
Annulla
Salva