From a2c8126b5623a309370765f1c43d33dfec3b8d97 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 21 Oct 2023 04:24:39 +0300 Subject: [PATCH 33/33] Autotools: Add support for gtk4x-client building See osdn #48874 Signed-off-by: Marko Lindqvist --- Makefile.am | 1 + client/Makefile.am | 18 ++++++++++++++++++ client/gui-gtk-5.0/Makefile.am | 19 ++++++++++++++++++- configure.ac | 17 ++++++++++++++++- data/themes/Makefile.am | 4 ++++ doc/README.packaging | 3 +-- m4/gtk5-client.m4 | 30 ++++++++++++++++++++++++++++++ 7 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 m4/gtk5-client.m4 diff --git a/Makefile.am b/Makefile.am index 37e2513a79..7032badb53 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,6 +64,7 @@ EXTRA_DIST = autogen.sh \ m4/gettimeofday.m4 \ m4/gtk3.22-client.m4 \ m4/gtk4-client.m4 \ + m4/gtk5-client.m4 \ m4/host-cpu-c-abi.m4 \ m4/iconv.m4 \ m4/intl.m4 \ diff --git a/client/Makefile.am b/client/Makefile.am index 8d4a3c80e7..ee9c3d02f9 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -17,7 +17,9 @@ if CLIENT_GUI_GTK_4 GUI_SUBDIRS += gui-gtk-4.0 endif +if CLIENT_GUI_GTK_5 GUI_SUBDIRS += gui-gtk-5.0 +endif if CLIENT_GUI_QT GUI_SUBDIRS += gui-qt @@ -211,6 +213,22 @@ freeciv_gtk4_LDADD = \ $(gui_gtk4_libs) endif +if CLIENT_GUI_GTK_5 +bin_PROGRAMS += freeciv-gtk4x +noinst_LTLIBRARIES += libfcgui-gtk5.la +libfcgui_gtk5_la_SOURCES = $(freeciv_client_src) +libfcgui_gtk5_la_LIBADD = gui-gtk-5.0/libgui-gtk5.la $(clientlibs) +freeciv_gtk4x_SOURCES = dummy.c +freeciv_gtk4x_LDFLAGS = $(gui_gtk4_ldflags) +freeciv_gtk4x_LDADD = \ + libfcgui-gtk5.la $(SOUND_LIBS) gui-gtk-5.0/gui_main.lo \ + $(top_builddir)/common/libfreeciv.la \ + $(INTLLIBS) $(CLIENT_LIBS) $(CLIENTICON) \ + $(TINYCTHR_LIBS) $(MAPIMG_WAND_LIBS) \ + $(gui_3d_libs) \ + $(gui_gtk5_libs) +endif + if CLIENT_GUI_SDL2 bin_PROGRAMS += freeciv-sdl2 noinst_LTLIBRARIES += libfcgui-sdl2.la diff --git a/client/gui-gtk-5.0/Makefile.am b/client/gui-gtk-5.0/Makefile.am index 58f79bd850..9d3f9b4038 100644 --- a/client/gui-gtk-5.0/Makefile.am +++ b/client/gui-gtk-5.0/Makefile.am @@ -1,6 +1,21 @@ ## Process this file with automake to produce Makefile.in -EXTRA_DIST = \ +noinst_LTLIBRARIES = libgui-gtk5.la +AM_CPPFLAGS = \ + -I$(srcdir)/.. \ + -I$(srcdir)/../include \ + -I$(top_srcdir)/utility \ + -I$(top_srcdir)/common \ + -I$(top_srcdir)/common/aicore \ + -I$(top_srcdir)/common/networking \ + -I$(top_srcdir)/common/scriptcore \ + -I$(srcdir)/../agents \ + -I$(srcdir)/../luascript \ + -I$(top_srcdir)/dependencies/tinycthread \ + -I$(top_srcdir)/gen_headers/enums \ + $(gui_gtk5_cflags) $(SOUND_CFLAGS) + +libgui_gtk5_la_SOURCES = \ action_dialog.c \ canvas.c \ canvas.h \ @@ -93,3 +108,5 @@ EXTRA_DIST = \ voteinfo_bar.h \ wldlg.c \ wldlg.h + +libgui_gtk5_la_LIBADD = -lm diff --git a/configure.ac b/configure.ac index eddfa33e8d..cc6d21b8fa 100644 --- a/configure.ac +++ b/configure.ac @@ -497,13 +497,14 @@ dnl auto: Autodetect one. dnl all: Autodetect as many as possible. dnl comma-separated-list: Detect these or abort. AC_ARG_ENABLE([client], - AS_HELP_STRING([--enable-client=auto/all/gtk3.22/sdl2/qt/gtk4/stub], + AS_HELP_STRING([--enable-client=auto/all/gtk3.22/sdl2/qt/gtk4/gtk4x/stub], [clients to compile [auto](list for multiple)]), [clients=${enableval}], [client=auto]) gui_gtk3_22=no gui_gtk4=no +gui_gtk5=no gui_sdl2=no gui_qt=no gui_stub=no @@ -520,6 +521,8 @@ for gui in $(echo $clients | $SED 's/,/ /g') ; do gui_gtk3_22=yes elif test "x$gui" = "xgtk4" ; then gui_gtk4=yes + elif test "x$gui" = "xgtk4x" ; then + gui_gtk5=yes elif test "x$gui" = "xgtk" ; then AC_MSG_WARN([for requested client 'gtk' enabled gtk3.22-client, that has changed since earlier versions and will change again in the future]) gui_gtk3_22=yes @@ -1106,6 +1109,9 @@ if test "x$client" != "xno"; then dnl SDL2-specific overrides FC_SDL2_CLIENT + dnl Gtk-5.0-specific overrides + FC_GTK5_CLIENT + dnl Stub-specific overrides if test "x$gui_stub" = "xyes" || test "x$client" = "xall" ; then gui_stub=yes @@ -1124,6 +1130,7 @@ fi if test "x$client" = "xall" ; then if test "x$gui_gtk3_22" = "xyes" || test "x$gui_gtk4" = "xyes" || + test "x$gui_gtk5" = "xyes" || test "x$gui_sdl2" = "xyes" || test "x$gui_qt" = "xyes" || test "x$gui_stub" = "xyes" ; then @@ -1449,6 +1456,9 @@ AC_SUBST([gui_gtk3_22_ldflags]) AC_SUBST([gui_gtk4_cflags]) AC_SUBST([gui_gtk4_libs]) AC_SUBST([gui_gtk4_ldflags]) +AC_SUBST([gui_gtk5_cflags]) +AC_SUBST([gui_gtk5_libs]) +AC_SUBST([gui_gtk5_ldflags]) AC_SUBST([gui_sdl2_cflags]) AC_SUBST([gui_sdl2_libs]) AC_SUBST([gui_sdl2_ldflags]) @@ -1485,6 +1495,7 @@ AM_CONDITIONAL(AUDIO_SDL, test "x$SDL_mixer" != "xno") AM_CONDITIONAL(CLIENT_GUI_SDL2, test "x$gui_sdl2" = "xyes") AM_CONDITIONAL(CLIENT_GUI_GTK_3_22, test "x$gui_gtk3_22" = "xyes") AM_CONDITIONAL(CLIENT_GUI_GTK_4, test "x$gui_gtk4" = "xyes") +AM_CONDITIONAL(CLIENT_GUI_GTK_5, test "x$gui_gtk5" = "xyes") AM_CONDITIONAL(CLIENT_GUI_QT, test "x$gui_qt" = "xyes") AM_CONDITIONAL(CLIENT_GUI_STUB, test "x$gui_stub" = "xyes") AM_CONDITIONAL(MINGW, test x"$MINGW" = "xyes") @@ -2038,6 +2049,10 @@ AC_MSG_NOTICE([ SDL2: $gui_sdl2 Stub: $gui_stub + In-development client frontends: + (these are not yet ready for general use) + Gtk-4.x: $gui_gtk5 + == Server == Build freeciv server: $server AI modules support: $enable_aimodules diff --git a/data/themes/Makefile.am b/data/themes/Makefile.am index 6f6744c487..1bdf0acf46 100644 --- a/data/themes/Makefile.am +++ b/data/themes/Makefile.am @@ -9,6 +9,10 @@ endif if CLIENT_GUI_GTK_4 SUBDIRS += gtk4 +else +if CLIENT_GUI_GTK_5 +SUBDIRS += gtk4 +endif endif if CLIENT_GUI_SDL2 diff --git a/doc/README.packaging b/doc/README.packaging index 853932413a..0c670da8f2 100644 --- a/doc/README.packaging +++ b/doc/README.packaging @@ -23,8 +23,7 @@ Updating from 3.2 to 3.3 * Minimum autoconf version, for autotools based builds, is now 2.69 * New 'qt6x' mode for building Qt based components linked against relatively new Qt6 versions -* Build with meson supports building gtk4x-client that is linked - against relatively new gtk4 versions +* New gtk4x-client that is linked against relatively new gtk4 versions * Build with meson supports building gtk4x modpack installer that is linked against relatively new gtk4 versions * va_copy support is now mandatory diff --git a/m4/gtk5-client.m4 b/m4/gtk5-client.m4 new file mode 100644 index 0000000000..edccba079c --- /dev/null +++ b/m4/gtk5-client.m4 @@ -0,0 +1,30 @@ +# Try to configure the GTK-4.x client (gui-gtk-5.0) + +# FC_GTK5_CLIENT +# Test for GTK-5.0 libraries needed for gui-gtk-4.x + +AC_DEFUN([FC_GTK5_CLIENT], +[ + if test "x$gui_gtk5" = "xyes" || + test "x$client" = "xall" || test "x$client" = "xauto" ; then + PKG_CHECK_MODULES([GTK5], [gtk4 >= 4.10.0], + [ + GTK5_CFLAGS="$GTK5_CFLAGS -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_4_8" + GTK5_CFLAGS="$GTK5_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_66" + gui_gtk5=yes + if test "x$client" = "xauto" ; then + client=yes + fi + gui_gtk5_cflags="$GTK5_CFLAGS" + gui_gtk5_libs="$GTK5_LIBS" + if test "x$MINGW" = "xyes"; then + dnl Required to compile gtk5 on Windows platform + gui_gtk5_cflags="$gui_gtk5_cflags -mms-bitfields" + gui_gtk5_ldflags="$gui_gtk5_ldflags $MWINDOWS_FLAG" + fi + ], + [ + FC_NO_CLIENT([gtk4x], [GTK-4.x libraries not found]) + ]) + fi +]) -- 2.42.0