Project

General

Profile

Feature #932 ยป 0035-Autotools-Drop-emscripten-support.patch

Marko Lindqvist, 10/05/2024 01:28 PM

View differences:

Makefile.am
m4/codeset.m4 \
m4/compiler.m4 \
m4/debug.m4 \
m4/emscripten.m4 \
m4/expanddir.m4 \
m4/fc-sdl2.m4 \
m4/fcdb-mysql.m4 \
configure.ac
m4_ifdef([AC_SYS_YEAR2038],
[AC_SYS_YEAR2038])
FC_EMSCRIPTEN
BUG_URL="$PACKAGE_BUGREPORT"
MAIL_ADDRESS="freeciv-dev AT freelists.org"
......
AS_HELP_STRING([--enable-fcdb[=no/all/mysql/odbc/postgres/sqlite3]],
[database backends [sqlite3](no, or list)]),
[databases=${enableval}],
[if test "x$emscripten" != "xyes" ; then
databases=sqlite3
else
databases=no
fi])
if test "x$emscripten" = "xyes" && test "x$databases" != "xno" ; then
AC_MSG_ERROR([fcdb not supported with emscripten])
fi
[databases=sqlite3])
for db in $(echo $databases | $SED 's/,/ /g') ; do
if test "x$db" = "xall" ; then
......
AC_ARG_ENABLE([fcmp],
AS_HELP_STRING([--enable-fcmp=no/yes/gtk3/gtk4/gtk4x/qt/cli/all/auto], [build freeciv-modpack-program [auto]]),
[fc_mp=${enableval}],
[if test "x$emscripten" = "xyes" ; then
fc_mp=no
else
fc_mp=auto
fi])
[fc_mp=auto])
fcmp_cli=no
fcmp_gtk3=no
......
fcmp_qt=no
fcmp_list=
if test "x$fc_mp" != "xno" && test "x$emscripten" = "xyes" ; then
AC_MSG_ERROR([fcmp not supported with emscripten])
fi
if test "x$fc_mp" = "xcli" ; then
dnl Only cli requested -> no gui needed
modinst=cli
......
AC_MSG_ERROR([pkg-config not found])
fi
if test "x$emscripten" != "xyes" ; then
PKG_CHECK_MODULES([CURL_MIME_API], [libcurl > 7.56.0],
[UTILITY_CFLAGS="${UTILITY_CFLAGS} ${CURL_MIME_API_CFLAGS}"
UTILITY_LIBS="${UTILITY_LIBS} ${CURL_MIME_API_LIBS}"
AC_DEFINE([HAVE_CURL_MIME_API], [1], [libcurl has the mime api])],
[PKG_CHECK_MODULES([CURL], [libcurl >= 7.15.4],
[UTILITY_CFLAGS="${UTILITY_CFLAGS} ${CURL_CFLAGS}"
UTILITY_LIBS="${UTILITY_LIBS} ${CURL_LIBS}"],
[AC_MSG_ERROR([libcurl development files required])])])
fi
PKG_CHECK_MODULES([CURL_MIME_API], [libcurl > 7.56.0],
[UTILITY_CFLAGS="${UTILITY_CFLAGS} ${CURL_MIME_API_CFLAGS}"
UTILITY_LIBS="${UTILITY_LIBS} ${CURL_MIME_API_LIBS}"
AC_DEFINE([HAVE_CURL_MIME_API], [1], [libcurl has the mime api])],
[PKG_CHECK_MODULES([CURL], [libcurl >= 7.15.4],
[UTILITY_CFLAGS="${UTILITY_CFLAGS} ${CURL_CFLAGS}"
UTILITY_LIBS="${UTILITY_LIBS} ${CURL_LIBS}"],
[AC_MSG_ERROR([libcurl development files required])])])
AC_ARG_ENABLE([xml-registry],
AS_HELP_STRING([--enable-xml-registry], [build xml-backend for registry (WIP)]),
......
AC_DEFINE([FREECIV_HAVE_XML_REGISTRY], [1], [Build xml-backend for registry])
fi
if test "x$emscripten" != "xyes" ; then
PKG_CHECK_MODULES([ICU], [icu-uc],,
[AC_MSG_ERROR([icu development files not found. Adjusting PKG_CONFIG_PATH may help])])
UTILITY_CFLAGS="${UTILITY_CFLAGS} ${ICU_CFLAGS}"
UTILITY_LIBS="${UTILITY_LIBS} ${ICU_LIBS}"
else
CFLAGS="$CFLAGS -s USE_ICU=1"
CXXFLAGS="$CXXFLAGS -s USE_ICU=1"
fi
PKG_CHECK_MODULES([ICU], [icu-uc],,
[AC_MSG_ERROR([icu development files not found. Adjusting PKG_CONFIG_PATH may help])])
UTILITY_CFLAGS="${UTILITY_CFLAGS} ${ICU_CFLAGS}"
UTILITY_LIBS="${UTILITY_LIBS} ${ICU_LIBS}"
dnl Should we build Qt5 versions of Qt programs?
dnl This needs to be before C++ compiler check FC_WORKING_CXX, and
......
HOST_PATH_SEPARATOR=":"
HOST_DIR_SEPARATOR="/"
if test "x$emscripten" = "xyes" ; then
AC_DEFINE([ALWAYS_ROOT], [1], [Can execute program as root - emscripten])
fi
dnl Settings specific to host OS
case "$host_os" in
......
COMMON_LIBS="${COMMON_LIBS} -lm"
if test "x$emscripten" != "xyes" ; then
dnl Check for zlib
AC_CHECK_LIB([z], [gzgets],
[AC_DEFINE([FREECIV_HAVE_LIBZ], [1], [zlib is available])
UTILITY_LIBS="${UTILITY_LIBS} -lz"
COMMON_LIBS="$COMMON_LIBS -lz"],
AC_MSG_ERROR([Could not find zlib library.]))
dnl Check for zlib
AC_CHECK_LIB([z], [gzgets],
[AC_DEFINE([FREECIV_HAVE_LIBZ], [1], [zlib is available])
UTILITY_LIBS="${UTILITY_LIBS} -lz"
COMMON_LIBS="$COMMON_LIBS -lz"],
AC_MSG_ERROR([Could not find zlib library.]))
AC_CHECK_HEADER([zlib.h], [],
AC_MSG_ERROR([zlib found but not zlib.h.
AC_CHECK_HEADER([zlib.h], [],
AC_MSG_ERROR([zlib found but not zlib.h.
You may need to install a zlib devel package.]))
else
CFLAGS="$CFLAGS -s USE_ZLIB=1"
CXXFLAGS="$CXXFLAGS -s USE_ZLIB=1"
fi
AC_PATH_PROG(GZIP, gzip, "no")
if test "$GZIP" = "no"; then
......
if test "x$fctinycthr" = "xyes" ; then
thread_impl_c=tinycthread
thread_impl_cpp=tinycthread
elif test "x$emscripten" = "xyes" ; then
thread_impl_c=pthreads
thread_impl_cpp=pthreads
CFLAGS="$CFLAGS -s USE_PTHREADS=1"
CXXFLAGS="$CXXFLAGS -s USE_PTHREADS=1"
fi
if test "x$thread_impl_c" = "xnone" ; then
......
no)
if test "x$cross_compiling" = "xyes" ; then
AC_MSG_ERROR([Must use external build system tolua command when cross-compiling])
elif test "x$emscripten" = "xyes" ; then
AC_MSG_ERROR([Must use external build system tolua command in emscripten build])
fi
sys_tolua_cmd=false ;;
*)
sys_tolua_cmd=${enableval} ;;
esac], [
if test "x$cross_compiling" = "xyes" || test "x$emscripten" = "xyes" ; then
if test "x$cross_compiling" = "xyes" ; then
sys_tolua_cmd=true
else
dnl Our own tolua is better than upstream one, so prefer it.
gen_headers/freeciv_config.h.in
/* Metaserver URL */
#undef FREECIV_META_URL
#ifndef __EMSCRIPTEN__
/* Metaserver communication built in */
#define FREECIV_META_ENABLED
#endif /* __EMSCRIPTEN__ */
/* Month next version will be released */
#undef FREECIV_RELEASE_MONTH
m4/emscripten.m4
# Configure checks for emscripten client
AC_DEFUN([FC_EMSCRIPTEN],
[
AC_MSG_CHECKING([for emscripten])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#ifndef __EMSCRIPTEN__
error fail
#endif
]])],
[AC_MSG_RESULT([yes])
emscripten=yes],
[AC_MSG_RESULT([no])
emscripten=no])
])
m4/sdl2-client.m4
[
if test "x$gui_sdl2" = "xyes" || test "x$client" = "xall" ||
test "x$client" = "xauto" ; then
if test "x$emscripten" = "xyes" ; then
gui_sdl2_cflags="-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_TTF=2 -s USE_SDL_GFX=2"
gui_sdl2_ldflags="-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_TTF=2 -s USE_SDL_GFX=2"
gui_sdl2=yes
client=yes
else
AM_PATH_SDL2([2.0.0], [sdl2_found="yes"], [sdl2_found="no"])
if test "$sdl2_found" = yes; then
gui_sdl2_cflags="$SDL2_CFLAGS"
gui_sdl2_libs="$SDL2_LIBS"
FC_SDL2_PROJECT([SDL2_image], [IMG_Load], [SDL_image.h])
if test "x$sdl2_h_found" = "xyes" ; then
FC_SDL2_PROJECT([SDL2_ttf], [TTF_OpenFont], [SDL_ttf.h])
else
missing_2_project="SDL2_image"
AM_PATH_SDL2([2.0.0], [sdl2_found="yes"], [sdl2_found="no"])
if test "$sdl2_found" = yes; then
gui_sdl2_cflags="$SDL2_CFLAGS"
gui_sdl2_libs="$SDL2_LIBS"
FC_SDL2_PROJECT([SDL2_image], [IMG_Load], [SDL_image.h])
if test "x$sdl2_h_found" = "xyes" ; then
FC_SDL2_PROJECT([SDL2_ttf], [TTF_OpenFont], [SDL_ttf.h])
else
missing_2_project="SDL2_image"
fi
if test "x$sdl2_h_found" = "xyes" ; then
FC_SDL2_PROJECT([SDL2_gfx], [rotozoomSurface], [SDL2_rotozoom.h])
elif test "x$missing_2_project" = "x" ; then
missing_2_project="SDL2_ttf"
fi
if test "x$sdl2_h_found" = "xyes" ; then
dnl Version number here is as specified by libtool, not the main
dnl freetype version number.
dnl See https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/VERSIONS.TXT
PKG_CHECK_MODULES([FT2], [freetype2 >= 7.0.1], [freetype_found="yes"], [freetype_found="no"])
if test "$freetype_found" = yes; then
gui_sdl2_cflags="$gui_sdl2_cflags $FT2_CFLAGS"
gui_sdl2_libs="$gui_sdl2_libs $FT2_LIBS"
found_sdl2_client=yes
elif test "x$gui_sdl2" = "xyes"; then
AC_MSG_ERROR([specified client 'sdl2' not configurable (FreeType2 >= 2.1.3 is needed (www.freetype.org))])
fi
if test "x$sdl2_h_found" = "xyes" ; then
FC_SDL2_PROJECT([SDL2_gfx], [rotozoomSurface], [SDL2_rotozoom.h])
elif test "x$missing_2_project" = "x" ; then
missing_2_project="SDL2_ttf"
elif test "x$gui_sdl2" = "xyes"; then
if test "x$missing_2_project" = "x" ; then
missing_2_project="SDL2_gfx"
fi
if test "x$sdl2_h_found" = "xyes" ; then
dnl Version number here is as specified by libtool, not the main
dnl freetype version number.
dnl See https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/VERSIONS.TXT
PKG_CHECK_MODULES([FT2], [freetype2 >= 7.0.1], [freetype_found="yes"], [freetype_found="no"])
if test "$freetype_found" = yes; then
gui_sdl2_cflags="$gui_sdl2_cflags $FT2_CFLAGS"
gui_sdl2_libs="$gui_sdl2_libs $FT2_LIBS"
found_sdl2_client=yes
elif test "x$gui_sdl2" = "xyes"; then
AC_MSG_ERROR([specified client 'sdl2' not configurable (FreeType2 >= 2.1.3 is needed (www.freetype.org))])
fi
elif test "x$gui_sdl2" = "xyes"; then
if test "x$missing_2_project" = "x" ; then
missing_2_project="SDL2_gfx"
fi
if test "x$sdl2_lib_found" = "xyes" ; then
missing_type="-devel"
else
missing_type=""
fi
AC_MSG_ERROR([specified client 'sdl2' not configurable (${missing_2_project}${missing_type} is needed (www.libsdl.org))])
if test "x$sdl2_lib_found" = "xyes" ; then
missing_type="-devel"
else
missing_type=""
fi
AC_MSG_ERROR([specified client 'sdl2' not configurable (${missing_2_project}${missing_type} is needed (www.libsdl.org))])
fi
fi
if test "$found_sdl2_client" = yes; then
gui_sdl2=yes
if test "x$client" = "xauto" ; then
client=yes
fi
if test "$found_sdl2_client" = yes; then
gui_sdl2=yes
if test "x$client" = "xauto" ; then
client=yes
fi
dnl Check for libiconv (which is usually included in glibc, but may
dnl be distributed separately).
AM_ICONV
FC_LIBCHARSET
AM_LANGINFO_CODESET
gui_sdl2_libs="$LIBICONV $gui_sdl2_libs"
dnl Check for libiconv (which is usually included in glibc, but may
dnl be distributed separately).
AM_ICONV
FC_LIBCHARSET
AM_LANGINFO_CODESET
gui_sdl2_libs="$LIBICONV $gui_sdl2_libs"
dnl Check for some other libraries - needed under BeOS for instance.
dnl These should perhaps be checked for in all cases?
AC_CHECK_LIB(socket, connect, gui_sdl2_libs="-lsocket $gui_sdl2_libs")
AC_CHECK_LIB(bind, gethostbyaddr, gui_sdl2_libs="-lbind $gui_sdl2_libs")
dnl Check for some other libraries - needed under BeOS for instance.
dnl These should perhaps be checked for in all cases?
AC_CHECK_LIB(socket, connect, gui_sdl2_libs="-lsocket $gui_sdl2_libs")
AC_CHECK_LIB(bind, gethostbyaddr, gui_sdl2_libs="-lbind $gui_sdl2_libs")
dnl Control -mwindows flag ourselves instead of letting pkg-config to force
dnl it on us.
gui_sdl2_libs="$(echo $gui_sdl2_libs | $SED 's/-mwindows//g') $MWINDOWS_FLAG"
dnl Control -mwindows flag ourselves instead of letting pkg-config to force
dnl it on us.
gui_sdl2_libs="$(echo $gui_sdl2_libs | $SED 's/-mwindows//g') $MWINDOWS_FLAG"
elif test "x$gui_sdl2" = "xyes"; then
AC_MSG_ERROR([specified client 'sdl2' not configurable (SDL2 >= 2.0.0 is needed (www.libsdl.org))])
fi
elif test "x$gui_sdl2" = "xyes"; then
AC_MSG_ERROR([specified client 'sdl2' not configurable (SDL2 >= 2.0.0 is needed (www.libsdl.org))])
fi
fi
])
m4/sound.m4
if test "x$USE_SOUND_SDL" != "xno" ; then
dnl Add SDL2-mixer support to client
if test "x$emscripten" = "xyes" ; then
SOUND_CFLAGS="$SOUND_CFLAGS -s USE_SDL_MIXER=2"
SOUND_LIBS="$SOUND_LIBS -s USE_SDL_MIXER=2"
SDL2_VERSION=2.0.6
AM_PATH_SDL2([$SDL2_VERSION], [SDL2=yes], [SDL2=no])
if test "x$SDL2" != "xno" ; then
PKG_CHECK_MODULES([SDL2MIXER], [SDL2_mixer],
[
SOUND_CFLAGS="$SOUND_CFLAGS $SDL2MIXER_CFLAGS"
SOUND_LIBS="$SOUND_LIBS $SDL2MIXER_LIBS"
AC_DEFINE([AUDIO_SDL], [1], [SDL Mixer support])
SDL_mixer=sdl2
SOUND_SDL_OK=true
else
SDL2_VERSION=2.0.6
AM_PATH_SDL2([$SDL2_VERSION], [SDL2=yes], [SDL2=no])
if test "x$SDL2" != "xno" ; then
PKG_CHECK_MODULES([SDL2MIXER], [SDL2_mixer],
[
SOUND_CFLAGS="$SOUND_CFLAGS $SDL2MIXER_CFLAGS"
SOUND_LIBS="$SOUND_LIBS $SDL2MIXER_LIBS"
AC_DEFINE([AUDIO_SDL], [1], [SDL Mixer support])
SDL_mixer=sdl2
SOUND_SDL_OK=true
if test x$sdl_headers_without_path != xyes ; then
AC_CHECK_HEADER([SDL2/SDL_mixer.h], [], [
if test x$sdl_headers_without_path != xyes ; then
AC_CHECK_HEADER([SDL2/SDL_mixer.h], [], [
AC_DEFINE([SDL2_PLAIN_INCLUDE], [1], [sdl2 headers must be included without path])
sdl_headers_without_path=yes])
fi
], [
ac_save_CPPFLAGS="$CPPFLAGS"
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $SDL2_CFLAGS"
CFLAGS="$CFLAGS $SDL2_CFLAGS"
LIBS="$LIBS $SDL2_LIBS"
AC_CHECK_HEADER([SDL_mixer.h], [SDL_mixer_h=1], [SDL_mixer_h=0])
AC_CHECK_LIB([SDL2_mixer], [Mix_OpenAudio], [SDL_mixer=sdl2])
CPPFLAGS="$ac_save_CPPFLAGS"
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
ac_save_CPPFLAGS="$CPPFLAGS"
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $SDL2_CFLAGS"
CFLAGS="$CFLAGS $SDL2_CFLAGS"
LIBS="$LIBS $SDL2_LIBS"
AC_CHECK_HEADER([SDL_mixer.h], [SDL_mixer_h=1], [SDL_mixer_h=0])
AC_CHECK_LIB([SDL2_mixer], [Mix_OpenAudio], [SDL_mixer=sdl2])
CPPFLAGS="$ac_save_CPPFLAGS"
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
AC_MSG_CHECKING([building SDL2_mixer support])
if test "x$SDL_mixer_h" = "x1"; then
if test "x$SDL_mixer" = "xsdl2"; then
SOUND_CFLAGS="$SOUND_CFLAGS $SDL2_CFLAGS"
SOUND_LIBS="$SOUND_LIBS -lSDL2_mixer $SDL2_LIBS"
AC_DEFINE([AUDIO_SDL], [1], [SDL Mixer support])
AC_MSG_RESULT([yes])
SOUND_SDL_OK=true
else
AC_MSG_RESULT([no SDL2_mixer library found, install from https://github.com/libsdl-org/SDL_mixer ])
fi
AC_MSG_CHECKING([building SDL2_mixer support])
if test "x$SDL_mixer_h" = "x1"; then
if test "x$SDL_mixer" = "xsdl2"; then
SOUND_CFLAGS="$SOUND_CFLAGS $SDL2_CFLAGS"
SOUND_LIBS="$SOUND_LIBS -lSDL2_mixer $SDL2_LIBS"
AC_DEFINE([AUDIO_SDL], [1], [SDL Mixer support])
AC_MSG_RESULT([yes])
SOUND_SDL_OK=true
else
AC_MSG_RESULT([no SDL2_mixer headers found, install from https://github.com/libsdl-org/SDL_mixer])
fi ])
fi
AC_MSG_RESULT([no SDL2_mixer library found, install from https://github.com/libsdl-org/SDL_mixer ])
fi
else
AC_MSG_RESULT([no SDL2_mixer headers found, install from https://github.com/libsdl-org/SDL_mixer])
fi ])
fi
fi
    (1-1/1)