[m-dev.] diff: fix portability problem with `-lm'
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Sep 22 19:23:32 AEDT 2000
Estimated hours taken: 1
Fix a portability problem: we were assuming that `-lm' would work, but
on some systems, e.g. MacOS X (Darwin), it doesn't.
configure.in:
Check for the existence of the `-lm' library;
set MATH_LIB to `-lm' if it exists, and empty otherwise.
bindist/bindist.build_vars.in:
Mmake.common.in:
Pass on MATH_LIB.
scripts/ml.in:
compiler/Mmakefile:
profiler/Mmakefile:
Use MATH_LIB rather than hard-coding `-lm'.
Workspace: /home/pgrad/fjh/ws/hg
Index: bindist/bindist.build_vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/bindist.build_vars.in,v
retrieving revision 1.14
diff -u -d -r1.14 bindist.build_vars.in
--- bindist/bindist.build_vars.in 2000/09/14 14:30:51 1.14
+++ bindist/bindist.build_vars.in 2000/09/21 08:30:31
@@ -51,3 +51,4 @@
LINK_LIB="@LINK_LIB@"
LINK_OPT_SEP="@LINK_OPT_SEP@"
CYGPATH="@CYGPATH@"
+MATH_LIB="@MATH_LIB@"
Index: compiler/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Mmakefile,v
retrieving revision 1.29
diff -u -d -r1.29 Mmakefile
--- compiler/Mmakefile 2000/08/17 05:31:03 1.29
+++ compiler/Mmakefile 2000/09/21 08:37:47
@@ -51,7 +51,7 @@
*.gc*.prof*) echo $(BOEHM_GC_DIR)/libgc_prof.$A ;; \
*.gc*) echo $(BOEHM_GC_DIR)/libgc.$A ;; \
esac \
- ` -lm
+ ` $(MATH_LIB)
MTAGS = $(SCRIPTS_DIR)/mtags
MTAGSFLAGS = $(EXTRA_MTAGSFLAGS)
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.225
diff -u -d -r1.225 configure.in
--- configure.in 2000/09/18 14:02:28 1.225
+++ configure.in 2000/09/22 08:23:01
@@ -223,6 +223,10 @@
AC_C_CROSS
AC_RETSIGTYPE
#-----------------------------------------------------------------------------#
+# Check for `-lm': some systems, e.g. MacOS X (Darwin), don't have it.
+AC_CHECK_LIB(m,[MATH_LIB=-lm],[MATH_LIB=])
+AC_SUBST(MATH_LIB)
+#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(for use of a Microsoft compiler)
AC_EGREP_CPP(yes,
[
@@ -2014,7 +2018,7 @@
# see Mmake.common.in for documentation on the meaning of these variables
LINK_SHARED_OBJ="$CC -shared"
LINK_SHARED_OBJ_SH="$CC -shared"
-SHARED_LIBS='`gcc -print-libgcc-file-name` -lm -lc'
+SHARED_LIBS='`gcc -print-libgcc-file-name` $(MATH_LIB) -lc'
EXE_RPATH_OPT="-Wl,-rpath,"
EXE_RPATH_SEP=" -Wl,-rpath,"
SHLIB_RPATH_OPT="-Wl,-rpath,"
@@ -2051,7 +2055,7 @@
;;
sparc-sun-solaris2.*)
AC_MSG_RESULT(yes)
- SHARED_LIBS="-lm -lc" # don't link in libgcc.a
+ SHARED_LIBS="$(MATH_LIB) -lc" # don't link in libgcc.a
LINK_SHARED_OBJ="$CC -G"
LINK_SHARED_OBJ_SH="$CC -G"
ERROR_UNDEFINED="-Wl,-z,defs"
Index: Mmake.common.in
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmake.common.in,v
retrieving revision 1.47
diff -u -d -r1.47 Mmake.common.in
--- Mmake.common.in 2000/06/28 12:20:12 1.47
+++ Mmake.common.in 2000/09/21 08:39:21
@@ -178,6 +178,10 @@
#-----------------------------------------------------------------------------#
+# The linker option to use to link in the math library, if any.
+# Typically `-lm'.
+MATH_LIB=@MATH_LIB@
+
# Extensions to use
O=@OBJ_SUFFIX@
A=@LIB_SUFFIX@
Index: profiler/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/profiler/Mmakefile,v
retrieving revision 1.16
diff -u -d -r1.16 Mmakefile
--- profiler/Mmakefile 2000/08/17 05:31:08 1.16
+++ profiler/Mmakefile 2000/09/21 08:37:55
@@ -51,7 +51,7 @@
*.gc*.prof*) echo $(BOEHM_GC_DIR)/libgc_prof.$A ;; \
*.gc*) echo $(BOEHM_GC_DIR)/libgc.$A ;; \
esac \
- ` -lm
+ ` $(MATH_LIB)
MSL = MERCURY_SP_LIB_DIR=$(LIBRARY_DIR) $(SCRIPTS_DIR)/msl
MNLFLAGS = -u 6000
MTAGS = $(SCRIPTS_DIR)/mtags
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.82
diff -u -d -r1.82 ml.in
--- scripts/ml.in 2000/09/06 11:04:43 1.82
+++ scripts/ml.in 2000/09/22 08:23:08
@@ -33,6 +33,7 @@
SHLIB_RPATH_SEP=${MERCURY_SHLIB_RPATH_SEP="@SHLIB_RPATH_SEP@"}
SHARED_LIBS=${MERCURY_SHARED_LIBS="@SHARED_LIBS@"}
TMPDIR=${TMPDIR=/tmp}
+MATH_LIB=${MERCURY_MATH_LIB="@MATH_LIB@"}
# When compiling in the hlc.gc grade using the Microsoft Visual C
# compiler, the default maximum stack size of 4Mb is too low for a
@@ -589,7 +590,7 @@
UNDEF_OPT=""
RPATH_OPT="$EXE_RPATH_OPT"
RPATH_SEP="$EXE_RPATH_SEP"
- STDLIBS="-lm $THREAD_LIBS"
+ STDLIBS="$MATH_LIB $THREAD_LIBS"
;;
esac
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list