Support for using GNU g++ demangler, rationalize use of libiberty
[dyninst.git] / configure.in
1 dnl == process this file with autoconf to produce a configure script ==
2
3
4 AC_PREREQ(2.59)
5 AC_INIT([Dyninst], [6.1], [bugs@dyninst.org], [dyninst])
6
7 AC_PREFIX_DEFAULT(`pwd`/..)
8
9 AC_CONFIG_AUX_DIR([autodyninst])
10 AC_CONFIG_MACRO_DIR([autodyninst])
11
12 AC_PROG_CXX(g++)
13 AC_PATH_PROG(_ICC_, icc)
14 AC_PATH_PROG(_ICPC_, icpc)
15 AC_PATH_PROG(_PGC_, pgcc)
16 AC_PATH_PROG(_PGCXX_, pgCC)
17 AC_PATH_PROG(_CC_, cc)
18 AC_PATH_PROG(_CXX_, CC)
19 AC_LANG(C++)
20
21
22 dnl === configure options ==
23
24
25 PACKAGE_BASE=""
26 AC_ARG_WITH(package-base,
27            [AS_HELP_STRING([--with-package-base],[Base directory to look for packages])],
28            [PACKAGE_BASE="${withval}";
29             TCLTK_INC_DIR="${PACKAGE_BASE}/tcl8.4.5/include";
30             TCLTK_LIB_DIR="${PACKAGE_BASE}/tcl8.4.5/lib";
31             LIBELF_INC_DIR="${PACKAGE_BASE}/libelf/include";
32             LIBELF_LIB_DIR="${PACKAGE_BASE}/libelf/lib";
33             LIBDWARF_INC_DIR="${PACKAGE_BASE}/libdwarf/include";
34             LIBDWARF_LIB_DIR="${PACKAGE_BASE}/libdwarf/lib";
35             ARG_WRAPPER_LIBS="";
36             LIBXML2_INC_DIR="${PACKAGE_BASE}/libxml2/include/libxml2"
37             LIBXML2_LIB_DIR="${PACKAGE_BASE}/libxml2/lib";
38             LIBUNWIND_INC_DIR="${PACKAGE_BASE}/libunwind/include";
39             LIBUNWIND_LIB_DIR="${PACKAGE_BASE}/libunwind/lib";
40             LIBFLEX_LIB_DIR="${PACKAGE_BASE}/libflex/lib";
41            ],[
42             # We fall back on these defaults if both --with-package-base and
43             # specific --with-<package> arguments are not provided.
44             TCLTK_INC_DIR="/usr/include";
45             TCLTK_LIB_DIR="/usr/lib";
46             LIBELF_INC_DIR="/usr/include";
47             LIBELF_LIB_DIR="/usr/lib";
48             ARG_WRAPPER_LIBS="";
49             LIBDWARF_INC_DIR="/usr/include";
50             LIBDWARF_LIB_DIR="/usr/lib";
51             LIBXML2_INC_DIR="/usr/include/libxml2"
52             LIBXML2_LIB_DIR="/usr/lib";
53             LIBUNWIND_INC_DIR="/usr/include";
54             LIBUNWIND_LIB_DIR="/usr/lib";
55             LIBFLEX_LIB_DIR="/usr/lib";
56            ])
57 # 3/15/09: We don't include libiberty in the cs.wisc.edu package-base.
58 #          Why?  Putting these here for now...
59 LIBIBERTY_LIB_DIR="/usr/lib";
60
61
62 AC_ARG_WITH(tcl83,
63             [AS_HELP_STRING([--with-tcl83],[Use Tcl/Tk 8.3])],
64             [TCL_VERSION="tcl8.3"; USE_TCL83="${withval}";],
65             [TCL_VERSION="tcl8.4"; USE_TCL83="false";])
66 AC_ARG_WITH(tcltk-incdir,
67             [AS_HELP_STRING([--with-tcltk-incdir],[TCL/TK include directory])],
68             [TCLTK_INC_DIR="${withval}";],)
69 AC_ARG_WITH(tcltk-libdir,
70             [AS_HELP_STRING([--with-tcltk-libdir],[TCL/TK library directory])],
71             [TCLTK_LIB_DIR="${withval}";],)
72 PD_SOFT_CHECK_INC_DIR($TCLTK_INC_DIR, [tcl.h], [tcl])
73 PD_SOFT_CHECK_LIB_DIR($TCLTK_LIB_DIR, $TCL_VERSION, [Tcl_Eval])
74 AC_SUBST(USE_TCL83)
75 AC_SUBST(TCLTK_INC_DIR)
76 AC_SUBST(TCLTK_LIB_DIR)
77
78 AC_CANONICAL_HOST
79
80 AC_ARG_WITH(wrapper-libs, 
81             [AS_HELP_STRING([--with-wrapper-libs],[Comma seperated list of archive to wrap])],
82             [ARG_WRAPPER_LIBS="${withval}";],)
83 AC_SUBST(ARG_WRAPPER_LIBS)
84
85 AC_ARG_ENABLE(gnu-demangler,
86               [AS_HELP_STRING([--enable-gnu-demangler],[Use g++'s built in demangler])],
87               [GNU_DEMANGLER="true"],)
88
89 if test "`echo $host_os | cut -b-3`" = "aix" ; then
90    AC_MSG_NOTICE([AIX system, skipping libelf...])
91    
92 else
93    AC_ARG_WITH(libelf-incdir,
94                    [AS_HELP_STRING([--with-libelf-incdir],[LIBELF include directory])],
95                    [LIBELF_INC_DIR="${withval}";],)
96    AC_ARG_WITH(libelf-libdir,
97             [AS_HELP_STRING([--with-libelf-libdir],[LIBELF library directory])],
98             [LIBELF_LIB_DIR="${withval}";],)
99   
100    CXXFLAGS_HOLD=$CXXFLAGS;
101    CXXFLAGS="$CXXFLAGS -I$LIBELF_INC_DIR";
102    CPPFLAGS_HOLD=$CPPFLAGS;
103    CPPFLAGS="$CPPFLAGS -I$LIBELF_INC_DIR";
104                         
105    AC_CHECK_HEADER([$LIBELF_INC_DIR/libelf.h], [AC_MSG_NOTICE(ELF include directory: $LIBELF_INC_DIR)],
106         [CXXFLAGS="$CXXFLAGS -I$LIBELF_INC_DIR/libelf";
107          CPPFLAGS="$CPPFLAGS -I$LIBELF_INC_DIR/libelf";
108          AC_CHECK_HEADER([$LIBELF_INC_DIR/libelf/libelf.h],
109                          [LIBELF_INC_DIR+="/libelf";AC_MSG_NOTICE(ELF include directory: $LIBELF_INC_DIR)],
110                          [AC_ERROR(couldn't find libelf.h)])])
111    CXXFLAGS=$CXXFLAGS_HOLD;
112    CPPFLAGS=$CPPFLAGS_HOLD;
113    PD_CHECK_LIB_DIR($LIBELF_LIB_DIR,[elf],[elf_memory])
114    PD_CHECK_LIB_TYPE($LIBELF_LIB_DIR, elf)
115    LIBELF_STATIC="$LIB_TYPE_STATIC"
116    LIBELF_DYNAMIC="$LIB_TYPE_DYNAMIC"
117    AC_SUBST(LIBELF_INC_DIR)
118    AC_SUBST(LIBELF_LIB_DIR)
119    AC_SUBST(LIBELF_STATIC)
120    AC_SUBST(LIBELF_DYNAMIC)
121 fi
122
123 if test "$host_cpu" != "x86_64" -a "$host_cpu" != "i686"; then
124    AC_MSG_NOTICE([Not x86/x86_64, skipping icc on $host_cpu...])
125 else
126    AC_ARG_WITH(icc,
127                [AS_HELP_STRING([--with-icc],[Path to Intel's ICC compiler])],
128                [_ICC_="${withval}"; _ICPC_=`dirname ${withval}`/icpc;],)
129 fi
130 AC_SUBST(_ICC_)
131 AC_SUBST(_ICPC_)
132
133 if test "$host_cpu" != "x86_64" -a "$host_cpu" != "i686"; then
134    AC_MSG_NOTICE([Not x86/x86_64, skipping pgcc on $host_cpu...])
135 else
136    AC_ARG_WITH(pgcc,
137                [AS_HELP_STRING([--with-pgcc],[Path to Pathscale's PGCC compiler])],
138                [_PGC_="${withval}"; _PGCXX_=`dirname ${withval}`/pgCC;],)
139 fi
140 AC_SUBST(_PGC_)
141 AC_SUBST(_PGCXX_)
142
143 if test "`echo $host_os | cut -b-3`" = "aix" ; then
144    if test "`basename $CXX`" = "xlC" ; then
145       BUILD_XLC="true";
146    elif test "`basename $CC`" = "xlc" ; then
147       BUILD_XLC="true";
148    else
149       BUILD_XLC="";
150    fi
151    AC_SUBST(BUILD_XLC)
152 fi
153
154 if test "x$BUILD_XLC" == "x" ; then
155    AC_ARG_WITH(libiberty-libdir,
156             [AS_HELP_STRING([--with-libiberty-libdir],[LIBIBERTY library directory])],
157             [LIBIBERTY_LIB_DIR="${withval}";],)
158    LIBS_HOLD=$LIBS
159    LIBS="-L$LIBIBERTY_LIB_DIR"
160    AC_CHECK_LIB([iberty], [cplus_demangle], [HAVE_LIBIBERTY="true";],[HAVE_LIBIBERTY="false"])
161
162    LIBS_BAK=$LIBS
163    LDFLAGS_BAK=$LDFLAGS
164    LIBS="$LIBS -liberty"
165    LDFLAGS="$LDFLAGS -shared"
166    AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" { char *cplus_demangle(char *s, int opts); }]],
167                                    [[cplus_demangle("", 0);]])],
168                                    [LIBIBERTY_LINK="true"],
169                                    [LIBIBERTY_LINK="false"])
170    LDFLAGS=$LDFLAGS_BAK
171    LIBS=$LIBS_BAK
172
173    if test "x$HAVE_LIBIBERTY" == "xtrue" ; then
174       if test "x$LIBIBERTY_LINK" == "xtrue" ; then
175          USE_LIBERTY=true
176          LINK_LIBERTY=true
177       elif test "x$_PGC_" != "x" ; then 
178          USE_LIBERTY=true
179          echo "WARNING: libiberty does not link with shared objects.  Mutatees will have to be linked with -liberty."
180       else
181          GNU_DEMANGLER=true
182       fi
183    else
184       GNU_DEMANGLER=true
185    fi
186
187    if test "x$GNU_DEMANGLER" == "xtrue" ; then
188       USE_LIBIBERTY=""
189       LINK_LIBIBERTY=""
190    fi
191 fi
192
193 AC_SUBST(GNU_DEMANGLER)
194 AC_SUBST(USE_LIBERTY)
195 AC_SUBST(LINK_LIBERTY)
196 AC_SUBST(LIBIBERTY_LIB_DIR)
197  
198 if test "`echo $host_os | cut -b-3`" = "aix" ; then
199    AC_MSG_NOTICE([AIX system, skipping libdwarf...])
200    
201 else
202    AC_ARG_WITH(libdwarf-incdir,
203             [AS_HELP_STRING([--with-libdwarf-incdir],[LIBDWARF include directory])],
204             [LIBDWARF_INC_DIR="${withval}";],)
205    AC_ARG_WITH(libdwarf-libdir,
206             [AS_HELP_STRING([--with-libdwarf-libdir],[LIBDWARF library directory])],
207             [LIBDWARF_LIB_DIR="${withval}";],)
208    
209    CXXFLAGS_HOLD=$CXXFLAGS;
210    CXXFLAGS="$CXXFLAGS -I$LIBDWARF_INC_DIR";
211    CPPFLAGS_HOLD=$CPPFLAGS;
212    CPPFLAGS="$CPPFLAGS -I$LIBDWARF_INC_DIR";
213                         
214    AC_CHECK_HEADER([$LIBDWARF_INC_DIR/libdwarf.h], [AC_MSG_NOTICE(DWARF include directory: $LIBDWARF_INC_DIR)],
215         [CXXFLAGS="$CXXFLAGS -I$LIBDWARF_INC_DIR/libdwarf";
216          CPPFLAGS="$CPPFLAGS -I$LIBDWARF_INC_DIR/libdwarf";
217          AC_CHECK_HEADER([$LIBDWARF_INC_DIR/libdwarf/libdwarf.h],
218                          [LIBDWARF_INC_DIR+="/libdwarf";AC_MSG_NOTICE(DWARF include directory: $LIBDWARF_INC_DIR)],
219                          [AC_ERROR(couldn't find libdwarf.h)])])
220    CXXFLAGS=$CXXFLAGS_HOLD;
221    CPPFLAGS=$CPPFLAGS_HOLD;
222
223    PD_CHECK_LIB_DIR($LIBDWARF_LIB_DIR,[dwarf],[dwarf_add_arange],$LIBELF_LIB_DIR,[-lelf])
224    PD_CHECK_LIB_TYPE($LIBDWARF_LIB_DIR, dwarf)
225    LIBDWARF_STATIC="$LIB_TYPE_STATIC"
226    LIBDWARF_DYNAMIC="$LIB_TYPE_DYNAMIC"
227    AC_SUBST(LIBDWARF_INC_DIR)
228    AC_SUBST(LIBDWARF_LIB_DIR)
229    AC_SUBST(LIBDWARF_STATIC)
230    AC_SUBST(LIBDWARF_DYNAMIC)
231
232    PD_CHECK_LIB_FEATURE($LIBDWARF_LIB_DIR,[dwarf],[dwarf_set_frame_cfa_value],$LIBELF_LIB_DIR,[-lelf])
233    LIBDWARF_HAS_SET_FRAME="$HAS_FEATURE"
234    AC_SUBST(LIBDWARF_HAS_SET_FRAME)
235 fi
236
237
238
239
240 AC_ARG_WITH(libxml2-incdir,
241             [AS_HELP_STRING([--with-libxml2-incdir],[LIBXML2 include directory])],
242             [LIBXML2_INC_DIR="${withval}";],)
243 AC_ARG_WITH(libxml2-libdir,
244             [AS_HELP_STRING([--with-libxml2-libdir],[LIBXML2 library directory])],
245             [LIBXML2_LIB_DIR="${withval}";],)
246 PD_SOFT_CHECK_INC_DIR($LIBXML2_INC_DIR, [libxml/xmlschemas.h], [libxml])
247 PD_SOFT_CHECK_LIB_DIR($LIBXML2_LIB_DIR,[xml2],[xmlAddID])
248 AC_SUBST(LIBXML2_INC_DIR)
249 AC_SUBST(LIBXML2_LIB_DIR)
250
251 if test "$host_cpu" != "ia64" ; then
252    AC_MSG_NOTICE([Not IA-64, skipping libunwind...])
253 else
254    AC_ARG_WITH(libunwind-incdir,
255             [AS_HELP_STRING([--with-libunwind-incdir],[LIBUNWIND include directory])],
256             [LIBUNWIND_INC_DIR="${withval}";],)
257    AC_ARG_WITH(libunwind-libdir,
258             [AS_HELP_STRING([--with-libunwind-libdir],[LIBUNWIND library directory])],
259             [LIBUNWIND_LIB_DIR="${withval}";],)
260
261    PD_CHECK_INC_DIR(${LIBUNWIND_INC_DIR}, [libunwind.h])
262 fi
263 AC_SUBST(LIBUNWIND_INC_DIR)
264 AC_SUBST(LIBUNWIND_LIB_DIR)
265
266 AC_ARG_WITH(libflex-libdir,
267             [AS_HELP_STRING([--with-libflex-libdir],[Absolute path to flex library])],
268             [LIBFLEX_LIB_DIR="${withval}";],)
269 # 3/15/09: We are not checking for libflex sources and they are not in cs.wisc.edu package-base.
270 #          What's the story here?  Not needed?
271 PD_SOFT_CHECK_LIB_DIR(${LIBFLEX_LIB_DIR}, [fl], [yywrap])
272 AC_SUBST(LIBFLEX_LIB_DIR)
273 AC_PATH_PROG(NASM, nasm, "", "${PACKAGE_BASE}/nasm/bin:$PATH")
274 AC_SUBST(NASM)
275
276 AC_MSG_CHECKING([for -fno-stack-protector])
277 SAVED_CXXFLAGS=$CXXFLAGS
278 CXXFLAGS="-fno-stack-protector"
279 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], 
280                                 [AC_MSG_RESULT([yes]); STACKPROT="DISABLE_STACK_PROT=1"], 
281                                 [AC_MSG_RESULT([no]); STACKPROT=""])
282 AC_SUBST(STACKPROT)
283 CXXFLAGS=$SAVED_CXXFLAGS
284
285 if test "`echo $host_os | cut -b-3`" = "aix" ; then
286     M32FLAG="-maix32"
287 else
288     M32FLAG="-m32"
289 fi
290 AC_MSG_CHECKING([for 32-bit build environment])
291 SAVED_CXXFLAGS=$CXXFLAGS
292 CXXFLAGS=$M32FLAG
293 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], [[]])], 
294                                 [AC_MSG_RESULT([yes]); BUILD32=""],
295                                 [AC_MSG_RESULT([no]); BUILD32="SKIP_BUILD_RTLIB_32=1"])
296 AC_SUBST(BUILD32)
297 CXXFLAGS=$SAVED_CXXFLAGS
298
299 AC_MSG_CHECKING([whether to use MM timer])
300 case $host in
301      ia64-*-*-*) MMTIMER=true ;;
302      *)    MMTIMER=false ;;
303 esac
304 AC_MSG_RESULT(${MMTIMER})
305 AC_SUBST([MMTIMER])
306
307 AC_SUBST([DEFS])
308
309 AC_ARG_ENABLE(testsuite, AS_HELP_STRING([--disable-testsuite], [Disable the Dyninst test suite (default is no)]),
310                          [], [enable_testsuite=yes])
311
312 AS_IF([test "x$enable_testsuite" != xyes], [TESTSUITE="DONT_BUILD_NEWTESTSUITE=1"], [TESTSUITE=""])
313 AC_SUBST([TESTSUITE])
314
315 AC_CONFIG_FILES([make.config.local:autodyninst/make.config.local.in])
316 AC_OUTPUT