changeset 1317:e12cef71aa1a

Karn Kallio's patch for static mhash linking
author Adam Chlipala <adam@chlipala.net>
date Thu, 18 Nov 2010 14:22:04 -0500
parents df7bfb30dcc3
children e2f803080934
files Makefile.in config.h.in configure configure.ac src/c/Makefile.in src/compiler.sml src/config.sig src/config.sml.in
diffstat 8 files changed, 72 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Sat Nov 13 14:38:06 2010 -0500
+++ b/Makefile.in	Thu Nov 18 14:22:04 2010 -0500
@@ -146,6 +146,7 @@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MHASH_LIB_DIR = @MHASH_LIB_DIR@
 MKDIR_P = @MKDIR_P@
 MLLEX = @MLLEX@
 MLTON := mlton
--- a/config.h.in	Sat Nov 13 14:38:06 2010 -0500
+++ b/config.h.in	Thu Nov 18 14:22:04 2010 -0500
@@ -6,9 +6,6 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the `mhash' library (-lmhash). */
-#undef HAVE_LIBMHASH
-
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
--- a/configure	Sat Nov 13 14:38:06 2010 -0500
+++ b/configure	Thu Nov 18 14:22:04 2010 -0500
@@ -743,6 +743,7 @@
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+MHASH_LIB_DIR
 GCCARGS
 SITELISP
 INCLUDE
@@ -866,6 +867,7 @@
 enable_fast_install
 with_gnu_ld
 enable_libtool_lock
+with_mhash_dir
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1510,6 +1512,7 @@
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-mhash-dir=DIR    mhash directory; default = /usr
 
 Some influential environment variables:
   CC          C compiler command
@@ -5326,13 +5329,13 @@
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:5329: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:5332: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5332: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:5335: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5335: output\"" >&5)
+  (eval echo "\"\$as_me:5338: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -6537,7 +6540,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 6540 "configure"' > conftest.$ac_ext
+  echo '#line 6543 "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7799,11 +7802,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7802: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7805: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7806: \$? = $ac_status" >&5
+   echo "$as_me:7809: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8138,11 +8141,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8141: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8144: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8145: \$? = $ac_status" >&5
+   echo "$as_me:8148: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8243,11 +8246,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8246: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8249: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8250: \$? = $ac_status" >&5
+   echo "$as_me:8253: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8298,11 +8301,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8301: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8304: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8305: \$? = $ac_status" >&5
+   echo "$as_me:8308: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -10682,7 +10685,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10685 "configure"
+#line 10688 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10778,7 +10781,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10781 "configure"
+#line 10784 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11009,6 +11012,17 @@
 ac_config_headers="$ac_config_headers config.h"
 
 
+
+# Check whether --with-mhash-dir was given.
+if test "${with_mhash_dir+set}" = set; then :
+  withval=$with_mhash_dir; with_mhash_dir="$withval"
+else
+  with_mhash_dir="/usr"
+fi
+
+
+LIBS_save="$LIBS"
+LIBS="-L${with_mhash_dir}/lib/ -lmhash"
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mhash_get_block_size in -lmhash" >&5
 $as_echo_n "checking for mhash_get_block_size in -lmhash... " >&6; }
 if test "${ac_cv_lib_mhash_mhash_get_block_size+set}" = set; then :
@@ -11046,19 +11060,17 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mhash_mhash_get_block_size" >&5
 $as_echo "$ac_cv_lib_mhash_mhash_get_block_size" >&6; }
 if test "x$ac_cv_lib_mhash_mhash_get_block_size" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBMHASH 1
-_ACEOF
-
-  LIBS="-lmhash $LIBS"
-
+  MHASH_LIB_DIR="${with_mhash_dir}/lib"
 else
   echo "You must install libmhash."; exit 1
 fi
 
-ac_fn_c_check_header_mongrel "$LINENO" "mhash.h" "ac_cv_header_mhash_h" "$ac_includes_default"
-if test "x$ac_cv_header_mhash_h" = x""yes; then :
-
+LIBS="${LIBS_save}"
+
+as_ac_Header=`$as_echo "ac_cv_header_"${with_mhash_dir}/include/mhash.h"" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" ""${with_mhash_dir}/include/mhash.h"" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  CPPFLAGS="${CPPFLAGS} -I${with_mhash_dir}/include"
 else
   echo "You must install libmhash dev files."; exit 1
 fi
@@ -11220,6 +11232,7 @@
 
 
 
+
 ac_config_files="$ac_config_files Makefile src/c/Makefile src/config.sml"
 
 
@@ -13565,9 +13578,10 @@
 cat <<EOF
 
 Ur/Web configuration:
-  bin directory:       BIN       $BIN
-  lib directory:       LIB       $LIB
-  include directory:   INCLUDE   $INCLUDE
-  site-lisp directory: SITELISP  $SITELISP
-  Extra GCC args:      GCCARGS   $GCCARGS
+  bin directory:       BIN            $BIN
+  lib directory:       LIB            $LIB
+  include directory:   INCLUDE        $INCLUDE
+  site-lisp directory: SITELISP       $SITELISP
+  mhash lib directory: MHASH_LIB_DIR  $MHASH_LIB_DIR
+  Extra GCC args:      GCCARGS        $GCCARGS
 EOF
--- a/configure.ac	Sat Nov 13 14:38:06 2010 -0500
+++ b/configure.ac	Thu Nov 18 14:22:04 2010 -0500
@@ -6,8 +6,20 @@
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config.h])
 
-AC_CHECK_LIB(mhash, mhash_get_block_size, [], [echo "You must install libmhash."; exit 1])
-AC_CHECK_HEADER([mhash.h], [], [echo "You must install libmhash dev files."; exit 1])
+dnl Setting the search directory for mhash.
+AC_ARG_WITH(mhash-dir, AS_HELP_STRING([--with-mhash-dir=DIR], [mhash directory; default = /usr]), 
+                          with_mhash_dir="$withval", with_mhash_dir="/usr")
+
+dnl Check for libmhash
+LIBS_save="$LIBS"
+LIBS="-L${with_mhash_dir}/lib/ -lmhash"
+AC_CHECK_LIB(mhash, mhash_get_block_size, 
+                    [MHASH_LIB_DIR="${with_mhash_dir}/lib"], [echo "You must install libmhash."; exit 1])
+LIBS="${LIBS_save}"
+
+dnl Check for mhash.h
+AC_CHECK_HEADER(["${with_mhash_dir}/include/mhash.h"],
+        [CPPFLAGS="${CPPFLAGS} -I${with_mhash_dir}/include"], [echo "You must install libmhash dev files."; exit 1])
 
 AC_CHECK_PROG(MLTON, mlton, yes, [])
 
@@ -55,6 +67,7 @@
 AC_SUBST(INCLUDE)
 AC_SUBST(SITELISP)
 AC_SUBST(GCCARGS)
+AC_SUBST(MHASH_LIB_DIR)
 
 AC_CONFIG_FILES([
         Makefile
@@ -67,9 +80,10 @@
 cat <<EOF
 
 Ur/Web configuration:
-  bin directory:       BIN       $BIN
-  lib directory:       LIB       $LIB
-  include directory:   INCLUDE   $INCLUDE
-  site-lisp directory: SITELISP  $SITELISP
-  Extra GCC args:      GCCARGS   $GCCARGS
+  bin directory:       BIN            $BIN
+  lib directory:       LIB            $LIB
+  include directory:   INCLUDE        $INCLUDE
+  site-lisp directory: SITELISP       $SITELISP
+  mhash lib directory: MHASH_LIB_DIR  $MHASH_LIB_DIR
+  Extra GCC args:      GCCARGS        $GCCARGS  
 EOF
--- a/src/c/Makefile.in	Sat Nov 13 14:38:06 2010 -0500
+++ b/src/c/Makefile.in	Thu Nov 18 14:22:04 2010 -0500
@@ -145,6 +145,7 @@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MHASH_LIB_DIR = @MHASH_LIB_DIR@
 MKDIR_P = @MKDIR_P@
 MLLEX = @MLLEX@
 MLTON = @MLTON@
--- a/src/compiler.sml	Sat Nov 13 14:38:06 2010 -0500
+++ b/src/compiler.sml	Thu Nov 18 14:22:04 2010 -0500
@@ -1225,16 +1225,16 @@
     let
         val proto = Settings.currentProtocol ()
 
-        val lib = if Settings.getStaticLinking () then
-                      #linkStatic proto ^ " " ^ Config.lib ^ "/../liburweb.a"
-                  else
-                      "-L" ^ Config.lib ^ "/.. -lurweb " ^ #linkDynamic proto
+        val (lib, mhash) = if Settings.getStaticLinking () then
+                               (#linkStatic proto ^ " " ^ Config.lib ^ "/../liburweb.a", Config.libMhash ^ "/libmhash.a")
+                           else
+                               ("-L" ^ Config.lib ^ "/.. -lurweb " ^ #linkDynamic proto, "-L" ^ Config.libMhash ^ " -lmhash")
 
         val compile = "gcc " ^ Config.gccArgs ^ " -Wimplicit -Werror -O3 -fno-inline -I " ^ Config.includ
                       ^ " " ^ #compile proto
                       ^ " -c " ^ cname ^ " -o " ^ oname
 
-        val link = "gcc -Werror -O3 -lm -lmhash -pthread " ^ Config.gccArgs ^ " " ^ libs ^ " " ^ lib ^ " " ^ oname
+        val link = "gcc -Werror -O3 -lm -pthread " ^ Config.gccArgs ^ " " ^ libs ^ " " ^ lib ^ " " ^ mhash ^ " " ^ oname
                    ^ " -o " ^ ename
 
         val (compile, link) =
--- a/src/config.sig	Sat Nov 13 14:38:06 2010 -0500
+++ b/src/config.sig	Thu Nov 18 14:22:04 2010 -0500
@@ -9,4 +9,5 @@
     val libJs : string
 
     val gccArgs : string
+    val libMhash : string
 end
--- a/src/config.sml.in	Sat Nov 13 14:38:06 2010 -0500
+++ b/src/config.sml.in	Thu Nov 18 14:22:04 2010 -0500
@@ -13,5 +13,6 @@
                                  file = "js"}
 
 val gccArgs = "@GCCARGS@"
+val libMhash = "@MHASH_LIB_DIR@"
 
 end