The Ur/Web compiler links to the libmhash dynamic library independent of the
-static parameter being given to the compiler, which links only the liburweb
statically.
This patch makes the Ur/Web compiler also link libmhash statically with the -
static flag. The motivation is to have -static produce programs which can run
on machines without a special Ur/Web installation ( considering libmhash as
part of a Ur/Web installation because it is not likely to be found on many
machines ).
The goal is to use -static to produce executables which can be placed on
shared hosting Linux servers with Apache CGI via FTP ... "bringing Ur to the
world"
The patch adds a configure flag --with-mhash-dir to let the Ur/Web compiler
know how to find libmhash.a in order to pass it along to gcc.
I do not know if this patch will interact badly with the FFI mechanism of
Ur/Web.
Note: after applying the patch I did $autoreconf -i to update the autotools
build system.
diff -r df7bfb30dcc3 configure.ac
--- a/configure.ac Sat Nov 13 14:38:06 2010 -0500
+++ b/configure.ac Mon Nov 15 20:04:17 2010 -0430
@@ -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
diff -r df7bfb30dcc3 src/compiler.sml
--- a/src/compiler.sml Sat Nov 13 14:38:06 2010 -0500
+++ b/src/compiler.sml Mon Nov 15 20:04:17 2010 -0430
@@ -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) =
diff -r df7bfb30dcc3 src/config.sig
--- a/src/config.sig Sat Nov 13 14:38:06 2010 -0500
+++ b/src/config.sig Mon Nov 15 20:04:17 2010 -0430
@@ -9,4 +9,5 @@
val libJs : string
val gccArgs : string
+ val libMhash : string
end
diff -r df7bfb30dcc3 src/config.sml.in
--- a/src/config.sml.in Sat Nov 13 14:38:06 2010 -0500
+++ b/src/config.sml.in Mon Nov 15 20:04:17 2010 -0430
@@ -14,4 +14,6 @@
val gccArgs = "@GCCARGS@"
+val libMhash = "@MHASH_LIB_DIR@"
+
end
_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur