cvs diff: scripts/ml.in

Fergus Henderson fjh at cs.mu.oz.au
Sat Feb 8 00:39:33 AEDT 1997


Hi Tyson,

Can you please review the following change?

scripts/ml.in:
	Add a `--mercury-libs {shared, static, none}' option
	(`--mercury-libs none' replaces the old `--no-libs' option).
	Add `--shared' and `--static' options.
	Add a `--help' option.

Index: ml.in
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/ml.in,v
retrieving revision 1.21
diff -u -r1.21 ml.in
--- ml.in	1997/02/05 05:40:41	1.21
+++ ml.in	1997/02/07 13:40:13
@@ -10,19 +10,42 @@
 #
 # Invokes GCC with the appropriate options to link in the Mercury library.
 #
-# Usage: ml [<ml options>] [<gcc options] files...
-# Options:
-# 	-v, --verbose
-#		Echo gcc command line before executing it
-# 	--no-demangle
-#		Don't pipe the output of the linker the Mercury demangler
-# 	-g, --no-strip
-#		Do not strip debugging information
-#	-s <grade>, --grade <grade>
-#		Specify which grade of the Mercury library to link with.
-#		(The default grade is determined by `configure'.)
+# Usage: see below.
 #
-# Environment variables: MERCURY_C_LIB_DIR, MERCURY_DEFAULT_GRADE
+# Environment variables: MERCURY_C_LIB_DIR, MERCURY_DEFAULT_GRADE, ...
+
+Help="\
+Name: ml - Mercury Linker
+Usage: ml [<ml options>] [<gcc options] files...
+Options:
+	-h, --help
+		Print this help message.
+	-v, --verbose
+		Echo the gcc command line before executing it.
+	--mercury-libs {shared, static, none}
+		Specify which version of the standard Mercury libraries to
+		link with:
+			--mercury-libs shared
+				Link with the shared Mercury libraries (*.so),
+				if possible, otherwise with the static ones.
+			--mercury-libs static
+				Link with the static Mercury libraries (*.a).
+			--mercury-libs none
+				Don't link in the Mercury libraries.
+	-shared, --shared
+		Similar to \`--mercury-libs shared', but applies to all
+		libraries, not just the standard Mercury libraries.
+	-static, --static
+		Similar to \`--mercury-libs static', but applies to all
+		libraries, not just the standard Mercury libraries.
+	--no-demangle
+		Don't pipe the output of the linker through the Mercury
+		demangler.
+	-g, --no-strip
+		Do not strip debugging information
+	-s <grade>, --grade <grade>
+		Specify which grade of the Mercury library to link with.
+		(The default grade is determined by ``configure'.)"
 
 FULLARCH=@FULLARCH@
 NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=@NONSHARED_LIB_DIR@}
@@ -44,11 +67,26 @@
 		strip=true
 		;;
 esac
+case $FULLARCH in
+	i?86-*-linux*)
+		# shared libraries are not the default on Linux
+		# -- see README.Linux
+		mercury_libs=static
+		;;
+	*)
+		mercury_libs=shared
+		;;
+esac
 demangle=true
 GRADE=$DEFAULT_GRADE
+SHARED_OR_STATIC_OPT=""
 
 while true; do
     case "$1" in
+	-h|--help|"-?")
+		echo "$Help"
+		exit 0
+		;;
 	-v|--verbose)
 		verbose=true
 		shift ;;
@@ -69,13 +107,45 @@
 		strip=false
 		shift ;;
 	--no-libs)
-		MERCURY_LIBS=
-		shift ;;
+		progname=`basename $0`
+		cat 1>&2 << EOF
+$progname: Warning: option \`--no-libs' is deprecated --
+$progname:   please use the new option \`--mercury-libs none' instead.
+$progname:   Support for \`--no-libs' may be removed in a future release.
+EOF
+		mercury_libs=none
+		shift ;;
+	--mercury-libs)
+		case "$2" in
+			shared|static|none)
+				mercury_libs="$2"
+				shift; shift ;;
+			*)
+				progname=`basename $0`
+				cat 1>&2 << EOF
+$progname: Error: parameter to \`--mercury-libs' option should be
+$progname:   either \`shared', \`static', or \`none', not \`$2'.
+$progname: Try `$0 --help' for help.
+EOF
+				exit 1
+				;;
+		esac
+		;;
+	-shared|--shared)
+		STATIC_OR_SHARED_OPT=-shared
+		case $mercury_libs in static)
+			mercury_libs=shared ;;
+		esac
+		;;
+	-static|--static)
+		STATIC_OR_SHARED_OPT=-static
+		case $mercury_libs in shared)
+			mercury_libs=static ;;
+		esac
+		;;
 	--)
 		shift
 		break ;;
-	-static|-shared)
-		break ;;
 	-s*)
 		GRADE="` expr $1 : '-s\(.*\)' `"
 		shift ;;
@@ -87,12 +157,15 @@
 case "$GRADE" in
 	*.gc.prof*)
 		LIBGC="-lgc_prof"
+		LIBGC_STATIC="$LIBDIR/$FULLARCH/libgc_prof.a"
 		;;
 	*.gc*)
 		LIBGC="-lgc"
+		LIBGC_STATIC="$LIBDIR/$FULLARCH/libgc.a"
 		;;
 	*)
 		LIBGC=
+		LIBGC_STATIC=
 		;;
 esac
 
@@ -101,7 +174,18 @@
 	false)  STRIP_OPTS="" ;;
 esac
 
-LIBS=${MERCURY_LIBS="-lmercury -lmer $LIBGC -lm"}
+case $mercury_libs in
+	shared) LIBS=${MERCURY_LIBS="-lmercury -lmer $LIBGC -lm"}
+		;;
+	static) LIBS=${MERCURY_LIBS="\
+			$LIBDIR/$GRADE/$FULLARCH/libmercury.a \
+			$LIBDIR/$GRADE/$FULLARCH/libmer.a \
+			$LIBGC_STATIC \
+			-lm"}
+		;;
+	none)	LIBS=""
+		;;
+esac
 
 case $FULLARCH in
 	i?86-*-linux*)

-- 
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.



More information about the developers mailing list