blob: b1f7c7080fad509c7cd3522246c3899d58e075f2 [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])
Patrick Williams5e0b6812016-11-04 16:45:33 -05007AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
8AM_SILENT_RULES([yes])
9
William A. Kennington III592128c2018-06-19 18:34:17 -070010# Make sure the default CFLAGS of `-O2 -g` don't override CODE_COVERAGE_CFLAGS
11# It is important that this comes before AC_PROG_C{C,XX}, as we are attempting
12# to stop them from populating default CFLAGS and CXXFLAGS.
13AS_IF([test "x$enable_code_coverage" != "xno"], [
14 AS_IF([test "x${CXXFLAGS+set}" != "xset"], [
15 AC_SUBST(CXXFLAGS, [""])
16 ])
17 AS_IF([test "x${CFLAGS+set}" != "xset"], [
18 AC_SUBST(CFLAGS, [""])
19 ])
20])
21
Patrick Williams5e0b6812016-11-04 16:45:33 -050022# Checks for programs.
Patrick Williams83a9d0b2016-11-04 17:06:13 -050023AC_PROG_CXX
Patrick Williams5e0b6812016-11-04 16:45:33 -050024AC_PROG_CC
25AM_PROG_AR
26AC_PROG_INSTALL
27AC_PROG_MAKE_SET
28
Brad Bishopbba7f8c2016-11-10 09:32:58 -050029# setup sdbus++
30AM_PATH_PYTHON([2.7], [AC_SUBST([PYTHON], [echo "$PYTHON"])])
31AC_SUBST([PYTHONDIR], ${pythondir})
32AS_IF([test "$PYTHON" != :], [have_python=yes], [have_python=no])
33
34AC_ARG_ENABLE([sdbuspp],
35 AS_HELP_STRING([--disable-sdbuspp], [Disable sdbus++]))
36
37AS_IF([test "x$enable_sdbuspp" != "xno"],
38 [AS_IF([test "x$have_python" = "xno"], [AC_MSG_ERROR([sdbus++ requires python])])])
39
40AM_CONDITIONAL([WANT_SDBUSPP], [test "x$enable_sdbuspp" != "xno"])
41
Brad Bishop14275cf2016-11-10 16:24:48 -050042# setup libsdbusplus
Brad Bishop5e703892017-02-10 11:52:48 -050043AX_PKG_CHECK_MODULES(
44 [SYSTEMD],
45 [libsystemd >= 221],
46 [],
47 [have_systemd=yes],
48 [have_systemd=no])
Brad Bishop14275cf2016-11-10 16:24:48 -050049AC_ARG_ENABLE([libsdbusplus],
50 AS_HELP_STRING([--disable-libsdbusplus], [Disable libsdbusplus]))
51
52AS_IF([test "x$enable_libsdbusplus" != "xno"],
53 [AS_IF([test "x$have_systemd" = "xno"], [AC_MSG_ERROR([libsdbusplus requires systemd])])])
54
55AM_CONDITIONAL([WANT_LIBSDBUSPLUS], [test "x$enable_libsdbusplus" != "xno"])
Patrick Williams5e0b6812016-11-04 16:45:33 -050056
Adriana Kobylakfd43ef72017-02-12 09:12:37 -060057# setup transaction
58AC_ARG_ENABLE([transaction],
59 AS_HELP_STRING([--enable-transaction], [Enable transaction id support.]))
60AC_ARG_VAR(WANT_TRANSACTION, [Enable transaction id support.])
61AS_IF([test "x$enable_transaction" = "xyes"], \
62 [WANT_TRANSACTION="1"], \
63 [WANT_TRANSACTION="0"])
64AM_CONDITIONAL([WANT_TRANSACTION], [test "x$enable_transaction" = "xyes"])
65
Patrick Williams5e0b6812016-11-04 16:45:33 -050066# Checks for header files.
Patrick Williamsab7de322017-01-06 15:14:45 -060067AS_IF([test "x$enable_libsdbusplus" != "xno"],
Gunnar Millsa4b4a0b2018-04-08 14:30:38 -050068 [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 -050069
70# Checks for typedefs, structures, and compiler characteristics.
Patrick Williamsab7de322017-01-06 15:14:45 -060071AS_IF([test "x$enable_libsdbusplus" != "xno"],
Brad Bishop14275cf2016-11-10 16:24:48 -050072 [AX_CXX_COMPILE_STDCXX_14([noext])])
Patrick Williams83a9d0b2016-11-04 17:06:13 -050073AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CFLAGS])
74AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
Patrick Williams5e0b6812016-11-04 16:45:33 -050075
76# Checks for library functions.
77LT_INIT # Removes 'unrecognized options: --with-libtool-sysroot'
78
William A. Kennington IIIb4b32472018-06-21 16:38:47 -070079# Make it possible for users to choose if they want test support
80# explicitly or not at all
81AC_ARG_ENABLE([tests], [Whether we should build test cases])
82
83# Legacy tests require pthread support
84AS_IF([test "x$enable_tests" != "xno"], [
85 AX_PTHREAD([], [
86 AS_IF([test "x$enable_tests" != "xyes"], [
87 AC_MSG_ERROR([Testing enabled but could not find pthreads])
88 ])
89 ])
90])
91
Patrick Williams5e0b6812016-11-04 16:45:33 -050092# Check/set gtest specific functions.
William A. Kennington IIIb4b32472018-06-21 16:38:47 -070093AS_IF([test "x$enable_tests" != "xno"], [
William A. Kennington III40c22792018-06-29 16:21:17 -070094 PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
William A. Kennington IIIc20acf62018-06-22 18:38:03 -070095 PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
William A. Kennington IIIb4b32472018-06-21 16:38:47 -070096
97 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
98 AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
99 AC_LANG_PUSH([C++])
100 AC_CHECK_HEADERS([gtest/gtest.h], [
101 AS_IF([test "x$GTEST_CFLAGS" = "x"], [
102 AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [
103 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS])
104 ], [
105 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS])
106 AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS])
107 ])
108 ])
109 ], [
110 AS_IF([test "x$enable_tests" = "xyes"], [
111 AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h])
112 ])
113 ])
114 AC_LANG_POP([C++])
115 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
116
William A. Kennington IIIc20acf62018-06-22 18:38:03 -0700117 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
118 AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
119 AC_LANG_PUSH([C++])
120 AC_CHECK_HEADERS([gmock/gmock.h], [], [
121 AS_IF([test "x$enable_tests" = "xyes"], [
122 AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
123 ])
124 ])
125 AC_LANG_POP([C++])
126 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
127
William A. Kennington IIIb4b32472018-06-21 16:38:47 -0700128 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
129 AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
130 AC_CHECK_LIB([gtest], [main], [
131 AS_IF([test "x$GTEST_LIBS" = "x"], [
132 AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS])
133 ])
134 ], [
135 AS_IF([test "x$enable_tests" = "xyes"], [
136 AC_MSG_ERROR([Testing enabled but couldn't find gtest libs])
137 ])
138 ])
139 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
William A. Kennington IIIc20acf62018-06-22 18:38:03 -0700140
141 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
142 AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
143 AC_CHECK_LIB([gmock], [main], [
144 AS_IF([test "x$GMOCK_LIBS" = "x"], [
145 AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
146 ])
147 ], [
148 AS_IF([test "x$enable_tests" = "xyes"], [
149 AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
150 ])
151 ])
152 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
William A. Kennington IIIb4b32472018-06-21 16:38:47 -0700153])
Patrick Williams5e0b6812016-11-04 16:45:33 -0500154
William A. Kennington III592128c2018-06-19 18:34:17 -0700155# Code coverage
156AX_CODE_COVERAGE
157AM_EXTRA_RECURSIVE_TARGETS([check-code-coverage])
158
Patrick Williams5e0b6812016-11-04 16:45:33 -0500159AC_ARG_ENABLE([oe-sdk],
160 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
161)
162AC_ARG_VAR(OECORE_TARGET_SYSROOT,
163 [Path to the OE SDK SYSROOT])
164AS_IF([test "x$enable_oe_sdk" == "xyes"],
165 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
166 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
167 )
168 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
169 [
170 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
171 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
172 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
173 ]
174 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
175)
176
James Feist284a0f92018-04-05 15:28:16 -0700177AC_ARG_ENABLE([boost],
178 AS_HELP_STRING([--enable-boost], [Enable building with boost.]))
179AM_CONDITIONAL(BOOST, [test "x$enable_boost" = "xyes"])
180
Patrick Williams5e0b6812016-11-04 16:45:33 -0500181# Create configured output
Brad Bishopbba7f8c2016-11-10 09:32:58 -0500182AC_CONFIG_FILES([Makefile test/Makefile tools/Makefile tools/setup.py])
Patrick Williams4edb7852017-07-03 11:50:11 -0500183AC_CONFIG_FILES([example/Makefile])
Adriana Kobylaka1fb5e62017-01-30 11:41:19 -0600184AC_CONFIG_FILES([sdbusplus.pc])
Adriana Kobylakfd43ef72017-02-12 09:12:37 -0600185AC_CONFIG_FILES([sdbusplus/bus.hpp])
186AC_CONFIG_FILES([sdbusplus/server.hpp])
187AC_CONFIG_FILES([tools/sdbusplus/templates/interface.mako.server.cpp])
188AC_CONFIG_FILES([tools/sdbusplus/templates/method.mako.prototype.hpp])
Adriana Kobylakee6ac692018-06-06 09:36:51 -0500189AC_CONFIG_FILES([tools/sdbusplus/templates/property.mako.prototype.hpp])
Patrick Williams5e0b6812016-11-04 16:45:33 -0500190AC_OUTPUT