Support for thread_db in ProcControlAPI Linux and BlueGene
[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 AC_ARG_WITH(default-component,
62             [AS_HELP_STRING([--with-default-component],[Valid values: DyninstAPI, SymtabAPI, InstructionAPI, ProcControlAPI, ParseAPI, default])],
63             [DEFAULT_COMPONENT="${withval}";],
64             [DEFAULT_COMPONENT=`cat autodyninst/default_component`;])                                                            
65 AC_ARG_WITH(tcl83,
66             [AS_HELP_STRING([--with-tcl83],[Use Tcl/Tk 8.3])],
67             [TCL_VERSION="tcl8.3"; USE_TCL83="${withval}";],
68             [TCL_VERSION="tcl8.4"; USE_TCL83="false";])
69 AC_ARG_WITH(tcltk-incdir,
70             [AS_HELP_STRING([--with-tcltk-incdir],[TCL/TK include directory])],
71             [TCLTK_INC_DIR="${withval}";],)
72 AC_ARG_WITH(tcltk-libdir,
73             [AS_HELP_STRING([--with-tcltk-libdir],[TCL/TK library directory])],
74             [TCLTK_LIB_DIR="${withval}";],)
75 PD_SOFT_CHECK_INC_DIR($TCLTK_INC_DIR, [tcl.h], [tcl])
76 PD_SOFT_CHECK_LIB_DIR($TCLTK_LIB_DIR, $TCL_VERSION, [Tcl_Eval])
77 AC_SUBST(USE_TCL83)
78 AC_SUBST(TCLTK_INC_DIR)
79 AC_SUBST(TCLTK_LIB_DIR)
80 AC_SUBST(DEFAULT_COMPONENT)
81
82 AC_CANONICAL_HOST
83
84 AC_ARG_WITH(wrapper-libs, 
85             [AS_HELP_STRING([--with-wrapper-libs],[Comma seperated list of archive to wrap])],
86             [ARG_WRAPPER_LIBS="${withval}";],)
87 AC_SUBST(ARG_WRAPPER_LIBS)
88
89 AC_ARG_ENABLE(gnu-demangler,
90               [AS_HELP_STRING([--enable-gnu-demangler],[Use g++'s built in demangler])],
91               [GNU_DEMANGLER="true"],)
92
93 if test "x$DEFAULT_COMPONENT" = "xInstructionAPI"; then
94    AC_MSG_NOTICE([InstructionAPI, not requiring libelf...])   
95    SUPPRESS_LIBELF_REQ="true"
96    AC_MSG_NOTICE([InstructionAPI, not requiring thread_db...])   
97    SUPPRESS_THREADDB_REQ="true"
98    AC_MSG_NOTICE([InstructionAPI, not requiring libdwarf...])   
99    SUPPRESS_LIBDWARF_REQ="true"
100 fi
101 if test "x$DEFAULT_COMPONENT" = "xSymtabAPI"; then
102    AC_MSG_NOTICE([SymtabAPI, not requiring thread_db...])
103    SUPPRESS_THREADDB_REQ="true"
104 fi
105 if test "x$DEFAULT_COMPONENT" = "xParseAPI"; then
106    AC_MSG_NOTICE([ParseAPI, not requiring thread_db...])
107    SUPPRESS_THREADDB_REQ="true"
108 fi
109 if test "x$DEFAULT_COMPONENT" = "xProcControlAPI"; then
110    AC_MSG_NOTICE([ProcControlAPI, not requiring libdwarf...])   
111    SUPPRESS_LIBDWARF_REQ="true"
112 fi 
113 if test "`echo $host_os | cut -b-5`" = "linux" ; then
114   if test "x$PLATFORM" = "xppc32_bgp_ion"; then
115    AC_MSG_NOTICE([BG/P, thread_db required...])   
116   elif test "x$PLATFORM" = "xppc32_bgl_ion"; then
117    AC_MSG_NOTICE([BG/L, thread_db required...])
118   else 
119    AC_MSG_NOTICE([Linux, not requiring thread_db...])
120    SUPPRESS_THREADDB_REQ="true"
121   fi
122 fi
123
124 if test "`echo $host_os | cut -b-3`" = "aix" ; then
125    AC_MSG_NOTICE([AIX, not requiring thread_db...])
126    SUPPRESS_THREADDB_REQ="true"
127 fi
128
129 if test "`echo $host_os | cut -b-3`" = "aix" ; then
130    AC_MSG_NOTICE([AIX system, skipping libelf...])
131 else
132    AC_ARG_WITH(libelf-incdir,
133                    [AS_HELP_STRING([--with-libelf-incdir],[LIBELF include directory])],
134                    [LIBELF_INC_DIR="${withval}";],)
135    AC_ARG_WITH(libelf-libdir,
136             [AS_HELP_STRING([--with-libelf-libdir],[LIBELF library directory])],
137             [LIBELF_LIB_DIR="${withval}";],)
138   
139    if test "x$SUPPRESS_LIBELF_REQ" = "x"; then
140       CXXFLAGS_HOLD=$CXXFLAGS;
141       CXXFLAGS="$CXXFLAGS -I$LIBELF_INC_DIR";
142       CPPFLAGS_HOLD=$CPPFLAGS;
143       CPPFLAGS="$CPPFLAGS -I$LIBELF_INC_DIR";
144
145       AC_CHECK_HEADER([$LIBELF_INC_DIR/libelf.h], [AC_MSG_NOTICE(ELF include directory: $LIBELF_INC_DIR)],
146            [CXXFLAGS="$CXXFLAGS -I$LIBELF_INC_DIR/libelf";
147             CPPFLAGS="$CPPFLAGS -I$LIBELF_INC_DIR/libelf";
148             AC_CHECK_HEADER([$LIBELF_INC_DIR/libelf/libelf.h],
149                             [LIBELF_INC_DIR+="/libelf";AC_MSG_NOTICE(ELF include directory: $LIBELF_INC_DIR)],
150                             [AC_ERROR(couldn't find libelf.h)])])
151       CXXFLAGS=$CXXFLAGS_HOLD;
152       CPPFLAGS=$CPPFLAGS_HOLD;
153       PD_CHECK_LIB_DIR($LIBELF_LIB_DIR,[elf],[elf_memory])
154       PD_CHECK_LIB_TYPE($LIBELF_LIB_DIR, elf)
155    fi
156    LIBELF_STATIC="$LIB_TYPE_STATIC"
157    LIBELF_DYNAMIC="$LIB_TYPE_DYNAMIC"
158    AC_SUBST(LIBELF_INC_DIR)
159    AC_SUBST(LIBELF_LIB_DIR)
160    AC_SUBST(LIBELF_STATIC)
161    AC_SUBST(LIBELF_DYNAMIC)
162 fi
163
164 if test "$host_cpu" != "x86_64" -a "$host_cpu" != "i686"; then
165    AC_MSG_NOTICE([Not x86/x86_64, skipping icc on $host_cpu...])
166 else
167    AC_ARG_WITH(icc,
168                [AS_HELP_STRING([--with-icc],[Path to Intel's ICC compiler])],
169                [_ICC_="${withval}"; _ICPC_=`dirname ${withval}`/icpc;],)
170 fi
171 AC_SUBST(_ICC_)
172 AC_SUBST(_ICPC_)
173
174 if test "$host_cpu" != "x86_64" -a "$host_cpu" != "i686"; then
175    AC_MSG_NOTICE([Not x86/x86_64, skipping pgcc on $host_cpu...])
176 else
177    AC_ARG_WITH(pgcc,
178                [AS_HELP_STRING([--with-pgcc],[Path to Pathscale's PGCC compiler])],
179                [_PGC_="${withval}"; _PGCXX_=`dirname ${withval}`/pgCC;],)
180 fi
181 AC_SUBST(_PGC_)
182 AC_SUBST(_PGCXX_)
183
184 if test "`echo $host_os | cut -b-3`" = "aix" ; then
185    if test "`basename $CXX`" = "xlC" ; then
186       BUILD_XLC="true";
187    elif test "`basename $CC`" = "xlc" ; then
188       BUILD_XLC="true";
189    else
190       BUILD_XLC="";
191    fi
192    AC_SUBST(BUILD_XLC)
193 fi
194
195 if test "x$BUILD_XLC" = "x" ; then
196    AC_ARG_WITH(libiberty-libdir,
197             [AS_HELP_STRING([--with-libiberty-libdir],[LIBIBERTY library directory])],
198             [LIBIBERTY_LIB_DIR="${withval}";],)
199    LIBS_HOLD=$LIBS
200    if test "x$LIBIBERTY_LIB_DIR" != "x" ; then
201       LIBS="-L$LIBIBERTY_LIB_DIR"
202    fi
203    AC_CHECK_LIB([iberty], [cplus_demangle], [HAVE_LIBIBERTY="true";],[HAVE_LIBIBERTY="false"])
204
205    LIBS_BAK=$LIBS
206    LDFLAGS_BAK=$LDFLAGS
207    CXXFLAGS_BAK=$CXXFLAGS
208    LIBS="$LIBS -liberty"
209    LDFLAGS="$LDFLAGS -shared"
210    CXXFLAGS="-fPIC"
211    AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" { char *cplus_demangle(char *s, int opts); }]],
212                                    [[cplus_demangle("", 0);]])],
213                                    [LIBIBERTY_LINK="true"],
214                                    [LIBIBERTY_LINK="false"])
215    LDFLAGS=$LDFLAGS_BAK
216    LIBS=$LIBS_BAK
217    CXXFLAGS=$CXXFLAGS_BAK
218
219    if test "x$HAVE_LIBIBERTY" = "xtrue" ; then
220       if test "x$LIBIBERTY_LINK" = "xtrue" ; then
221          USE_LIBERTY=true
222          LINK_LIBERTY=true
223       elif test "x$_PGC_" != "x" ; then 
224          USE_LIBERTY=true
225          echo "WARNING: libiberty does not link with shared objects.  Mutatees will have to be linked with -liberty."
226       else
227          GNU_DEMANGLER=true
228       fi
229    else
230       GNU_DEMANGLER=true
231    fi
232
233    if test "x$GNU_DEMANGLER" = "xtrue" ; then
234       USE_LIBIBERTY=""
235       LINK_LIBIBERTY=""
236    fi
237 fi
238
239 AC_SUBST(GNU_DEMANGLER)
240 AC_SUBST(USE_LIBERTY)
241 AC_SUBST(LINK_LIBERTY)
242 AC_SUBST(LIBIBERTY_LIB_DIR)
243
244 if test "`echo $host_os | cut -b-3`" = "aix" ; then
245    AC_MSG_NOTICE([AIX system, skipping libdwarf...])
246 else
247    AC_ARG_WITH(libdwarf-incdir,
248             [AS_HELP_STRING([--with-libdwarf-incdir],[LIBDWARF include directory])],
249             [LIBDWARF_INC_DIR="${withval}";],)
250    AC_ARG_WITH(libdwarf-libdir,
251             [AS_HELP_STRING([--with-libdwarf-libdir],[LIBDWARF library directory])],
252             [LIBDWARF_LIB_DIR="${withval}";],)
253    
254    if test "x$SUPPRESS_LIBDWARF_REQ" = "x"; then                        
255        CXXFLAGS_HOLD=$CXXFLAGS;
256        CXXFLAGS="$CXXFLAGS -I$LIBDWARF_INC_DIR";
257        CPPFLAGS_HOLD=$CPPFLAGS;
258        CPPFLAGS="$CPPFLAGS -I$LIBDWARF_INC_DIR";
259
260        AC_CHECK_HEADER([$LIBDWARF_INC_DIR/libdwarf.h], [AC_MSG_NOTICE(DWARF include directory: $LIBDWARF_INC_DIR)],
261                         [CXXFLAGS="$CXXFLAGS -I$LIBDWARF_INC_DIR/libdwarf";
262                          CPPFLAGS="$CPPFLAGS -I$LIBDWARF_INC_DIR/libdwarf";
263                          AC_CHECK_HEADER([$LIBDWARF_INC_DIR/libdwarf/libdwarf.h],
264                               [LIBDWARF_INC_DIR+="/libdwarf";AC_MSG_NOTICE(DWARF include directory: $LIBDWARF_INC_DIR)],
265                               [AC_ERROR(couldn't find libdwarf.h)])])
266        CXXFLAGS=$CXXFLAGS_HOLD;
267        CPPFLAGS=$CPPFLAGS_HOLD;
268
269        PD_CHECK_LIB_DIR($LIBDWARF_LIB_DIR,[dwarf],[dwarf_add_arange],$LIBELF_LIB_DIR,[-lelf])
270        PD_CHECK_LIB_TYPE($LIBDWARF_LIB_DIR, dwarf)
271    fi
272
273    LIBDWARF_STATIC="$LIB_TYPE_STATIC"
274    LIBDWARF_DYNAMIC="$LIB_TYPE_DYNAMIC"
275    AC_SUBST(LIBDWARF_INC_DIR)
276    AC_SUBST(LIBDWARF_LIB_DIR)
277    AC_SUBST(LIBDWARF_STATIC)
278    AC_SUBST(LIBDWARF_DYNAMIC)
279
280    PD_CHECK_LIB_FEATURE($LIBDWARF_LIB_DIR,[dwarf],[dwarf_set_frame_cfa_value],$LIBELF_LIB_DIR,[-lelf])
281    LIBDWARF_HAS_SET_FRAME="$HAS_FEATURE"
282    AC_SUBST(LIBDWARF_HAS_SET_FRAME)
283 fi
284
285
286 AC_ARG_WITH(threaddb-incdir,
287          [AS_HELP_STRING([--with-threaddb-incdir],[THREADDB include directory])],
288          [THREADDB_INC_DIR="${withval}";],)
289 AC_ARG_WITH(threaddb-libdir,
290          [AS_HELP_STRING([--with-threaddb-libdir],[THREADDB library directory])],
291          [THREADDB_LIB_DIR="${withval}";],)
292 CXXFLAGS_HOLD=$CXXFLAGS;
293 CPPFLAGS_HOLD=$CPPFLAGS;
294 LDFLAGS_HOLD=$LDFLAGS
295 if test "x$THREADDB_INC_DIR" != "x"; then
296   CXXFLAGS="$CXXFLAGS -I$THREADDB_INC_DIR"
297   CPPFLAGS="$CPPFLAGS -I$THREADDB_INC_DIR"
298 fi
299 LDFLAGS="-shared"
300 HAVE_THREADDB="true"
301 if test "x$SUPPRESS_THREADDB_REQ" = "x"; then
302     AC_CHECK_HEADER([thread_db.h], [AC_MSG_NOTICE(thread_db include directory: $THREADDB_INC_DIR)],
303                      [AC_ERROR(couldn't find thread_db.h)], )
304     PD_CHECK_LIB_DIR($THREADDB_LIB_DIR,[thread_db],[td_ta_new], , )
305 else
306     AC_CHECK_HEADER([thread_db.h], [AC_MSG_NOTICE(thread_db include directory: $THREADDB_INC_DIR)],
307                      [HAVE_THREADDB=""], )
308     PD_CHECK_LIB_DIR_WERR($THREADDB_LIB_DIR,[thread_db],[td_ta_new], , , [HAVE_THREADDB=""])
309 fi
310 if test "x$HAVE_THREADDB" = "xtrue"; then
311     PD_CHECK_LIB_TYPE($THREADDB_LIB_DIR, thread_db)
312 fi
313 CXXFLAGS=$CXXFLAGS_HOLD
314 CPPFLAGS=$CPPFLAGS_HOLD
315 LDFLAGS=$LDFLAGS_HOLD
316 THREADDB_STATIC="$LIB_TYPE_STATIC"
317 THREADDB_DYNAMIC="$LIB_TYPE_DYNAMIC"
318 AC_SUBST(THREADDB_INC_DIR)
319 AC_SUBST(THREADDB_LIB_DIR)
320 AC_SUBST(THREADDB_STATIC)
321 AC_SUBST(THREADDB_DYNAMIC)
322 AC_SUBST(HAVE_THREADDB)
323
324 AC_ARG_WITH(libxml2-incdir,
325             [AS_HELP_STRING([--with-libxml2-incdir],[LIBXML2 include directory])],
326             [LIBXML2_INC_DIR="${withval}";],)
327 AC_ARG_WITH(libxml2-libdir,
328             [AS_HELP_STRING([--with-libxml2-libdir],[LIBXML2 library directory])],
329             [LIBXML2_LIB_DIR="${withval}";],)
330 PD_SOFT_CHECK_INC_DIR($LIBXML2_INC_DIR, [libxml/xmlschemas.h], [libxml])
331 PD_SOFT_CHECK_LIB_DIR($LIBXML2_LIB_DIR,[xml2],[xmlAddID])
332 AC_SUBST(LIBXML2_INC_DIR)
333 AC_SUBST(LIBXML2_LIB_DIR)
334
335 if test "$host_cpu" != "ia64" ; then
336    AC_MSG_NOTICE([Not IA-64, skipping libunwind...])
337 else
338    AC_ARG_WITH(libunwind-incdir,
339             [AS_HELP_STRING([--with-libunwind-incdir],[LIBUNWIND include directory])],
340             [LIBUNWIND_INC_DIR="${withval}";],)
341    AC_ARG_WITH(libunwind-libdir,
342             [AS_HELP_STRING([--with-libunwind-libdir],[LIBUNWIND library directory])],
343             [LIBUNWIND_LIB_DIR="${withval}";],)
344
345    PD_CHECK_INC_DIR(${LIBUNWIND_INC_DIR}, [libunwind.h])
346 fi
347 AC_SUBST(LIBUNWIND_INC_DIR)
348 AC_SUBST(LIBUNWIND_LIB_DIR)
349
350 AC_ARG_WITH(launchmon-incdir,
351             [AS_HELP_STRING([--with-launchmon-incdir],[Launchmon include directory])],
352             [LAUNCHMON_INC_DIR="${withval}";],)
353 AC_ARG_WITH(launchmon-libdir,
354             [AS_HELP_STRING([--with-launchmon-libdir],[Launchmon library directory])],
355             [LAUNCHMON_LIB_DIR="${withval}";],)
356 AC_SUBST(LAUNCHMON_INC_DIR)
357 AC_SUBST(LAUNCHMON_LIB_DIR)
358
359 AC_ARG_WITH(libflex-libdir,
360             [AS_HELP_STRING([--with-libflex-libdir],[Absolute path to flex library])],
361             [LIBFLEX_LIB_DIR="${withval}";],)
362 # 3/15/09: We are not checking for libflex sources and they are not in cs.wisc.edu package-base.
363 #          What's the story here?  Not needed?
364 PD_SOFT_CHECK_LIB_DIR(${LIBFLEX_LIB_DIR}, [fl], [yywrap])
365 AC_SUBST(LIBFLEX_LIB_DIR)
366 AC_PATH_PROG(NASM, nasm, "", "${PACKAGE_BASE}/nasm/bin:$PATH")
367 AC_SUBST(NASM)
368
369 AC_MSG_CHECKING([for -fno-stack-protector])
370 SAVED_CXXFLAGS=$CXXFLAGS
371 CXXFLAGS="-fno-stack-protector"
372 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], 
373                                 [AC_MSG_RESULT([yes]); STACKPROT="DISABLE_STACK_PROT=1"], 
374                                 [AC_MSG_RESULT([no]); STACKPROT=""])
375 AC_SUBST(STACKPROT)
376 CXXFLAGS=$SAVED_CXXFLAGS
377
378 if test "`echo $host_os | cut -b-3`" = "aix" ; then
379     M32FLAG="-maix32"
380 else
381     M32FLAG="-m32"
382 fi
383 AC_MSG_CHECKING([for 32-bit build environment])
384 SAVED_CXXFLAGS=$CXXFLAGS
385 CXXFLAGS=$M32FLAG
386 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], [[]])], 
387                                 [AC_MSG_RESULT([yes]); BUILD32=""],
388                                 [AC_MSG_RESULT([no]); BUILD32="SKIP_BUILD_RTLIB_32=1"])
389 AC_SUBST(BUILD32)
390 CXXFLAGS=$SAVED_CXXFLAGS
391
392 AC_MSG_CHECKING([whether to use MM timer])
393 case $host in
394      ia64-*-*-*) MMTIMER=true ;;
395      *)    MMTIMER=false ;;
396 esac
397 AC_MSG_RESULT(${MMTIMER})
398 AC_SUBST([MMTIMER])
399
400 AC_SUBST([DEFS])
401
402 AC_ARG_ENABLE(testsuite, AS_HELP_STRING([--disable-testsuite], [Disable the Dyninst test suite (default is no)]),
403                          [], [enable_testsuite=yes])
404
405 AS_IF([test "x$enable_testsuite" != xyes], [TESTSUITE="DONT_BUILD_NEWTESTSUITE=1"], [TESTSUITE=""])
406 AC_SUBST([TESTSUITE])
407
408 AC_CONFIG_FILES([make.config.local:autodyninst/make.config.local.in])
409 AC_OUTPUT