changeset 242:82470f83f0c2

autotools: make windows build work also, I've added back the method I made for getting the vars as variables rather than separate files, so less clutter in tmp folders :)
author Paper <paper@paper.us.eu.org>
date Mon, 22 Jan 2024 19:06:23 -0800
parents 06d6c351925c
children ed5ab3896666
files Makefile.am m4/m4_ax_have_qt.m4 rc/win32/version.rc rc/win32/version.rc.in
diffstat 4 files changed, 189 insertions(+), 164 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.am	Mon Jan 22 16:36:19 2024 -0500
+++ b/Makefile.am	Mon Jan 22 19:06:23 2024 -0800
@@ -90,15 +90,17 @@
 
 if BUILD_WIN
 files_win = src/sys/win32/dark_theme.cc
+libs_win = -lole32 -luuid
 
 if BUILD_WINDRES
 # Untested...
-wrcflags_version = -DWRC_VERSION=0,`echo '$(PACKAGE_VERSION)' | sed 's/(\d+)\.(\d+)\.(\d+)/\1,\2,\3/'`
 
-WRCFLAGS = --use-temp-file -I. -I$(srcdir) $(wrcflags_version)
+wrcflags_version = -DWRC_VERSION=0,`echo $(PACKAGE_VERSION) | sed 's/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\).*/\1,\2,\3/'`
+
+WRCFLAGS = --use-temp-file -I. -I$(srcdir) $(wrcflags_version) $(CPPFLAGS)
 .rc.$(OBJEXT):
 	$(WINDRES) $(WRCFLAGS) -i $< -o $@
-files_windres=rc/win32/version.rc
+files_windres=rc/win32/version.rc rc/win32/resource.rc
 endif
 endif
 
@@ -170,7 +172,7 @@
 minori_LDFLAGS = $(ldflags_osx)
 
 minori_DEPENDENCIES = dep/pugixml/libpugixml.la dep/animia/libanimia.la dep/anitomy/libanitomy.la
-minori_LDADD = $(libs_glib) $(libs_osx) @LIBCURL@ @QT_LIBS@ dep/pugixml/libpugixml.la dep/animia/libanimia.la dep/anitomy/libanitomy.la
+minori_LDADD = $(libs_glib) $(libs_osx) $(libs_win) @LIBCURL@ @QT_LIBS@ dep/pugixml/libpugixml.la dep/animia/libanimia.la dep/anitomy/libanitomy.la
 
 .h_moc.cc:
 	@MKDIR_P@ -- `dirname $@`
--- a/m4/m4_ax_have_qt.m4	Mon Jan 22 16:36:19 2024 -0500
+++ b/m4/m4_ax_have_qt.m4	Mon Jan 22 19:06:23 2024 -0800
@@ -49,6 +49,7 @@
 #
 #   Copyright (c) 2008 Bastiaan Veelo <Bastiaan@Veelo.net>
 #   Copyright (c) 2014 Alex Henrie <alexhenrie24@gmail.com>
+#   Copyright (c) 2024 Paper <mrpapersonic@gmail.com>
 #
 #   Copying and distribution of this file, with or without modification, are
 #   permitted in any medium without royalty provided the copyright notice
@@ -60,33 +61,41 @@
 AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT])
 AC_DEFUN([AX_HAVE_QT],
 [
-  AC_REQUIRE([AC_PROG_CXX])
-  AC_REQUIRE([AC_PATH_X])
-  AC_REQUIRE([AC_PATH_XTRA])
-  # openSUSE leap 15.3 installs qmake-qt5, not qmake, for example.
-  # Store the full name (like qmake-qt5) into QMAKE
-  # and the specifier (like -qt5 or empty) into am_have_qt_qmexe_suff.
-  AC_ARG_VAR([QMAKE],"Qt make tool")
-  AC_CHECK_TOOLS([QMAKE],[qmake qmake-qt6 qmake-qt5],[false])
+	AC_REQUIRE([AC_PROG_CXX])
+	AC_REQUIRE([AC_PATH_X])
+	AC_REQUIRE([AC_PATH_XTRA])
+	# openSUSE leap 15.3 installs qmake-qt5, not qmake, for example.
+	# Store the full name (like qmake-qt5) into QMAKE
+	# and the specifier (like -qt5 or empty) into am_have_qt_qmexe_suff.
+	AC_ARG_VAR([QMAKE],"Qt make tool")
+	AC_CHECK_TOOLS([QMAKE],[qmake qmake-qt6 qmake-qt5],[false])
 
-  AC_MSG_CHECKING(for Qt)
-  am_have_qt_qmexe_suff=`echo $QMAKE | sed 's,^.*qmake,,'`
-  # If we have Qt5 or later in the path, we're golden
-  ver=`$QMAKE --version | grep -o "Qt version ."`
+	AC_MSG_CHECKING(for Qt)
+	am_have_qt_qmexe_suff=`echo $QMAKE | sed 's,^.*qmake,,'`
+	# If we have Qt5 or later in the path, we're golden
+	ver=`$QMAKE --version | grep -o "Qt version ."`
 
-  if test "$ver" ">" "Qt version 4"; then
-    have_qt=yes
-    # This pro file dumps qmake's variables, but it only works on Qt 5 or later
-    am_have_qt_dir=`mktemp -d`
-    am_have_qt_pro="$am_have_qt_dir/test.pro"
-    am_have_qt_stash="$am_have_qt_dir/.qmake.stash"
-    am_have_qt_makefile="$am_have_qt_dir/Makefile"
-    # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt
-    cat > $am_have_qt_pro << EOF
+	if test "$ver" ">" "Qt version 4"; then
+		have_qt=yes
+		# This pro file dumps qmake's variables, but it only works on Qt 5 or later
+		am_have_qt_dir=`mktemp -d`
+		am_have_qt_pro="$am_have_qt_dir/test.pro"
+		am_have_qt_stash="$am_have_qt_dir/.qmake.stash"
+		am_have_qt_makefile="$am_have_qt_dir/Makefile"
+		# http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt
+		cat > $am_have_qt_pro << EOF
 win32 {
-    CONFIG -= debug_and_release
-    CONFIG += release
+		CONFIG -= debug_and_release
+		CONFIG += release
 }
+
+CONFIG += sdk_no_version_check
+
+# use absolute paths, useful on windows
+# where qmake really loves giving relative paths
+QMAKE_PROJECT_DEPTH = 0
+
+# commented out all the modules we don't use
 #qtHaveModule(axcontainer):       QT += axcontainer
 #qtHaveModule(axserver):          QT += axserver
 #qtHaveModule(concurrent):        QT += concurrent
@@ -121,127 +130,139 @@
 percent.commands = @echo -n "\$(\$(@))\ "
 QMAKE_EXTRA_TARGETS += percent
 EOF
-    $QMAKE $am_have_qt_pro -o $am_have_qt_makefile
-    QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile CXXFLAGS INCPATH`
-    QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile LIBS`
-    rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile
-    rmdir $am_have_qt_dir
+		am_have_qt_makefile_cxxflags=`cat << EOF
+include $am_have_qt_makefile
+
+VAR:
+	@echo \\$(CXXFLAGS) \\$(INCPATH)
+EOF`
+		am_have_qt_makefile_libs=`cat << EOF
+include $am_have_qt_makefile
 
-    # Look for specific tools in $PATH
-    QT_MOC=`which moc$am_have_qt_qmexe_suff`
-    QT_UIC=`which uic$am_have_qt_qmexe_suff`
-    QT_RCC=`which rcc$am_have_qt_qmexe_suff`
-    QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff`
-    QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff`
+VAR:
+	@echo \\$(LIBS)
+EOF`
+		$QMAKE "$am_have_qt_pro" -o "$am_have_qt_makefile"
+		QT_CXXFLAGS=`cd $am_have_qt_dir; echo "\$am_have_qt_makefile_cxxflags" | make -s -f - VAR`
+		QT_LIBS=`cd $am_have_qt_dir; echo "\$am_have_qt_makefile_libs" | make -s -f - VAR`
+		rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile
+		rmdir $am_have_qt_dir
 
-    # Get Qt version from qmake
-    QT_DIR=`$QMAKE --version | grep -o -E /.+`
+		# Look for specific tools in $PATH
+		QT_MOC=`which moc$am_have_qt_qmexe_suff`
+		QT_UIC=`which uic$am_have_qt_qmexe_suff`
+		QT_RCC=`which rcc$am_have_qt_qmexe_suff`
+		QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff`
+		QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff`
+
+		# Get Qt version from qmake
+		QT_DIR=`$QMAKE --version | grep -o -E /.+`
 
-    # All variables are defined, report the result
-    AC_MSG_RESULT([$have_qt:
-    QT_CXXFLAGS=$QT_CXXFLAGS
-    QT_DIR=$QT_DIR
-    QT_LIBS=$QT_LIBS
-    QT_UIC=$QT_UIC
-    QT_MOC=$QT_MOC
-    QT_RCC=$QT_RCC
-    QT_LRELEASE=$QT_LRELEASE
-    QT_LUPDATE=$QT_LUPDATE])
-  else
-    # Qt was not found
-    have_qt=no
-    QT_CXXFLAGS=
-    QT_DIR=
-    QT_LIBS=
-    QT_UIC=
-    QT_MOC=
-    QT_RCC=
-    QT_LRELEASE=
-    QT_LUPDATE=
-    AC_MSG_RESULT($have_qt)
-  fi
-  AC_SUBST(QT_CXXFLAGS)
-  AC_SUBST(QT_DIR)
-  AC_SUBST(QT_LIBS)
-  AC_SUBST(QT_UIC)
-  AC_SUBST(QT_MOC)
-  AC_SUBST(QT_RCC)
-  AC_SUBST(QT_LRELEASE)
-  AC_SUBST(QT_LUPDATE)
-  AC_SUBST(QMAKE)
+		# All variables are defined, report the result
+		AC_MSG_RESULT([$have_qt:
+		QT_CXXFLAGS=$QT_CXXFLAGS
+		QT_DIR=$QT_DIR
+		QT_LIBS=$QT_LIBS
+		QT_UIC=$QT_UIC
+		QT_MOC=$QT_MOC
+		QT_RCC=$QT_RCC
+		QT_LRELEASE=$QT_LRELEASE
+		QT_LUPDATE=$QT_LUPDATE])
+	else
+		# Qt was not found
+		have_qt=no
+		QT_CXXFLAGS=
+		QT_DIR=
+		QT_LIBS=
+		QT_UIC=
+		QT_MOC=
+		QT_RCC=
+		QT_LRELEASE=
+		QT_LUPDATE=
+		AC_MSG_RESULT($have_qt)
+	fi
+	AC_SUBST(QT_CXXFLAGS)
+	AC_SUBST(QT_DIR)
+	AC_SUBST(QT_LIBS)
+	AC_SUBST(QT_UIC)
+	AC_SUBST(QT_MOC)
+	AC_SUBST(QT_RCC)
+	AC_SUBST(QT_LRELEASE)
+	AC_SUBST(QT_LUPDATE)
+	AC_SUBST(QMAKE)
 
-  #### Being paranoid:
-  if test x"$have_qt" = xyes; then
-    AC_MSG_CHECKING(correct functioning of Qt installation)
-    AC_CACHE_VAL(ax_cv_qt_test_result,
-    [
-      cat > ax_qt_test.h << EOF
+	#### Being paranoid:
+	if test x"$have_qt" = xyes; then
+		AC_MSG_CHECKING(correct functioning of Qt installation)
+		AC_CACHE_VAL(ax_cv_qt_test_result,
+		[
+			cat > ax_qt_test.h << EOF
 #include <qobject.h>
 class Test : public QObject
 {
 Q_OBJECT
 public:
-  Test() {}
-  ~Test() {}
+	Test() {}
+	~Test() {}
 public slots:
-  void receive() {}
+	void receive() {}
 signals:
-  void send();
+	void send();
 };
 EOF
 
-      cat > ax_qt_main.$ac_ext << EOF
+			cat > ax_qt_main.$ac_ext << EOF
 #include "ax_qt_test.h"
 #include <qapplication.h>
 int main( int argc, char **argv )
 {
-  QApplication app( argc, argv );
-  Test t;
-  QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) );
+	QApplication app( argc, argv );
+	Test t;
+	QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) );
 }
 EOF
 
-      ax_cv_qt_test_result="failure"
-      ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
-      AC_TRY_EVAL(ax_try_1)
-      if test x"$ac_status" != x0; then
-        echo "$ax_err_1" >&AS_MESSAGE_LOG_FD
-        echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD
-        cat ax_qt_test.h >&AS_MESSAGE_LOG_FD
-      else
-        ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
-        AC_TRY_EVAL(ax_try_2)
-        if test x"$ac_status" != x0; then
-          echo "$ax_err_2" >&AS_MESSAGE_LOG_FD
-          echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
-          cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD
-        else
-          ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null"
-          AC_TRY_EVAL(ax_try_3)
-          if test x"$ac_status" != x0; then
-            echo "$ax_err_3" >&AS_MESSAGE_LOG_FD
-            echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
-            cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD
-          else
-            ax_try_4="$CXX -o ax_qt_main ax_qt_main.o moc_ax_qt_test.o $QT_LIBS $LIBS >/dev/null 2>/dev/null"
-            AC_TRY_EVAL(ax_try_4)
-            if test x"$ac_status" != x0; then
-              echo "$ax_err_4" >&AS_MESSAGE_LOG_FD
-            else
-              ax_cv_qt_test_result="success"
-            fi
-          fi
-        fi
-      fi
-    ])dnl AC_CACHE_VAL ax_cv_qt_test_result
-    AC_MSG_RESULT([$ax_cv_qt_test_result])
-    if test x"$ax_cv_qt_test_result" = "xfailure"; then
-      AC_MSG_ERROR([Failed to find matching components of a complete
-                  Qt installation. Try using more options,
-                  see ./configure --help.])
-    fi
+			ax_cv_qt_test_result="failure"
+			ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
+			AC_TRY_EVAL(ax_try_1)
+			if test x"$ac_status" != x0; then
+				echo "$ax_err_1" >&AS_MESSAGE_LOG_FD
+				echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD
+				cat ax_qt_test.h >&AS_MESSAGE_LOG_FD
+			else
+				ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
+				AC_TRY_EVAL(ax_try_2)
+				if test x"$ac_status" != x0; then
+					echo "$ax_err_2" >&AS_MESSAGE_LOG_FD
+					echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
+					cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD
+				else
+					ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null"
+					AC_TRY_EVAL(ax_try_3)
+					if test x"$ac_status" != x0; then
+						echo "$ax_err_3" >&AS_MESSAGE_LOG_FD
+						echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
+						cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD
+					else
+						ax_try_4="$CXX -o ax_qt_main ax_qt_main.o moc_ax_qt_test.o $QT_LIBS $LIBS >/dev/null 2>/dev/null"
+						AC_TRY_EVAL(ax_try_4)
+						if test x"$ac_status" != x0; then
+							echo "$ax_err_4" >&AS_MESSAGE_LOG_FD
+						else
+							ax_cv_qt_test_result="success"
+						fi
+					fi
+				fi
+			fi
+		])dnl AC_CACHE_VAL ax_cv_qt_test_result
+		AC_MSG_RESULT([$ax_cv_qt_test_result])
+		if test x"$ax_cv_qt_test_result" = "xfailure"; then
+			AC_MSG_ERROR([Failed to find matching components of a complete
+						  Qt installation. Try using more options,
+						  see ./configure --help.])
+		fi
 
-    rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \
-          ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main
-  fi
-])
\ No newline at end of file
+		rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \
+					ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main
+	fi
+])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/win32/version.rc	Mon Jan 22 19:06:23 2024 -0800
@@ -0,0 +1,37 @@
+#include "winver.h"
+
+#ifndef WRC_VERSION
+#   define WRC_VERSION 0,0,0,0
+#endif
+
+#ifndef PACKAGE_VERSION
+#	define PACKAGE_VERSION "0.0.0"
+#endif
+
+VS_VERSION_INFO VERSIONINFO
+	FILEVERSION WRC_VERSION
+	PRODUCTVERSION WRC_VERSION
+	FILEFLAGS 0x0L
+	FILEFLAGSMASK 0x3fL
+	FILEOS 0x00040004L
+	FILETYPE 0x1L
+	FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "000004b0"
+        BEGIN
+            VALUE "CompanyName", "Paper"
+            VALUE "FileDescription", "A lightweight anime tracker built with Qt."
+            VALUE "FileVersion", PACKAGE_VERSION
+            VALUE "InternalName", "minori"
+            VALUE "OriginalFilename", "minori.exe"
+            VALUE "ProductName", "Minori"
+            VALUE "ProductVersion", PACKAGE_VERSION
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1252
+    END
+END
--- a/rc/win32/version.rc.in	Mon Jan 22 16:36:19 2024 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#include "winver.h"
-
-#ifndef WRC_VERSION
-#   define WRC_VERSION 0,0,0,0
-#endif
-
-#define RC_INFO_STRING "@RC_INFO_STRING@\0"
-
-VS_VERSION_INFO VERSIONINFO
-	FILEVERSION WRC_VERSION
-	PRODUCTVERSION WRC_VERSION
-	FILEFLAGS 0x0L
-	FILEFLAGSMASK 0x3fL
-	FILEOS 0x00040004L
-	FILETYPE 0x1L
-	FILESUBTYPE 0x0L
-BEGIN
-    BLOCK "StringFileInfo"
-    BEGIN
-        BLOCK "000004b0"
-        BEGIN
-            VALUE "CompanyName", "Paper"
-            VALUE "FileDescription", RC_INFO_STRING
-            VALUE "FileVersion", VER_FILEVERSION_STR
-            VALUE "InternalName", "minori"
-            VALUE "OriginalFilename", "minori.exe"
-            VALUE "ProductName", "Minori"
-            VALUE "ProductVersion", VER_PRODUCTVERSION_STR
-        END
-    END
-    BLOCK "VarFileInfo"
-    BEGIN
-        VALUE "Translation", 0x409, 1252
-    END
-END