blob: 34a49be2ee703d2199c70d94c3b7aa432ff1e4b1 [file] [log] [blame]
Patrick Williams5e0b6812016-11-04 16:45:33 -05001# Initialization
2AC_PREREQ([2.69])
3AC_INIT([sdbusplus], [1.0], [https://github.com/openbmc/sdbusplus/issues])
4AC_CONFIG_HEADERS([config.h])
William A. Kennington IIIc65d74e2018-06-19 18:32:09 -07005AC_CONFIG_MACRO_DIRS([m4])
6AC_CONFIG_AUX_DIR([build-aux])
William A. Kennington IIIebdc3712019-03-15 13:42:44 -07007AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign dist-xz])
Patrick Williams5e0b6812016-11-04 16:45:33 -05008AM_SILENT_RULES([yes])
Patrick Venture6b4fb292018-10-29 18:54:16 -07009AC_LANG([C++])
Patrick Williams5e0b6812016-11-04 16:45:33 -050010
William A. Kennington III592128c2018-06-19 18:34:17 -070011# Make sure the default CFLAGS of `-O2 -g` don't override CODE_COVERAGE_CFLAGS
12# It is important that this comes before AC_PROG_C{C,XX}, as we are attempting
13# to stop them from populating default CFLAGS and CXXFLAGS.
William A. Kennington III387110b2018-08-21 19:23:19 -070014AS_IF([test "x$enable_tests" = "xno"], [enable_code_coverage=no])
15AS_IF([test "x$enable_code_coverage" != "xno"], [
16 AS_IF([test "x${CXXFLAGS+set}" != "xset"], [
17 AC_SUBST(CXXFLAGS, [""])
18 ])
19 AS_IF([test "x${CFLAGS+set}" != "xset"], [
20 AC_SUBST(CFLAGS, [""])
William A. Kennington III592128c2018-06-19 18:34:17 -070021 ])
22])
23
Patrick Williams5e0b6812016-11-04 16:45:33 -050024# Checks for programs.
Patrick Williams83a9d0b2016-11-04 17:06:13 -050025AC_PROG_CXX
Patrick Williams5e0b6812016-11-04 16:45:33 -050026AC_PROG_CC
27AM_PROG_AR
28AC_PROG_INSTALL
29AC_PROG_MAKE_SET
30
Brad Bishopbba7f8c2016-11-10 09:32:58 -050031# setup sdbus++
Patrick Williams18ce8032020-01-31 18:47:38 -080032AM_PATH_PYTHON([3.0], [AC_SUBST([PYTHON], [echo "$PYTHON"])])
Brad Bishopbba7f8c2016-11-10 09:32:58 -050033AC_SUBST([PYTHONDIR], ${pythondir})
34AS_IF([test "$PYTHON" != :], [have_python=yes], [have_python=no])
35
36AC_ARG_ENABLE([sdbuspp],
37 AS_HELP_STRING([--disable-sdbuspp], [Disable sdbus++]))
38
39AS_IF([test "x$enable_sdbuspp" != "xno"],
40 [AS_IF([test "x$have_python" = "xno"], [AC_MSG_ERROR([sdbus++ requires python])])])
41
42AM_CONDITIONAL([WANT_SDBUSPP], [test "x$enable_sdbuspp" != "xno"])
43
Brad Bishop14275cf2016-11-10 16:24:48 -050044# setup libsdbusplus
Brad Bishop5e703892017-02-10 11:52:48 -050045AX_PKG_CHECK_MODULES(
46 [SYSTEMD],
47 [libsystemd >= 221],
48 [],
49 [have_systemd=yes],
50 [have_systemd=no])
Brad Bishop14275cf2016-11-10 16:24:48 -050051AC_ARG_ENABLE([libsdbusplus],
52 AS_HELP_STRING([--disable-libsdbusplus], [Disable libsdbusplus]))
53
54AS_IF([test "x$enable_libsdbusplus" != "xno"],
55 [AS_IF([test "x$have_systemd" = "xno"], [AC_MSG_ERROR([libsdbusplus requires systemd])])])
56
57AM_CONDITIONAL([WANT_LIBSDBUSPLUS], [test "x$enable_libsdbusplus" != "xno"])
Patrick Williams5e0b6812016-11-04 16:45:33 -050058
Adriana Kobylakfd43ef72017-02-12 09:12:37 -060059# setup transaction
60AC_ARG_ENABLE([transaction],
61 AS_HELP_STRING([--enable-transaction], [Enable transaction id support.]))
62AC_ARG_VAR(WANT_TRANSACTION, [Enable transaction id support.])
63AS_IF([test "x$enable_transaction" = "xyes"], \
64 [WANT_TRANSACTION="1"], \
65 [WANT_TRANSACTION="0"])
66AM_CONDITIONAL([WANT_TRANSACTION], [test "x$enable_transaction" = "xyes"])
67
Patrick Williams5e0b6812016-11-04 16:45:33 -050068# Checks for header files.
Patrick Williamsab7de322017-01-06 15:14:45 -060069AS_IF([test "x$enable_libsdbusplus" != "xno"],
Gunnar Millsa4b4a0b2018-04-08 14:30:38 -050070 [AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd development package required])])])
Patrick Williams5e0b6812016-11-04 16:45:33 -050071
72# Checks for typedefs, structures, and compiler characteristics.
Patrick Williamsab7de322017-01-06 15:14:45 -060073AS_IF([test "x$enable_libsdbusplus" != "xno"],
Vernon Maueryca46b9d2018-10-02 14:05:09 -070074 [AX_CXX_COMPILE_STDCXX_17([noext])])
Patrick Williams83a9d0b2016-11-04 17:06:13 -050075AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CFLAGS])
76AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
Patrick Williams5e0b6812016-11-04 16:45:33 -050077
78# Checks for library functions.
79LT_INIT # Removes 'unrecognized options: --with-libtool-sysroot'
80
William A. Kennington IIIb4b32472018-06-21 16:38:47 -070081# Make it possible for users to choose if they want test support
82# explicitly or not at all
83AC_ARG_ENABLE([tests], [Whether we should build test cases])
84
Patrick Williams5e0b6812016-11-04 16:45:33 -050085# Check/set gtest specific functions.
William A. Kennington IIIb4b32472018-06-21 16:38:47 -070086AS_IF([test "x$enable_tests" != "xno"], [
William A. Kennington III40c22792018-06-29 16:21:17 -070087 PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
William A. Kennington IIIc20acf62018-06-22 18:38:03 -070088 PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
William A. Kennington III6f574672018-06-27 11:19:03 -070089 AX_PTHREAD
William A. Kennington IIIb4b32472018-06-21 16:38:47 -070090
91 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
92 AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
William A. Kennington IIIb4b32472018-06-21 16:38:47 -070093 AC_CHECK_HEADERS([gtest/gtest.h], [
94 AS_IF([test "x$GTEST_CFLAGS" = "x"], [
95 AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [
96 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS])
97 ], [
98 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS])
99 AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS])
100 ])
101 ])
102 ], [
103 AS_IF([test "x$enable_tests" = "xyes"], [
104 AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h])
105 ])
106 ])
William A. Kennington IIIb4b32472018-06-21 16:38:47 -0700107 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
108
William A. Kennington IIIc20acf62018-06-22 18:38:03 -0700109 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
110 AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
William A. Kennington IIIc20acf62018-06-22 18:38:03 -0700111 AC_CHECK_HEADERS([gmock/gmock.h], [], [
112 AS_IF([test "x$enable_tests" = "xyes"], [
113 AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
114 ])
115 ])
William A. Kennington IIIc20acf62018-06-22 18:38:03 -0700116 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
117
William A. Kennington IIIb4b32472018-06-21 16:38:47 -0700118 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
119 AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
120 AC_CHECK_LIB([gtest], [main], [
121 AS_IF([test "x$GTEST_LIBS" = "x"], [
122 AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS])
123 ])
124 ], [
125 AS_IF([test "x$enable_tests" = "xyes"], [
126 AC_MSG_ERROR([Testing enabled but couldn't find gtest libs])
127 ])
128 ])
129 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
William A. Kennington IIIc20acf62018-06-22 18:38:03 -0700130
131 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
132 AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
133 AC_CHECK_LIB([gmock], [main], [
134 AS_IF([test "x$GMOCK_LIBS" = "x"], [
135 AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
136 ])
137 ], [
138 AS_IF([test "x$enable_tests" = "xyes"], [
139 AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
140 ])
141 ])
142 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
William A. Kennington IIIb4b32472018-06-21 16:38:47 -0700143])
Patrick Williams5e0b6812016-11-04 16:45:33 -0500144
William A. Kennington III6c17d3d2018-06-19 18:34:43 -0700145# Check for valgrind
William A. Kennington III387110b2018-08-21 19:23:19 -0700146AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
147m4_foreach([vgtool], [valgrind_tool_list],
148 [AX_VALGRIND_DFLT(vgtool, [off])])
149AX_VALGRIND_DFLT([memcheck], [on])
150AX_VALGRIND_CHECK
151AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
152m4_foreach([vgtool], [valgrind_tool_list],
153 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
William A. Kennington III6c17d3d2018-06-19 18:34:43 -0700154
William A. Kennington III592128c2018-06-19 18:34:17 -0700155# Code coverage
William A. Kennington III387110b2018-08-21 19:23:19 -0700156AX_CODE_COVERAGE
William A. Kennington IIIebdc3712019-03-15 13:42:44 -0700157AS_IF([test "x$CODE_COVERAGE_ENABLED" = "xyes"], [
158 AX_APPEND_COMPILE_FLAGS([-DHAVE_GCOV], [CODE_COVERAGE_CPPFLAGS])
159])
160m4_ifdef([_AX_CODE_COVERAGE_RULES],
161 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
162 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
163AX_ADD_AM_MACRO_STATIC([])
William A. Kennington III592128c2018-06-19 18:34:17 -0700164
Patrick Williams5e0b6812016-11-04 16:45:33 -0500165AC_ARG_ENABLE([oe-sdk],
166 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
167)
168AC_ARG_VAR(OECORE_TARGET_SYSROOT,
169 [Path to the OE SDK SYSROOT])
170AS_IF([test "x$enable_oe_sdk" == "xyes"],
171 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
172 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
173 )
174 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
175 [
176 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
177 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
178 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
179 ]
180 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
181)
182
James Feist284a0f92018-04-05 15:28:16 -0700183AC_ARG_ENABLE([boost],
184 AS_HELP_STRING([--enable-boost], [Enable building with boost.]))
185AM_CONDITIONAL(BOOST, [test "x$enable_boost" = "xyes"])
186
Patrick Williams5e0b6812016-11-04 16:45:33 -0500187# Create configured output
Patrick Williams50981162020-05-15 17:38:42 -0500188AC_CONFIG_FILES([Makefile test/Makefile tools/Makefile tools/setup_autotools.py])
Patrick Williams4edb7852017-07-03 11:50:11 -0500189AC_CONFIG_FILES([example/Makefile])
Adriana Kobylaka1fb5e62017-01-30 11:41:19 -0600190AC_CONFIG_FILES([sdbusplus.pc])
Patrick Williams5e0b6812016-11-04 16:45:33 -0500191AC_OUTPUT