~ubuntu-branches/ubuntu/quantal/nettle/quantal

« back to all changes in this revision

Viewing changes to acinclude.m4

  • Committer: Bazaar Package Importer
  • Author(s): Marek Habersack
  • Date: 2004-05-04 15:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20040504155602-7jbhw5mabvwksl3j
Tags: upstream-1.10
ImportĀ upstreamĀ versionĀ 1.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl Try to detect the type of the third arg to getsockname() et al
 
2
AC_DEFUN([LSH_TYPE_SOCKLEN_T],
 
3
[AH_TEMPLATE([socklen_t], [Length type used by getsockopt])
 
4
AC_CACHE_CHECK([for socklen_t in sys/socket.h], ac_cv_type_socklen_t,
 
5
[AC_EGREP_HEADER(socklen_t, sys/socket.h,
 
6
  [ac_cv_type_socklen_t=yes], [ac_cv_type_socklen_t=no])])
 
7
if test $ac_cv_type_socklen_t = no; then
 
8
        AC_MSG_CHECKING(for AIX)
 
9
        AC_EGREP_CPP(yes, [
 
10
#ifdef _AIX
 
11
 yes
 
12
#endif
 
13
],[
 
14
AC_MSG_RESULT(yes)
 
15
AC_DEFINE(socklen_t, size_t)
 
16
],[
 
17
AC_MSG_RESULT(no)
 
18
AC_DEFINE(socklen_t, int)
 
19
])
 
20
fi
 
21
])
 
22
 
 
23
dnl LSH_PATH_ADD(path-id, directory)
 
24
AC_DEFUN([LSH_PATH_ADD],
 
25
[AC_MSG_CHECKING($2)
 
26
ac_exists=no
 
27
if test -d "$2/." ; then
 
28
  ac_real_dir=`cd $2 && pwd`
 
29
  if test -n "$ac_real_dir" ; then
 
30
    ac_exists=yes
 
31
    for old in $1_REAL_DIRS ; do
 
32
      ac_found=no
 
33
      if test x$ac_real_dir = x$old ; then
 
34
        ac_found=yes;
 
35
        break;
 
36
      fi
 
37
    done
 
38
    if test $ac_found = yes ; then
 
39
      AC_MSG_RESULT(already added)
 
40
    else
 
41
      AC_MSG_RESULT(added)
 
42
      # LDFLAGS="$LDFLAGS -L $2"
 
43
      $1_REAL_DIRS="$ac_real_dir [$]$1_REAL_DIRS"
 
44
      $1_DIRS="$2 [$]$1_DIRS"
 
45
    fi
 
46
  fi
 
47
fi
 
48
if test $ac_exists = no ; then
 
49
  AC_MSG_RESULT(not found)
 
50
fi
 
51
])
 
52
 
 
53
dnl LSH_RPATH_ADD(dir)
 
54
AC_DEFUN([LSH_RPATH_ADD], [LSH_PATH_ADD(RPATH_CANDIDATE, $1)])
 
55
 
 
56
dnl LSH_RPATH_INIT(candidates)
 
57
AC_DEFUN([LSH_RPATH_INIT],
 
58
[AC_MSG_CHECKING([for -R flag])
 
59
RPATHFLAG=''
 
60
case `uname -sr` in
 
61
  OSF1\ V4.*)
 
62
    RPATHFLAG="-rpath "
 
63
    ;;
 
64
  IRIX\ 6.*)
 
65
    RPATHFLAG="-rpath "
 
66
    ;;
 
67
  IRIX\ 5.*)
 
68
    RPATHFLAG="-rpath "
 
69
    ;;
 
70
  SunOS\ 5.*)
 
71
    if test "$TCC" = "yes"; then
 
72
      # tcc doesn't know about -R
 
73
      RPATHFLAG="-Wl,-R,"
 
74
    else
 
75
      RPATHFLAG=-R
 
76
    fi
 
77
    ;;
 
78
  Linux\ 2.*)
 
79
    RPATHFLAG="-Wl,-rpath,"
 
80
    ;;
 
81
  *)
 
82
    :
 
83
    ;;
 
84
esac
 
85
 
 
86
if test x$RPATHFLAG = x ; then
 
87
  AC_MSG_RESULT(none)
 
88
else
 
89
  AC_MSG_RESULT([using $RPATHFLAG])
 
90
fi
 
91
 
 
92
RPATH_CANDIDATE_REAL_DIRS=''
 
93
RPATH_CANDIDATE_DIRS=''
 
94
 
 
95
AC_MSG_RESULT([Searching for libraries])
 
96
 
 
97
for d in $1 ; do
 
98
  LSH_RPATH_ADD($d)
 
99
done
 
100
])    
 
101
 
 
102
dnl Try to execute a main program, and if it fails, try adding some
 
103
dnl -R flag.
 
104
dnl LSH_RPATH_FIX
 
105
AC_DEFUN([LSH_RPATH_FIX],
 
106
[if test $cross_compiling = no -a "x$RPATHFLAG" != x ; then
 
107
  ac_success=no
 
108
  AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
 
109
    ac_success=yes, ac_success=no, :)
 
110
  
 
111
  if test $ac_success = no ; then
 
112
    AC_MSG_CHECKING([Running simple test program failed. Trying -R flags])
 
113
dnl echo RPATH_CANDIDATE_DIRS = $RPATH_CANDIDATE_DIRS
 
114
    ac_remaining_dirs=''
 
115
    ac_rpath_save_LDFLAGS="$LDFLAGS"
 
116
    for d in $RPATH_CANDIDATE_DIRS ; do
 
117
      if test $ac_success = yes ; then
 
118
        ac_remaining_dirs="$ac_remaining_dirs $d"
 
119
      else
 
120
        LDFLAGS="$RPATHFLAG$d $LDFLAGS"
 
121
dnl echo LDFLAGS = $LDFLAGS
 
122
        AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
 
123
          [ac_success=yes
 
124
          ac_rpath_save_LDFLAGS="$LDFLAGS"
 
125
          AC_MSG_RESULT([adding $RPATHFLAG$d])
 
126
          ],
 
127
          [ac_remaining_dirs="$ac_remaining_dirs $d"], :)
 
128
        LDFLAGS="$ac_rpath_save_LDFLAGS"
 
129
      fi
 
130
    done
 
131
    RPATH_CANDIDATE_DIRS=$ac_remaining_dirs
 
132
  fi
 
133
  if test $ac_success = no ; then
 
134
    AC_MSG_RESULT(failed)
 
135
  fi
 
136
fi
 
137
])
 
138
 
 
139
dnl Like AC_CHECK_LIB, but uses $KRB_LIBS rather than $LIBS.
 
140
dnl LSH_CHECK_KRB_LIB(LIBRARY, FUNCTION, [, ACTION-IF-FOUND [,
 
141
dnl                  ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
 
142
 
 
143
AC_DEFUN([LSH_CHECK_KRB_LIB],
 
144
[AC_CHECK_LIB([$1], [$2],
 
145
  ifelse([$3], ,
 
146
      [[ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
 
147
            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
 
148
        AC_DEFINE_UNQUOTED($ac_tr_lib)
 
149
        KRB_LIBS="-l$1 $KRB_LIBS"
 
150
      ]], [$3]),
 
151
  ifelse([$4], , , [$4
 
152
])dnl
 
153
, [$5 $KRB_LIBS])
 
154
])
 
155
 
 
156
dnl LSH_LIB_ARGP(ACTION-IF-OK, ACTION-IF-BAD)
 
157
AC_DEFUN([LSH_LIB_ARGP],
 
158
[ ac_argp_save_LIBS="$LIBS"
 
159
  ac_argp_save_LDFLAGS="$LDFLAGS"
 
160
  ac_argp_ok=no
 
161
  # First check if we can link with argp.
 
162
  AC_SEARCH_LIBS(argp_parse, argp,
 
163
  [ LSH_RPATH_FIX
 
164
    AC_CACHE_CHECK([for working argp],
 
165
      lsh_cv_lib_argp_works,
 
166
      [ AC_TRY_RUN(
 
167
[#include <argp.h>
 
168
#include <stdlib.h>
 
169
 
 
170
static const struct argp_option
 
171
options[] =
 
172
{
 
173
  { NULL, 0, NULL, 0, NULL, 0 }
 
174
};
 
175
 
 
176
struct child_state
 
177
{
 
178
  int n;
 
179
};
 
180
 
 
181
static error_t
 
182
child_parser(int key, char *arg, struct argp_state *state)
 
183
{
 
184
  struct child_state *input = (struct child_state *) state->input;
 
185
  
 
186
  switch(key)
 
187
    {
 
188
    default:
 
189
      return ARGP_ERR_UNKNOWN;
 
190
    case ARGP_KEY_END:
 
191
      if (!input->n)
 
192
        input->n = 1;
 
193
      break;
 
194
    }
 
195
  return 0;
 
196
}
 
197
 
 
198
const struct argp child_argp =
 
199
{
 
200
  options,
 
201
  child_parser,
 
202
  NULL, NULL, NULL, NULL, NULL
 
203
};
 
204
 
 
205
struct main_state
 
206
{
 
207
  struct child_state child;
 
208
  int m;
 
209
};
 
210
 
 
211
static error_t
 
212
main_parser(int key, char *arg, struct argp_state *state)
 
213
{
 
214
  struct main_state *input = (struct main_state *) state->input;
 
215
 
 
216
  switch(key)
 
217
    {
 
218
    default:
 
219
      return ARGP_ERR_UNKNOWN;
 
220
    case ARGP_KEY_INIT:
 
221
      state->child_inputs[0] = &input->child;
 
222
      break;
 
223
    case ARGP_KEY_END:
 
224
      if (!input->m)
 
225
        input->m = input->child.n;
 
226
      
 
227
      break;
 
228
    }
 
229
  return 0;
 
230
}
 
231
 
 
232
static const struct argp_child
 
233
main_children[] =
 
234
{
 
235
  { &child_argp, 0, "", 0 },
 
236
  { NULL, 0, NULL, 0}
 
237
};
 
238
 
 
239
static const struct argp
 
240
main_argp =
 
241
{ options, main_parser, 
 
242
  NULL,
 
243
  NULL,
 
244
  main_children,
 
245
  NULL, NULL
 
246
};
 
247
 
 
248
int main(int argc, char **argv)
 
249
{
 
250
  struct main_state input = { { 0 }, 0 };
 
251
  char *v[2] = { "foo", NULL };
 
252
 
 
253
  argp_parse(&main_argp, 1, v, 0, NULL, &input);
 
254
 
 
255
  if ( (input.m == 1) && (input.child.n == 1) )
 
256
    return 0;
 
257
  else
 
258
    return 1;
 
259
}
 
260
], lsh_cv_lib_argp_works=yes,
 
261
   lsh_cv_lib_argp_works=no,
 
262
   lsh_cv_lib_argp_works=no)])
 
263
 
 
264
  if test x$lsh_cv_lib_argp_works = xyes ; then
 
265
    ac_argp_ok=yes
 
266
  else
 
267
    # Reset link flags
 
268
    LIBS="$ac_argp_save_LIBS"
 
269
    LDFLAGS="$ac_argp_save_LDFLAGS"
 
270
  fi])
 
271
 
 
272
  if test x$ac_argp_ok = xyes ; then
 
273
    ifelse([$1],, true, [$1])
 
274
  else
 
275
    ifelse([$2],, true, [$2])
 
276
  fi   
 
277
])
 
278
 
 
279
dnl LSH_GCC_ATTRIBUTES
 
280
dnl Check for gcc's __attribute__ construction
 
281
 
 
282
AC_DEFUN([LSH_GCC_ATTRIBUTES],
 
283
[AC_CACHE_CHECK(for __attribute__,
 
284
               lsh_cv_c_attribute,
 
285
[ AC_TRY_COMPILE([
 
286
#include <stdlib.h>
 
287
],
 
288
[
 
289
static void foo(void) __attribute__ ((noreturn));
 
290
 
 
291
static void __attribute__ ((noreturn))
 
292
foo(void)
 
293
{
 
294
  exit(1);
 
295
}
 
296
],
 
297
lsh_cv_c_attribute=yes,
 
298
lsh_cv_c_attribute=no)])
 
299
 
 
300
AH_TEMPLATE([HAVE_GCC_ATTRIBUTE], [Define if the compiler understands __attribute__])
 
301
if test "x$lsh_cv_c_attribute" = "xyes"; then
 
302
  AC_DEFINE(HAVE_GCC_ATTRIBUTE)
 
303
fi
 
304
 
 
305
AH_BOTTOM(
 
306
[#if __GNUC__ && HAVE_GCC_ATTRIBUTE
 
307
# define NORETURN __attribute__ ((__noreturn__))
 
308
# define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
 
309
# define UNUSED __attribute__ ((__unused__))
 
310
#else
 
311
# define NORETURN
 
312
# define PRINTF_STYLE(f, a)
 
313
# define UNUSED
 
314
#endif
 
315
])])
 
316
 
 
317
AC_DEFUN([LSH_GCC_FUNCTION_NAME],
 
318
[# Check for gcc's __FUNCTION__ variable
 
319
AH_TEMPLATE([HAVE_GCC_FUNCTION],
 
320
            [Define if the compiler understands __FUNCTION__])
 
321
AH_BOTTOM(
 
322
[#if HAVE_GCC_FUNCTION
 
323
# define FUNCTION_NAME __FUNCTION__
 
324
#else
 
325
# define FUNCTION_NAME "Unknown"
 
326
#endif
 
327
])
 
328
 
 
329
AC_CACHE_CHECK(for __FUNCTION__,
 
330
               lsh_cv_c_FUNCTION,
 
331
  [ AC_TRY_COMPILE(,
 
332
      [ #if __GNUC__ == 3
 
333
        #  error __FUNCTION__ is broken in gcc-3
 
334
        #endif
 
335
        void foo(void) { char c = __FUNCTION__[0]; } ],
 
336
      lsh_cv_c_FUNCTION=yes,
 
337
      lsh_cv_c_FUNCTION=no)])
 
338
 
 
339
if test "x$lsh_cv_c_FUNCTION" = "xyes"; then
 
340
  AC_DEFINE(HAVE_GCC_FUNCTION)
 
341
fi
 
342
])
 
343
 
 
344
# Check for alloca, and include the standard blurb in config.h
 
345
AC_DEFUN([LSH_FUNC_ALLOCA],
 
346
[AC_FUNC_ALLOCA
 
347
AC_CHECK_HEADERS([malloc.h])
 
348
AH_BOTTOM(
 
349
[/* AIX requires this to be the first thing in the file.  */
 
350
#ifndef __GNUC__
 
351
# if HAVE_ALLOCA_H
 
352
#  include <alloca.h>
 
353
# else
 
354
#  ifdef _AIX
 
355
 #pragma alloca
 
356
#  else
 
357
#   ifndef alloca /* predefined by HP cc +Olibcalls */
 
358
char *alloca ();
 
359
#   endif
 
360
#  endif
 
361
# endif
 
362
#else /* defined __GNUC__ */
 
363
# if HAVE_ALLOCA_H
 
364
#  include <alloca.h>
 
365
# endif
 
366
#endif
 
367
/* Needed for alloca on windows */
 
368
#if HAVE_MALLOC_H
 
369
# include <malloc.h>
 
370
#endif
 
371
])])
 
372
 
 
373
AC_DEFUN([LSH_FUNC_STRERROR],
 
374
[AC_CHECK_FUNCS(strerror)
 
375
AH_BOTTOM(
 
376
[#if HAVE_STRERROR
 
377
#define STRERROR strerror
 
378
#else
 
379
#define STRERROR(x) (sys_errlist[x])
 
380
#endif
 
381
])])
 
382
 
 
383
AC_DEFUN([LSH_FUNC_STRSIGNAL],
 
384
[AC_CHECK_FUNCS(strsignal)
 
385
AC_CHECK_DECLS([sys_siglist, _sys_siglist])
 
386
AH_BOTTOM(
 
387
[#if HAVE_STRSIGNAL
 
388
# define STRSIGNAL strsignal
 
389
#else /* !HAVE_STRSIGNAL */
 
390
# if HAVE_DECL_SYS_SIGLIST
 
391
#  define STRSIGNAL(x) (sys_siglist[x])
 
392
# else
 
393
#  if HAVE_DECL__SYS_SIGLIST
 
394
#   define STRSIGNAL(x) (_sys_siglist[x])
 
395
#  else
 
396
#   define STRSIGNAL(x) "Unknown signal"
 
397
#   if __GNUC__
 
398
#    warning Using dummy STRSIGNAL
 
399
#   endif
 
400
#  endif
 
401
# endif
 
402
#endif /* !HAVE_STRSIGNAL */
 
403
])])
 
404
 
 
405
dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
 
406
dnl
 
407
dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
 
408
dnl existence of an include file <stdint.h> that defines a set of 
 
409
dnl typedefs, especially uint8_t,int32_t,uintptr_t.
 
410
dnl Many older installations will not provide this file, but some will
 
411
dnl have the very same definitions in <inttypes.h>. In other enviroments
 
412
dnl we can use the inet-types in <sys/types.h> which would define the
 
413
dnl typedefs int8_t and u_int8_t respectivly.
 
414
dnl
 
415
dnl This macros will create a local "_stdint.h" or the headerfile given as 
 
416
dnl an argument. In many cases that file will just "#include <stdint.h>" 
 
417
dnl or "#include <inttypes.h>", while in other environments it will provide 
 
418
dnl the set of basic 'stdint's definitions/typedefs: 
 
419
dnl   int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
 
420
dnl   int_least32_t.. int_fast32_t.. intmax_t
 
421
dnl which may or may not rely on the definitions of other files,
 
422
dnl or using the AC_CHECK_SIZEOF macro to determine the actual
 
423
dnl sizeof each type.
 
424
dnl
 
425
dnl if your header files require the stdint-types you will want to create an
 
426
dnl installable file mylib-int.h that all your other installable header
 
427
dnl may include. So if you have a library package named "mylib", just use
 
428
dnl      AX_CREATE_STDINT_H(mylib-int.h) 
 
429
dnl in configure.ac and go to install that very header file in Makefile.am
 
430
dnl along with the other headers (mylib.h) - and the mylib-specific headers
 
431
dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
 
432
dnl
 
433
dnl Remember, if the system already had a valid <stdint.h>, the generated
 
434
dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
 
435
dnl
 
436
dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
 
437
dnl @version $Id: acinclude.m4,v 1.19 2004/03/01 15:49:39 nisse Exp $
 
438
dnl @author  Guido Draheim <guidod@gmx.de> 
 
439
 
 
440
AC_DEFUN([AX_CREATE_STDINT_H],
 
441
[# ------ AX CREATE STDINT H -------------------------------------
 
442
AC_MSG_CHECKING([for stdint types])
 
443
ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
 
444
# try to shortcircuit - if the default include path of the compiler
 
445
# can find a "stdint.h" header then we assume that all compilers can.
 
446
AC_CACHE_VAL([ac_cv_header_stdint_t],[
 
447
old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
 
448
old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
 
449
old_CFLAGS="$CFLAGS"     ; CFLAGS=""
 
450
AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
 
451
[ac_cv_stdint_result="(assuming C99 compatible system)"
 
452
 ac_cv_header_stdint_t="stdint.h"; ],
 
453
[ac_cv_header_stdint_t=""])
 
454
CXXFLAGS="$old_CXXFLAGS"
 
455
CPPFLAGS="$old_CPPFLAGS"
 
456
CFLAGS="$old_CFLAGS" ])
 
457
 
 
458
v="... $ac_cv_header_stdint_h"
 
459
if test "$ac_stdint_h" = "stdint.h" ; then
 
460
 AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
 
461
elif test "$ac_stdint_h" = "inttypes.h" ; then
 
462
 AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
 
463
elif test "_$ac_cv_header_stdint_t" = "_" ; then
 
464
 AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
 
465
else
 
466
 ac_cv_header_stdint="$ac_cv_header_stdint_t"
 
467
 AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
 
468
fi
 
469
 
 
470
if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
 
471
 
 
472
dnl .....intro message done, now do a few system checks.....
 
473
dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore
 
474
dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead
 
475
 
 
476
inttype_headers=`echo $2 | sed -e 's/,/ /g'`
 
477
 
 
478
ac_cv_stdint_result="(no helpful system typedefs seen)"
 
479
AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
 
480
 ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
 
481
  AC_MSG_RESULT([(..)])
 
482
  for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers ; do
 
483
   unset ac_cv_type_uintptr_t 
 
484
   unset ac_cv_type_uint64_t
 
485
   _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
 
486
     continue,[#include <$i>])
 
487
   AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
 
488
   ac_cv_stdint_result="(seen uintptr_t$and64 in $i)"
 
489
   break;
 
490
  done
 
491
  AC_MSG_CHECKING([for stdint uintptr_t])
 
492
 ])
 
493
 
 
494
if test "_$ac_cv_header_stdint_x" = "_" ; then
 
495
AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
 
496
 ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
 
497
  AC_MSG_RESULT([(..)])
 
498
  for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers ; do
 
499
   unset ac_cv_type_uint32_t
 
500
   unset ac_cv_type_uint64_t
 
501
   AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
 
502
     continue,[#include <$i>])
 
503
   AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
 
504
   ac_cv_stdint_result="(seen uint32_t$and64 in $i)"
 
505
   break;
 
506
  done
 
507
  AC_MSG_CHECKING([for stdint uint32_t])
 
508
 ])
 
509
fi
 
510
 
 
511
if test "_$ac_cv_header_stdint_x" = "_" ; then
 
512
if test "_$ac_cv_header_stdint_o" = "_" ; then
 
513
AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
 
514
 ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
 
515
  AC_MSG_RESULT([(..)])
 
516
  for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do
 
517
   unset ac_cv_type_u_int32_t
 
518
   unset ac_cv_type_u_int64_t
 
519
   AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
 
520
     continue,[#include <$i>])
 
521
   AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
 
522
   ac_cv_stdint_result="(seen u_int32_t$and64 in $i)"
 
523
   break;
 
524
  done
 
525
  AC_MSG_CHECKING([for stdint u_int32_t])
 
526
 ])
 
527
fi fi
 
528
 
 
529
dnl if there was no good C99 header file, do some typedef checks...
 
530
if test "_$ac_cv_header_stdint_x" = "_" ; then
 
531
   AC_MSG_CHECKING([for stdint datatype model])
 
532
   AC_MSG_RESULT([(..)])
 
533
   AC_CHECK_SIZEOF(char)
 
534
   AC_CHECK_SIZEOF(short)
 
535
   AC_CHECK_SIZEOF(int)
 
536
   AC_CHECK_SIZEOF(long)
 
537
   AC_CHECK_SIZEOF(void*)
 
538
   ac_cv_stdint_char_model=""
 
539
   ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char"
 
540
   ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short"
 
541
   ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int"
 
542
   ac_cv_stdint_long_model=""
 
543
   ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int"
 
544
   ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long"
 
545
   ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp"
 
546
   name="$ac_cv_stdint_long_model"
 
547
   case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in
 
548
    122/242)     name="$name,  IP16 (standard 16bit machine)" ;;
 
549
    122/244)     name="$name,  LP32 (standard 32bit mac/win)" ;;
 
550
    122/*)       name="$name        (unusual int16 model)" ;; 
 
551
    124/444)     name="$name, ILP32 (standard 32bit unixish)" ;;
 
552
    124/488)     name="$name,  LP64 (standard 64bit unixish)" ;;
 
553
    124/448)     name="$name, LLP64 (unusual  64bit unixish)" ;;
 
554
    124/*)       name="$name        (unusual int32 model)" ;; 
 
555
    128/888)     name="$name, ILP64 (unusual  64bit numeric)" ;;
 
556
    128/*)       name="$name        (unusual int64 model)" ;; 
 
557
    222/*|444/*) name="$name        (unusual dsptype)" ;;
 
558
     *)          name="$name        (very unusal model)" ;;
 
559
   esac
 
560
   AC_MSG_RESULT([combined for stdint datatype model...  $name])
 
561
fi
 
562
 
 
563
if test "_$ac_cv_header_stdint_x" != "_" ; then
 
564
   ac_cv_header_stdint="$ac_cv_header_stdint_x"
 
565
elif  test "_$ac_cv_header_stdint_o" != "_" ; then
 
566
   ac_cv_header_stdint="$ac_cv_header_stdint_o"
 
567
elif  test "_$ac_cv_header_stdint_u" != "_" ; then
 
568
   ac_cv_header_stdint="$ac_cv_header_stdint_u"
 
569
else
 
570
   ac_cv_header_stdint="stddef.h"
 
571
fi
 
572
 
 
573
AC_MSG_CHECKING([for extra inttypes in chosen header])
 
574
AC_MSG_RESULT([($ac_cv_header_stdint)])
 
575
dnl see if int_least and int_fast types are present in _this_ header.
 
576
unset ac_cv_type_int_least32_t
 
577
unset ac_cv_type_int_fast32_t
 
578
AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
 
579
AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
 
580
AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
 
581
 
 
582
fi # shortcircut to system "stdint.h"
 
583
# ------------------ PREPARE VARIABLES ------------------------------
 
584
if test "$GCC" = "yes" ; then
 
585
ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1` 
 
586
else
 
587
ac_cv_stdint_message="using $CC"
 
588
fi
 
589
 
 
590
AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
 
591
$ac_cv_stdint_result])
 
592
 
 
593
# ----------------- DONE inttypes.h checks START header -------------
 
594
AC_CONFIG_COMMANDS([$ac_stdint_h],[
 
595
AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
 
596
ac_stdint=$tmp/_stdint.h
 
597
 
 
598
echo "#ifndef" $_ac_stdint_h >$ac_stdint
 
599
echo "#define" $_ac_stdint_h "1" >>$ac_stdint
 
600
echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
 
601
echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
 
602
echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
 
603
if test "_$ac_cv_header_stdint_t" != "_" ; then 
 
604
echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
 
605
fi
 
606
 
 
607
cat >>$ac_stdint <<STDINT_EOF
 
608
 
 
609
/* ................... shortcircuit part ........................... */
 
610
 
 
611
#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
 
612
#include <stdint.h>
 
613
#else
 
614
#include <stddef.h>
 
615
 
 
616
/* .................... configured part ............................ */
 
617
 
 
618
STDINT_EOF
 
619
 
 
620
echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
 
621
if test "_$ac_cv_header_stdint_x" != "_" ; then
 
622
  ac_header="$ac_cv_header_stdint_x"
 
623
  echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
 
624
else
 
625
  echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
 
626
fi
 
627
 
 
628
echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
 
629
if  test "_$ac_cv_header_stdint_o" != "_" ; then
 
630
  ac_header="$ac_cv_header_stdint_o"
 
631
  echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
 
632
else
 
633
  echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
 
634
fi
 
635
 
 
636
echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
 
637
if  test "_$ac_cv_header_stdint_u" != "_" ; then
 
638
  ac_header="$ac_cv_header_stdint_u"
 
639
  echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
 
640
else
 
641
  echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
 
642
fi
 
643
 
 
644
echo "" >>$ac_stdint
 
645
 
 
646
if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
 
647
  echo "#include <$ac_header>" >>$ac_stdint
 
648
  echo "" >>$ac_stdint
 
649
fi fi
 
650
 
 
651
echo "/* which 64bit typedef has been found */" >>$ac_stdint
 
652
if test "$ac_cv_type_uint64_t" = "yes" ; then
 
653
echo "#define   _STDINT_HAVE_UINT64_T" "1"  >>$ac_stdint
 
654
else
 
655
echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
 
656
fi
 
657
if test "$ac_cv_type_u_int64_t" = "yes" ; then
 
658
echo "#define   _STDINT_HAVE_U_INT64_T" "1"  >>$ac_stdint
 
659
else
 
660
echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
 
661
fi
 
662
echo "" >>$ac_stdint
 
663
 
 
664
echo "/* which type model has been detected */" >>$ac_stdint
 
665
if test "_$ac_cv_stdint_char_model" != "_" ; then
 
666
echo "#define   _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint
 
667
echo "#define   _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint
 
668
else
 
669
echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
 
670
echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
 
671
fi
 
672
echo "" >>$ac_stdint
 
673
 
 
674
echo "/* whether int_least types were detected */" >>$ac_stdint
 
675
if test "$ac_cv_type_int_least32_t" = "yes"; then
 
676
echo "#define   _STDINT_HAVE_INT_LEAST32_T" "1"  >>$ac_stdint
 
677
else
 
678
echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
 
679
fi
 
680
echo "/* whether int_fast types were detected */" >>$ac_stdint
 
681
if test "$ac_cv_type_int_fast32_t" = "yes"; then
 
682
echo "#define   _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
 
683
else
 
684
echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
 
685
fi
 
686
echo "/* whether intmax_t type was detected */" >>$ac_stdint
 
687
if test "$ac_cv_type_intmax_t" = "yes"; then
 
688
echo "#define   _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
 
689
else
 
690
echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
 
691
fi
 
692
echo "" >>$ac_stdint
 
693
 
 
694
  cat >>$ac_stdint <<STDINT_EOF
 
695
/* .................... detections part ............................ */
 
696
 
 
697
/* whether we need to define bitspecific types from compiler base types */
 
698
#ifndef _STDINT_HEADER_INTPTR
 
699
#ifndef _STDINT_HEADER_UINT32
 
700
#ifndef _STDINT_HEADER_U_INT32
 
701
#define _STDINT_NEED_INT_MODEL_T
 
702
#else
 
703
#define _STDINT_HAVE_U_INT_TYPES
 
704
#endif
 
705
#endif
 
706
#endif
 
707
 
 
708
#ifdef _STDINT_HAVE_U_INT_TYPES
 
709
#undef _STDINT_NEED_INT_MODEL_T
 
710
#endif
 
711
 
 
712
#ifdef  _STDINT_CHAR_MODEL
 
713
#if     _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
 
714
#ifndef _STDINT_BYTE_MODEL
 
715
#define _STDINT_BYTE_MODEL 12
 
716
#endif
 
717
#endif
 
718
#endif
 
719
 
 
720
#ifndef _STDINT_HAVE_INT_LEAST32_T
 
721
#define _STDINT_NEED_INT_LEAST_T
 
722
#endif
 
723
 
 
724
#ifndef _STDINT_HAVE_INT_FAST32_T
 
725
#define _STDINT_NEED_INT_FAST_T
 
726
#endif
 
727
 
 
728
#ifndef _STDINT_HEADER_INTPTR
 
729
#define _STDINT_NEED_INTPTR_T
 
730
#ifndef _STDINT_HAVE_INTMAX_T
 
731
#define _STDINT_NEED_INTMAX_T
 
732
#endif
 
733
#endif
 
734
 
 
735
 
 
736
/* .................... definition part ............................ */
 
737
 
 
738
/* some system headers have good uint64_t */
 
739
#ifndef _HAVE_UINT64_T
 
740
#if     defined _STDINT_HAVE_UINT64_T  || defined HAVE_UINT64_T
 
741
#define _HAVE_UINT64_T
 
742
#elif   defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
 
743
#define _HAVE_UINT64_T
 
744
typedef u_int64_t uint64_t;
 
745
#endif
 
746
#endif
 
747
 
 
748
#ifndef _HAVE_UINT64_T
 
749
/* .. here are some common heuristics using compiler runtime specifics */
 
750
#if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
 
751
#define _HAVE_UINT64_T
 
752
typedef long long int64_t;
 
753
typedef unsigned long long uint64_t;
 
754
 
 
755
#elif !defined __STRICT_ANSI__
 
756
#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
 
757
#define _HAVE_UINT64_T
 
758
typedef __int64 int64_t;
 
759
typedef unsigned __int64 uint64_t;
 
760
 
 
761
#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
 
762
/* note: all ELF-systems seem to have loff-support which needs 64-bit */
 
763
#if !defined _NO_LONGLONG
 
764
#define _HAVE_UINT64_T
 
765
typedef long long int64_t;
 
766
typedef unsigned long long uint64_t;
 
767
#endif
 
768
 
 
769
#elif defined __alpha || (defined __mips && defined _ABIN32)
 
770
#if !defined _NO_LONGLONG
 
771
typedef long int64_t;
 
772
typedef unsigned long uint64_t;
 
773
#endif
 
774
  /* compiler/cpu type to define int64_t */
 
775
#endif
 
776
#endif
 
777
#endif
 
778
 
 
779
#if defined _STDINT_HAVE_U_INT_TYPES
 
780
/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
 
781
typedef u_int8_t uint8_t;
 
782
typedef u_int16_t uint16_t;
 
783
typedef u_int32_t uint32_t;
 
784
 
 
785
/* glibc compatibility */
 
786
#ifndef __int8_t_defined
 
787
#define __int8_t_defined
 
788
#endif
 
789
#endif
 
790
 
 
791
#ifdef _STDINT_NEED_INT_MODEL_T
 
792
/* we must guess all the basic types. Apart from byte-adressable system, */
 
793
/* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
 
794
/* (btw, those nibble-addressable systems are way off, or so we assume) */
 
795
 
 
796
dnl   /* have a look at "64bit and data size neutrality" at */
 
797
dnl   /* http://unix.org/version2/whatsnew/login_64bit.html */
 
798
dnl   /* (the shorthand "ILP" types always have a "P" part) */
 
799
 
 
800
#if defined _STDINT_BYTE_MODEL
 
801
#if _STDINT_LONG_MODEL+0 == 242
 
802
/* 2:4:2 =  IP16 = a normal 16-bit system                */
 
803
typedef unsigned char   uint8_t;
 
804
typedef unsigned short  uint16_t;
 
805
typedef unsigned long   uint32_t;
 
806
#ifndef __int8_t_defined
 
807
#define __int8_t_defined
 
808
typedef          char    int8_t;
 
809
typedef          short   int16_t;
 
810
typedef          long    int32_t;
 
811
#endif
 
812
#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
 
813
/* 2:4:4 =  LP32 = a 32-bit system derived from a 16-bit */
 
814
/* 4:4:4 = ILP32 = a normal 32-bit system                */
 
815
typedef unsigned char   uint8_t;
 
816
typedef unsigned short  uint16_t;
 
817
typedef unsigned int    uint32_t;
 
818
#ifndef __int8_t_defined
 
819
#define __int8_t_defined
 
820
typedef          char    int8_t;
 
821
typedef          short   int16_t;
 
822
typedef          int     int32_t;
 
823
#endif
 
824
#elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
 
825
/* 4:8:4 =  IP32 = a 32-bit system prepared for 64-bit    */
 
826
/* 4:8:8 =  LP64 = a normal 64-bit system                 */
 
827
typedef unsigned char   uint8_t;
 
828
typedef unsigned short  uint16_t;
 
829
typedef unsigned int    uint32_t;
 
830
#ifndef __int8_t_defined
 
831
#define __int8_t_defined
 
832
typedef          char    int8_t;
 
833
typedef          short   int16_t;
 
834
typedef          int     int32_t;
 
835
#endif
 
836
/* this system has a "long" of 64bit */
 
837
#ifndef _HAVE_UINT64_T
 
838
#define _HAVE_UINT64_T
 
839
typedef unsigned long   uint64_t;
 
840
typedef          long    int64_t;
 
841
#endif
 
842
#elif _STDINT_LONG_MODEL+0 == 448
 
843
/*      LLP64   a 64-bit system derived from a 32-bit system */
 
844
typedef unsigned char   uint8_t;
 
845
typedef unsigned short  uint16_t;
 
846
typedef unsigned int    uint32_t;
 
847
#ifndef __int8_t_defined
 
848
#define __int8_t_defined
 
849
typedef          char    int8_t;
 
850
typedef          short   int16_t;
 
851
typedef          int     int32_t;
 
852
#endif
 
853
/* assuming the system has a "long long" */
 
854
#ifndef _HAVE_UINT64_T
 
855
#define _HAVE_UINT64_T
 
856
typedef unsigned long long uint64_t;
 
857
typedef          long long  int64_t;
 
858
#endif
 
859
#else
 
860
#define _STDINT_NO_INT32_T
 
861
#endif
 
862
#else
 
863
#define _STDINT_NO_INT8_T
 
864
#define _STDINT_NO_INT32_T
 
865
#endif
 
866
#endif
 
867
 
 
868
/*
 
869
 * quote from SunOS-5.8 sys/inttypes.h:
 
870
 * Use at your own risk.  As of February 1996, the committee is squarely
 
871
 * behind the fixed sized types; the "least" and "fast" types are still being
 
872
 * discussed.  The probability that the "fast" types may be removed before
 
873
 * the standard is finalized is high enough that they are not currently
 
874
 * implemented.
 
875
 */
 
876
 
 
877
#if defined _STDINT_NEED_INT_LEAST_T
 
878
typedef  int8_t    int_least8_t;
 
879
typedef  int16_t   int_least16_t;
 
880
typedef  int32_t   int_least32_t;
 
881
#ifdef _HAVE_UINT64_T
 
882
typedef  int64_t   int_least64_t;
 
883
#endif
 
884
 
 
885
typedef uint8_t   uint_least8_t;
 
886
typedef uint16_t  uint_least16_t;
 
887
typedef uint32_t  uint_least32_t;
 
888
#ifdef _HAVE_UINT64_T
 
889
typedef uint64_t  uint_least64_t;
 
890
#endif
 
891
  /* least types */
 
892
#endif
 
893
 
 
894
#if defined _STDINT_NEED_INT_FAST_T
 
895
typedef  int8_t    int_fast8_t; 
 
896
typedef  int       int_fast16_t;
 
897
typedef  int32_t   int_fast32_t;
 
898
#ifdef _HAVE_UINT64_T
 
899
typedef  int64_t   int_fast64_t;
 
900
#endif
 
901
 
 
902
typedef uint8_t   uint_fast8_t; 
 
903
typedef unsigned  uint_fast16_t;
 
904
typedef uint32_t  uint_fast32_t;
 
905
#ifdef _HAVE_UINT64_T
 
906
typedef uint64_t  uint_fast64_t;
 
907
#endif
 
908
  /* fast types */
 
909
#endif
 
910
 
 
911
#ifdef _STDINT_NEED_INTMAX_T
 
912
#ifdef _HAVE_UINT64_T
 
913
typedef  int64_t       intmax_t;
 
914
typedef uint64_t      uintmax_t;
 
915
#else
 
916
typedef          long  intmax_t;
 
917
typedef unsigned long uintmax_t;
 
918
#endif
 
919
#endif
 
920
 
 
921
#ifdef _STDINT_NEED_INTPTR_T
 
922
#ifndef __intptr_t_defined
 
923
#define __intptr_t_defined
 
924
/* we encourage using "long" to store pointer values, never use "int" ! */
 
925
#if   _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
 
926
typedef  unsinged int   uintptr_t;
 
927
typedef           int    intptr_t;
 
928
#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
 
929
typedef  unsigned long  uintptr_t;
 
930
typedef           long   intptr_t;
 
931
#elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
 
932
typedef        uint64_t uintptr_t;
 
933
typedef         int64_t  intptr_t;
 
934
#else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
 
935
typedef  unsigned long  uintptr_t;
 
936
typedef           long   intptr_t;
 
937
#endif
 
938
#endif
 
939
#endif
 
940
 
 
941
  /* shortcircuit*/
 
942
#endif
 
943
  /* once */
 
944
#endif
 
945
#endif
 
946
STDINT_EOF
 
947
    if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
 
948
      AC_MSG_NOTICE([$ac_stdint_h is unchanged])
 
949
    else
 
950
      ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
 
951
      AS_MKDIR_P(["$ac_dir"])
 
952
      rm -f $ac_stdint_h
 
953
      mv $ac_stdint $ac_stdint_h
 
954
    fi
 
955
],[# variables for create stdint.h replacement
 
956
PACKAGE="$PACKAGE"
 
957
VERSION="$VERSION"
 
958
ac_stdint_h="$ac_stdint_h"
 
959
_ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
 
960
ac_cv_stdint_message="$ac_cv_stdint_message"
 
961
ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
 
962
ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
 
963
ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
 
964
ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
 
965
ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
 
966
ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
 
967
ac_cv_stdint_char_model="$ac_cv_stdint_char_model"
 
968
ac_cv_stdint_long_model="$ac_cv_stdint_long_model"
 
969
ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
 
970
ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
 
971
ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
 
972
])
 
973
])