Skip to content

Commit

Permalink
BUILD: Apply xoreos build system changes to Phaethon
Browse files Browse the repository at this point in the history
- Bump required Boost version to 1.53.0; add Atomic and Locale
- Fix autotools out of tree builds
- Fix autotools gitstamp .dirty flag
- Add automake foreign option
- Check for C/C++ warning flag support before using them
- Add --with-lto
- Add --with-release
  • Loading branch information
DrMcCoy committed Aug 7, 2015
1 parent 3d58943 commit 3302b88
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 28 deletions.
9 changes: 7 additions & 2 deletions BUILDDEP
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ Build-time library dependencies
- zlib (>= 1.2.3.4)
- liblzma (>= 5.0.5)

- Boost (>= 1.48.0)
- Boost (>= 1.53.0)
- Boost.StringAlgo
- Boost.System
- Boost.Filesystem
- Boost.StringAlgo
- Boost.Regex
- Boost.Unordered
- Boost.Hash
- Boost.Date_Time
- Boost.Chrono
- Boost.Function
- Boost.Bind
- Boost.Uuid
- Boost.Smart_Ptr
- Boost.Atomic
- Boost.Locale
- Boost.Thread

- wxWidgets (>= 3.0.0)
Expand Down
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ EXTRA_DIST = \
BUILDDEP \
Doxyfile \
README.dox \
README.md \
$(EMPTY)

dist_doc_DATA = \
Expand Down
11 changes: 3 additions & 8 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,18 @@ LIBSF_CXX = $(WX_CXXFLAGS) \
LIBSL_BOOST = $(BOOST_SYSTEM_LDFLAGS) $(BOOST_SYSTEM_LIBS) \
$(BOOST_FILESYSTEM_LDFLAGS) $(BOOST_FILESYSTEM_LIBS) \
$(BOOST_REGEX_LDFLAGS) $(BOOST_REGEX_LIBS) \
$(BOOST_UNORDERED_LDFLAGS) $(BOOST_UNORDERED_LIBS) \
$(BOOST_HASH_LDFLAGS) $(BOOST_HASH_LIBS) \
$(BOOST_DATE_TIME_LDFLAGS) $(BOOST_DATE_TIME_LIBS) \
$(BOOST_CHRONO_LDFLAGS) $(BOOST_CHRONO_LIBS) \
$(BOOST_ATOMIC_LDFLAGS) $(BOOST_ATOMIC_LIBS) \
$(BOOST_LOCALE_LDFLAGS) $(BOOST_LOCALE_LIBS) \
$(BOOST_THREAD_LDFLAGS) $(BOOST_THREAD_LIBS)
LIBSL = $(PHAETHON_LIBS) $(LTLIBICONV) $(ZLIB_LIBS) $(LZMA_LIBS) \
$(WX_LIBS) \
$(AL_LIBS) $(MAD_LIBS) $(OGG_LIBS) $(VORBIS_LIBS) \
$(LIBSL_BOOST)

FLAGS_C_CXX = -I$(top_srcdir) -ggdb -Wall -Wno-multichar \
-Wignored-qualifiers \
-Wpointer-arith -Wshadow -Wsign-compare -Wtype-limits \
-Wuninitialized -Wunused-parameter $(WERROR)
FLAGS_C_CXX = -I$(top_srcdir) -ggdb $(LTO) $(WARN_C_CXX) $(WERROR)
FLAGS_C =
FLAGS_CXX = -Wnon-virtual-dtor -Wno-overloaded-virtual
FLAGS_CXX = $(WARN_CXX)

AM_CFLAGS = $(FLAGS_C_CXX) $(FLAGS_C) $(LIBSF_C_CXX) $(LIBSF_C)
AM_CXXFLAGS = $(FLAGS_C_CXX) $(FLAGS_CXX) $(LIBSF_C_CXX) $(LIBSF_CXX)
Expand Down
Empty file removed NEWS
Empty file.
1 change: 0 additions & 1 deletion README

This file was deleted.

66 changes: 61 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ AC_CONFIG_AUX_DIR([build-aux])

AC_CANONICAL_TARGET

AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability no-dist-gzip dist-xz subdir-objects])
AM_INIT_AUTOMAKE([1.11 foreign -Wall -Wno-portability no-dist-gzip dist-xz subdir-objects])
# Support silent build rules. Disable
# by either passing --disable-silent-rules to configure or passing V=1
# to make
Expand Down Expand Up @@ -38,6 +38,52 @@ dnl Standard C, C++
AC_C_CONST
AC_HEADER_STDC

dnl Compiler warning flags
AC_ARG_WITH([warnings], [AS_HELP_STRING([--without-warnings], [Compile without extra warnings @<:@default=no@:>@])], [], [with_warnings=yes])

if test "x$with_warnings" = "xno"; then
WARN_C_CXX=""
WARN_CXX=""
else
WARN_C_CXX="-Wall"
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wignored-qualifiers])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wpointer-arith])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wshadow])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wsign-compare])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wtype-limits])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wuninitialized])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wunused-parameter])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wunused-but-set-parameter])

WARN_CXX=""
AX_CHECK_COMPILER_FLAGS_VAR([C++], [WARN_CXX], [-Wnon-virtual-dtor])
AX_CHECK_COMPILER_FLAGS_VAR([C++], [WARN_CXX], [-Wno-overloaded-virtual])
fi

AC_SUBST(WARN_C_CXX)
AC_SUBST(WARN_CXX)

dnl Link-time optimization
AC_ARG_WITH([lto], [AS_HELP_STRING([--with-lto], [Compile with link-time optimization @<:@default=no@:>@])], [], [with_lto=no])

LTO=""
if test "x$with_lto" = "xyes"; then
AX_CHECK_COMPILER_FLAGS_VAR([C], [LTO], [-flto])
fi

AC_SUBST(LTO)

dnl Release version number
AC_ARG_WITH([release], [AS_HELP_STRING([--with-release=VER], [Set the version suffix to VER instead of the git revision. If no VER is given, do not add a version suffix at all])], [], [with_release=no])

if test "x$with_release" != "xno"; then
AC_DEFINE([PHAETHON_RELEASE], 1, [Define to 1 if we are in release version mode])

if test "x$with_release" != "xyes"; then
AC_DEFINE_UNQUOTED([PHAETHON_DISTRO], ["+$with_release"], [Release version suffix])
fi
fi

dnl Endianness
AC_C_BIGENDIAN()

Expand All @@ -54,6 +100,11 @@ AC_CHECK_FUNCS([fabsf])
AC_CHECK_FUNCS([fminf])
AC_CHECK_FUNCS([fmaxf])

dnl String to integer/float conversion functions
AC_CHECK_FUNCS([strtoll])
AC_CHECK_FUNCS([strtoull])
AC_CHECK_FUNCS([strtof])

dnl General purpose libraries
AX_CHECK_ICONV( , AC_MSG_ERROR([No useable iconv() function found!]))
AX_CHECK_ZLIB(1, 2, 3, 4, , AC_MSG_ERROR([zlib(>= 1.2.3.4) is required and could not be found!]))
Expand All @@ -69,16 +120,21 @@ AX_CHECK_OGG(, AC_MSG_ERROR([libOgg (>= 1.2.0) is required and could not be foun
AX_CHECK_VORBIS(, AC_MSG_ERROR([libVorbisFile (>= 1.3.1) is required and could not be found!]))

dnl Boost
BOOST_REQUIRE(1.48.0)
BOOST_REQUIRE(1.53.0)
BOOST_STRING_ALGO
BOOST_SYSTEM
BOOST_FILESYSTEM
BOOST_STRING_ALGO
BOOST_REGEX
BOOST_UNORDERED
BOOST_HASH
BOOST_DATE_TIME
BOOST_CHRONO
BOOST_FUNCTION
BOOST_BIND
BOOST_UUID
BOOST_SMART_PTR
BOOST_ATOMIC
BOOST_LOCALE
BOOST_THREAD

dnl Extra flags
Expand All @@ -88,8 +144,8 @@ case "$target" in
PHAETHON_LIBS=""
;;
*mingw*)
PHAETHON_CFLAGS=""
PHAETHON_LIBS="-static-libgcc -static-libstdc++"
PHAETHON_CFLAGS="-mconsole"
PHAETHON_LIBS=""
;;
*)
PHAETHON_CFLAGS="-DUNIX"
Expand Down
2 changes: 1 addition & 1 deletion gitstamp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LIBS =
.PHONY: gitstamp
gitstamp:
@-$(eval $@_REVLINE := $(shell git describe --long --match desc/\* | cut -d '/' -f 2- | sed -e 's/\(.*\)-\([^-]*\)-\([^-]*\)/\1+\2.\3/'))
@-$(eval $@_REVDIRT := $(shell update-index --refresh --unmerged 1>/dev/null 2>&1; git diff-index --quiet HEAD || echo ".dirty"))
@-$(eval $@_REVDIRT := $(shell git update-index --refresh --unmerged 1>/dev/null 2>&1; git diff-index --quiet HEAD || echo ".dirty"))
@-$(eval $@_REVDESC := $(shell if test x$($@_REVLINE) != "x"; then echo $($@_REVLINE)$($@_REVDIRT); fi ))
@[ -f $@ ] || touch $@
$(AM_V_GEN)echo $($@_REVDESC) | cmp -s $@ - || echo $($@_REVDESC) > $@
Expand Down
46 changes: 46 additions & 0 deletions m4/ax_check_compiler_flags.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#serial 1000
dnl @synopsis AX_CHECK_COMPILER_FLAGS(FLAGS, EXTRAFLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
dnl
dnl @summary check whether FLAGS are accepted by the compiler
dnl
dnl Check whether the given compiler FLAGS work with the current
dnl language's compiler, or whether they give an error. (Warnings,
dnl however, are ignored.)
dnl
dnl EXTRAFLAGS will be added for the check, and can be used to, for
dnl example, for warnings to produce an error.
dnl
dnl ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
dnl success/failure.
dnl
dnl @category Misc
dnl @author Steven G. Johnson <[email protected]> and Matteo Frigo.
dnl @version 2005-05-30
dnl @license GPLWithACException

AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
AS_LITERAL_IF([$1],
[AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$1 $2"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
[ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$1 $2"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)
AC_MSG_RESULT($ax_check_compiler_flags)
if test "x$ax_check_compiler_flags" = xyes; then
m4_default([$3], :)
else
m4_default([$4], :)
fi
])dnl AX_CHECK_COMPILER_FLAGS
20 changes: 20 additions & 0 deletions m4/ax_check_compiler_flags_var.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#serial 1000
dnl @synopsis AX_CHECK_COMPILER_FLAGS_VAR(language, variable, flag)
dnl
dnl @summary Check whether the compiler for this language accepts this flag, and
dnl add it to the variable if it does
dnl
dnl Depends on the AX_CHECK_COMPILER_FLAGS macro.
dnl
dnl @category Misc
dnl @author Sven Hesse <[email protected]>
dnl @version 2015-07-12
dnl @license Creative Commons CC0 1.0 Universal Public Domain Dedication

AC_DEFUN([AX_CHECK_COMPILER_FLAGS_VAR], [
AC_LANG_PUSH([$1])
AX_CHECK_COMPILER_FLAGS([$3], [-Werror], AS_VAR_APPEND([$2], [" $3"]))
AC_LANG_POP([$1])
])
5 changes: 1 addition & 4 deletions m4/ax_check_zlib.m4
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ AC_DEFUN([AX_CHECK_ZLIB], [
#include <zlib.h>
int main(int argc, char **argv) {
#if (ZLIB_VER_MAJOR < $1) || \
((ZLIB_VER_MAJOR == $1) && (ZLIB_VER_MINOR < $2)) || \
((ZLIB_VER_MAJOR == $1) && (ZLIB_VER_MINOR == $2) && (ZLIB_VER_REVISION < $3)) || \
((ZLIB_VER_MAJOR == $1) && (ZLIB_VER_MINOR == $2) && (ZLIB_VER_REVISION == $3) && (ZLIB_VER_SUBREVISION < $4))
#if ZLIB_VERNUM < (($1 * 4096) + ($2 * 256) + ($3 * 16) + $4)
#error zlib version too low
#endif
Expand Down
23 changes: 20 additions & 3 deletions m4/boost.m4
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,25 @@ BOOST_DEFUN([Lambda],
# --------------
# Look for Boost.Locale
BOOST_DEFUN([Locale],
[BOOST_FIND_LIB([locale], [$1],
[boost/locale.hpp],
[[boost::locale::generator gen; std::locale::global(gen(""));]])
[# Do we have to check for Boost.System? This link-time dependency was
# added as of 1.35.0. If we have a version <1.35, we must not attempt to
# find Boost.System as it didn't exist by then.
if test $boost_major_version -ge 135; then
BOOST_SYSTEM([$1])
fi # end of the Boost.System check.
boost_locale_save_LIBS=$LIBS
boost_locale_save_LDFLAGS=$LDFLAGS
m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
LIBS="$LIBS $BOOST_SYSTEM_LIBS"
LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
BOOST_FIND_LIB([locale], [$1],
[boost/locale.hpp],
[[boost::locale::generator gen; std::locale::global(gen(""));]])
if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
BOOST_LOCALE_LIBS="$BOOST_LOCALE_LIBS $BOOST_SYSTEM_LIBS"
fi
LIBS=$boost_locale_save_LIBS
LDFLAGS=$boost_locale_save_LDFLAGS
])# BOOST_LOCALE

# BOOST_LOG([PREFERRED-RT-OPT])
Expand Down Expand Up @@ -1308,6 +1324,7 @@ if test x$boost_cv_inc_path != xno; then
# I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
# the same defines as GCC's).
for i in \
_BOOST_gcc_test(5, 2) \
_BOOST_gcc_test(5, 1) \
_BOOST_gcc_test(5, 0) \
_BOOST_gcc_test(4, 10) \
Expand Down
6 changes: 3 additions & 3 deletions src/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ include $(top_srcdir)/Makefile.common

# Pass the git version information to the compiler

VER_REVDESC = $(shell cat $(top_srcdir)/gitstamp/gitstamp)
VER_REVDESC = $(shell cat $(top_builddir)/gitstamp/gitstamp)
VERSION_FLAGS = $(shell if test x$(VER_REVDESC) != "x"; then echo "-DPHAETHON_REVDESC=\\\"$(VER_REVDESC)\\\""; fi)

VER_REV = $(shell cat $(top_srcdir)/gitstamp/gitstamp | cut -d '+' -f 2-)
VER_REV = $(shell cat $(top_builddir)/gitstamp/gitstamp | cut -d '+' -f 2-)
VERSION_FLAGS += $(shell if test x$(VER_REV) != "x"; then echo "-DPHAETHON_REV=\\\"$(VER_REV)\\\""; fi)

VER_DATE = $(shell date -u '+%Y-%m-%dT%H:%M:%S')
Expand All @@ -15,7 +15,7 @@ AM_CXXFLAGS += $(VERSION_FLAGS)
AM_CFLAGS += $(VERSION_FLAGS)

# Rebuild the version.lo when the git version changed
version.lo: $(top_srcdir)/gitstamp/gitstamp
version.lo: $(top_builddir)/gitstamp/gitstamp

SUBDIRS = \
$(EMPTY)
Expand Down

0 comments on commit 3302b88

Please sign in to comment.