From 1b04b3273c099abf87504de85d411530b31f10b8 Mon Sep 17 00:00:00 2001
From: Patrick Welche <prlw1@cam.ac.uk>
Date: Mon, 19 Nov 2012 12:34:49 +0000
Subject: [PATCH] Add --disable-fltk switch to configure

Make it possible to build octave without FLTK support even if FLTK
is installed.
---
 configure.ac | 112 +++++++++++++++++++++++++++++++----------------------------
 1 file changed, 59 insertions(+), 53 deletions(-)

diff --git a/configure.ac b/configure.ac
index ea1772b..e0ffdf9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -876,69 +876,75 @@ if test -n "$OPENGL_LIBS"; then
 
   ## fltk (www.fltk.org)
 
-  AC_ARG_WITH([fltk-prefix], [
-    AS_HELP_STRING([--with-fltk-prefix=PFX],
-      [Prefix where FLTK is installed (optional)])], [
-    fltk_prefix="$withval"], [
-    fltk_prefix=""])
-
-  AC_ARG_WITH([fltk-exec-prefix], [
-    AS_HELP_STRING([--with-fltk-exec-prefix=PFX],
-      [Exec prefix where FLTK is installed (optional)])], [
-    fltk_exec_prefix="$withval"], [
-    fltk_exec_prefix=""])
-
-  if test -n "$fltk_exec_prefix"; then
-    fltk_args="$fltk_args --exec-prefix=$fltk_exec_prefix"
-    if test "x${FLTK_CONFIG+set}" != xset ; then
-      FLTK_CONFIG="$fltk_exec_prefix/bin/fltk-config"
+  AC_ARG_ENABLE([fltk], [
+    AS_HELP_STRING([--disable-fltk], [Disable use of FLTK])])
+
+  AS_IF([test $enable_fltk != no], [
+
+    AC_ARG_WITH([fltk-prefix], [
+      AS_HELP_STRING([--with-fltk-prefix=PFX],
+        [Prefix where FLTK is installed (optional)])], [
+      fltk_prefix="$withval"], [
+      fltk_prefix=""])
+
+    AC_ARG_WITH([fltk-exec-prefix], [
+      AS_HELP_STRING([--with-fltk-exec-prefix=PFX],
+        [Exec prefix where FLTK is installed (optional)])], [
+      fltk_exec_prefix="$withval"], [
+      fltk_exec_prefix=""])
+
+    if test -n "$fltk_exec_prefix"; then
+      fltk_args="$fltk_args --exec-prefix=$fltk_exec_prefix"
+      if test "x${FLTK_CONFIG+set}" != xset ; then
+        FLTK_CONFIG="$fltk_exec_prefix/bin/fltk-config"
+      fi
     fi
-  fi
 
-  if test -n "$fltk_prefix"; then
-    fltk_args="$fltk_args --prefix=$fltk_prefix"
-    if test x${FLTK_CONFIG+set} != xset ; then
-      FLTK_CONFIG="$fltk_prefix/bin/fltk-config"
+    if test -n "$fltk_prefix"; then
+      fltk_args="$fltk_args --prefix=$fltk_prefix"
+      if test x${FLTK_CONFIG+set} != xset ; then
+        FLTK_CONFIG="$fltk_prefix/bin/fltk-config"
+      fi
     fi
-  fi
 
-  AC_PATH_PROG([FLTK_CONFIG], [fltk-config], [no])
+    AC_PATH_PROG([FLTK_CONFIG], [fltk-config], [no])
 
-  warn_fltk_config=""
-  warn_fltk_opengl=""
+    warn_fltk_config=""
+    warn_fltk_opengl=""
 
-  if test "$FLTK_CONFIG" = "no" ; then
-    warn_fltk_config="FLTK config script not found.  Native graphics will be disabled."
-  else
-    FLTK_CFLAGS="`$FLTK_CONFIG $fltkconf_args --use-gl --cflags`"
-    FLTK_LDFLAGS="`$FLTK_CONFIG $fltkconf_args --use-gl --ldflags`"
+    if test "$FLTK_CONFIG" = "no" ; then
+      warn_fltk_config="FLTK config script not found.  Native graphics will be disabled."
+    else
+      FLTK_CFLAGS="`$FLTK_CONFIG $fltkconf_args --use-gl --cflags`"
+      FLTK_LDFLAGS="`$FLTK_CONFIG $fltkconf_args --use-gl --ldflags`"
 
-    case "$canonical_host_type" in
-      *-*-mingw*)
-        FLTK_LDFLAGS="`echo $FLTK_LDFLAGS | sed -e 's/-mwindows//g'`"
-      ;;
-    esac
+      case "$canonical_host_type" in
+        *-*-mingw*)
+          FLTK_LDFLAGS="`echo $FLTK_LDFLAGS | sed -e 's/-mwindows//g'`"
+        ;;
+      esac
 
-    AC_MSG_CHECKING([for OpenGL support in FLTK])
-    save_CFLAGS="$CFLAGS"
-    CFLAGS="$CFLAGS $FLTK_CFLAGS"
-    AC_COMPILE_IFELSE(
-      [AC_LANG_PROGRAM([[#include <FL/gl.h>]], [[int nothing = 0;]])],
-        [
-         AC_MSG_RESULT([no])
-         warn_fltk_opengl="FLTK does not have OpenGL support.  Native graphics will be disabled."
-        ],[
-         AC_DEFINE(HAVE_FLTK, 1, [Define if FLTK is available])
-         AC_MSG_RESULT([yes])
-        ])
-         
-    if test -z "$warn_fltk_opengl"; then
-      GRAPHICS_CFLAGS="$FLTK_CFLAGS"
-      GRAPHICS_LIBS="$FLTK_LDFLAGS"
+      AC_MSG_CHECKING([for OpenGL support in FLTK])
+      save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS $FLTK_CFLAGS"
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([[#include <FL/gl.h>]], [[int nothing = 0;]])],
+          [
+           AC_MSG_RESULT([no])
+           warn_fltk_opengl="FLTK does not have OpenGL support.  Native graphics will be disabled."
+          ],[
+           AC_DEFINE(HAVE_FLTK, 1, [Define if FLTK is available])
+           AC_MSG_RESULT([yes])
+          ])
+
+      if test -z "$warn_fltk_opengl"; then
+        GRAPHICS_CFLAGS="$FLTK_CFLAGS"
+        GRAPHICS_LIBS="$FLTK_LDFLAGS"
+      fi
+      CFLAGS="$save_CFLAGS"
     fi
-    CFLAGS="$save_CFLAGS"
   fi
-fi
+]) # AS_IF enable fltk
 
 AC_SUBST(GRAPHICS_CFLAGS)
 AC_SUBST(GRAPHICS_LIBS)
-- 
1.7.12.2

