Update autotools build system

Make genmodules create a simpler Makefile.am:
Instead of generating separate rules for modules and implementations, just create rules for modules and lua libraries
Disable selection of non-lua libraries, they will now be built when needed.
Also disable selection of implementations, because that was useless anyway.

Note: inter-module dependencies aren't dealt with (yet).

--HG--
branch : minor
This commit is contained in:
Bart van Strien
2017-03-12 10:47:19 +01:00
parent cc4dea07b5
commit 4ccbe6dfec
2 changed files with 89 additions and 67 deletions
+33 -7
View File
@@ -52,35 +52,61 @@ AC_ARG_WITH([luaversion], [AS_HELP_STRING([--with-luaversion], [Select the lua v
with_clean_luaversion=`printf ${with_luaversion} | sed 's/\.//g'`
# Generated sources for enabling/disabling modules
m4_include([configure-modules.ac])
m4_include([configure-modules-pre.ac])
# Other features that can be enabled/disabled
AC_ARG_ENABLE([mpg123], AC_HELP_STRING([--disable-mpg123], [Disable mp3 support, for patent-free builds]), [], [enable_mpg123=yes])
AC_ARG_ENABLE([gme], AC_HELP_STRING([--enable-gme], [Enable GME support, for more chiptuney goodness]), [], [enable_gme=no])
# Dependencies we always use
ACLOVE_DEP_LUA
ACLOVE_DEP_SDL2
ACLOVE_DEP_LIBM
ACLOVE_DEP_ZLIB
AS_VAR_IF([enable_audio_openal], [true], [ACLOVE_DEP_OPENAL], [])
AS_VAR_IF([enable_filesystem_physfs], [true], [ACLOVE_DEP_PHYSFS], [])
AS_VAR_IF([enable_font_freetype], [true], [ACLOVE_DEP_FREETYPE2], [])
AS_VAR_IF([enable_sound_lullaby], [true], [
# Conditional dependencies
AS_VAR_IF([enable_module_audio], [yes], [ACLOVE_DEP_OPENAL], [])
AS_VAR_IF([enable_module_filesystem], [yes], [ACLOVE_DEP_PHYSFS], [])
AS_VAR_IF([enable_module_font], [yes], [ACLOVE_DEP_FREETYPE2], [])
AS_VAR_IF([enable_module_sound], [yes], [
ACLOVE_DEP_LIBMODPLUG
ACLOVE_DEP_VORBISFILE
], [enable_mpg123=no])
AS_VAR_IF([enable_video_theora], [true], [ACLOVE_DEP_THEORA], [])
AS_VAR_IF([enable_module_video], [yes], [ACLOVE_DEP_THEORA], [])
AS_VAR_IF([enable_gme], [yes], [ACLOVE_DEP_GME], [])
AS_VAR_IF([enable_mpg123], [no],
AC_DEFINE([LOVE_NOMPG123], [], [Build without mpg123]),
[ACLOVE_DEP_MPG123])
# GME, treated seperately because it can be enabled (default off)
# Add flags for optional libraries
AC_ARG_ENABLE([library-enet], [ --disable-library-enet Turn off library enet], [], [enable_library_enet=yes])
AC_ARG_ENABLE([library-luasocket], [ --disable-library-luasocket Turn off library luasocket], [], [enable_library_luasocket=yes])
AC_ARG_ENABLE([library-luautf8], [ --disable-library-luautf8 Turn off library luautf8], [], [enable_library_luautf8=yes])
# Select the libraries we need to build, based on the selected modules
AS_VAR_IF([enable_module_physics], [yes], [enable_library_Box2D=yes], [enable_library_Box2D=no])
AS_VAR_IF([enable_module_image], [yes], [enable_library_ddsparse=yes], [enable_library_ddsparse=no])
AS_VAR_IF([enable_module_graphics], [yes], [enable_library_glad=yes], [enable_library_glad=no])
AS_VAR_IF([enable_module_graphics], [yes], [enable_library_glslang=yes], [enable_library_glslang=no])
AS_VAR_IF([enable_module_image], [yes], [enable_library_lodepng=yes], [enable_library_lodepng=no])
AS_VAR_IF([enable_module_math], [yes], [enable_library_lz4=yes], [enable_library_lz4=no])
AS_VAR_IF([enable_module_math], [yes], [enable_library_noise1234=yes], [enable_library_noise1234=no])
AS_VAR_IF([enable_module_image], [yes], [enable_library_stb=yes], [enable_library_stb=no])
AS_VAR_IF([enable_module_image], [yes], [enable_library_tinyexr=yes], [enable_library_tinyexr=no])
AS_VAR_IF([enable_module_sound], [yes], [enable_library_Wuff=yes], [enable_library_Wuff=no])
AS_VAR_IF([enable_module_graphics], [yes], [enable_library_xxHash=yes], [enable_library_xxHash=no])
# Utf8 is required by both graphics and font, so enable if either is enabled
enable_library_utf8=no
AS_VAR_IF([enable_module_graphics], [yes], [enable_library_utf8=yes], [])
AS_VAR_IF([enable_module_font], [yes], [enable_library_utf8=yes], [])
# libenet check for socklen_t
ACLOVE_SOCKLEN_T
# Generated sources for enabling/disabling modules
m4_include([configure-modules-post.ac])
# Optionally build the executable (default on)
AC_ARG_ENABLE([exe],
AC_HELP_STRING([--disable-exe], [Disable building of executable launcher]), [], [enable_exe=yes])
+56 -60
View File
@@ -3,20 +3,15 @@
love_suffix="$1"
love_amsuffix="$(echo "$love_suffix" | sed 's/\-/_/g' | sed 's/\./_/g')"
flags=""
flags=()
upper()
{
echo "$@" | tr '[:lower:]' '[:upper:]'
}
implfind()
{
find "$1" -maxdepth 1 -type d -exec basename '{}' \; | grep -v "^\." | tail -n +2
}
sourcefind()
{
find "$1" $2 -type f \( -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.lch" -o -iname "*.lua" \) | awk "{print \"./$prefix\"\$0\" \\\\\"}" | grep -v -f"$LOVEROOT/platform/unix/exclude"
find "$1" $2 -type f \( -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.lch" -o -iname "*.lua" \) | awk "{print \"./$prefix\"\$0\" \\\\\"}" | grep -v -f"$LOVEROOT/platform/unix/exclude" | sort
}
handlemodule()
@@ -26,21 +21,6 @@ handlemodule()
printf "$DEFINENAME"
}
handleimpl()
{
module="$1"
implementation="$2"
name="$3"
printf "if $name\n"
FILES="$(sourcefind "$module/$implementation" | sed "s/^/ /")"
if [[ "x$FILES" != "x" ]]; then
printf "liblove${love_amsuffix}_la_SOURCES += \\\\\n"
printf "${FILES:0:${#FILES}-2}\n"
fi
printf "endif\n\n"
}
genmodules()
{
LOVEROOT="$(pwd)"
@@ -51,57 +31,80 @@ genmodules()
FILES="$(sourcefind "scripts" | sed "s/^/ /")"
printf "${FILES:0:${#FILES}-2}\n\n"
local -a modulelist=()
local -a liblist=()
cd modules
prefix="modules/"
for module in *; do
NAME=$(handlemodule "$module")
flags="$flags module-$module"
flags+=("module-$module")
printf "if $NAME\n"
for implementation in $(implfind "$module"); do
flags="$flags implementation-$module-$implementation"
handleimpl "$module" "$implementation" "LOVE_IMPLEMENTATION_$(upper "$module")_$(upper "$implementation")"
done
FILES="$(sourcefind "$module" "-maxdepth 1" | sed "s/^/ /")"
FILES="$(sourcefind "$module" | sed "s/^/ /")"
if [[ "x$FILES" != "x" ]]; then
printf "liblove${love_amsuffix}_la_SOURCES += \\\\\n"
printf "${FILES:0:${#FILES}-2}\n"
printf "liblove_module_$module = \\\\\n"
printf "${FILES:0:${#FILES}-2}\n\n"
modulelist+=("$module")
fi
printf "endif\n\n"
if [[ "$module" = "sound" ]]; then
printf "if !LOVE_NOMPG123\n"
printf "liblove_module_$module += \\\\\n"
printf "\t./modules/sound/lullaby/Mpg123Decoder.cpp \\\\\n"
printf "\t./modules/sound/lullaby/Mpg123Decoder.h\n"
printf "endif\n\n"
fi
done
cd ../libraries
prefix="libraries/"
for library in *; do
NAME="LOVE_LIBRARY_$(upper "$library")"
flags="$flags library-$library"
flags+=("library-$library")
FILES="$(sourcefind "$library" | sed "s/^/ /")"
if [[ ${#FILES} -gt 2 ]]; then
printf "if $NAME\n"
printf "liblove${love_amsuffix}_la_SOURCES += \\\\\n"
printf "${FILES:0:${#FILES}-2}\nendif\n\n"
printf "liblove_library_$library = \\\\\n"
printf "${FILES:0:${#FILES}-2}\n\n"
liblist+=("$library")
fi
done
for module in "${modulelist[@]}"; do
NAME=$(handlemodule "$module")
printf "if $NAME\n"
printf "liblove${love_amsuffix}_la_SOURCES += \$(liblove_module_$module)\n"
printf "endif\n\n"
done
for library in "${liblist[@]}"; do
NAME="LOVE_LIBRARY_$(upper "$library")"
printf "if $NAME\n"
printf "liblove${love_amsuffix}_la_SOURCES += \$(liblove_library_$library)\n"
printf "endif\n\n"
done
cd ../..
}
genflags()
{
for flag in $flags; do
prettyflag="$(echo "$flag" | sed 's/-/ love./' | sed 's/-/./g')"
varflag="enable_$(echo "$flag" | sed 's/^[^-]*-//' | sed 's/[^a-zA-Z0-9]/_/')"
defineflag="LOVE_ENABLE_$(upper $(echo $flag | sed 's/^[^-]*-//' | sed 's/-/_/g'))"
printf > configure-modules-pre.ac
printf > configure-modules-post.ac
for flag in "${flags[@]}"; do
prettyflag="$(echo "$flag" | sed -e 's/-/ love./' -e 's/-/./g')"
varflag="enable_$(echo "$flag" | sed -e 's/[^a-zA-Z0-9]/_/')"
defineflag="LOVE_ENABLE_$(upper $(echo $flag | sed -e 's/^[^-]*-//' -e 's/-/_/g'))"
amflag="$(upper $(echo love-$flag | sed 's/-/_/g'))"
printf "AC_ARG_ENABLE([$flag], [ --disable-$flag Turn off $prettyflag], [], [$varflag=true])\n"
printf "AH_TEMPLATE([$defineflag], [])\n"
printf "if test x\"\$$varflag\" = xtrue; then\n"
printf " AC_DEFINE([$defineflag], [])\n"
printf "fi\n"
printf "AM_CONDITIONAL([$amflag], [test x\$$varflag = xtrue])\n\n"
# Don't generate an --enable rule for libraries
if [[ "$(echo $flag | sed -e '/^library-/d')" != "" ]]; then
printf "AC_ARG_ENABLE([$flag], [ --disable-$flag Turn off $prettyflag], [], [$varflag=yes])\n" >> configure-modules-pre.ac
fi
printf "AH_TEMPLATE([$defineflag], [])\n" >> configure-modules-post.ac
printf "if test x\"\$$varflag\" = xyes; then\n" >> configure-modules-post.ac
printf " AC_DEFINE([$defineflag], [])\n" >> configure-modules-post.ac
printf "fi\n" >> configure-modules-post.ac
printf "AM_CONDITIONAL([$amflag], [test x\$$varflag = xyes])\n\n" >> configure-modules-post.ac
done
}
@@ -147,23 +150,16 @@ liblove${love_amsuffix}_la_LIBADD = \
\$(SDL_LIBS) \$(freetype2_LIBS) \$(lua_LIBS)\
\$(openal_LIBS) \$(zlib_LIBS) \$(libmodplug_LIBS)\
\$(vorbisfile_LIBS) \$(theora_LIBS)
EOF
genmodules >> src/Makefile.am
cat >> src/Makefile.am << EOF
if !LOVE_NOMPG123
liblove${love_amsuffix}_la_SOURCES += \\
./modules/sound/lullaby/Mpg123Decoder.cpp \\
./modules/sound/lullaby/Mpg123Decoder.h
endif
EOF
echo "src/Makefile.am is updated! ^.^"
echo "Generating configure-modules.ac"
genflags > configure-modules.ac
cat >> configure-modules.ac << EOF
genflags
cat >> configure-modules-post.ac << EOF
AC_SUBST([LOVE_SUFFIX], [${love_suffix}])
EOF
echo "configure-modules.ac is updated! ^.^"