Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /configure.ac [85cf30] .. [9e9fb5] Maximize Restore

  Switch to side-by-side view

--- a/configure.ac
+++ b/configure.ac
@@ -9,32 +9,53 @@
 CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
 CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
 
+# Guess the installation prefix from location of the jags executable
+
 AC_PREFIX_PROGRAM(jags)
 
-#Set optional include path with option --with-jags-include or
-#environment variable JAGS_INCLUDE
+# For installations in a non-standard location, set the prefix
+# manually, using either option --with-jags-prefix or environment
+# variable JAGS_PREFIX. Otherwise we accept the guess from
+# AC_PREFIX_PROGRAM.
 
-AC_ARG_WITH([jags-include],
-            AC_HELP_STRING([--with-jags-include=INCLUDE_PATH],
-                           [the location of JAGS header files]),
-            [jags_include_path=$withval])
-if test [ -n "$jags_include_path" ] ; then
-   JAGS_INCLUDE=${jags_include_path}
+AC_ARG_WITH([jags-prefix],
+            AC_HELP_STRING([--with-jags-prefix=PREFIX_PATH],
+                           [the prefix used when installing JAGS]),
+            [jags_prefix_path=$withval])
+if test [ -n "$jags_prefix_path" ] ; then
+   JAGS_PREFIX=${jags_prefix_path}
 else
-   if test [ -z "${JAGS_INCLUDE}" ] ; then
+   if test [ -z "${JAGS_PREFIX}" ] ; then
       if test [ "$prefix" = "NONE" ]; then
-         AC_MSG_ERROR("Location of JAGS headers not defined. Use configure arg '--with-jags-include' or environment variable 'JAGS_INCLUDE'")
+         AC_MSG_ERROR("Cannot find JAGS installation. See the file README for help.")
       else
-         JAGS_INCLUDE=${prefix}/include/JAGS
+         JAGS_PREFIX=${prefix}
       fi
    fi
 fi
 
+# Set include path with option --with-jags-includedir or environment
+# variable JAGS_INCLUDEDIR. By default, this is determined from
+# JAGS_PREFIX.
+
+AC_ARG_WITH([jags-includedir],
+            AC_HELP_STRING([--with-jags-includedir=INCLUDE_PATH],
+                           [the location of JAGS header files]),
+            [jags_include_path=$withval])
+if test [ -n "$jags_include_path" ] ; then
+   JAGS_INCLUDEDIR=${jags_include_path}
+else
+   if test [ -z "${JAGS_INCLUDEDIR}" ] ; then
+      JAGS_INCLUDEDIR=${JAGS_PREFIX}/include
+   fi
+fi
+JAGS_PKGINCLUDEDIR=${JAGS_INCLUDEDIR}/JAGS
+
 AC_LANG_PUSH(C++)
 OCPPFLAGS=${CPPFLAGS}
-CPPFLAGS=-I${JAGS_INCLUDE}
+CPPFLAGS=-I${JAGS_PKGINCLUDEDIR}
 AC_CHECK_HEADER(Console.h, [],
-             [AC_MSG_FAILURE("Problem with header file ${JAGS_INCLUDE}/Console.h ")])
+             [AC_MSG_FAILURE("Cannot find header file ${JAGS_PKGINCLUDEDIR}/Console.h ")])
 CPPFLAGS=${OCPPFLAGS}
 AC_LANG_POP()
 
@@ -42,7 +63,7 @@
 # There is no consensus on where 64- versus 32-bit libraries should be
 # installed.  We take a hint from R, assuming that if R is installed
 # in, say, /usr/LIBnn/R then we can find the jags library in
-# ${prefix}/LIBnn.
+# ${JAGS_PREFIX}/LIBnn.
 #
 # This is a reasonable assumption if both JAGS and R have been
 # properly packaged, but may not be true if either has been manually
@@ -53,24 +74,26 @@
    LIBnn=`"${R_HOME}/bin/R" CMD config LIBnn`
 fi
 
-#Set optional library path with option --with-jags-lib or
-#environment variable JAGS_LIBS
+# Set optional library path with option --with-jags-libdir or
+# environment variable JAGS_LIBDIR. By default this is determined by
+# JAGS_PREFIX and LIBnn.
 
-AC_ARG_WITH([jags-lib],
-            AC_HELP_STRING([--with-jags-lib=LIB_PATH],
+AC_ARG_WITH([jags-libdir],
+            AC_HELP_STRING([--with-jags-libdir=LIB_PATH],
                            [the location of the JAGS library]),
             [jags_lib_path=$withval])
 if test [ -n "$jags_lib_path" ] ; then
-   JAGS_LIB=$jags_lib_path
+   JAGS_LIBDIR=$jags_lib_path
 else
-   if test [ -z "${JAGS_LIB}" ] ; then
-      if test [ "${prefix}" = "NONE" ] ; then 
-         AC_MSG_ERROR("Location of JAGS library not defined. Use configure arg '--with-jags-lib' or environment variable 'JAGS_LIB'")
-      else
-         JAGS_LIB=${prefix}/${LIBnn}
-      fi
+   if test [ -z "${JAGS_LIBDIR}" ] ; then
+      JAGS_LIBDIR=${JAGS_PREFIX}/${LIBnn}
    fi
 fi
+
+
+# Set location of modules
+
+JAGS_MODDIR=${JAGS_LIBDIR}/JAGS/modules-${PACKAGE_VERSION}
 
 # Support for private installations of JAGS. If the jags library is not
 # on the linker path then it helps to hard-code the location of JAGS into
@@ -80,39 +103,21 @@
             AC_HELP_STRING([--enable-rpath],
                            [Hard link the location of the JAGS library]))
 if test [ "x$enable_rpath" = "xyes"]; then
-   JAGS_RPATH="-Wl,-rpath ${JAGS_LIB}"
+   JAGS_RPATH="-Wl,-rpath ${JAGS_LIBDIR}"
 fi
 
 OLDFLAGS=${LDFLAGS}
 AC_LANG_PUSH(C)
-LDFLAGS="-L${JAGS_LIB}"
+LDFLAGS="-L${JAGS_LIBDIR}"
 AC_CHECK_LIB(jags, jags_version, [],
-             [AC_MSG_ERROR("Cannot load JAGS library in ${JAGS_LIB}")])
+             [AC_MSG_ERROR("Cannot load JAGS library in ${JAGS_LIBDIR}")])
 
 AC_LANG_POP()
 LDFLAGS=${OLDFLAGS}
 
-#Finally, set optional module directory using --with-jags-modules or
-#environment variable JAGS_MODULES
-
-AC_ARG_WITH([jags-modules],
-            AC_HELP_STRING([--with-jags-modules=MOD_PATH],
-                           [the location of the JAGS modules]),
-            [jags_mod_path=$withval])
-if test [ -n "$jags_mod_path" ] ; then
-   JAGS_MODULES=$jags_mod_path
-else
-   if test [ -z "${JAGS_MODULES}" ] ; then
-      JAGS_MODULES=${JAGS_LIB}/JAGS/modules-${PACKAGE_VERSION}
-      if test [! -d ${JAGS_MODULES} ]; then
-         AC_MSG_ERROR("JAGS module directory ${JAGS_MODULES} does not exist.")
-      fi
-   fi
-fi
-
-AC_SUBST(JAGS_INCLUDE)
-AC_SUBST(JAGS_LIB)
-AC_SUBST(JAGS_MODULES)
+AC_SUBST(JAGS_PKGINCLUDEDIR)
+AC_SUBST(JAGS_LIBDIR)
+AC_SUBST(JAGS_MODDIR)
 AC_SUBST(JAGS_RPATH)
 
 AC_OUTPUT(src/Makevars)