You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jim Jagielski <ji...@jaguNET.com> on 1997/07/25 03:24:18 UTC

[PATCH] Barf if using HP-UX non-ANSI cc, Take II

This involves a minor change to TestLib and dummy.c...

We could also be more generic and do a overall check if $(CC)
is ANSI for all OSs and not just HP-UX. As mentioned in the
wordy comments, we would use TestLib to check for libc and,
if it fails, assume that it's because the compiler barfed on the
ANSI-ism of dummy.c (and not because libc doesn't exist or some
other weird error)... I'm kinda cold on that idea but I really
don't like having Configure make these kind of assumptions since
that's what I hate about autoconf's in general.

Index: apache/src/Configure
===================================================================
RCS file: /export/home/cvs/apache/src/Configure,v
retrieving revision 1.120
diff -u -r1.120 Configure
--- Configure	1997/07/24 04:35:45	1.120
+++ Configure	1997/07/25 01:19:03
@@ -629,9 +629,24 @@
 	;;
     'HP-UX'|'HP-UX 10')
 	if [ "$TCC" = "cc" ]; then
-	    CFLAGS="$CFLAGS -Aa -D_HPUX_SOURCE"
-	    OPTIM=" "
-	    TOPTIM=""
+	    # Check for bogus HP-UX cc compiler... We do this
+	    # by using TestLib to check for the libc library,
+	    # which we know exists, but allowing TestLib to
+	    # print out error messages. We check to see if we
+	    # get the "I'm not ANSI so I don't know what const"
+	    # error message. Of course, we could also simply see
+	    # if TestLib succeeded or not (assuming that libc.a
+	    # really DOES exist) but we'll be paranoid.
+	    if ./helpers/TestLib c | grep "will become a keyword"
+	    then
+	    	echo "** Apache will not compile using HP-UX's 'cc' compiler"
+		echo "** We strongly recommend that you install 'gcc'"
+		exit 1
+	    else
+		CFLAGS="$CFLAGS -Aa -D_HPUX_SOURCE"
+		OPTIM=" "
+		TOPTIM=""
+	    fi
 	fi
 	;;
 esac
@@ -709,19 +724,19 @@
 case "$PLAT" in
     *-linux*)
 	# newer systems using glibc 2.x need -lcrypt
-	if ./helpers/TestLib crypt; then
+	if ./helpers/TestLib -s crypt; then
 	    LIBS="$LIBS -lcrypt"
 	fi
 	# many systems have -ldb installed
 	DB_LIB=""
-	if ./helpers/TestLib db; then
+	if ./helpers/TestLib -s db; then
 	    DB_LIB="-ldb"
 	fi;
 	# many systems don't have -ldbm
 	DBM_LIB=""
-	if ./helpers/TestLib dbm; then
+	if ./helpers/TestLib -s dbm; then
 	    DBM_LIB="-ldbm"
-	elif ./helpers/TestLib ndbm; then
+	elif ./helpers/TestLib -s ndbm; then
 	    DBM_LIB="-lndbm"
 	fi
 	;;
Index: apache/src/helpers/TestLib
===================================================================
RCS file: /export/home/cvs/apache/src/helpers/TestLib,v
retrieving revision 1.8
diff -u -r1.8 TestLib
--- TestLib	1997/07/21 20:18:59	1.8
+++ TestLib	1997/07/25 01:19:03
@@ -20,6 +20,13 @@
 #
 # Make sure we have an argument
 #
+if [ "x$1" = "x-s" ]; then
+    shift
+    quiet=""
+else
+    quiet='> /dev/null 2>&1'
+fi
+
 if [ "x$1" = "x" ]; then
   exit
 fi
@@ -42,7 +49,8 @@
 EOF
 
 # Now run that Makefile
-make dummy > /dev/null 2<&1
+eval "make dummy $quiet"
+
 
 # And see if dummy exists, if so, then we assume the 
 # library we are testing for exists
Index: apache/src/helpers/dummy.c
===================================================================
RCS file: /export/home/cvs/apache/src/helpers/dummy.c,v
retrieving revision 1.2
diff -u -r1.2 dummy.c
--- dummy.c	1997/07/21 20:18:59	1.2
+++ dummy.c	1997/07/25 01:19:03
@@ -1,4 +1,10 @@
 /* this file is used by TestLib */
+int foo ( const char *c )
+{
+return 0;
+}
 int main(void) {
+    const char *c = '\0';
+    (void)foo(c);
     return 0;
 }
-- 
====================================================================
      Jim Jagielski            |       jaguNET Access Services
     jim@jaguNET.com           |       http://www.jaguNET.com/
            "Look at me! I'm wearing a cardboard belt!"

Re: [PATCH] Barf if using HP-UX non-ANSI cc, Take II

Posted by Alexei Kosut <ak...@organic.com>.
On Thu, 24 Jul 1997, Marc Slemko wrote:

> You could also run cc -Ae and see if it printed:
> 
> (Bundled) cc: warning 480: The -A option is available only with the C/ANSI C product; ignored.
> 
> or some subset thereof.  The real cc won't ouput that warning.

I should point out that I think this only works with HP-UX 10; the HP-UX 9
bundled cc is just as stupid, but it doesn't know it. "cc -Ae" prints out
the following:

cc: warning %1$s: Unknown option "%2$s%3$s" ignored.

-- Alexei Kosut <ak...@organic.com>


Re: [PATCH] Barf if using HP-UX non-ANSI cc, Take II

Posted by Marc Slemko <ma...@worldgate.com>.
You could also run cc -Ae and see if it printed:

(Bundled) cc: warning 480: The -A option is available only with the C/ANSI C product; ignored.

or some subset thereof.  The real cc won't ouput that warning.

The other one I can think of that could perhaps be worth checking is SunOS
4.x cc.

On Thu, 24 Jul 1997, Jim Jagielski wrote:

> This involves a minor change to TestLib and dummy.c...
> 
> We could also be more generic and do a overall check if $(CC)
> is ANSI for all OSs and not just HP-UX. As mentioned in the
> wordy comments, we would use TestLib to check for libc and,
> if it fails, assume that it's because the compiler barfed on the
> ANSI-ism of dummy.c (and not because libc doesn't exist or some
> other weird error)... I'm kinda cold on that idea but I really
> don't like having Configure make these kind of assumptions since
> that's what I hate about autoconf's in general.
> 
> Index: apache/src/Configure
> ===================================================================
> RCS file: /export/home/cvs/apache/src/Configure,v
> retrieving revision 1.120
> diff -u -r1.120 Configure
> --- Configure	1997/07/24 04:35:45	1.120
> +++ Configure	1997/07/25 01:19:03
> @@ -629,9 +629,24 @@
>  	;;
>      'HP-UX'|'HP-UX 10')
>  	if [ "$TCC" = "cc" ]; then
> -	    CFLAGS="$CFLAGS -Aa -D_HPUX_SOURCE"
> -	    OPTIM=" "
> -	    TOPTIM=""
> +	    # Check for bogus HP-UX cc compiler... We do this
> +	    # by using TestLib to check for the libc library,
> +	    # which we know exists, but allowing TestLib to
> +	    # print out error messages. We check to see if we
> +	    # get the "I'm not ANSI so I don't know what const"
> +	    # error message. Of course, we could also simply see
> +	    # if TestLib succeeded or not (assuming that libc.a
> +	    # really DOES exist) but we'll be paranoid.
> +	    if ./helpers/TestLib c | grep "will become a keyword"
> +	    then
> +	    	echo "** Apache will not compile using HP-UX's 'cc' compiler"
> +		echo "** We strongly recommend that you install 'gcc'"
> +		exit 1
> +	    else
> +		CFLAGS="$CFLAGS -Aa -D_HPUX_SOURCE"
> +		OPTIM=" "
> +		TOPTIM=""
> +	    fi
>  	fi
>  	;;
>  esac
> @@ -709,19 +724,19 @@
>  case "$PLAT" in
>      *-linux*)
>  	# newer systems using glibc 2.x need -lcrypt
> -	if ./helpers/TestLib crypt; then
> +	if ./helpers/TestLib -s crypt; then
>  	    LIBS="$LIBS -lcrypt"
>  	fi
>  	# many systems have -ldb installed
>  	DB_LIB=""
> -	if ./helpers/TestLib db; then
> +	if ./helpers/TestLib -s db; then
>  	    DB_LIB="-ldb"
>  	fi;
>  	# many systems don't have -ldbm
>  	DBM_LIB=""
> -	if ./helpers/TestLib dbm; then
> +	if ./helpers/TestLib -s dbm; then
>  	    DBM_LIB="-ldbm"
> -	elif ./helpers/TestLib ndbm; then
> +	elif ./helpers/TestLib -s ndbm; then
>  	    DBM_LIB="-lndbm"
>  	fi
>  	;;
> Index: apache/src/helpers/TestLib
> ===================================================================
> RCS file: /export/home/cvs/apache/src/helpers/TestLib,v
> retrieving revision 1.8
> diff -u -r1.8 TestLib
> --- TestLib	1997/07/21 20:18:59	1.8
> +++ TestLib	1997/07/25 01:19:03
> @@ -20,6 +20,13 @@
>  #
>  # Make sure we have an argument
>  #
> +if [ "x$1" = "x-s" ]; then
> +    shift
> +    quiet=""
> +else
> +    quiet='> /dev/null 2>&1'
> +fi
> +
>  if [ "x$1" = "x" ]; then
>    exit
>  fi
> @@ -42,7 +49,8 @@
>  EOF
>  
>  # Now run that Makefile
> -make dummy > /dev/null 2<&1
> +eval "make dummy $quiet"
> +
>  
>  # And see if dummy exists, if so, then we assume the 
>  # library we are testing for exists
> Index: apache/src/helpers/dummy.c
> ===================================================================
> RCS file: /export/home/cvs/apache/src/helpers/dummy.c,v
> retrieving revision 1.2
> diff -u -r1.2 dummy.c
> --- dummy.c	1997/07/21 20:18:59	1.2
> +++ dummy.c	1997/07/25 01:19:03
> @@ -1,4 +1,10 @@
>  /* this file is used by TestLib */
> +int foo ( const char *c )
> +{
> +return 0;
> +}
>  int main(void) {
> +    const char *c = '\0';
> +    (void)foo(c);
>      return 0;
>  }
> -- 
> ====================================================================
>       Jim Jagielski            |       jaguNET Access Services
>      jim@jaguNET.com           |       http://www.jaguNET.com/
>             "Look at me! I'm wearing a cardboard belt!"
>