[m-rev.] diff: avoid gcc 3.1/3.2 warnings about -I/usr/local/include

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Oct 6 01:06:15 AEST 2002


Estimated hours taken: 3
Branches: main

Avoid warnings with gcc 3.1, 3.1.1 and 3.2: don't add -I/usr/local/include for gcc.  Also don't add -I/usr/local/include or -L/usr/local/lib if those directories
don't exist, because that too can result in annoying warnings.

configure.in:
	Move the code to check whether to add -I/usr/local/include
	from configure.in to a new macro MERCURY_CHECK_LOCAL_INCL_DIRS
	in aclocal.m4, so that it can also be used by bindist/bindist.configure.in.
	Don't add /usr/local/lib to LIBS if that doesn't exist.

aclocal.m4:
	Define the new macro.
	Change that code so that it does not add -I/usr/local/include
	if the C compiler is GCC, or if /usr/local/include doesn't exist.
	Record whether or not to add -I/usr/local/include in a new autoconf
	substitution variable ALL_LOCAL_INCL_DIRS.

bindist/bindist.configure.in
	Call the new macro.

scripts/mgnuc.in:
	Use @ALL_LOCAL_INCL_DIRS@ rather than -I$MERCURY_LOCAL_C_INCL_DIR
	or -I/usr/local/include.  (The ability to set the MERCURY_LOCAL_C_INCL_DIR
	environment variable was not documented and was not used anywhere else
	in the Mercury distribution.)

Workspace: /home/ceres/fjh/mercury
Index: aclocal.m4
===================================================================
RCS file: /home/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.11
diff -u -d -r1.11 aclocal.m4
--- aclocal.m4	3 Oct 2002 03:25:00 -0000	1.11
+++ aclocal.m4	5 Oct 2002 15:03:30 -0000
@@ -41,6 +41,36 @@
 ])
 #-----------------------------------------------------------------------------#
 #
+# Check whether we need to add any extra directories to the search path for
+# header files, and set ALL_LOCAL_C_INCL_DIRS to the -I option(s) needed
+# for this, if any.
+#
+# GNU C normally searches /usr/local/include by default;
+# to keep things consistent, we do the same for other C compilers.
+#
+AC_DEFUN(MERCURY_CHECK_LOCAL_C_INCL_DIRS,
+[
+AC_REQUIRE([AC_PROG_CC])
+AC_MSG_CHECKING(whether to pass -I/usr/local/include to C compiler)
+ALL_LOCAL_C_INCL_DIRS=""
+if test $GCC = yes; then
+	# Don't add -I/usr/local/include, since it causes a warning
+	# with gcc 3.1, and gcc already searches /usr/local/include
+	AC_MSG_RESULT(no)
+else
+	# It's some other compiler.  We don't know if it searches
+	# /usr/local/include by default, so add it.
+	if test -d /usr/local/include; then
+		AC_MSG_RESULT(yes)
+		ALL_LOCAL_C_INCL_DIRS="-I/usr/local/include "
+	else
+		AC_MSG_RESULT(nos)
+	fi
+fi
+AC_SUBST(ALL_LOCAL_C_INCL_DIRS)
+])
+#-----------------------------------------------------------------------------#
+#
 # Check for readline and related header files and libraries
 #
 AC_DEFUN(MERCURY_CHECK_READLINE,
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.320
diff -u -d -r1.320 configure.in
--- configure.in	3 Oct 2002 03:25:00 -0000	1.320
+++ configure.in	5 Oct 2002 14:40:24 -0000
@@ -365,11 +365,15 @@
 
 # Make sure we search /usr/local/include and /usr/local/lib for
 # header files and libraries.  GNU C normally searches /usr/local/include
-# by default, but (inconsistently) it does _not_ search /usr/local/lib;
-# and in any case the user might be using a different C compiler that
+# by default, but (inconsistently) on some systems, such as Solaris,
+# it does _not_ search /usr/local/lib.
+# The user might also be using a different C compiler that
 # doesn't search either of those by default.
-CPPFLAGS="-I/usr/local/include $CPPFLAGS"
-LIBS="-L/usr/local/lib $LIBS"
+MERCURY_CHECK_LOCAL_C_INCL_DIRS
+CPPFLAGS="$ALL_LOCAL_C_INCL_DIRS $CPPFLAGS"
+if test -d /usr/local/lib/.; then
+	LIBS="-L/usr/local/lib $LIBS"
+fi
 
 AC_PROG_CPP
 #-----------------------------------------------------------------------------#
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.92
diff -u -d -r1.92 mgnuc.in
--- scripts/mgnuc.in	9 Sep 2002 18:07:39 -0000	1.92
+++ scripts/mgnuc.in	5 Oct 2002 14:22:34 -0000
@@ -232,8 +232,8 @@
 	;;
 esac
 
-LOCAL_C_INCL_DIR=${MERCURY_LOCAL_C_INCL_DIR=/usr/local/include}
-ALL_LOCAL_C_INCL_DIRS=${MERCURY_ALL_LOCAL_C_INCL_DIRS=-I$LOCAL_C_INCL_DIR}
+# add /usr/local/include to the default search path, if needed
+ALL_LOCAL_C_INCL_DIRS=${MERCURY_ALL_LOCAL_C_INCL_DIRS=@ALL_LOCAL_C_INCL_DIRS@}
 
 #
 # convert non-grade mgnuc options into gcc options

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list