classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Patch: FYI: configure.ac cleanups


From: Tom Tromey
Subject: [cp-patches] Patch: FYI: configure.ac cleanups
Date: 22 Apr 2005 18:19:46 -0600

I'm checking this in.

This fixes a few problems with the Classpath configure script:

* We called AC_C_BIGENDIAN twice

* Additionally, at least two things were not suitable for
  cross-compilation; I imported some autoconf macros from the gcc
  tree which clean this up.  (I still haven't actually tried cross
  compilation; I'll probably do this when doing the big classpath
  merge in libgcj.)

* We made multiple calls to AC_CHECK_HEADERS and AC_CHECK_FUNCS.
  Doing a single call is no less maintainable (IMO) and reduces the
  size of the resulting configure script.  (In this case we had a net
  reduction of 30k, after adding code for the above.)

* We did a function check for a function named 'sizeof'.  This makes
  no sense.

Tom

Index: ChangeLog
from  Tom Tromey  <address@hidden>

        * accross.m4: New file, from gcc.
        * configure.ac: Only call AC_C_BIGENDIAN once.  Use a single
        AC_CHECK_HEADERS call for most headers.  Likewise for
        AC_CHECK_FUNCS.  Use AC_COMPILE_CHECK_SIZEOF.  Don't look for
        function named 'sizeof'.

Index: accross.m4
===================================================================
RCS file: accross.m4
diff -N accross.m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ accross.m4 23 Apr 2005 00:15:51 -0000
@@ -0,0 +1,98 @@
+AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
+[changequote(<<, >>)dnl
+dnl The name to #define.
+define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
+dnl The cache variable name.
+define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
+changequote([, ])dnl
+AC_MSG_CHECKING(size of $1)
+AC_CACHE_VAL(AC_CV_NAME,
+[for ac_size in 4 8 1 2 16 12 $2 ; do # List sizes in rough order of 
prevalence.
+  AC_TRY_COMPILE([#include "confdefs.h"
+#include <sys/types.h>
+$2
+], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
+  if test x$AC_CV_NAME != x ; then break; fi
+done
+])
+if test x$AC_CV_NAME = x ; then
+  AC_MSG_ERROR([cannot determine a size for $1])
+fi
+AC_MSG_RESULT($AC_CV_NAME)
+AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
+undefine([AC_TYPE_NAME])dnl
+undefine([AC_CV_NAME])dnl
+])
+
+AC_DEFUN([AC_C_BIGENDIAN_CROSS],
+[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
+[ac_cv_c_bigendian=unknown
+# See if sys/param.h defines the BYTE_ORDER macro.
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/param.h>], [
+#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/param.h>], [
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
+if test $ac_cv_c_bigendian = unknown; then
+AC_TRY_RUN([main () {
+  /* Are we little or big endian?  From Harbison&Steele.  */
+  union
+  {
+    long l;
+    char c[sizeof (long)];
+  } u;
+  u.l = 1;
+  exit (u.c[sizeof (long) - 1] == 1);
+}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes,
+[ echo $ac_n "cross-compiling... " 2>&AC_FD_MSG ])
+fi])
+if test $ac_cv_c_bigendian = unknown; then
+AC_MSG_CHECKING(to probe for byte ordering)
+[
+cat >conftest.c <<EOF
+short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; }
+short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; }
+int main() { _ascii (); _ebcdic (); return 0; }
+EOF
+] if test -f conftest.c ; then
+     if ${CC-cc} ${CFLAGS} -c conftest.c -o conftest.o && test -f conftest.o ; 
then
+        if test `grep -l BIGenDianSyS conftest.o` ; then
+           echo $ac_n ' big endian probe OK, ' 1>&AC_FD_MSG
+           ac_cv_c_bigendian=yes
+        fi
+        if test `grep -l LiTTleEnDian conftest.o` ; then
+           echo $ac_n ' little endian probe OK, ' 1>&AC_FD_MSG
+           if test $ac_cv_c_bigendian = yes ; then
+            ac_cv_c_bigendian=unknown;
+           else
+            ac_cv_c_bigendian=no
+           fi
+        fi
+        echo $ac_n 'guessing bigendian ...  ' >&AC_FD_MSG
+     fi
+  fi
+AC_MSG_RESULT($ac_cv_c_bigendian)
+fi
+if test $ac_cv_c_bigendian = yes; then
+  AC_DEFINE(WORDS_BIGENDIAN, 1, [whether byteorder is bigendian])
+  AC_DEFINE(HOST_WORDS_BIG_ENDIAN, 1,
+  [Define if the host machine stores words of multi-word integers in
+   big-endian order.])
+  BYTEORDER=4321
+else
+  BYTEORDER=1234
+fi
+AC_DEFINE_UNQUOTED(BYTEORDER, $BYTEORDER, [1234 = LIL_ENDIAN, 4321 = 
BIGENDIAN])
+if test $ac_cv_c_bigendian = unknown; then
+  AC_MSG_ERROR([unknown endianess - sorry, please pre-set ac_cv_c_bigendian])
+fi
+])
Index: configure.ac
===================================================================
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.78
diff -u -r1.78 configure.ac
--- configure.ac 22 Mar 2005 19:06:30 -0000 1.78
+++ configure.ac 23 Apr 2005 00:15:51 -0000
@@ -134,33 +134,34 @@
 
   dnl Checking sizeof void * is needed for fdlibm to work properly on ppc64, 
   dnl at least. 
-  AC_CHECK_SIZEOF(void *)
+  AC_COMPILE_CHECK_SIZEOF(void *)
 
   dnl Checking for endianess.
-  AC_C_BIGENDIAN
+  AC_C_BIGENDIAN_CROSS
   
   dnl We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
   dnl On that system, sys/ioctl.h will not include sys/filio.h unless
   dnl BSD_COMP is defined; just including sys/filio.h is simpler.
-  AC_CHECK_HEADERS([unistd.h sys/types.h sys/config.h sys/ioctl.h 
asm/ioctls.h])
-  AC_CHECK_HEADERS([inttypes.h stdint.h utime.h sys/utime.h sys/filio.h])
-  AC_CHECK_HEADERS([sys/time.h])
-  AC_CHECK_HEADERS([sys/select.h])
   dnl Check for crt_externs.h on Darwin.
-  AC_CHECK_HEADERS([crt_externs.h])
+  AC_CHECK_HEADERS([unistd.h sys/types.h sys/config.h sys/ioctl.h \
+                   asm/ioctls.h \
+                   inttypes.h stdint.h utime.h sys/utime.h sys/filio.h \
+                   sys/time.h \
+                   sys/select.h \
+                   crt_externs.h])
 
   AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define 
to 1 if you have uint32_t]))
   AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, 
[Define to 1 if you have uint32_t]))
   AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, 
[Define to 1 if you have BSD u_int32_t]))
   AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 
1, [Define to 1 if you have BSD u_int32_t]))
 
-  AC_CHECK_FUNCS([ftruncate fsync select])
-  AC_CHECK_FUNCS([gethostname socket strerror fork pipe execve open close])
-  AC_CHECK_FUNCS([lseek fstat read write htonl memset htons connect])
-  AC_CHECK_FUNCS([getsockname sizeof getpeername bind listen accept])
-  AC_CHECK_FUNCS([recvfrom send sendto setsockopt getsockopt time mktime])
-  AC_CHECK_FUNCS([localtime_r])
-  AC_CHECK_FUNCS([strerror_r])
+  AC_CHECK_FUNCS([ftruncate fsync select \
+                 gethostname socket strerror fork pipe execve open close \
+                 lseek fstat read write htonl memset htons connect \
+                 getsockname getpeername bind listen accept \
+                 recvfrom send sendto setsockopt getsockopt time mktime \
+                 localtime_r \
+                 strerror_r])
 
   AC_HEADER_TIME
   AC_STRUCT_TM
@@ -190,9 +191,6 @@
 
   AC_C_CONST
 
-  dnl FIXME - does not allow cross compiling
-  AC_C_BIGENDIAN
-
   dnl When using gcc we want warnings, lots of warnings :-)
   if test "x${GCC}" = xyes; then
     dnl We want ISO C90 pedantic ansi, but with longlong (jlong) support




reply via email to

[Prev in Thread] Current Thread [Next in Thread]