From ad7a8da887fdf3e68b2d8a77108ae2cd60f44f4b Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Fri, 23 Oct 2020 12:19:12 +0200
Subject: [PATCH] [build] assdraw compiles but SIGSEV at runtime...

---
 .gitignore       |  1 +
 Makefile.inc.in  |  2 +-
 assdraw/Makefile |  2 +-
 configure.ac     | 25 ++++++++++++++++---------
 4 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/.gitignore b/.gitignore
index e8a873187..b8b559509 100644
--- a/.gitignore
+++ b/.gitignore
@@ -68,6 +68,7 @@ packages/desktop/aegisub.desktop
 packages/desktop/aegisub.desktop.template
 packages/win_installer/vendor
 src/aegisub
+assdraw/assdraw
 Aegisub/
 src/libresrc/bitmap.cpp
 src/libresrc/bitmap.h
diff --git a/Makefile.inc.in b/Makefile.inc.in
index e5f3ad51a..abdb55d88 100644
--- a/Makefile.inc.in
+++ b/Makefile.inc.in
@@ -15,7 +15,7 @@ SYSTEM_LUAJIT   = @with_system_luajit@
 # BUILD OUTPUT
 ##############
 PROGRAM := $(PROGRAM)
-LIB := $(LIB)
+LIB     := $(LIB)
 
 ###################
 # PLATFORM SETTINGS
diff --git a/assdraw/Makefile b/assdraw/Makefile
index e5c66c448..bc727458f 100644
--- a/assdraw/Makefile
+++ b/assdraw/Makefile
@@ -38,7 +38,7 @@ assdraw_SOURCES := \
 	$(d)library.cpp \
 	$(d)settings.cpp
 
-assdraw_CPPFLAGS := -I$(d)
+assdraw_CPPFLAGS := -I$(d) $(WX_CPPFLAGS)
 assdraw_CXXFLAGS := $(CXXFLAGS_WX)
 assdraw_OBJ      := $(assdraw_SOURCES:.cpp=.o)
 assdraw_LIBS     := $(LIBS_WX) $(LIBS_AGG)
diff --git a/configure.ac b/configure.ac
index 4dc7923b8..f4cde0e48 100644
--- a/configure.ac
+++ b/configure.ac
@@ -346,6 +346,7 @@ AS_IF([test x$agi_cv_with_iconv_const = xyes],
 ######
 ## agg
 ######
+build_assdraw="no"
 if test "x$build_linux" = "xyes"
 then
     AC_CHECK_HEADERS([agg2/agg_config.h], [], [not_found_agg="yes"], [
@@ -357,6 +358,7 @@ then
         AC_MSG_ERROR([con't find agg2, it's needed to compile assdraw])
     ], [
         AC_MSG_NOTICE([agg2 was found, will compile assdraw])
+        build_assdraw="yes"
     ])
     AGG_LIBS=${AGG_LIBS:--lagg}
     AC_SUBST(AGG_LIBS)
@@ -538,29 +540,34 @@ AS_IF([test x$enable_debug_exceptions = xyes],
 ################
 # Widget support
 ################
+WX_REQUIRED_CHECKS="std,gl,stc"
+if test x$build_assdraw = xyes
+then
+    WX_REQUIRED_CHECKS="${WX_REQUIRED_CHECKS},aui,propgrid"
+fi
 WX_CONFIG_OPTIONS
 WX_STANDARD_OPTIONS([debug])
 WX_DEBUG=$DEBUG
 WX_UNICODE=$UNICODE
-WX_CONFIG_CHECK([wx_required_version],,,[std,gl,stc],[$WXCONFIG_FLAGS])
+WX_CONFIG_CHECK([wx_required_version],,,[$WX_REQUIRED_CHECKS],[$WXCONFIG_FLAGS])
 AC_SUBST(WX_CONFIG_PATH)
 
 AS_IF([test x$WX_VERSION = x],
-  [AC_MSG_FAILURE([wxWidgets detection failed, please set --with-wx* or add the libraries to your LIBS, CXX/CFLAGS.])])
+    [AC_MSG_FAILURE([wxWidgets detection failed, please set --with-wx* or add the libraries to your LIBS, CXX/CFLAGS.])])
 
 AS_IF([test x$enable_sanity_checks != xno], [
-  AC_AGI_LINK([wxWidgets OpenGL support], [wxopengl], [wx/glcanvas.h], [$GL_CFLAGS $WX_CFLAGS], [$GL_LIBS $WX_LIBS],[
+    AC_AGI_LINK([wxWidgets OpenGL support], [wxopengl], [wx/glcanvas.h], [$GL_CFLAGS $WX_CFLAGS], [$GL_LIBS $WX_LIBS],[
 #include <wx/glcanvas.h>
 int main(void) {
-  wxGLCanvas *canvas;
-  wxGLContext *context;
-  return 0;
+    wxGLCanvas *canvas;
+    wxGLContext *context;
+    return 0;
 } ])
-  AC_AGI_LINK([wxWidgets StyledTextCtrl support], [wxstc], [wx/stc/stc.h], [$WX_CFLAGS], [$WX_LIBS],[
+    AC_AGI_LINK([wxWidgets StyledTextCtrl support], [wxstc], [wx/stc/stc.h], [$WX_CFLAGS], [$WX_LIBS],[
 #include <wx/stc/stc.h>
 int main(void) {
-  wxStyledTextCtrl *canvas;
-  return 0;
+    wxStyledTextCtrl *canvas;
+    return 0;
 } ])
 ])
 
-- 
GitLab