autoconf: Configurable demos directories
authorDan Nicholson <dbn.lists@gmail.com>
Thu, 15 Nov 2007 16:59:57 +0000 (08:59 -0800)
committerDan Nicholson <dbn.lists@gmail.com>
Fri, 7 Dec 2007 22:34:27 +0000 (14:34 -0800)
The user can request specific demos directories to build in. For
example:

    ./configure --with-demos="demos,xdemos"

The drawback is that we don't check for the necessary libararies in
that case, only that the directory in progs/ exists.

configure.ac

index db6a7850a46d28577eab4bed9296bdb23c38ecad..32fdf480c5a63dc66863363292235f541dc87e26 100644 (file)
@@ -129,6 +129,39 @@ AC_SUBST(GLU_DIRS)
 AC_SUBST(DRIVER_DIRS)
 AC_SUBST(WINDOW_SYSTEM)
 
+dnl
+dnl User supplied program configuration
+dnl
+if test -d "$srcdir/progs/demos"; then
+    default_demos=yes
+else
+    default_demos=no
+fi
+AC_ARG_WITH(demos,
+    [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
+        [optional comma delimited demo directories to build
+        @<:@default=yes if source available@:>@])],
+    with_demos="$withval",
+    with_demos="$default_demos")
+if test "x$with_demos" = x; then
+    with_demos=no
+fi
+
+dnl If $with_demos is yes, directories will be added as libs available
+PROGRAM_DIRS=""
+case "$with_demos" in
+no|yes) ;;
+*)
+    # verify the requested demos directories exist
+    demos=`IFS=,; echo $with_demos`
+    for demo in $demos; do
+        test -d "$srcdir/progs/$demo" || \
+            AC_MSG_ERROR([Program directory '$demo' doesn't exist])
+    done
+    PROGRAM_DIRS="$demos"
+    ;;
+esac
+
 dnl
 dnl Find out if X is available. The variables have_x or no_x will be
 dnl set and used later in the driver setups
@@ -381,7 +414,7 @@ if test "x$enable_glu" = xyes; then
     osmesa)
         # If GLU is available and we have libOSMesa (not 16 or 32),
         # we can build the osdemos
-        if test "$osmesa_bits" = 8; then
+        if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
             PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
         fi
 
@@ -391,7 +424,9 @@ if test "x$enable_glu" = xyes; then
         ;;
     *)
         # If GLU is available, we can build the xdemos
-        PROGRAM_DIRS="$PROGRAM_DIRS xdemos"
+        if test "$with_demos" = yes; then
+            PROGRAM_DIRS="$PROGRAM_DIRS xdemos"
+        fi
 
         GLU_LIB_DEPS="-lm"
         GLU_MESA_DEPS='-l$(GL_LIB)'
@@ -470,7 +505,9 @@ if test "x$enable_glut" = xyes; then
     GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
 
     # If glut is available, we can build most programs
-    PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
+    if test "$with_demos" = yes; then
+        PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
+    fi
 
     GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
 fi