source: trunk/src/gcc/fastjar/acinclude.m4@ 1446

Last change on this file since 1446 was 1389, checked in by bird, 21 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.8 KB
Line 
1
2dnl Host type sizes probe.
3dnl By Kaveh R. Ghazi. One typo fixed since.
4dnl
5AC_DEFUN([gcc_AC_COMPILE_CHECK_SIZEOF],
6[changequote(<<, >>)dnl
7dnl The name to #define.
8define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
9dnl The cache variable name.
10define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
11changequote([, ])dnl
12AC_MSG_CHECKING(size of $1)
13AC_CACHE_VAL(AC_CV_NAME,
14[for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
15 AC_TRY_COMPILE([#include "confdefs.h"
16#include <sys/types.h>
17$2
18], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
19 if test x$AC_CV_NAME != x ; then break; fi
20done
21])
22if test x$AC_CV_NAME = x ; then
23 AC_MSG_ERROR([cannot determine a size for $1])
24fi
25AC_MSG_RESULT($AC_CV_NAME)
26AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
27undefine([AC_TYPE_NAME])dnl
28undefine([AC_CV_NAME])dnl
29])
30
31dnl Utility macro used by next two tests.
32dnl AC_EXAMINE_OBJECT(C source code,
33dnl commands examining object file,
34dnl [commands to run if compile failed]):
35dnl
36dnl Compile the source code to an object file; then convert it into a
37dnl printable representation. All unprintable characters and
38dnl asterisks (*) are replaced by dots (.). All white space is
39dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
40dnl output, but runs of newlines are compressed to a single newline.
41dnl Finally, line breaks are forcibly inserted so that no line is
42dnl longer than 80 columns and the file ends with a newline. The
43dnl result of all this processing is in the file conftest.dmp, which
44dnl may be examined by the commands in the second argument.
45dnl
46AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
47[AC_LANG_SAVE
48AC_LANG_C
49dnl Next bit cribbed from AC_TRY_COMPILE.
50cat > conftest.$ac_ext <<EOF
51[#line __oline__ "configure"
52#include "confdefs.h"
53$1
54]EOF
55if AC_TRY_EVAL(ac_compile); then
56 od -c conftest.o |
57 sed ['s/^[0-7]*[ ]*/ /
58 s/\*/./g
59 s/ \\n/*/g
60 s/ [0-9][0-9][0-9]/./g
61 s/ \\[^ ]/./g'] |
62 tr -d '
63 ' | tr -s '*' '
64' | fold | sed '$a\
65' > conftest.dmp
66 $2
67ifelse($3, , , else
68 $3
69)dnl
70fi
71rm -rf conftest*
72AC_LANG_RESTORE])
73
74dnl Host endianness probe.
75dnl Differs from AC_C_BIGENDIAN in that it does not require
76dnl running a program on the host.
77dnl
78AC_DEFUN([fastjar_AC_COMPILE_C_BIGENDIAN],
79[AC_CACHE_CHECK(byte ordering, ac_cv_c_compile_endian,
80[ac_cv_c_compile_endian=unknown
81gcc_AC_EXAMINE_OBJECT([
82#ifdef HAVE_LIMITS_H
83# include <limits.h>
84#endif
85/* This structure must have no internal padding. */
86 struct {
87 char prefix[sizeof "\nendian:" - 1];
88 short word;
89 char postfix[2];
90 } tester = {
91 "\nendian:",
92#if SIZEOF_SHORT == 4
93 ('A' << (CHAR_BIT * 3)) | ('B' << (CHAR_BIT * 2)) |
94#endif
95 ('A' << CHAR_BIT) | 'B',
96 'X', '\n'
97};],
98 [if grep 'endian:AB' conftest.dmp >/dev/null 2>&1; then
99 ac_cv_c_compile_endian=big-endian
100 elif grep 'endian:BA' conftest.dmp >/dev/null 2>&1; then
101 ac_cv_c_compile_endian=little-endian
102 fi])
103])
104if test $ac_cv_c_compile_endian = unknown; then
105 AC_MSG_ERROR([*** unable to determine endianness])
106elif test $ac_cv_c_compile_endian = big-endian; then
107 AC_DEFINE(WORDS_BIG_ENDIAN, 1,
108 [Define if the host machine stores words of multi-word integers in
109 big-endian order.])
110fi
111])
112
113dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
114dnl of the usual 2.
115AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
116[AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
117[AC_TRY_COMPILE([
118#include <sys/types.h>
119#ifdef HAVE_SYS_STAT_H
120# include <sys/stat.h>
121#endif
122#ifdef HAVE_UNISTD_H
123# include <unistd.h>
124#endif
125#ifdef HAVE_DIRECT_H
126# include <direct.h>
127#endif], [mkdir ("foo", 0);],
128 gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
129if test $gcc_cv_mkdir_takes_one_arg = yes ; then
130 AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a
131single argument.])
132fi
133])
Note: See TracBrowser for help on using the repository browser.