source: trunk/m4/ac_create_stdint_h.m4 @ 1028

Revision 1028, 15.4 KB checked in by alonbl, 4 years ago (diff)

New build system

Sync with other projects.

merge -r 1014:1027  https://www.opensc-project.org/svn/openct/branches/alonbl/build

_M .
_M macos
M macos/Makefile.am
M configure.ac
_M doc
D doc/changelog.sh
M doc/doxygen.conf.in
D doc/export-wiki.xsl
M doc/Makefile.am
A doc/opensc-logo.gif
D doc/generate-api.sh
D doc/export-wiki.sh
AM doc/nonpersistent
A doc/nonpersistent/export-wiki.xsl
A doc/nonpersistent/Makefile.am
A doc/nonpersistent/export-wiki.sh
A doc/nonpersistent/svn2cl.xsl
D doc/svn2cl.xsl
A doc/doxygen-footer.html
_M src
_M src/ctapi
M src/ctapi/Makefile.am
_M src/tools
M src/tools/Makefile.am
_M src/ifd
M src/ifd/ifd-cm4000.c
M src/ifd/atr.c
M src/ifd/ifd-pertosmart1030.c
M src/ifd/ifd-pertosmart1038.c
M src/ifd/ifd-rutoken.c
M src/ifd/sys-linux.c
M src/ifd/Makefile.am
_M src/include
_M src/include/openct
M src/include/openct/Makefile.am
M src/include/Makefile.am
_M src/ct
M src/ct/Makefile.am
_M src/pcsc
M src/pcsc/Makefile.am
M src/Makefile.am
M Makefile.am
A svnignore
_M etc
M etc/Makefile.am
_M solaris
_M aclocal
D aclocal/pkg.m4
M aclocal/ac_create_stdint_h.m4
D aclocal/ac_compile_check_sizeof.m4
M aclocal/Makefile.am

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1dnl @synopsis AC_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]
2dnl
3dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
4dnl existence of an include file <stdint.h> that defines a set of
5dnl typedefs, especially uint8_t,int32_t,uintptr_t.
6dnl Many older installations will not provide this file, but some will
7dnl have the very same definitions in <inttypes.h>. In other enviroments
8dnl we can use the inet-types in <sys/types.h> which would define the
9dnl typedefs int8_t and u_int8_t respectivly.
10dnl
11dnl This macros will create a local "_stdint.h" or the headerfile given as
12dnl an argument. In many cases that file will just have a singular
13dnl "#include <stdint.h>" or "#include <inttypes.h>" statement, while
14dnl in other environments it will provide the set of basic 'stdint's defined:
15dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
16dnl int_least32_t.. int_fast32_t.. intmax_t
17dnl which may or may not rely on the definitions of other files,
18dnl or using the AC_CHECK_SIZEOF macro to determine the actual
19dnl sizeof each type.
20dnl
21dnl if your header files require the stdint-types you will want to create an
22dnl installable file mylib-int.h that all your other installable header
23dnl may include. So if you have a library package named "mylib", just use
24dnl
25dnl      AC_CREATE_STDINT_H(mylib-int.h)
26dnl
27dnl in configure.in and go to install that very header file in Makefile.am
28dnl along with the other headers (mylib.h) - and the mylib-specific headers
29dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
30dnl
31dnl Remember, if the system already had a valid <stdint.h>, the generated
32dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
33dnl
34dnl (note also the newer variant AX_CREATE_STDINT_H of this macro)
35dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
36dnl @version $Id$
37dnl @author  Guido Draheim <guidod@gmx.de>
38
39AC_DEFUN([AC_CREATE_STDINT_H],
40[# ------ AC CREATE STDINT H -------------------------------------
41AC_PROG_MKDIR_P
42AC_PROG_SED
43AC_MSG_CHECKING([for stdint-types....])
44ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
45if test "$ac_stdint_h" = "stdint.h" ; then
46 AC_MSG_RESULT("(are you sure you want them in ./stdint.h?)")
47elif test "$ac_stdint_h" = "inttypes.h" ; then
48 AC_MSG_RESULT("(are you sure you want them in ./inttypes.h?)")
49else
50 AC_MSG_RESULT("(putting them into $ac_stdint_h)")
51fi
52
53inttype_headers=`echo inttypes.h sys/inttypes.h sys/inttypes.h $2 \
54| sed -e 's/,/ /g'`
55
56 ac_cv_header_stdint_x="no-file"
57 ac_cv_header_stdint_o="no-file"
58 ac_cv_header_stdint_u="no-file"
59 for i in stdint.h $inttype_headers ; do
60   unset ac_cv_type_uintptr_t
61   unset ac_cv_type_uint64_t
62   _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
63     continue,[#include <$i>])
64   AC_CHECK_TYPE(uint64_t,[and64="(uint64_t too)"],[and64=""],[#include<$i>])
65   AC_MSG_RESULT(... seen our uintptr_t in $i $and64)
66   break;
67 done
68 if test "$ac_cv_header_stdint_x" = "no-file" ; then
69 for i in stdint.h $inttype_headers ; do
70   unset ac_cv_type_uint32_t
71   unset ac_cv_type_uint64_t
72   AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
73     continue,[#include <$i>])
74   AC_CHECK_TYPE(uint64_t,[and64="(uint64_t too)"],[and64=""],[#include<$i>])
75   AC_MSG_RESULT(... seen our uint32_t in $i $and64)
76   break;
77 done
78 if test "$ac_cv_header_stdint_o" = "no-file" ; then
79 for i in sys/types.h $inttype_headers ; do
80   unset ac_cv_type_u_int32_t
81   unset ac_cv_type_u_int64_t
82   AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
83     continue,[#include <$i>])
84   AC_CHECK_TYPE(uint64_t,[and64="(u_int64_t too)"],[and64=""],[#include<$i>])
85   AC_MSG_RESULT(... seen our u_int32_t in $i $and64)
86   break;
87 done
88 fi
89 fi
90
91# ----------------- DONE inttypes.h checks MAYBE C basic types --------
92
93if test "$ac_cv_header_stdint_x" = "no-file" ; then
94   AC_CHECK_SIZEOF(char)
95   AC_CHECK_SIZEOF(short)
96   AC_CHECK_SIZEOF(int)
97   AC_CHECK_SIZEOF(long)
98   AC_CHECK_SIZEOF(void*)
99   ac_cv_header_stdint_test="yes"
100else
101   ac_cv_header_stdint_test="no"
102fi
103
104# ----------------- DONE inttypes.h checks START header -------------
105_ac_stdint_h=AS_TR_CPP(_$ac_stdint_h)
106AC_MSG_RESULT(creating $ac_stdint_h : $_ac_stdint_h)
107${MKDIR_P} $(echo "${ac_stdint_h}" | ${SED} 's/[[^/]]*$//') 2> /dev/null
108echo "#ifndef" $_ac_stdint_h >$ac_stdint_h
109echo "#define" $_ac_stdint_h "1" >>$ac_stdint_h
110echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint_h
111echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint_h
112if test "$GCC" = "yes" ; then
113  echo "/* generated using a gnu compiler version" `$CC --version` "*/" \
114  >>$ac_stdint_h
115else
116  echo "/* generated using $CC */" >>$ac_stdint_h
117fi
118echo "" >>$ac_stdint_h
119
120if test "$ac_cv_header_stdint_x" != "no-file" ; then
121   ac_cv_header_stdint="$ac_cv_header_stdint_x"
122elif  test "$ac_cv_header_stdint_o" != "no-file" ; then
123   ac_cv_header_stdint="$ac_cv_header_stdint_o"
124elif  test "$ac_cv_header_stdint_u" != "no-file" ; then
125   ac_cv_header_stdint="$ac_cv_header_stdint_u"
126else
127   ac_cv_header_stdint="stddef.h"
128fi
129
130# ----------------- See if int_least and int_fast types are present
131unset ac_cv_type_int_least32_t
132unset ac_cv_type_int_fast32_t
133AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
134AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
135
136if test "$ac_cv_header_stdint" != "stddef.h" ; then
137if test "$ac_cv_header_stdint" != "stdint.h" ; then
138AC_MSG_RESULT(..adding include stddef.h)
139   echo "#include <stddef.h>" >>$ac_stdint_h
140fi ; fi
141AC_MSG_RESULT(..adding include $ac_cv_header_stdint)
142   echo "#include <$ac_cv_header_stdint>" >>$ac_stdint_h
143echo "" >>$ac_stdint_h
144
145# ----------------- DONE header START basic int types -------------
146if test "$ac_cv_header_stdint_x" = "no-file" ; then
147   AC_MSG_RESULT(... need to look at C basic types)
148dnl ac_cv_header_stdint_test="yes" # moved up before creating the file
149else
150   AC_MSG_RESULT(... seen good stdint.h inttypes)
151dnl ac_cv_header_stdint_test="no"  # moved up before creating the file
152fi
153
154if test "$ac_cv_header_stdint_u" != "no-file" ; then
155   AC_MSG_RESULT(... seen bsd/sysv typedefs)
156   cat >>$ac_stdint_h <<EOF
157
158/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
159typedef u_int8_t uint8_t;
160typedef u_int16_t uint16_t;
161typedef u_int32_t uint32_t;
162EOF
163    cat >>$ac_stdint_h <<EOF
164
165/* glibc compatibility */
166#ifndef __int8_t_defined
167#define __int8_t_defined
168#endif
169EOF
170fi
171
172ac_cv_sizeof_x="$ac_cv_sizeof_char:$ac_cv_sizeof_short"
173ac_cv_sizeof_X="$ac_cv_sizeof_x:$ac_cv_sizeof_int"
174ac_cv_sizeof_X="$ac_cv_sizeof_X:$ac_cv_sizeof_voidp:$ac_cv_sizeof_long"
175if test "$ac_cv_header_stdint" = "stddef.h" ; then
176#   we must guess all the basic types. Apart from byte-adressable system,
177# there a few 32-bit-only dsp-systems. nibble-addressable systems are way off.
178    cat >>$ac_stdint_h <<EOF
179/* ------------ BITSPECIFIC INTTYPES SECTION --------------- */
180EOF
181    t="typedefs for a"
182    case "$ac_cv_sizeof_X" in
183     1:2:2:2:4) AC_MSG_RESULT(..adding $t normal 16-bit system)
184                cat >>$ac_stdint_h <<EOF
185/*              a normal 16-bit system                       */
186typedef unsigned char   uint8_t;
187typedef unsigned short  uint16_t;
188typedef unsigned long   uint32_t;
189#ifndef __int8_t_defined
190#define __int8_t_defined
191typedef          char    int8_t;
192typedef          short   int16_t;
193typedef          long    int32_t;
194#endif
195EOF
196;;
197     1:2:2:4:4) AC_MSG_RESULT(..adding $t 32-bit system derived from a 16-bit)
198                cat >>$ac_stdint_h <<EOF
199/*              a 32-bit system derived from a 16-bit        */
200typedef unsigned char   uint8_t;
201typedef unsigned short  uint16_t;
202typedef unsigned int    uint32_t;
203#ifndef __int8_t_defined
204#define __int8_t_defined
205typedef          char    int8_t;
206typedef          short   int16_t;
207typedef          int     int32_t;
208#endif
209EOF
210;;
211     1:2:4:4:4) AC_MSG_RESULT(..adding $t normal 32-bit system)
212                cat >>$ac_stdint_h <<EOF
213/*              a normal 32-bit system                       */
214typedef unsigned char   uint8_t;
215typedef unsigned short  uint16_t;
216typedef unsigned int    uint32_t;
217#ifndef __int8_t_defined
218#define __int8_t_defined
219typedef          char    int8_t;
220typedef          short   int16_t;
221typedef          int     int32_t;
222#endif
223EOF
224;;
225     1:2:4:4:8) AC_MSG_RESULT(..adding $t 32-bit system prepared for 64-bit)
226                cat >>$ac_stdint_h <<EOF
227
228/*              a 32-bit system prepared for 64-bit          */
229typedef unsigned char   uint8_t;
230typedef unsigned short  uint16_t;
231typedef unsigned int    uint32_t;
232#ifndef __int8_t_defined
233#define __int8_t_defined
234typedef          char    int8_t;
235typedef          short   int16_t;
236typedef          int     int32_t;
237#endif
238EOF
239;;
240     1:2:4:8:8) AC_MSG_RESULT(..adding $t normal 64-bit system)
241                cat >>$ac_stdint_h <<EOF
242
243/*              a normal 64-bit system                       */
244typedef unsigned char   uint8_t;
245typedef unsigned short  uint16_t;
246typedef unsigned int    uint32_t;
247#ifndef __int8_t_defined
248#define __int8_t_defined
249typedef          char    int8_t;
250typedef          short   int16_t;
251typedef          int     int32_t;
252#endif
253EOF
254;;
255     1:2:4:8:4) AC_MSG_RESULT(..adding $t 64-bit system derived from a 32-bit)
256                cat >>$ac_stdint_h <<EOF
257
258/*              a 64-bit system derived from a 32-bit system */
259typedef unsigned char   uint8_t;
260typedef unsigned short  uint16_t;
261typedef unsigned int    uint32_t;
262#ifndef __int8_t_defined
263#define __int8_t_defined
264typedef          char    int8_t;
265typedef          short   int16_t;
266typedef          int     int32_t;
267#endif
268EOF
269;;
270  *)
271    AC_MSG_ERROR([ $ac_cv_sizeof_X dnl
272 what is that a system? contact the author, quick! http://ac-archive.sf.net])
273    exit 1
274;;
275   esac
276fi
277
278# ------------- DONE basic int types START int64_t types ------------
279if test "$ac_cv_type_uint64_t" = "yes"
280then AC_MSG_RESULT(... seen good uint64_t)
281     cat >>$ac_stdint_h <<EOF
282
283/* system headers have good uint64_t */
284#ifndef _HAVE_UINT64_T
285#define _HAVE_UINT64_T
286#endif
287EOF
288
289elif test "$ac_cv_type_u_int64_t" = "yes"
290then AC_MSG_RESULT(..adding typedef u_int64_t uint64_t)
291     cat >>$ac_stdint_h <<EOF
292
293/* system headers have an u_int64_t */
294#ifndef _HAVE_UINT64_T
295#define _HAVE_UINT64_T
296typedef u_int64_t uint64_t;
297#endif
298EOF
299else AC_MSG_RESULT(..adding generic uint64_t runtime checks)
300     cat >>$ac_stdint_h <<EOF
301
302/* -------------------- 64 BIT GENERIC SECTION -------------------- */
303/* here are some common heuristics using compiler runtime specifics */
304#if defined __STDC_VERSION__ && defined __STDC_VERSION__ > 199901L
305
306#ifndef _HAVE_UINT64_T
307#define _HAVE_UINT64_T
308typedef long long int64_t;
309typedef unsigned long long uint64_t;
310#endif
311
312#elif !defined __STRICT_ANSI__
313#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
314
315#ifndef _HAVE_UINT64_T
316#define _HAVE_UINT64_T
317typedef __int64 int64_t;
318typedef unsigned __int64 uint64_t;
319#endif
320
321#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
322dnl /* note: all ELF-systems seem to have loff-support which needs 64-bit */
323
324#if !defined _NO_LONGLONG
325#ifndef _HAVE_UINT64_T
326#define _HAVE_UINT64_T
327typedef long long int64_t;
328typedef unsigned long long uint64_t;
329#endif
330#endif
331
332#elif defined __alpha || (defined __mips && defined _ABIN32)
333
334#if !defined _NO_LONGLONG
335#ifndef _HAVE_UINT64_T
336#define _HAVE_UINT64_T
337typedef long int64_t;
338typedef unsigned long uint64_t;
339#endif
340#endif
341  /* compiler/cpu type ... or just ISO C99 */
342#endif
343#endif
344EOF
345
346# plus a default 64-bit for systems that are likely to be 64-bit ready
347  case "$ac_cv_sizeof_x:$ac_cv_sizeof_voidp:$ac_cv_sizeof_long" in
348    1:2:8:8) AC_MSG_RESULT(..adding uint64_t default, normal 64-bit system)
349cat >>$ac_stdint_h <<EOF
350/* DEFAULT: */
351/* seen normal 64-bit system, CC has sizeof(long and void*) == 8 bytes */
352#ifndef _HAVE_UINT64_T
353#define _HAVE_UINT64_T
354typedef long int64_t;
355typedef unsigned long uint64_t;
356#endif
357EOF
358;;
359    1:2:4:8) AC_MSG_RESULT(..adding uint64_t default, typedef to long)
360cat >>$ac_stdint_h <<EOF
361/* DEFAULT: */
362/* seen 32-bit system prepared for 64-bit, CC has sizeof(long) == 8 bytes */
363#ifndef _HAVE_UINT64_T
364#define _HAVE_UINT64_T
365typedef long int64_t;
366typedef unsigned long uint64_t;
367#endif
368EOF
369;;
370    1:2:8:4) AC_MSG_RESULT(..adding uint64_t default, typedef long long)
371cat >>$ac_stdint_h <<EOF
372/* DEFAULT: */
373/* seen 64-bit derived from a 32-bit, CC has sizeof(long) == 4 bytes */
374#ifndef _HAVE_UINT64_T
375#define _HAVE_UINT64_T
376typedef long long int64_t;
377typedef unsigned long long uint64_t;
378#endif
379EOF
380;;
381   *)
382cat >>$ac_stdint_h <<EOF
383/* NOTE: */
384/* the configure-checks for the basic types did not make us believe */
385/* that we could add a fallback to a 'long long' typedef to int64_t */
386EOF
387  esac
388fi
389
390# ------------- DONE int64_t types START intptr types ------------
391if test "$ac_cv_header_stdint_x" = "no-file" ; then
392  cat >>$ac_stdint_h <<EOF
393
394/* -------------------------- INPTR SECTION --------------------------- */
395EOF
396  case "$ac_cv_sizeof_x:$ac_cv_sizeof_voidp" in
397  1:2:2)
398    a="int16_t" ; cat >>$ac_stdint_h <<EOF
399/* we tested sizeof(void*) to be of 2 chars, hence we declare it 16-bit */
400
401typedef uint16_t uintptr_t;
402typedef  int16_t  intptr_t;
403EOF
404;;
405  1:2:4)
406    a="int32_t" ; cat >>$ac_stdint_h <<EOF
407/* we tested sizeof(void*) to be of 4 chars, hence we declare it 32-bit */
408
409typedef uint32_t uintptr_t;
410typedef  int32_t  intptr_t;
411EOF
412;;
413  1:2:8)
414    a="int64_t" ; cat >>$ac_stdint_h <<EOF
415/* we tested sizeof(void*) to be of 8 chars, hence we declare it 64-bit */
416
417typedef uint64_t uintptr_t;
418typedef  int64_t  intptr_t;
419EOF
420;;
421  *)
422    a="long" ; cat >>$ac_stdint_h <<EOF
423/* we tested sizeof(void*) but got no guess, hence we declare it as if long */
424
425typedef unsigned long uintptr_t;
426typedef          long  intptr_t;
427EOF
428;;
429  esac
430AC_MSG_RESULT(..adding typedef $a intptr_t)
431fi
432
433# ------------- DONE intptr types START int_least types ------------
434if test "$ac_cv_type_int_least32_t" = "no"; then
435AC_MSG_RESULT(..adding generic int_least-types)
436     cat >>$ac_stdint_h <<EOF
437
438/* --------------GENERIC INT_LEAST ------------------ */
439
440typedef  int8_t    int_least8_t;
441typedef  int16_t   int_least16_t;
442typedef  int32_t   int_least32_t;
443#ifdef _HAVE_UINT64_T
444typedef  int64_t   int_least64_t;
445#endif
446
447typedef uint8_t   uint_least8_t;
448typedef uint16_t  uint_least16_t;
449typedef uint32_t  uint_least32_t;
450#ifdef _HAVE_UINT64_T
451typedef uint64_t  uint_least64_t;
452#endif
453EOF
454fi
455
456# ------------- DONE intptr types START int_least types ------------
457if test "$ac_cv_type_int_fast32_t" = "no"; then
458AC_MSG_RESULT(..adding generic int_fast-types)
459     cat >>$ac_stdint_h <<EOF
460
461/* --------------GENERIC INT_FAST ------------------ */
462
463typedef  int8_t    int_fast8_t;
464typedef  int32_t   int_fast16_t;
465typedef  int32_t   int_fast32_t;
466#ifdef _HAVE_UINT64_T
467typedef  int64_t   int_fast64_t;
468#endif
469
470typedef uint8_t   uint_fast8_t;
471typedef uint32_t  uint_fast16_t;
472typedef uint32_t  uint_fast32_t;
473#ifdef _HAVE_UINT64_T
474typedef uint64_t  uint_fast64_t;
475#endif
476EOF
477fi
478
479if test "$ac_cv_header_stdint_x" = "no-file" ; then
480     cat >>$ac_stdint_h <<EOF
481
482#ifdef _HAVE_UINT64_T
483typedef int64_t        intmax_t;
484typedef uint64_t      uintmax_t;
485#else
486typedef long int       intmax_t;
487typedef unsigned long uintmax_t;
488#endif
489EOF
490fi
491
492AC_MSG_RESULT(... DONE $ac_stdint_h)
493   cat >>$ac_stdint_h <<EOF
494
495  /* once */
496#endif
497#endif
498EOF
499])
500
501dnl quote from SunOS-5.8 sys/inttypes.h:
502dnl Use at your own risk.  As of February 1996, the committee is squarely
503dnl behind the fixed sized types; the "least" and "fast" types are still being
504dnl discussed.  The probability that the "fast" types may be removed before
505dnl the standard is finalized is high enough that they are not currently
506dnl implemented.
507
Note: See TracBrowser for help on using the repository browser.