httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf S. Engelschall" <...@engelschall.com>
Subject [PATCH] Making HAVE_XXXX_H automatic (take 2)
Date Tue, 21 Apr 1998 12:08:38 GMT

Make HAVE_XXXX_H automatic (take 2)
===================================

This patch is a more general one although the current PR's would just needs
some specific ones. But this way we are more future directed. It currently
solves PR#2093 (where the AIX bindprocessor hack don't works on all AIX
machines because of no <sys/processor.h>) and PR#???? (where an older Linux
doesn't have <dlfcn.h> [What is the PR-number Dean, I couldn't find it). And
we'll see more if we don't use a better strategy...

The general problem is that in the past we've defined HAVE_XXXX_H based on the
system type in conf.h. This is very erroneous and a lot of effort has to be
made to make sure it is in sync with the available systems.

The above patch gets rid of this manual defines by automating them.
It does the following:

1. It src/Configure another check-cycle is done where we test for various
   header files which conditionally have to be included via
 
     #ifdef HAVE_XXX_H  
     #include <xxx.h>
     #endif

   This is done by calling TestCompile with a new command "header" which
   checks for existing header files.  As a result the file include/conf_auto.h
   is generated containing these HAVE_XXX_H defines.
   
2. In include/conf.h all HAVE_XXX_H defines/undefines were replaced by
   a single #include "conf_auto.h" statement

3. And of course it solves the above two PR's ;-)

Comments?
                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com

Index: src/CHANGES
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/CHANGES,v
retrieving revision 1.779
diff -u -r1.779 CHANGES
--- CHANGES	1998/04/21 08:04:59	1.779
+++ CHANGES	1998/04/21 12:05:14
@@ -1,5 +1,10 @@
 Changes with Apache 1.3b7
 
+  *) Autogenerate the HAVE_XXXXX_H defines in conf_auto.h via TestCompile
+     instead of defining them manually in conf.h. This way we no longer have
+     to fiddle with OS-type and/or OS-version identifers to discover if a
+     system header file exists or not. [Ralf S. Engelschall, PR#2093, PR#????]
+
   *) Fix the path to the MimeMagicFile in the install-config target, too.
      [Ralf S. Engelschall, PR#2089]
 
Index: src/Configure
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/Configure,v
retrieving revision 1.241
diff -u -r1.241 Configure
--- Configure	1998/04/20 23:49:07	1.241
+++ Configure	1998/04/21 12:06:11
@@ -1057,6 +1057,36 @@
 	;;
 esac
 
+# Use TestCompile to look for various general system header files
+echo " + checking for various system header files"
+CONF_AUTO_H=include/conf_auto.h
+echo "/* Automatically generated file - do not edit */" >$CONF_AUTO_H
+echo "" >>$CONF_AUTO_H
+for header in dlfcn.h dl.h bstring.h crypt.h unistd.h \
+              sys/resource.h sys/select.h; do
+    echo "/* <$header> */" >>$CONF_AUTO_H
+    name=`echo $header | sed -e 's:/:_:g' -e 's:\.:_:g' | tr "a-z" "A-Z"`
+    if ./helpers/TestCompile header $header; then
+        echo "#ifndef HAVE_$name" >>$CONF_AUTO_H
+        echo "#define HAVE_$name 1" >>$CONF_AUTO_H
+        echo "#endif" >>$CONF_AUTO_H
+    else
+        echo "#ifdef HAVE_$name" >>$CONF_AUTO_H
+        echo "#undef HAVE_$name" >>$CONF_AUTO_H
+        echo "#endif" >>$CONF_AUTO_H
+    fi
+    echo "" >>$CONF_AUTO_H
+done
+
+# Use TestCompile to look for various special system header files
+case "$PLAT" in
+    *-ibm-aix*)
+        if ./helpers/TestCompile header sys/processor.h; then
+            CFLAGS="$CFLAGS -DAIX_BIND_PROCESSOR"
+        fi
+        ;;
+esac
+
 # Now SOCKS4.
 # NOTE: We assume that if they are using SOCKS4, then they've
 #       adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
Index: src/helpers/TestCompile
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/helpers/TestCompile,v
retrieving revision 1.11
diff -u -r1.11 TestCompile
--- TestCompile	1998/04/11 15:45:59	1.11
+++ TestCompile	1998/04/21 12:01:53
@@ -4,7 +4,7 @@
 #
 # Yet another Apache Configure helper script.
 # This script tests certain aspects of the compilation
-# process. Right now, it can perform 3 tests:
+# process. Right now, it can perform 5 tests:
 #
 # ./helpers/TestCompile lib <libname>
 #    Which checks to see if <libname> exists on this system
@@ -16,6 +16,9 @@
 # ./helpers/TestCompile func <function>
 #    Which checks to see if <function> exists
 #
+# ./helpers/TestCompile header <header>
+#    Which checks to see if header file <header> exists
+#
 # ./helpers/TestCompile sanity
 #    Which does a simple sanity check/test compile
 #
@@ -92,6 +95,22 @@
 void main(void) {
     $2();
 }
+EOF
+	;;
+    "header")
+	if [ "x$2" = "x" ]; then
+	    exit
+	fi
+	TLIB=""
+	if [ "$VERBOSE" = "yes" ]; then
+	    ERRDIR=""
+	else
+	    ERRDIR='2>/dev/null'
+	fi
+	TARGET='testfunc'
+	cat <<EOF >testfunc.c
+#include <$2>
+void main(void) { }
 EOF
 	;;
     *)
Index: src/include/conf.h
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/include/conf.h,v
retrieving revision 1.202
diff -u -r1.202 conf.h
--- conf.h	1998/04/20 23:49:08	1.202
+++ conf.h	1998/04/21 12:01:54
@@ -63,6 +63,7 @@
  * See PORTING for a listing of what they mean
  */
 
+#include "conf_auto.h"
 
 /* Have to include sys/stat.h before ../os/win32/os.h so we can override
 stat() properly */
@@ -84,7 +85,6 @@
 /* Define one of these according to your system. */
 #if defined(MINT)
 typedef int rlim_t;
-#define HAVE_SYS_RESOURCE_H 1
 #define JMP_BUF sigjmp_buf
 #define NO_LONG_DOUBLE
 #define USE_FLOCK_SERIALIZED_ACCEPT
@@ -119,7 +119,6 @@
 
 #elif defined(SUNOS4)
 #define HAVE_GMTOFF 1
-#define HAVE_SYS_RESOURCE_H 1
 #undef NO_KILLPG
 #undef NO_SETSID
 char *crypt(const char *pw, const char *salt);
@@ -140,8 +139,6 @@
 #undef HAVE_GMTOFF
 #define NO_KILLPG
 #undef NO_SETSID
-#define HAVE_SYS_RESOURCE_H 1
-#define HAVE_DLFCN_H 1
 #define bzero(a,b) memset(a,0,b)
 #if !defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && \
     !defined(USE_PTHREAD_SERIALIZED_ACCEPT)
@@ -151,7 +148,6 @@
 #define HAVE_MMAP 1
 #define USE_MMAP_SCOREBOARD
 #define USE_MMAP_FILES
-#define HAVE_CRYPT_H 1
 int gethostname(char *name, int namelen);
 #define HAVE_SYSLOG 1
 
@@ -168,15 +164,11 @@
 #define USE_SHMGET_SCOREBOARD
 #define HAVE_MMAP 1
 #define USE_MMAP_FILES
-#define HAVE_CRYPT_H 1
-#define HAVE_DLFCN_H 1
 #define NO_LONG_DOUBLE
-#define HAVE_BSTRING_H 1
 #define NO_LINGCLOSE
 #define HAVE_SYSLOG 1
 
 #elif defined(HIUX)
-#define HAVE_SYS_RESOURCE_H 1
 #undef HAVE_GMTOFF
 #define NO_KILLPG
 #undef NO_SETSID
@@ -189,7 +181,6 @@
 #define HAVE_SYSLOG 1
 
 #elif defined(HPUX) || defined(HPUX10)
-#define HAVE_SYS_RESOURCE_H 1
 #undef HAVE_GMTOFF
 #define NO_KILLPG
 #undef NO_SETSID
@@ -213,9 +204,6 @@
 #define USE_SHMGET_SCOREBOARD
 #undef  HAVE_GMTOFF
 #define HAVE_RESOURCE
-#define HAVE_CRYPT_H
-#undef  HAVE_SYS_SELECT_H
-#define HAVE_SYS_RESOURCE_H
 #define USE_FCNTL_SERIALIZED_ACCEPT
 /* feeling brave?  want to try using POSIX mutexes? */
 /* #define HAVE_MMAP */
@@ -230,7 +218,6 @@
 #undef HAVE_GMTOFF
 #undef NO_KILLPG
 #undef NO_SETSID
-#define HAVE_SYS_SELECT_H 1
 #ifndef __ps2__
 #define HAVE_MMAP 1
 #define USE_MMAP_SCOREBOARD
@@ -269,7 +256,6 @@
 #define HAVE_MMAP 1
 #define USE_MMAP_SCOREBOARD
 #define USE_MMAP_FILES
-#define HAVE_CRYPT_H 1
 #define NO_LONG_DOUBLE
 #define HAVE_SYSLOG 1
 #define USE_FLOCK_SERIALIZED_ACCEPT
@@ -282,7 +268,6 @@
 #define HAVE_MMAP 1
 #define USE_MMAP_SCOREBOARD
 #define USE_MMAP_FILES
-#define HAVE_CRYPT_H 1
 #define NO_LONG_DOUBLE
 #define HAVE_SYSLOG 1
 typedef int rlim_t;
@@ -302,7 +287,6 @@
 #define NO_SETSID
 #define NEED_STRDUP
 #define NO_LINGCLOSE
-#define NO_UNISTD_H
 #undef _POSIX_SOURCE
 #ifndef FD_CLOEXEC
 #define FD_CLOEXEC 1
@@ -355,7 +339,6 @@
 #define HAVE_SYSLOG 1
 
 #elif defined(LINUX)
-#define HAVE_DLFCN_H 1
 
 #if LINUX > 1
 #include <features.h>
@@ -389,7 +372,6 @@
 #define USE_SHMGET_SCOREBOARD
 #define HAVE_MMAP 1
 #define USE_MMAP_FILES
-#define HAVE_SYS_RESOURCE_H 1
 
 /* glibc 2.1 and later finally define rlim_t */
 #if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__
< 1)
@@ -421,12 +403,10 @@
 
 #elif defined(SCO5)
 
-#define HAVE_SYS_SELECT_H 1
 #define USE_FCNTL_SERIALIZED_ACCEPT
 #define HAVE_MMAP 1
 #define USE_MMAP_SCOREBOARD
 #define USE_MMAP_FILES
-#define HAVE_SYS_RESOURCE_H 1
 #define SecureWare
 #define HAVE_SYSLOG 1
 
@@ -510,9 +490,6 @@
 #define USE_MMAP_FILES
 #define HAVE_SHMGET 1
 #undef USE_SHMGET_SCOREBOARD	/* force use of mmap() scoreboard */
-#define HAVE_CRYPT_H 1
-#define HAVE_SYS_SELECT_H 1
-#define HAVE_SYS_RESOURCE_H 1
 #include <sys/time.h>
 #if UW >= 200
 #define _POSIX_SOURCE
@@ -534,7 +511,6 @@
 #define HAVE_SYSLOG 1
 
 #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(NETBSD)
-#define HAVE_SYS_RESOURCE_H 1
 #define HAVE_GMTOFF 1
 #undef NO_KILLPG
 #undef NO_SETSID
@@ -569,8 +545,6 @@
 #if defined(__FreeBSD__)
 #include <osreldate.h>
 #endif
-#define HAVE_DLFCN_H 1
-#define HAVE_SYS_RESOURCE_H 1
 #define HAVE_GMTOFF 1
 #undef NO_KILLPG
 #undef NO_SETSID
@@ -605,7 +579,6 @@
 #define NEED_INITGROUPS
 #define NEED_SELECT_H
 #define NEED_PROCESS_H
-#define HAVE_SYS_SELECT_H 1
 #include <unix.h>
 #define HAVE_MMAP 1
 #define USE_POSIX_SCOREBOARD
@@ -616,13 +589,9 @@
 #define HAVE_RESOURCE 1
 #undef USE_MMAP_SCOREBOARD
 #undef USE_SHMGET_SCOREBOARD
-#undef HAVE_CRYPT_H
-#undef HAVE_SYS_SELECT_H
-#define HAVE_SYS_RESOURCE_H 1
 #undef USE_FCNTL_SERIALIZED_ACCEPT
 #undef USE_FLOCK_SERIALIZED_ACCEPT
 #define USE_LONGJMP
-#undef NO_UNISTD_H
 #undef NO_KILLPG
 #undef NO_SETSID
 #undef NO_USE_SIGACTION
@@ -644,7 +613,6 @@
 #define HAVE_MMAP 1
 #define USE_MMAP_SCOREBOARD
 #define USE_MMAP_FILES
-#define HAVE_CRYPT_H 1
 #define HAVE_SYSLOG 1
 
 #elif defined(__EMX__)
@@ -707,7 +675,6 @@
 #define HAVE_SYSLOG 1
 
 #elif defined(NEWSOS)
-#define HAVE_SYS_RESOURCE_H 1
 #define HAVE_SHMGET 1
 #define USE_SHMGET_SCOREBOARD
 #define USE_LONGJMP
@@ -812,13 +779,6 @@
 #define USE_GNU_INLINE
 #endif
 
-/* Do we have sys/resource.h; assume that BSD does. */
-#ifndef HAVE_SYS_RESOURCE_H
-#ifdef BSD
-#define HAVE_SYS_RESOURCE_H 1
-#endif
-#endif /* HAVE_SYS_RESOURCE_H */
-
 /*
  * The particular directory style your system supports. If you have dirent.h
  * in /usr/include (POSIX) or /usr/include/sys (SYSV), #include 
@@ -927,7 +887,7 @@
 #define LOGNAME_MAX 25
 #endif
 
-#ifndef NO_UNISTD_H
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
Index: src/main/http_main.c
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/main/http_main.c,v
retrieving revision 1.325
diff -u -r1.325 http_main.c
--- http_main.c	1998/04/19 20:10:46	1.325
+++ http_main.c	1998/04/21 12:01:54
@@ -3533,7 +3533,7 @@
     }
 
     if (!pid) {
-#ifdef AIX
+#ifdef AIX_BIND_PROCESSOR
 /* by default AIX binds to a single processor
  * this bit unbinds children which will then bind to another cpu
  */
Index: src/os/unix/os.h
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/os/unix/os.h,v
retrieving revision 1.21
diff -u -r1.21 os.h
--- os.h	1998/04/13 18:05:19	1.21
+++ os.h	1998/04/21 12:01:55
@@ -58,6 +58,8 @@
 #ifndef APACHE_OS_H
 #define APACHE_OS_H
 
+#include "conf.h"
+
 /*
  * This file in included in all Apache source code. It contains definitions
  * of facilities available on _this_ operating system (HAVE_* macros),
@@ -84,15 +86,6 @@
  *  Apache modules under run-time via 
  *  dynamic shared object (DSO) mechanism
  */
-
-#if defined(HPUX) || defined(HPUX10)
-#define HAVE_DL_H 1
-#endif
-
-#if defined(LINUX) || defined(__FreeBSD__) || defined(SOLARIS2) || \
-    defined(__bsdi__) || defined(IRIX) || defined(SVR4) || defined(OSF1)
-#define HAVE_DLFCN_H 1
-#endif
 
 #ifdef HAVE_DL_H
 #include <dl.h>

Mime
View raw message