configure: regroup os and arch specific defaults
[lttng-ust.git] / configure.ac
index 1f80ffe0a952667b98e3beb10597a930e1d217a1..6becf39f2314ac55c78957772c8cc26b80c45382 100644 (file)
@@ -57,207 +57,227 @@ AM_MAINTAINER_MODE([enable])
 # Enable silent rules by default
 AM_SILENT_RULES([yes])
 
-# Checks for C compiler
-AC_USE_SYSTEM_EXTENSIONS
-AC_SYS_LARGEFILE
+
+##                               ##
+## OS and Arch specific defaults ##
+##                               ##
+
+# Set os specific options
+AS_CASE([$host_os],
+  [freebsd*], [NO_NUMA=1]
+)
+
+# Set architecture specific options
+AS_CASE([$host_cpu],
+  [i[[3456]]86], [],
+  [x86_64], [],
+  [amd64], [],
+  [powerpc], [],
+  [ppc64], [],
+  [ppc64le], [],
+  [powerpc64], [],
+  [powerpc64le], [],
+  [s390], [],
+  [s390x], [],
+  [arm*], [
+    NO_NUMA=1
+    ],
+  [aarch64*], [],
+  [mips*], [],
+  [tile*], [],
+  [
+    unsupported_arch="yes"
+  ])
+
+
+##                   ##
+## C compiler checks ##
+##                   ##
+
+# Choose the C compiler
 AC_PROG_CC
 # AC_PROG_CC_STDC was merged in AC_PROG_CC in autoconf 2.70
 m4_version_prereq([2.70], [], [AC_PROG_CC_STDC])
-AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
-AM_CONDITIONAL([HAVE_CXX], [test "$HAVE_CXX11" = "1"])
 
-# Check if the compiler support weak symbols
-AX_SYS_WEAK_ALIAS
-
-AS_IF([test "x${ax_cv_sys_weak_alias}" = "xno"], [
-       AC_MSG_ERROR([Your platform doesn't support weak symbols.])
-])
-
-# Checks for programs.
-AM_PROG_AR
-AC_PROG_SED
-AC_PROG_GREP
-AC_PROG_LN_S
-AC_PROG_MKDIR_P
-AC_PROG_MAKE_SET
-AC_CHECK_PROG([CMAKE], [cmake])
-AM_CONDITIONAL([HAVE_CMAKE], [test "x$CMAKE" != "x"])
+# Make sure the C compiler supports C99
+AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])])
 
-# libtool link_all_deplibs fixup. See http://bugs.lttng.org/issues/321.
-AC_ARG_ENABLE([libtool-linkdep-fixup], [
-AS_HELP_STRING([--disable-libtool-linkdep-fixup], [disable the libtool fixup for linking all dependent libraries (link_all_deplibs)])
-], [
-       libtool_fixup=$enableval
-], [
-       libtool_fixup=yes
-])
+# Enable available system extensions and LFS support
+AC_USE_SYSTEM_EXTENSIONS
+AC_SYS_LARGEFILE
 
-AS_IF([test "x$libtool_fixup" = "xyes"], [
-       libtool_m4="$srcdir/m4/libtool.m4"
-       libtool_flag_pattern=".*link_all_deplibs\s*,\s*\$1\s*)"
-       AC_MSG_CHECKING([for occurence(s) of link_all_deplibs = no in $libtool_m4])
-       libtool_flag_pattern_count=$(grep -c "$libtool_flag_pattern\s*=\s*no" $libtool_m4)
+# Make sure the C compiler supports __attribute__
+AX_C___ATTRIBUTE__
+AS_IF([test "x$ax_cv___attribute__" != "xyes"],
+  [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
 
-       AS_IF([test $libtool_flag_pattern_count -ne 0], [
-       AC_MSG_RESULT([$libtool_flag_pattern_count])
-       AC_MSG_WARN([the detected libtool will not link all dependencies, forcing link_all_deplibs = unknown])
-               $SED -i "s/\($libtool_flag_pattern\)\s*=\s*no/\1=unknown/g" $libtool_m4
-       ], [
-               AC_MSG_RESULT([none])
-       ])
-])
-LT_INIT([disable-static])
+# Make sure we have pthread support
+AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])])
 
-AC_MSG_CHECKING([whether shared libraries are enabled])
-AS_IF([test "x$enable_shared" = "xyes"], [
-       AC_MSG_RESULT([yes])
-], [
-       AC_MSG_RESULT([no])
-       AC_MSG_ERROR([LTTng-UST requires shared libraries to be enabled])
-])
+# Make sure the C compiler supports weak symbols
+AX_SYS_WEAK_ALIAS
+AS_IF([test "x$ax_cv_sys_weak_alias" = "xno"],
+  [AC_MSG_ERROR([Your platform doesn't support weak symbols.])])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_INLINE
-AC_TYPE_INT8_T
+AC_C_TYPEOF
 AC_TYPE_INT16_T
 AC_TYPE_INT32_T
 AC_TYPE_INT64_T
+AC_TYPE_INT8_T
 AC_TYPE_MODE_T
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 AC_TYPE_SSIZE_T
 AC_TYPE_UID_T
-AC_TYPE_UINT8_T
 AC_TYPE_UINT16_T
 AC_TYPE_UINT32_T
 AC_TYPE_UINT64_T
+AC_TYPE_UINT8_T
 AC_CHECK_TYPES([ptrdiff_t])
 
-AX_C___ATTRIBUTE__
-AS_IF([test "x$ax_cv___attribute__" = "xyes"],
-       [:],
-       [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
 
-AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])
+##                     ##
+## C++ compiler checks ##
+##                     ##
+
+# Find an optional C++11 compiler without GNU extensions (-std=c++11)
+AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
+AM_CONDITIONAL([HAVE_CXX], [test "$HAVE_CXX11" = "1"])
+
+
+##               ##
+## Header checks ##
+##               ##
+
+AC_HEADER_STDBOOL
+AC_CHECK_HEADERS([ \
+  arpa/inet.h \
+  dlfcn.h \
+  fcntl.h \
+  float.h \
+  limits.h \
+  linux/perf_event.h \
+  locale.h \
+  stddef.h \
+  sys/socket.h \
+  sys/time.h \
+  wchar.h \
+])
+
+# Check for dlinfo() by testing for RTLD_DI_LINKMAP in dlfcn.h
+AS_IF([test "x$ac_cv_header_dlfcn_h" = "xyes"], [
+  AC_CHECK_DECL([RTLD_DI_LINKMAP], [], [], [[#include <dlfcn.h>]])
+])
+
+
+##                 ##
+## Programs checks ##
+##                 ##
+
+AM_PROG_AR
+AC_PROG_SED
+AC_PROG_GREP
+AC_PROG_LN_S
+AC_PROG_MKDIR_P
+AC_PROG_MAKE_SET
+AC_CHECK_PROGS([ASCIIDOC], [asciidoc])
+AC_CHECK_PROGS([CMAKE], [cmake])
+AC_CHECK_PROGS([FOLD], [fold])
+AC_CHECK_PROGS([XMLTO], [xmlto])
+
+AM_PATH_PYTHON([2.7], [], [PYTHON=""])
+
+AX_PROG_JAVAC
+AX_PROG_JAVA
+AX_PROG_JAR
+
+# Initialize and configure libtool
+LT_INIT([disable-static])
+
+
+##                ##
+## Library checks ##
+##                ##
 
-# Checks for library functions.
 AC_FUNC_CHOWN
 AC_FUNC_FORK
 AC_FUNC_MMAP
-AC_FUNC_REALLOC
 AC_FUNC_STRERROR_R
 AC_FUNC_STRNLEN
 AC_CHECK_FUNCS([ \
-       atexit \
-       clock_gettime \
-       ftruncate \
-       getpagesize \
-       gettimeofday \
-       localeconv \
-       memchr \
-       memmove \
-       memset \
-       mkdir \
-       munmap \
-       realpath \
-       sched_getcpu \
-       socket \
-       strchr \
-       strdup \
-       strerror \
-       strtol \
-       strtoul \
-       sysconf \
+  atexit \
+  clock_gettime \
+  ftruncate \
+  getpagesize \
+  gettimeofday \
+  localeconv \
+  memchr \
+  memmove \
+  memset \
+  mkdir \
+  munmap \
+  realpath \
+  sched_getcpu \
+  socket \
+  strchr \
+  strdup \
+  strerror \
+  strtol \
+  strtoul \
+  sysconf \
 ])
 
+# AC_FUNC_MALLOC causes problems when cross-compiling.
+#AC_FUNC_MALLOC
+#AC_FUNC_REALLOC
+
 # Check for pthread_setname_np and its signature
 LTTNG_PTHREAD_SETNAME_NP
 LTTNG_PTHREAD_GETNAME_NP
 
-# AC_FUNC_MALLOC causes problems when cross-compiling.
-#AC_FUNC_MALLOC
+# Check dor dlopen() in -ldl or -lc
+AC_CHECK_LIB([dl], [dlopen], [
+  libdl_name=dl
+  DL_LIBS="-ldl"
+], [
+  # dlopen not found in libdl, check in libc
+  AC_CHECK_LIB([c], [dlopen], [
+    libdl_name=c
+    DL_LIBS="-lc"
+  ], [
+    AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
+  ])
+])
+AC_SUBST(DL_LIBS)
 
-# Checks for header files.
-AC_HEADER_STDBOOL
-AC_CHECK_HEADERS([ \
-       arpa/inet.h \
-       fcntl.h \
-       float.h \
-       limits.h \
-       locale.h \
-       stddef.h \
-       sys/socket.h \
-       sys/time.h \
-       wchar.h \
+# Check if libdl has dlmopen()
+AC_CHECK_LIB([$libdl_name], [dlmopen], [
+  AC_DEFINE([HAVE_DLMOPEN], [1], [Define to 1 if dlmopen is available.])
 ])
 
-# Set architecture specific options
-AS_CASE([$host_cpu],
-       [i[[3456]]86], [],
-       [x86_64], [],
-       [amd64], [],
-       [powerpc], [],
-       [ppc64], [],
-       [ppc64le], [],
-       [powerpc64], [],
-       [powerpc64le], [],
-       [s390], [],
-       [s390x], [],
-       [arm*], [
-               NO_NUMA=1
-               ],
-       [aarch64*], [],
-       [mips*], [],
-       [tile*], [],
-       [
-               UNSUPPORTED_ARCH=1
-       ])
+# Require URCU >= 0.12 for DEFINE_URCU_TLS_INIT
+PKG_CHECK_MODULES([URCU], [liburcu >= 0.12])
 
-# Set os specific options
-AS_CASE([$host_os],
-       [freebsd*], [NO_NUMA=1]
-)
 
-# Configuration options, which will be installed in the config.h
-AH_TEMPLATE([LTTNG_UST_HAVE_SDT_INTEGRATION], [SystemTap integration via sdt.h])
+AM_CONDITIONAL([HAVE_CMAKE], [test "x$CMAKE" != "x"])
 
-# Checks for libraries.
-AC_CHECK_LIB([dl], [dlopen], [
-       libdl_name=dl
-       DL_LIBS="-ldl"
+AC_MSG_CHECKING([whether shared libraries are enabled])
+AS_IF([test "x$enable_shared" = "xyes"], [
+       AC_MSG_RESULT([yes])
 ], [
-       #libdl not found, check for dlopen in libc.
-       AC_CHECK_LIB([c], [dlopen], [
-               libdl_name=c
-               DL_LIBS="-lc"
-       ], [
-               AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
-       ])
+       AC_MSG_RESULT([no])
+       AC_MSG_ERROR([LTTng-UST requires shared libraries to be enabled])
 ])
-AC_SUBST(DL_LIBS)
 
-# Check if libdl has dlmopen support.
-AH_TEMPLATE([HAVE_DLMOPEN], ["Define to 1 if dlmopen is available."])
-AC_CHECK_LIB([$libdl_name], [dlmopen],
-       [AC_DEFINE([HAVE_DLMOPEN], [1])]
-)
+# Configuration options, which will be installed in the config.h
+AH_TEMPLATE([LTTNG_UST_HAVE_SDT_INTEGRATION], [SystemTap integration via sdt.h])
 
-# Check for dlfcn.h
-AC_CHECK_HEADER([dlfcn.h])
-AS_IF([test "x${ac_cv_header_dlfcn_h}" = "xyes"], [
-       AC_CHECK_DECLS([RTLD_DI_LINKMAP], [], [], [
-               #include <dlfcn.h>
-       ])
-], [
-       ac_cv_have_decl_RTLD_DI_LINKMAP="no"
-])
 
 AM_CONDITIONAL([ENABLE_UST_DL], [test "x${ac_cv_have_decl_RTLD_DI_LINKMAP}" = "xyes"])
 
-# Require URCU >= 0.12 for DEFINE_URCU_TLS_INIT
-PKG_CHECK_MODULES([URCU], [liburcu >= 0.12])
-
 # numa.h integration
 AS_IF([test "x$NO_NUMA" = "x1"],[
       AS_IF([test "x$enable_numa" = "x" ], [enable_numa=no])
@@ -279,17 +299,7 @@ AS_IF([test "x$enable_numa" = "xyes"], [
 ])
 AM_CONDITIONAL([ENABLE_NUMA], [test "x$have_libnuma" = "xyes"])
 
-# optional linux/perf_event.h
-AC_CHECK_HEADERS([linux/perf_event.h], [have_perf_event=yes], [])
-
-# Perf event counters are supported on all architectures supported by
-# perf, using the read system call as fallback.
-AM_CONDITIONAL([HAVE_PERF_EVENT], [test "x$have_perf_event" = "xyes"])
-
-AH_TEMPLATE([HAVE_PERF_EVENT], ["Perf event integration via perf_event.h"])
-AS_IF([test "x$have_perf_event" = "xyes"], [
-       AC_DEFINE([HAVE_PERF_EVENT], [1])
-])
+AM_CONDITIONAL([HAVE_PERF_EVENT], [test "x$ac_cv_header_linux_perf_event_h" = "xyes"])
 
 # Check for JNI header files if requested
 AC_ARG_ENABLE([jni-interface], [
@@ -332,9 +342,6 @@ AM_CONDITIONAL([ENABLE_JAVA_AGENT_WITH_LOG4J], [test "x$java_agent_log4j" = "xye
 
 AS_IF([test "x$jni_interface" = "xyes" || test "x$java_agent_jul" = "xyes" || test "x$java_agent_log4j" = "xyes"], [
        AX_JAVA_OPTIONS
-       AX_PROG_JAVAC
-       AX_PROG_JAVA
-       AX_PROG_JAR
        AC_ARG_VAR([CLASSPATH], [Java class path])
 
        AX_JNI_INCLUDE_DIR
@@ -366,9 +373,6 @@ AS_HELP_STRING([--enable-python-agent], [build the LTTng UST Python agent [defau
        python_agent=$enableval
 ], [:])
 AM_CONDITIONAL([ENABLE_PYTHON_AGENT], [test "x$python_agent" = "xyes"])
-AS_IF([test "x$python_agent" = "xyes"], [
-       AM_PATH_PYTHON([2.7])
-])
 
 # sdt.h integration
 AC_ARG_WITH([sdt], [
@@ -407,8 +411,7 @@ AS_HELP_STRING([--with-lttng-system-rundir], [Location of the system directory w
 AC_DEFINE_UNQUOTED([LTTNG_SYSTEM_RUNDIR], ["$lttng_system_rundir"],
                [LTTng system runtime directory])
 
-AC_CHECK_PROG([ENABLE_GEN_TP_EXAMPLES], [python], ["yes"])
-AM_CONDITIONAL([ENABLE_GEN_TP_EXAMPLES], [test "x$ENABLE_GEN_TP_EXAMPLES" = "xyes"])
+AM_CONDITIONAL([ENABLE_GEN_TP_EXAMPLES], [test "x$PYTHON" != "x"])
 
 # Enable building examples
 AC_ARG_ENABLE(
@@ -439,10 +442,7 @@ have_asciidoc_xmlto=no
 warn_prebuilt_man_pages=no
 
 AS_IF([test "x$man_pages_opt" = "xyes"], [
-       AC_PATH_PROG([ASCIIDOC], [asciidoc], [no])
-       AC_PATH_PROG([XMLTO], [xmlto], [no])
-
-       AS_IF([test "x$ASCIIDOC" = "xno" || test "x$XMLTO" = "xno"], [
+       AS_IF([test "x$ASCIIDOC" = "x" || test "x$XMLTO" = "x"], [
                AE_IF_IN_GIT_REPO([
                        # This is an error because we're in the Git repo, which
                        # means the man pages are not already generated for us,
@@ -587,7 +587,7 @@ PPRINT_SUBTITLE([System])
 
 PPRINT_PROP_STRING([Target architecture], $host_cpu)
 
-AS_IF([test "x$UNSUPPORTED_ARCH" = "x1"],[
+AS_IF([test "x$unsupported_arch" = "xyes"],[
        PPRINT_WARN([Your architecture ($host_cpu) is unsupported, using safe default of no unaligned access.])
 ])
 
@@ -610,7 +610,7 @@ PPRINT_PROP_BOOL_CUSTOM([JNI interface (JNI)], $value, [use --enable-jni-interfa
 test "x$python_agent" = xyes && value=1 || value=0
 PPRINT_PROP_BOOL_CUSTOM([Python agent], $value, [use --enable-python-agent])
 
-test "x$have_perf_event" = "xyes" && value=1 || value=0
+test "x$ac_cv_header_linux_perf_event_h" = "xyes" && value=1 || value=0
 PPRINT_PROP_BOOL_CUSTOM([Perf event integration], $value)
 
 test "x$enable_numa" = xyes && value=1 || value=0
This page took 0.029468 seconds and 4 git commands to generate.