1AC_INIT(simplereader.c,frame1.c)
2AC_CONFIG_HEADER(config.h)
3
4AC_PROG_CC
5AC_PROG_CXX
6AC_C_BIGENDIAN
7AC_GCC_TRADITIONAL
8AC_PROG_INSTALL
9AC_CHECK_TOOL(RANLIB, ranlib, :)
10AC_CHECK_TOOL(AR, ar)
11
12AC_CHECK_HEADERS(elf.h libelf.h sgidefs.h sys/types.h)
13
14dnl Attempt to determine if it is really IRIX/SGI or 'other'.
15AC_TRY_COMPILE([#include <sgidefs.h>],[  __uint32_t p; p = 27;] ,
16  AC_DEFINE(HAVE___UINT32_T_IN_SGIDEFS_H,1,
17        [Define 1 if __uint32_t is in sgidefs.h.]))
18AC_TRY_COMPILE([#include <sgidefs.h>],[  __uint64_t p; p = 27;] ,
19  AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1,
20        [Define 1 if __uint64_t is in sgidefs.h.]))
21AC_TRY_COMPILE([#include <sgidefs.h>],[  __uint64_t p; p = 27;] ,
22  AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1,
23        [Define 1 if  is in sgidefs.h.]))
24dnl the existence of sgidefs.h does not prove it's truly SGI, nor
25dnl prove that __uint32_t or __uint64_t is defined therein.
26AC_TRY_COMPILE([#include <sgidefs.h>],[  __uint32_t p; p = 27;] ,
27  AC_DEFINE(HAVE___UINT32_T_IN_SGIDEFS_H,1,
28        [Define 1 if __uint32_t is in sgidefs.h.]))
29AC_TRY_COMPILE([#include <stdint.h>],[intptr_t p; p = 27;] ,
30  AC_DEFINE(HAVE_INTPTR_T,1,
31        [Define 1 if intptr_t defined in C99 stdint.h]))
32AC_TRY_COMPILE([#include <sgidefs.h>],[  __uint64_t p; p = 27;] ,
33  AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1,
34        [Define 1 if __uint64_t is in sgidefs.h.]))
35AC_TRY_COMPILE([#include <sgidefs.h>],[  __uint64_t p; p = 27;] ,
36  AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1,
37        [Define 1 if  is in sgidefs.h.]))
38
39dnl default-disabled shared
40shrd=''
41AC_ARG_ENABLE(shared,AC_HELP_STRING([--enable-shared],
42                [build shared library libdwarf.so and use it if present]))
43AS_IF([ test "x$enable_shared" = "xyes"], [
44   shrd='--enable-shared'])
45
46nonshrd=''
47dnl default-enabled nonshared
48AC_SUBST(build_nonshared,[none.a])
49AC_ARG_ENABLE(nonshared,AC_HELP_STRING([--disable-nonshared],
50                [do not build archive library libdwarf.a]))
51AS_IF([ test "x$enable_nonshared" = "xno"], [
52   nonshrd='--disable-shared'
53])
54
55dnl This adds compiler option -Wall (gcc compiler warnings)
56AC_SUBST(dwfwall,[])
57AC_ARG_ENABLE(wall,AC_HELP_STRING([--enable-wall],
58        [Add -Wall (default is none)]),
59        [ AC_SUBST(dwfwall,[]) ]
60        [ AC_SUBST(dwfwall,["-Wall -O0 -Wpointer-arith -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wextra -Wcomment -Wformat -Wpedantic -Wuninitialized -Wno-long-long -Wshadow"]) ])
61
62dnl This adds compiler option -fsanitize=address (gcc compiler run-time checks))
63AC_SUBST(dwfsanitize,[])
64AC_MSG_CHECKING(build -fsanitize-address)
65AC_ARG_ENABLE(sanitize,AC_HELP_STRING([--enable-sanitize],
66       [Add -fsanitize (default is not to)]),
67       [ AC_SUBST(dwfsanitize,["-fsanitize=address -fsanitize=leak -fsanitize=undefined"])
68          AC_MSG_RESULT(yes) ],
69       [ AC_SUBST(dwfsanitize,[])
70          AC_MSG_RESULT(no)
71        ]
72        )
73
74
75AC_SUBST(dwfzlib,[])
76AC_TRY_COMPILE([#include "zlib.h"],[
77    Bytef dest[100];
78    uLongf destlen = 100;
79    Bytef *src = 0;
80    uLong srclen = 3;
81    int res = uncompress(dest,&destlen,src,srclen);
82    if (res == Z_OK) {
83         /* ALL IS WELL */
84    }
85    ] ,
86    [AC_DEFINE(HAVE_ZLIB,1,
87        [Define 1 if zlib (decompression library) seems available.])
88     AC_SUBST(dwfzlib,[-lz])
89    ])
90
91AC_OUTPUT(Makefile)
92
93