From 57765f0bfb9d456abf5f7251ca18b9c42874347b Mon Sep 17 00:00:00 2001
From: Bent Bisballe Nyeng <deva@aasimon.org>
Date: Sat, 25 Jan 2014 20:16:34 +0100
Subject: Choose GUI backend in configure script.

---
 configure.ac                    | 91 ++++++++++++++++++++++++++++++++++++-----
 lv2/Makefile.am                 |  2 +-
 plugingui/Makefile.am.plugingui |  4 +-
 3 files changed, 83 insertions(+), 14 deletions(-)

diff --git a/configure.ac b/configure.ac
index fdabdbf..79d81c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,12 +36,86 @@ if test x$with_experimental == xyes; then
     CXXFLAGS="$CXXFLAGS -DEXPERIMENTAL"
 fi 
 
-AC_ARG_ENABLE(pugl,  [  --enable-pugl             Build with Pugl support])
-if test x$enable_pugl == xyes; then
-    AC_MSG_WARN([*** Building with pugl support!])
-    CXXFLAGS="$CXXFLAGS -DPUGL -lGL -lGLU -lglut"
-fi 
-AM_CONDITIONAL([ENABLE_PUGL], [test "x$enable_pugl" = "xyes"])
+#AC_ARG_ENABLE(pugl,  [  --enable-pugl             Build with Pugl support])
+#if test x$enable_pugl == xyes; then
+#    AC_MSG_WARN([*** Building with pugl support!])
+#    CXXFLAGS="$CXXFLAGS -DPUGL -lGL -lGLU -lglut"
+#fi 
+#AM_CONDITIONAL([ENABLE_PUGL], [test "x$enable_pugl" = "xyes"])
+
+dnl ===========================
+dnl Check for GUI backend
+dnl ===========================
+AC_CANONICAL_HOST
+AC_ARG_ENABLE([gui],
+[  --enable-gui[=backend]   Use specified gui backend. Can be win32, x11, pugl or auto [default=auto]],,
+        [enable_gui="auto"])
+
+if test "x$enable_gui" = "xyes"; then
+  enable_gui="auto"
+fi
+
+if test "x$enable_gui" = "xauto"; then
+  AC_MSG_RESULT([Auto setting gui $host_os])
+  case $host_os in
+    darwin* )
+					enable_gui=""					
+          ;;
+    linux*|*BSD*)
+					enable_gui="x11"
+          ;;
+    mingw*|windows*|winnt)
+					enable_gui="win32"
+          ;;
+		*)
+          AC_MSG_ERROR([Your platform is not currently supported])
+          ;;
+  esac
+fi
+
+if test "x$enable_gui" = "xx11"; then
+  AC_MSG_RESULT([Setting gui backend to X11])
+
+	dnl ======================
+  dnl Check for Xlib
+  dnl ======================
+  PKG_CHECK_MODULES(X11, x11 >= 1.0)
+
+  GUI_CFLAGS="-DX11 $X11_CFLAGS"
+  GUI_LDFLAGS="$X11_LIBS"
+
+elif test "x$enable_gui" = "win32"; then
+
+  AC_MSG_RESULT([Setting gui backend to Win32])
+  GUI_CFLAGS="-DWIN32"
+  GUI_LDFLAGS="-lgdi32 -lsetupapi -lws2_32"
+
+elif test "x$enable_gui" = "xpugl"; then
+
+  AC_MSG_RESULT([Setting gui backend to Pugl])
+  GUI_CFLAGS="-DPUGL"
+  GUI_LDFLAGS="-lGLU -lGL -lglut"
+
+else 
+  AC_MSG_ERROR([*** No GUI backend has been selected ***])
+fi
+
+AC_SUBST(GUI_CFLAGS)
+AC_SUBST(GUI_LIBS)
+
+AM_CONDITIONAL([ENABLE_PUGL], [test "x$enable_gui" = "xpugl"])
+
+
+
+
+
+
+
+
+
+
+
+
 
 AC_ARG_WITH(test,  [  --with-test             Build unit tests])
 if test x$with_test == xyes; then
@@ -62,11 +136,6 @@ if test "x$enable_lv2" = "xyes"; then
    dnl Check for lv2core
    dnl ======================
    PKG_CHECK_MODULES(LV2, lv2 >= 1.0)
-
-   dnl ======================
-   dnl Check for Xlib
-   dnl ======================
-   PKG_CHECK_MODULES(X11, x11 >= 1.0)
 else
 	 AC_MSG_RESULT([*** LV2 plugin will not be compiled ***])
    enable_lv2=no
diff --git a/lv2/Makefile.am b/lv2/Makefile.am
index a91b1c5..a714dce 100644
--- a/lv2/Makefile.am
+++ b/lv2/Makefile.am
@@ -6,7 +6,7 @@ include $(top_srcdir)/src/Makefile.am.drumgizmo
 AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/plugingui \
 	-I$(top_srcdir)/include $(SNDFILE_CXXFLAGS) \
 	$(PTHREAD_CFLAGS) $(EXPAT_CFLAGS) $(LV2_CFLAGS) \
-	$(PLUGIN_GUI_CFLAGS) -DX11 $(SSEFLAGS)\
+	$(PLUGIN_GUI_CFLAGS) $(SSEFLAGS)\
 	-DUSE_THREAD $(SAMPLERATE_CFLAGS)
 
 plugindir = $(prefix)/lib/lv2/drumgizmo.lv2
diff --git a/plugingui/Makefile.am.plugingui b/plugingui/Makefile.am.plugingui
index 1c95310..8985d1f 100644
--- a/plugingui/Makefile.am.plugingui
+++ b/plugingui/Makefile.am.plugingui
@@ -39,6 +39,6 @@ PLUGIN_GUI_SOURCES = \
 	$(top_srcdir)/plugingui/resource.cc \
 	$(top_srcdir)/plugingui/resource_data.cc
 
-PLUGIN_GUI_LIBS = $(X11_LIBS) $(PTHREAD_LIBS) $(PNG_LIBS) $(ZLIB_LIBS)
+PLUGIN_GUI_LIBS = $(GUI_LIBS) $(PTHREAD_LIBS) $(PNG_LIBS) $(ZLIB_LIBS)
 
-PLUGIN_GUI_CFLAGS = $(X11_CFLAGS) $(PNG_CFLAGS) $(ZLIB_CFLAGS) -I$(top_srcdir)/hugin -DWITH_HUG_SYSLOG -DWITH_HUG_MUTEX $(PTHREAD_CFLAGS) -I$(top_srcdir)/pugl/pugl
+PLUGIN_GUI_CFLAGS = $(GUI_CFLAGS) $(PNG_CFLAGS) $(ZLIB_CFLAGS) -I$(top_srcdir)/hugin -DWITH_HUG_SYSLOG -DWITH_HUG_MUTEX $(PTHREAD_CFLAGS) -I$(top_srcdir)/pugl/pugl
-- 
cgit v1.2.3