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