From f2cf4e428bee937b6b9ac843ccdeea5ab562650c Mon Sep 17 00:00:00 2001
From: Mathieu L Bouchard <matju@artengine.ca>
Date: Sat, 2 Aug 2014 15:44:26 -0400
Subject: [PATCH] introducing --enable-qt, QTGUI makefile var, #define QTGUI,
 -qtcanvas, sys_qtcanvas.

---
 pd/src/configure.in | 11 +++++++++++
 pd/src/makefile.in  |  2 ++
 pd/src/s_main.c     | 18 +++++++++++++++---
 pd/src/s_stuff.h    |  3 +++
 4 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/pd/src/configure.in b/pd/src/configure.in
index b378e0761..edc36d78e 100644
--- a/pd/src/configure.in
+++ b/pd/src/configure.in
@@ -10,6 +10,7 @@ AC_SUBST(portmidi, no)
 AC_SUBST(binarymode, -m755)
 AC_SUBST(fftw, no)
 AC_SUBST(tk, yes)
+AC_SUBST(qt, yes)
 AC_SUBST(PDLIB)
 AC_SUBST(CPPFLAGS)
 AC_SUBST(MORECFLAGS)
@@ -51,6 +52,8 @@ AC_ARG_ENABLE(fat,      [  --disable-fat           build fat binary on Mac OS X]
     fat=$enableval, fat="yes")
 AC_ARG_ENABLE(tk,       [  --disable-tk            build without tcl/tk-GUI],
     tk=$enableval)
+AC_ARG_ENABLE(qt,       [  --enable-qt             build with Qt (not implemented)],
+    qt=$enableval)
 
 dnl Checks for programs.
 AC_PROG_CC
@@ -452,6 +455,14 @@ AC_TRY_LINK( [
 fi
 ## }JMZ: end of large-file support section
 
+
+if test x$qt != "xno"; then
+dnl Some kind of AC_CHECK_HEADER should go here.
+dnl Some kind of AC_CHECK_LIB    should go here.
+CPPFLAGS=$CPPFLAGS" -DQTGUI"
+fi
+
+
 if test -d ../obj
 then echo -n
 else mkdir ../obj
diff --git a/pd/src/makefile.in b/pd/src/makefile.in
index e42b6c996..f2e39f567 100644
--- a/pd/src/makefile.in
+++ b/pd/src/makefile.in
@@ -46,6 +46,8 @@ ARCH_CFLAGS = -DPD
 
 CFLAGS = @CFLAGS@ $(ARCH_CFLAGS) $(WARN_CFLAGS) $(CPPFLAGS) $(MORECFLAGS)
 
+QTGUI = @qt@
+
 # the sources
 
 SYSSRC += @SYSSRC@
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index b53a1ab9f..8b9532801 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -13,8 +13,6 @@
 #include <fcntl.h>
 #include <stdlib.h>
 
-#define UNISTD
-
 #ifdef UNISTD
 #include <unistd.h>
 #endif
@@ -54,6 +52,11 @@ int sys_console = 0;    /* default settings for the console is off */
 int sys_k12_mode = 0;   /* by default k12 mode is off */
 int sys_unique = 0;     /* by default off, prevents multiple instances
                            of pd-l2ork */
+
+#ifdef QTGUI
+int sys_qtcanvas = 0; /* enable Qt */
+#endif
+
 char *sys_guicmd;
 t_symbol *sys_libdir;
 t_symbol *sys_guidir;
@@ -447,7 +450,7 @@ static char *(usagemessage[]) = {
 };
 
 #ifdef QTGUI
-//   -nogui applies only to Tk until further notice.
+//   -nogui applies only to Tk.
 //   -qtcanvas should open a Qt window for every pd canvas (two toolkits at once)
 //   more options could go here, to enable a Qt main window, menus, dialogues.
 //   those are transitory options, until Tk is removed, at which point
@@ -476,6 +479,7 @@ static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
     *np = n;
 }
 
+/*
 static int sys_getmultidevchannels(int n, int *devlist)
 {
     int sum = 0;
@@ -484,6 +488,7 @@ static int sys_getmultidevchannels(int n, int *devlist)
     while(n--)sum+=*devlist++;
     return sum;
 }
+*/
 
 
     /* this routine tries to figure out where to find the auxilliary files
@@ -871,6 +876,13 @@ int sys_argparse(int argc, char **argv)
             sys_guicmd = argv[1];
             argc -= 2; argv += 2;
         }
+#ifdef QTGUI
+        else if (!strcmp(*argv, "-qtcanvas"))
+		{
+			sys_qtcanvas = 1;
+			argc--; argv++;
+		}
+#endif
         else if (!strcmp(*argv, "-send") && argc > 1)
         {
             sys_messagelist = namelist_append(sys_messagelist, argv[1], 1);
diff --git a/pd/src/s_stuff.h b/pd/src/s_stuff.h
index 565af95f5..862b2a44c 100644
--- a/pd/src/s_stuff.h
+++ b/pd/src/s_stuff.h
@@ -47,6 +47,9 @@ extern int sys_verbose;
 extern int sys_noloadbang;
 extern int sys_nogui;
 extern char *sys_guicmd;
+#ifdef QTGUI
+extern int sys_qtcanvas;
+#endif
 
 EXTERN int sys_nearestfontsize(int fontsize);
 EXTERN int sys_hostfontsize(int fontsize);
-- 
GitLab