]> sourceware.org Git - systemtap.git/blob - configure.ac
Pick up --prefix dependency usage in config.h.
[systemtap.git] / configure.ac
1 dnl configure.ac --- autoconf input file for systemtap
2 dnl Process this file with autoconf to produce a configure script.
3
4 AC_INIT([systemtap], 0.8, systemtap@sources.redhat.com, systemtap)
5 dnl ^^^^^ see also NEWS, systemtap.spec, testsuite/configure.ac
6
7 AC_PREREQ(2.59)
8 AM_INIT_AUTOMAKE
9 AM_MAINTAINER_MODE
10
11 AM_PROG_MKDIR_P
12 AC_PROG_LN_S
13 AC_PROG_CC
14 AC_PROG_CXX
15 AC_PROG_CPP
16 AM_PROG_CC_STDC
17 AM_PROG_CC_C_O
18 AM_C_PROTOTYPES
19 AC_PROG_RANLIB
20 AC_OBJEXT
21 AC_EXEEXT
22 AC_PROG_INSTALL
23 AC_PROG_MAKE_SET
24 AC_SUBST(CFLAGS)
25 AC_SUBST(CXXFLAGS)
26
27 dnl Handle the perfmon option.
28 AC_ARG_ENABLE([perfmon],
29 AS_HELP_STRING([--enable-perfmon@<:@=DIRECTORY@:>@],
30 [enable perfmon support (default is disabled). Optional DIRECTORY
31 is the path to the perfmon installation (needed if installed in a
32 non-standard location).]), [
33 if test "$enable_perfmon" != "no"; then
34 dnl Add perfmon define and library
35 CPPFLAGS="$CPPFLAGS -DPERFMON"
36 LIBS="$LIBS -lpfm"
37 dnl Handle custom install dir (if needed)
38 if test "$enable_perfmon" != "yes"; then
39 CPPFLAGS="$CPPFLAGS -I$enable_perfmon/include"
40 LDFLAGS="$LDFLAGS -L$enable_perfmon/lib"
41 fi
42 AC_CHECK_LIB([pfm], [pfm_start], [], [
43 AC_MSG_ERROR([systemtap cannot find required perfmon libs (libpfm-devel may need to be installed])])
44 fi])
45
46 dnl Handle the prologues option.
47 dnl
48 dnl If the user didn't specify --enable-prologues/--disable-prologues
49 dnl and the x86 system has a version of gcc less than version 4,
50 dnl automatically enable prologues.
51 if test "${enable_prologues+set}" != set; then
52 AC_MSG_CHECKING([to see if prologue searching should be the default])
53 if { echo '#if __i386__ == 1 && __GNUC__ < 4'
54 echo ' yes '
55 echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
56 enable_prologues=yes
57 AC_MSG_RESULT([yes])
58 else
59 AC_MSG_RESULT([no])
60 fi
61 fi
62 AC_ARG_ENABLE([prologues],
63 AS_HELP_STRING([--enable-prologues], [make -P prologue-searching default]),
64 [
65 if test "$enable_prologues" = yes; then
66 AC_DEFINE([ENABLE_PROLOGUES],[],[make -P prologue-searching default])
67 fi])
68
69 AC_ARG_ENABLE([ssp],
70 [AS_HELP_STRING([--disable-ssp], [disable gcc stack-protector])])
71 AS_IF([test "x$enable_ssp" != xno],[
72 save_CFLAGS="$CFLAGS"
73 save_CXXFLAGS="$CXXFLAGS"
74 CXXFLAGS="$CXXFLAGS -Werror -fstack-protector-all -D_FORTIFY_SOURCE=2"
75 CFLAGS="$CFLAGS -Werror -fstack-protector-all -D_FORTIFY_SOURCE=2"
76 AC_COMPILE_IFELSE([int something ();], [
77 AC_MSG_NOTICE([Compiling with gcc -fstack-protector-all et al.])
78 CFLAGS="$save_CFLAGS -fstack-protector-all -D_FORTIFY_SOURCE=2"
79 CXFXLAGS="$save_CXXFLAGS -fstack-protector-all -D_FORTIFY_SOURCE=2"],[
80 AC_MSG_NOTICE([Compiler does not support -fstack-protector-all et al.])
81 CFLAGS="$save_CFLAGS"
82 CXXFLAGS="$save_CXXFLAGS"])])
83
84 AC_ARG_ENABLE([pie],
85 [AS_HELP_STRING([--disable-pie], [disable position-independent-executable])])
86 AS_IF([test "x$enable_pie" != xno],[
87 save_CFLAGS="$CFLAGS"
88 save_CXXFLAGS="$CXXFLAGS"
89 save_LDFLAGS="$LDFLAGS"
90 CFLAGS="$CFLAGS -fPIE"
91 CXXFLAGS="$CXXFLAGS -fPIE"
92 LDFLAGS="$LDFLAGS -pie -Wl,-z,relro -Wl,-z,now"
93 AC_LINK_IFELSE([void main () {}], [
94 AC_MSG_NOTICE([Compiling with gcc pie et al.])
95 # LDFLAGS is special since it may be passed down to bundled-elfutils,
96 # and interfere with the .so's built therein
97 PIELDFLAGS="$LDFLAGS -pie -Wl,-z,relro -Wl,-z,now"
98 LDFLAGS="$save_LDFLAGS"
99 ],[
100 AC_MSG_NOTICE([Compiler does not support -pie et al.])
101 CFLAGS="$save_CFLAGS"
102 CXXFLAGS="$save_CXXFLAGS"
103 PIELDFLAGS=""
104 LDFLAGS="$save_LDFLAGS"])])
105 AC_SUBST(PIELDFLAGS)
106
107 dnl Handle optional sqlite support. If enabled/disabled by the user,
108 dnl do the right thing. If not specified by the user, use it if
109 dnl present.
110 AC_ARG_ENABLE([sqlite],
111 AS_HELP_STRING([--enable-sqlite], [build with sqlite support]),
112 [], dnl ACTION-IF-GIVEN
113 [enable_sqlite=check]) dnl ACTION-IF-NOT-GIVEN
114 sqlite3_LIBS=
115 AS_IF([test "x$enable_sqlite" != xno],
116 [AC_CHECK_LIB([sqlite3], [sqlite3_open],
117 [AC_SUBST([sqlite3_LIBS], [-lsqlite3])
118 AC_DEFINE([HAVE_LIBSQLITE3], [1], [Define to 1 if you have the `sqlite3' library (-lsqlite3).])],
119 [if test "x$enable_sqlite" != xcheck; then
120 AC_MSG_FAILURE([--enable-sqlite was given, but test for sqlite failed])
121 fi])])
122
123 dnl Handle the option to build the crash extension
124 AC_ARG_ENABLE([crash],
125 AS_HELP_STRING([--enable-crash@<:@=DIRECTORY@:>@],
126 [enable crash extension (default is disabled). Optional DIRECTORY
127 is the path to the crash header file (needed if installed in a
128 non-standard location).]),
129 [if test "$enable_crash" != "no"; then
130 dnl Handle custom install dir (if needed)
131 save_CPPFLAGS="$CPPFLAGS"
132 if test "$enable_crash" != "yes"; then
133 staplog_CPPFLAGS=-I$enable_crash
134 CPPFLAGS="${staplog_CPPFLAGS} $CPPFLAGS"
135 AC_SUBST([staplog_CPPFLAGS])
136 fi
137 AC_CHECK_HEADERS([crash/defs.h], [],
138 [AC_MSG_ERROR([cannot find required crash header (crash-devel may need to be installed)])],
139 [
140 #define NR_CPUS 256
141 ])
142 CPPFLAGS="$save_CPPFLAGS"
143 fi],
144 [enable_crash="no"])
145 AM_CONDITIONAL([BUILD_CRASHMOD], [test "$enable_crash" != "no"])
146
147 dnl Handle the option to build the documentation
148 building_docs="no"
149 AC_ARG_ENABLE([docs],
150 AS_HELP_STRING([--enable-docs],
151 [enable building documentation (default on if latex etc. found).]),
152 [enable_docs=$enableval],
153 [enable_docs="check"])
154 AC_CHECK_PROG(have_latex, latex, yes, no)
155 AC_CHECK_PROG(have_dvips, dvips, yes, no)
156 AC_CHECK_PROG(have_ps2pdf, ps2pdf, yes, no)
157 AC_CHECK_PROG(have_latex2html, latex2html, yes, no)
158 if test "x${have_latex}${have_dvips}${have_ps2pdf}${have_latex2html}" != "xyesyesyesyes"; then
159 if test "$enable_docs" == "yes"; then
160 AC_MSG_ERROR([cannot find all tools for building documentation])
161 fi
162 if test "$enable_docs" == "check"; then
163 AC_MSG_WARN([will not build documentation, cannot find all tools])
164 fi
165 fi
166 if test "x${have_latex}${have_dvips}${have_ps2pdf}${have_latex2html}" == "xyesyesyesyes" -a "$enable_docs" != "no"; then
167 building_docs="yes"
168 fi
169 AM_CONDITIONAL([BUILD_DOCS], [test "$building_docs" == "yes"])
170
171 dnl Handle the option to build the reference documentation
172 building_refdocs="no"
173 AC_ARG_ENABLE([refdocs],
174 AS_HELP_STRING([--enable-refdocs],
175 [enable building reference documentation (default on if xmlto etc. found and other documentation built).]),
176 [enable_refdocs=$enableval],
177 [enable_refdocs="check"])
178 if test "$building_docs" == "no" -a "$enable_refdocs" == "yes" ; then
179 AC_MSG_ERROR([must use --enable-docs with --enable-refdocs])
180 fi
181 AC_CHECK_PROG(have_xmlto, xmlto, yes, no)
182 if test "x${have_xmlto}" == "xyes"; then
183 AC_MSG_CHECKING([for xmlto pdf support])
184 cat > conftest.$ac_ext << EOF
185 <?xml version="1.0" encoding="UTF-8"?>
186 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
187 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
188 <book id="pdffromxml">
189 </book>
190 EOF
191 xmlto pdf conftest.$ac_ext >& /dev/null
192 if test $? == 0; then
193 have_xmlto_pdf="yes"
194 AC_MSG_RESULT([yes])
195 else
196 AC_MSG_RESULT([no])
197 fi
198 fi
199 if test "$enable_refdocs" == "yes"; then
200 if test "x${have_xmlto}${have_xmlto_pdf}" != "xyesyes"; then
201 AC_MSG_ERROR([cannot find proper yxmlto for building reference documentation])
202 fi
203 fi
204 if test "x${have_xmlto}${have_xmlto_pdf}" == "xyesyes" -a "$enable_refdocs" != "no" -a "${building_docs}" == "yes"; then
205 building_refdocs="yes"
206 fi
207 AM_CONDITIONAL([BUILD_REFDOCS], [test "$building_refdocs" == "yes"])
208
209 dnl Handle the option to build the server setup.
210 AC_ARG_ENABLE([server],
211 AS_HELP_STRING([--enble-server],
212 [enable building of stap-server/client (default on if nss etc. found).]),
213 [enable_server=$enableval],
214 [enable_server="check"])
215 PKG_CHECK_MODULES([nss],[nss >= 3], have_nss=yes, have_nss=no)
216 PKG_CHECK_MODULES([nspr],[nspr >= 4], have_nspr=yes, have_nspr=no)
217 if test "x${have_nss}${have_nspr}" != "xyesyes"; then
218 if test "$enable_server" == "yes"; then
219 AC_MSG_ERROR([cannot find all libraries for stap-server])
220 fi
221 if test "$enable_server" == "check"; then
222 AC_MSG_WARN([will not build stap-server, cannot find all libraries])
223 fi
224 fi
225 AM_CONDITIONAL([BUILD_SERVER], [test "x${have_nss}${have_nspr}" == "xyesyes" -a "$enable_server" != "no"])
226
227 dnl Handle elfutils. If '--with-elfutils=DIR' wasn't specified, used
228 dnl the system's elfutils.
229 build_elfutils=no
230 AC_ARG_WITH([elfutils],
231 AS_HELP_STRING([--with-elfutils=DIRECTORY],
232 [find elfutils source code in DIRECTORY]),
233 [
234 case "$with_elfutils" in
235 yes) AC_MSG_ERROR([--with-elfutils requires an argument]) ;;
236 ''|no) ;;
237 *) build_elfutils=yes ;;
238 esac])
239 AM_CONDITIONAL(BUILD_ELFUTILS, test $build_elfutils = yes)
240 AC_SUBST(elfutils_abs_srcdir, `AS_IF([test $build_elfutils = yes],
241 [cd $with_elfutils && pwd])`)
242
243 if test $build_elfutils = no; then
244 # Need libdwfl-capable recent elfutils http://elfutils.fedorahosted.org/
245 save_LIBS="$LIBS"
246 AC_CHECK_LIB(dw, dwfl_module_getsym,[],[
247 AC_MSG_ERROR([missing elfutils development headers/libraries (install elfutils-devel, libebl-dev, libdw-dev and/or libebl-devel)])],
248 [-Wl,--start-group -ldw -lebl -Wl,--end-group -lelf])
249 AC_CHECK_LIB(dw, dwarf_getelf,[],[
250 AC_MSG_ERROR([elfutils, libdw too old, need 0.126+])],
251 [-Wl,--start-group -ldw -lebl -Wl,--end-group -lelf])
252 stap_LIBS="-Wl,--start-group -ldw -lebl -Wl,--end-group -lelf"
253 LIBS="$save_LIBS"
254 else
255 # We built our own and stap_LDFLAGS points at the install.
256 stap_LIBS="-Wl,--start-group -ldw -lebl -Wl,--end-group -lelf"
257 fi
258
259 AC_SUBST(stap_LIBS)
260 AC_MSG_NOTICE([stap will link $stap_LIBS])
261
262 dnl Plop in the build (configure) date
263 date=`date +%Y-%m-%d`
264 AC_DEFINE_UNQUOTED(DATE, "$date", [Configuration/build date])
265 AC_SUBST(DATE, "$date")
266
267
268 # This procflags business is for staprun/stapio, which need to
269 # be compiled with the same bitness as the kernel. On e.g. PPC,
270 # userspace might be 32-bit default, but staprun needs to be
271 # 64-bit. See also bug #4037.
272
273 processor=`uname -p`
274 case "$processor" in
275 ppc64) PROCFLAGS=-m64 ;;
276 x86_64) PROCFLAGS=-m64 ;;
277 *) PROCFLAGS=""
278 esac
279 AC_SUBST([PROCFLAGS])
280
281 # Use tr1/unordered_map if available
282 AC_LANG_PUSH(C++)
283 AC_CHECK_HEADERS([tr1/unordered_map])
284 AC_LANG_POP(C++)
285
286
287 if test $build_elfutils = yes; then
288 case "$with_elfutils" in
289 /*) elfutils_srcdir="$with_elfutils" ;;
290 *) elfutils_srcdir="../$with_elfutils" ;;
291 esac
292 AC_MSG_NOTICE([running ${elfutils_srcdir}/configure])
293 # Our libdw.so's libebl will look in $ORIGIN/../lib/... but that
294 # $ORIGIN is where libdw.so resides, which is not where there is a ../lib.
295 # Note that $libdir might be using a quoted use of $exec_prefix or $prefix.
296 # So we must make sure to pass those settings to elfutils configure.
297 elfutils_rpath="-Wl,--enable-new-dtags,-rpath,${libdir}/${PACKAGE_NAME}"
298 here=`pwd`
299 (mkdir -p build-elfutils && cd build-elfutils &&
300 ${elfutils_srcdir}/configure --enable-libebl-subdir=${PACKAGE_NAME} \
301 --includedir="${here}/include-elfutils" \
302 --libdir="${here}/lib-elfutils" \
303 --exec-prefix="$exec_prefix" \
304 --prefix="$prefix" \
305 CFLAGS="${CFLAGS/-Wall/}" \
306 LDFLAGS="$LDFLAGS $elfutils_rpath" &&
307 make install-data # so that elfutils/version.h - if any - may be found.
308 )
309 fi
310
311 save_CPPFLAGS=${CPPFLAGS}
312 CPPFLAGS="${CPPFLAGS} -Iinclude-elfutils" # in case bundled elfutils
313 AC_CHECK_HEADERS([elfutils/version.h])
314 CPPFLAGS="$save_CPPFLAGS"
315
316 dnl This is here mainly to make sure that configure --prefix=... changes
317 dnl the config.h files so files depending on it are recompiled
318 dnl prefix is passed through indirectly in the Makefile.am AM_CPPFLAGS.
319 dnl Don't use this directly (when not given it is set to NONE).
320 AC_DEFINE_UNQUOTED(STAP_PREFIX, "$prefix", [configure prefix location])
321
322 AC_CONFIG_HEADERS([config.h:config.in])
323 AC_CONFIG_FILES(Makefile doc/Makefile doc/SystemTap_Tapset_Reference/Makefile stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 stap-server.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5)
324 AC_CONFIG_SUBDIRS(testsuite)
325 AC_CONFIG_FILES([run-stap], [chmod +x run-stap])
326 AC_OUTPUT
327
328 if test "${prefix}" = "/usr/local"; then
329 AC_MSG_NOTICE([])
330 AC_MSG_NOTICE([For a private or temporary build of systemtap, we recommend])
331 AC_MSG_NOTICE([configuring with a prefix. For example, try])
332 AC_MSG_NOTICE([$0 $ac_configure_args --prefix=$HOME/systemtap-${PACKAGE_VERSION}-$$])
333 AC_MSG_NOTICE([Running systemtap uninstalled, entirely out of the build tree,])
334 AC_MSG_NOTICE([is not supported.])
335 fi
This page took 0.048152 seconds and 6 git commands to generate.