[gimp/wip/Jehan/incremental-win-installer-improvements: 2/2] build: add aalib dependency for ASCII Art support.




commit f588c2f4762e3444cea232766d80893aff9a81df
Author: Jehan <jehan girinstud io>
Date:   Sat May 15 19:40:12 2021 +0200

    build: add aalib dependency for ASCII Art support.
    
    - Adding a patch sent to me by Sylvie Alexandre meant to help aalib
      build on MSYS2 for Windows 32 and 64-bit.
    - Additionally, add an additional patch from myself because it was still
      not building properly.
    - Also update the config.guess|sub files because the original ones (from
      2001!) were just too old and not properly recognizing the host mingw
      system (especially the 64-bit one apparently) in the MSYS2 CI jobs of
      GIMP.
    - Finally regenerate the whole aclocal/libtoolize/autoconf/automake
      build system because these old files just don't play nice with recent
      autotools though the source files still regenerate fine (despite with
      some warnings, but nothing blocking).
    - Add crt-git dependency because libws2_32 is in there.

 .gitlab-ci.yml                                     |   1 +
 build/windows/gitlab-ci/build-deps-msys2.sh        |  24 ++
 .../patches/aalib-0001-Apply-patch-for-MSYS2.patch | 242 +++++++++++++++++++++
 ...02-configure-src-tweak-Windows-link-flags.patch | 119 ++++++++++
 4 files changed, 386 insertions(+)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ebc151ce6f..127ec6aefd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -212,6 +212,7 @@ deps-win64-native:
     expire_in: 2 hours
     paths:
       - _install-w64
+      - aalib-1.4.0/_build
   needs: []
 
 gimp-win64-native:
diff --git a/build/windows/gitlab-ci/build-deps-msys2.sh b/build/windows/gitlab-ci/build-deps-msys2.sh
index d9470b1159..afe82defe8 100644
--- a/build/windows/gitlab-ci/build-deps-msys2.sh
+++ b/build/windows/gitlab-ci/build-deps-msys2.sh
@@ -42,6 +42,7 @@ pacman --noconfirm -S --needed \
     mingw-w64-$MSYS2_ARCH-meson \
     \
     mingw-w64-$MSYS2_ARCH-cairo \
+    mingw-w64-$MSYS2_ARCH-crt-git \
     mingw-w64-$MSYS2_ARCH-gobject-introspection \
     mingw-w64-$MSYS2_ARCH-json-glib \
     mingw-w64-$MSYS2_ARCH-lcms2 \
@@ -62,6 +63,29 @@ export LD_LIBRARY_PATH="${GIMP_PREFIX}/lib:${LD_LIBRARY_PATH}"
 export ACLOCAL_FLAGS="-I/c/msys64/mingw64/share/aclocal"
 export XDG_DATA_DIRS="${GIMP_PREFIX}/share:/mingw64/share/"
 
+## AA-lib (not available in MSYS2) ##
+
+wget https://downloads.sourceforge.net/aa-project/aalib-1.4rc5.tar.gz
+echo "9801095c42bba12edebd1902bcf0a990 aalib-1.4rc5.tar.gz" | md5sum -c -
+tar xzf aalib-1.4rc5.tar.gz
+cd aalib-1.4.0
+patch --binary -p1 < ../build/windows/patches/aalib-0001-Apply-patch-for-MSYS2.patch
+patch --binary -p1 < ../build/windows/patches/aalib-0002-configure-src-tweak-Windows-link-flags.patch
+wget "https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD"; 
--output-document config.guess
+wget "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD"; --output-document 
config.sub
+aclocal
+libtoolize --force
+automake --add-missing
+autoconf
+mkdir _build
+cd _build
+../configure --prefix="${GIMP_PREFIX}"
+make
+make install
+cd ../..
+
+## babl and GEGL (follow master branch) ##
+
 git clone --depth=${GIT_DEPTH} https://gitlab.gnome.org/GNOME/babl.git _babl
 git clone --depth=${GIT_DEPTH} https://gitlab.gnome.org/GNOME/gegl.git _gegl
 
diff --git a/build/windows/patches/aalib-0001-Apply-patch-for-MSYS2.patch 
b/build/windows/patches/aalib-0001-Apply-patch-for-MSYS2.patch
new file mode 100644
index 0000000000..6b8e4421ed
--- /dev/null
+++ b/build/windows/patches/aalib-0001-Apply-patch-for-MSYS2.patch
@@ -0,0 +1,242 @@
+From 533b7b01e435cb0dc3a2382b9414086d0a392384 Mon Sep 17 00:00:00 2001
+From: Jehan <jehan girinstud io>
+Date: Sat, 15 May 2021 19:50:08 +0200
+Subject: [PATCH] Apply patch for MSYS2.
+
+The contributor Sylvie Alexandre sent me (on 2021-05-06) a patch
+improving the Windows build for 32 and 64-bit on Windows for our Windows
+build of GIMP.
+
+I have not looked in details to the changes, but it's mostly include
+fixes, typo fixes and one function call change. Also I have not looked
+if it doesn't break other builds (such as Linux), as I'm mostly trying
+to get it to build on GIMP CI jobs for Windows anyway.
+---
+ configure      | 2 +-
+ configure.in   | 2 +-
+ src/aacurkbd.c | 2 +-
+ src/aacurses.c | 4 ++--
+ src/aados.c    | 2 +-
+ src/aadoskbd.c | 1 -
+ src/aaedit.c   | 2 +-
+ src/aakbdreg.c | 2 +-
+ src/aalib.c    | 2 +-
+ src/aalinux.c  | 1 -
+ src/aamoureg.c | 2 +-
+ src/aarec.c    | 2 +-
+ src/aaregist.c | 2 +-
+ src/aastdin.c  | 5 ++++-
+ src/aax.c      | 1 -
+ src/aaxkbd.c   | 1 -
+ src/aaxmouse.c | 1 -
+ 17 files changed, 16 insertions(+), 18 deletions(-)
+
+diff --git a/configure b/configure
+index a103cf0..2bbae5f 100755
+--- a/configure
++++ b/configure
+@@ -4040,7 +4040,7 @@ EOF
+ 
+ fi
+ 
+-for ac_hdr in fcntl.h limits.h malloc.h sys/ioctl.h sys/time.h unistd.h
++for ac_hdr in fcntl.h limits.h sys/ioctl.h sys/time.h unistd.h
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+diff --git a/configure.in b/configure.in
+index 4de06a8..78806dc 100644
+--- a/configure.in
++++ b/configure.in
+@@ -342,7 +342,7 @@ fi
+ 
+ dnl Checks for header files.
+ AC_HEADER_STDC
+-AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/ioctl.h sys/time.h unistd.h)
++AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h unistd.h)
+ 
+ dnl Checks for typedefs, structures, and compiler characteristics.
+ AC_STRUCT_ST_RDEV
+diff --git a/src/aacurkbd.c b/src/aacurkbd.c
+index 801897b..418b6a3 100644
+--- a/src/aacurkbd.c
++++ b/src/aacurkbd.c
+@@ -112,7 +112,7 @@ static int curses_getchar(aa_context * c1, int wait)
+       return (AA_UP);
+     case KEY_DOWN:
+       return (AA_DOWN);
+-#ifdef KEY_MOUDE
++#ifdef KEY_MOUSE
+     case KEY_MOUSE:
+ #ifdef GPM_MOUSEDRIVER
+       if (!__curses_usegpm)
+diff --git a/src/aacurses.c b/src/aacurses.c
+index a3dc713..6e2f5f6 100644
+--- a/src/aacurses.c
++++ b/src/aacurses.c
+@@ -71,8 +71,8 @@ static void curses_getsize(aa_context * c, int *width, int *height)
+ {
+     if (__resized_curses)
+       curses_uninit(c), curses_init(&c->params, NULL,&c->driverparams, NULL), __resized_curses = 0;
+-    *width = stdscr->_maxx + 1;
+-    *height = stdscr->_maxy + 1;
++    *width = getmaxx(stdscr) + 1;
++    *height = getmaxy(stdscr) + 1;
+ #ifdef GPM_MOUSEDRIVER
+     gpm_mx = *width;
+     gpm_my = *height;
+diff --git a/src/aados.c b/src/aados.c
+index 1256606..c98df20 100644
+--- a/src/aados.c
++++ b/src/aados.c
+@@ -5,7 +5,7 @@
+ #include <go32.h>
+ #include <dpmi.h>
+ #include <sys/nearptr.h>
+-#include <malloc.h>
++#include <stdlib.h>
+ #include "aalib.h"
+ #include "aaint.h"
+ int __use_nearptr_hack;
+diff --git a/src/aadoskbd.c b/src/aadoskbd.c
+index 2fc0f37..325fe91 100644
+--- a/src/aadoskbd.c
++++ b/src/aadoskbd.c
+@@ -4,7 +4,6 @@
+ #include <go32.h>
+ #include <dpmi.h>
+ #include <sys/nearptr.h>
+-#include <malloc.h>
+ #include <stdlib.h>
+ #include <dos.h>
+ #include <dpmi.h>
+diff --git a/src/aaedit.c b/src/aaedit.c
+index 09534d2..2ea52f9 100644
+--- a/src/aaedit.c
++++ b/src/aaedit.c
+@@ -1,6 +1,6 @@
+ #include <string.h>
+ #include <ctype.h>
+-#include <malloc.h>
++#include <stdlib.h>
+ #include "aalib.h"
+ #include "aaint.h"
+ static void aa_editdisplay(struct aa_edit *e)
+diff --git a/src/aakbdreg.c b/src/aakbdreg.c
+index def65fe..f4f8efb 100644
+--- a/src/aakbdreg.c
++++ b/src/aakbdreg.c
+@@ -1,4 +1,4 @@
+-#include <malloc.h>
++#include <stdlib.h>
+ #include "config.h"
+ #include "aalib.h"
+ #include "aaint.h"
+diff --git a/src/aalib.c b/src/aalib.c
+index 11fecc8..e3063b4 100644
+--- a/src/aalib.c
++++ b/src/aalib.c
+@@ -1,6 +1,6 @@
+ #include <stdio.h>
+ #include <string.h>
+-#include <malloc.h>
++#include <stdlib.h>
+ #include "aalib.h"
+ #include "aaint.h"
+ 
+diff --git a/src/aalinux.c b/src/aalinux.c
+index 0006d37..bb63120 100644
+--- a/src/aalinux.c
++++ b/src/aalinux.c
+@@ -1,7 +1,6 @@
+ #include "config.h"
+ #ifdef LINUX_DRIVER
+ #include <sys/stat.h>
+-#include <malloc.h>
+ #include <sys/ioctl.h>
+ #include <linux/kd.h>
+ #ifdef GPM_MOUSEDRIVER
+diff --git a/src/aamoureg.c b/src/aamoureg.c
+index 0380828..bb55fe3 100644
+--- a/src/aamoureg.c
++++ b/src/aamoureg.c
+@@ -1,4 +1,4 @@
+-#include <malloc.h>
++#include <stdlib.h>
+ #include "config.h"
+ #include "aalib.h"
+ #include "aaint.h"
+diff --git a/src/aarec.c b/src/aarec.c
+index 70f4ebc..ee43e8a 100644
+--- a/src/aarec.c
++++ b/src/aarec.c
+@@ -1,5 +1,5 @@
+ #include <string.h>
+-#include <malloc.h>
++#include <stdlib.h>
+ #include "aalib.h"
+ #include "aaint.h"
+ aa_linkedlist *aa_kbdrecommended = NULL, *aa_mouserecommended = NULL,
+diff --git a/src/aaregist.c b/src/aaregist.c
+index 54abec0..765155e 100644
+--- a/src/aaregist.c
++++ b/src/aaregist.c
+@@ -1,4 +1,4 @@
+-#include <malloc.h>
++#include <stdlib.h>
+ #include "config.h"
+ #include "aalib.h"
+ #include "aaint.h"
+diff --git a/src/aastdin.c b/src/aastdin.c
+index 696d87b..d18bd68 100644
+--- a/src/aastdin.c
++++ b/src/aastdin.c
+@@ -5,6 +5,9 @@
+ #include <setjmp.h>
+ #include <sys/time.h>
+ #include <sys/types.h>
++#ifdef _WIN32
++#include <winsock2.h>
++#endif
+ #ifdef GPM_MOUSEDRIVER
+ #include <gpm.h>
+ #endif
+@@ -88,7 +91,7 @@ static int stdin_getchar(aa_context * c1, int wait)
+     if (c > 0 && c < 127 && c != 127)
+       return (c);
+     switch (c) {
+-#ifdef KEY_MOUDE
++#ifdef KEY_MOUSE
+     case KEY_MOUSE:
+       return AA_MOUSE
+ #endif
+diff --git a/src/aax.c b/src/aax.c
+index 02797c4..d329564 100644
+--- a/src/aax.c
++++ b/src/aax.c
+@@ -1,4 +1,3 @@
+-#include <malloc.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+diff --git a/src/aaxkbd.c b/src/aaxkbd.c
+index f16afc6..c331c24 100644
+--- a/src/aaxkbd.c
++++ b/src/aaxkbd.c
+@@ -1,4 +1,3 @@
+-#include <malloc.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+diff --git a/src/aaxmouse.c b/src/aaxmouse.c
+index 9935b03..7e725ad 100644
+--- a/src/aaxmouse.c
++++ b/src/aaxmouse.c
+@@ -1,4 +1,3 @@
+-#include <malloc.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+-- 
+2.31.1
+
diff --git a/build/windows/patches/aalib-0002-configure-src-tweak-Windows-link-flags.patch 
b/build/windows/patches/aalib-0002-configure-src-tweak-Windows-link-flags.patch
new file mode 100644
index 0000000000..a01283b4e3
--- /dev/null
+++ b/build/windows/patches/aalib-0002-configure-src-tweak-Windows-link-flags.patch
@@ -0,0 +1,119 @@
+From a50637c4d5f8b91bfbd9434ad0484387282d1ae9 Mon Sep 17 00:00:00 2001
+From: Jehan <jehan girinstud io>
+Date: Sun, 16 May 2021 17:06:56 +0200
+Subject: [PATCH] configure, src: tweak Windows link flags.
+
+- libws2_32 is needed on Windows for the select() function.
+- Without flag -no-undefined, the build still succeeds but fails to
+  build the shared library and outputs:
+
+> libtool: warning: undefined symbols not allowed in x86_64-w64-mingw32 shared libraries; building static 
only
+
+Also adding some specific Windows detection code in the configure file
+and disabling some Linux-specific (apparently) paths (LINUX_DRIVER and
+LINUX_KBDDRIVER) as well as some X11 paths (X11_KBDDRIVER and
+X11_MOUSEDRIVER). I am not actually sure if these are really about
+building **for** Linux/X11 or **on** Linux/X11, especially because
+existing test on $system was actually looking at the build machine, not
+the host/target. But that may just be non-generic code which didn't
+expect cross-building (which is anyway a case where I failed to build
+without this change). For now let's just disable these code paths when
+building for Windows and not bother too much.
+---
+ configure.in    | 30 ++++++++++++++++++++++--------
+ src/Makefile.am |  7 ++++++-
+ 2 files changed, 28 insertions(+), 9 deletions(-)
+
+diff --git a/configure.in b/configure.in
+index 78806dc..27c133c 100644
+--- a/configure.in
++++ b/configure.in
+@@ -366,6 +366,9 @@ case "$target" in
+     *-*-solaris*)
+         ARCH=solaris
+       ;;
++    *-*-mingw32*)
++        ARCH=windows
++      ;;
+     *)
+         ARCH=other
+       ;;
+@@ -388,6 +391,9 @@ AC_SUBST(AALIB_LIBS)
+ AC_SUBST(AALIB_RLD_FLAGS)
+ AC_SUBST(XCURSES)
+ 
++# Windows needs some tweaking.
++AM_CONDITIONAL(PLATFORM_WIN32, test "$ARCH" = "windows")
++
+ # Set conditional variables for shared and static library selection.
+ # These are not used in any Makefile.am but in sdl-config.in.
+ AM_CONDITIONAL([ENABLE_SHARED], [test "$enable_shared" = yes])
+@@ -423,26 +429,34 @@ if test  "$curses_driver" = true; then
+ fi
+ if test  "$linux_driver_test" = yes; then
+  if test "x$system" = xLinux; then
+-   echo " Linux console"
+-   AC_DEFINE(LINUX_DRIVER)
+-   AC_DEFINE(LINUX_KBDDRIVER)
++   if test $ARCH != windows; then
++     echo " Linux console"
++     AC_DEFINE(LINUX_DRIVER)
++     AC_DEFINE(LINUX_KBDDRIVER)
++   fi
+  fi
+ fi
+ if test  "$x_driver" = true; then
+   echo " x11"
+   if test  "$x_kbddriver_test" = yes; then
+-     AC_DEFINE(X11_KBDDRIVER)
+-     x_kbddriver=true
++    if test $ARCH != windows; then
++      AC_DEFINE(X11_KBDDRIVER)
++      x_kbddriver=true
++    fi
+   fi
+   if test  "$x_mousedriver_test" = yes; then
+-     AC_DEFINE(X11_MOUSEDRIVER)
+-     x_mousedriver=true
++    if test $ARCH != windows; then
++      AC_DEFINE(X11_MOUSEDRIVER)
++      x_mousedriver=true
++    fi
+   fi
+ fi
+ echo "Keyboard drivers:"
+ if test  "$linux_driver_test" = yes; then
+  if test "x$system" = xLinux; then
+-   echo " Linux console"
++   if test $ARCH != windows; then
++     echo " Linux console"
++   fi
+  fi
+ fi
+ if test  "$slang_kbddriver" = true; then
+diff --git a/src/Makefile.am b/src/Makefile.am
+index ad23666..3d63dc0 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -1,4 +1,9 @@
+ AUTOMAKE_OPTIONS = foreign #include-deps
++
++if PLATFORM_WIN32
++libaa_ldflags = -no-undefined -lws2_32
++endif
++
+ EXTRA_DIST = config.dos config.os2 Makefile.dos Makefile.os2 aados.c aadoskbd.c aadosmou.c aaos2.c  
aaos2kbd.c aaos2mou.c  aaint.h aamktabl.h aaxint.h toc.c
+ lib_LTLIBRARIES=libaa.la
+ libaa_la_SOURCES= \
+@@ -57,7 +62,7 @@ libaa_la_SOURCES= \
+        aaattrs.c \
+        aaputpixel.c \
+        aarecfunc.c 
+-libaa_la_LDFLAGS=@LDFLAGS@ -version-info 1:4:0
++libaa_la_LDFLAGS=@LDFLAGS@ -version-info 1:4:0 $(libaa_ldflags)
+ bin_PROGRAMS=aainfo aatest aafire aasavefont
+ 
+ aainfo_LDADD= libaa.la
+-- 
+2.31.1
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]