Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
| 3 | AC_INIT([sdbusplus], [1.0], [https://github.com/openbmc/sdbusplus/issues]) |
| 4 | AC_CONFIG_HEADERS([config.h]) |
William A. Kennington III | c65d74e | 2018-06-19 18:32:09 -0700 | [diff] [blame] | 5 | AC_CONFIG_MACRO_DIRS([m4]) |
| 6 | AC_CONFIG_AUX_DIR([build-aux]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 7 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) |
| 8 | AM_SILENT_RULES([yes]) |
Patrick Venture | 6b4fb29 | 2018-10-29 18:54:16 -0700 | [diff] [blame^] | 9 | AC_LANG([C++]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 10 | |
William A. Kennington III | 592128c | 2018-06-19 18:34:17 -0700 | [diff] [blame] | 11 | # 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 III | 387110b | 2018-08-21 19:23:19 -0700 | [diff] [blame] | 14 | AS_IF([test "x$enable_tests" = "xno"], [enable_code_coverage=no]) |
| 15 | AS_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 III | 592128c | 2018-06-19 18:34:17 -0700 | [diff] [blame] | 21 | ]) |
| 22 | ]) |
| 23 | |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 24 | # Checks for programs. |
Patrick Williams | 83a9d0b | 2016-11-04 17:06:13 -0500 | [diff] [blame] | 25 | AC_PROG_CXX |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 26 | AC_PROG_CC |
| 27 | AM_PROG_AR |
| 28 | AC_PROG_INSTALL |
| 29 | AC_PROG_MAKE_SET |
| 30 | |
Brad Bishop | bba7f8c | 2016-11-10 09:32:58 -0500 | [diff] [blame] | 31 | # setup sdbus++ |
| 32 | AM_PATH_PYTHON([2.7], [AC_SUBST([PYTHON], [echo "$PYTHON"])]) |
| 33 | AC_SUBST([PYTHONDIR], ${pythondir}) |
| 34 | AS_IF([test "$PYTHON" != :], [have_python=yes], [have_python=no]) |
| 35 | |
| 36 | AC_ARG_ENABLE([sdbuspp], |
| 37 | AS_HELP_STRING([--disable-sdbuspp], [Disable sdbus++])) |
| 38 | |
| 39 | AS_IF([test "x$enable_sdbuspp" != "xno"], |
| 40 | [AS_IF([test "x$have_python" = "xno"], [AC_MSG_ERROR([sdbus++ requires python])])]) |
| 41 | |
| 42 | AM_CONDITIONAL([WANT_SDBUSPP], [test "x$enable_sdbuspp" != "xno"]) |
| 43 | |
Brad Bishop | 14275cf | 2016-11-10 16:24:48 -0500 | [diff] [blame] | 44 | # setup libsdbusplus |
Brad Bishop | 5e70389 | 2017-02-10 11:52:48 -0500 | [diff] [blame] | 45 | AX_PKG_CHECK_MODULES( |
| 46 | [SYSTEMD], |
| 47 | [libsystemd >= 221], |
| 48 | [], |
| 49 | [have_systemd=yes], |
| 50 | [have_systemd=no]) |
Brad Bishop | 14275cf | 2016-11-10 16:24:48 -0500 | [diff] [blame] | 51 | AC_ARG_ENABLE([libsdbusplus], |
| 52 | AS_HELP_STRING([--disable-libsdbusplus], [Disable libsdbusplus])) |
| 53 | |
| 54 | AS_IF([test "x$enable_libsdbusplus" != "xno"], |
| 55 | [AS_IF([test "x$have_systemd" = "xno"], [AC_MSG_ERROR([libsdbusplus requires systemd])])]) |
| 56 | |
| 57 | AM_CONDITIONAL([WANT_LIBSDBUSPLUS], [test "x$enable_libsdbusplus" != "xno"]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 58 | |
Adriana Kobylak | fd43ef7 | 2017-02-12 09:12:37 -0600 | [diff] [blame] | 59 | # setup transaction |
| 60 | AC_ARG_ENABLE([transaction], |
| 61 | AS_HELP_STRING([--enable-transaction], [Enable transaction id support.])) |
| 62 | AC_ARG_VAR(WANT_TRANSACTION, [Enable transaction id support.]) |
| 63 | AS_IF([test "x$enable_transaction" = "xyes"], \ |
| 64 | [WANT_TRANSACTION="1"], \ |
| 65 | [WANT_TRANSACTION="0"]) |
| 66 | AM_CONDITIONAL([WANT_TRANSACTION], [test "x$enable_transaction" = "xyes"]) |
| 67 | |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 68 | # Checks for header files. |
Patrick Williams | ab7de32 | 2017-01-06 15:14:45 -0600 | [diff] [blame] | 69 | AS_IF([test "x$enable_libsdbusplus" != "xno"], |
Gunnar Mills | a4b4a0b | 2018-04-08 14:30:38 -0500 | [diff] [blame] | 70 | [AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd development package required])])]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 71 | |
| 72 | # Checks for typedefs, structures, and compiler characteristics. |
Patrick Williams | ab7de32 | 2017-01-06 15:14:45 -0600 | [diff] [blame] | 73 | AS_IF([test "x$enable_libsdbusplus" != "xno"], |
Vernon Mauery | ca46b9d | 2018-10-02 14:05:09 -0700 | [diff] [blame] | 74 | [AX_CXX_COMPILE_STDCXX_17([noext])]) |
Patrick Williams | 83a9d0b | 2016-11-04 17:06:13 -0500 | [diff] [blame] | 75 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CFLAGS]) |
| 76 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 77 | |
| 78 | # Checks for library functions. |
| 79 | LT_INIT # Removes 'unrecognized options: --with-libtool-sysroot' |
| 80 | |
William A. Kennington III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 81 | # Make it possible for users to choose if they want test support |
| 82 | # explicitly or not at all |
| 83 | AC_ARG_ENABLE([tests], [Whether we should build test cases]) |
| 84 | |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 85 | # Check/set gtest specific functions. |
William A. Kennington III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 86 | AS_IF([test "x$enable_tests" != "xno"], [ |
William A. Kennington III | 40c2279 | 2018-06-29 16:21:17 -0700 | [diff] [blame] | 87 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
William A. Kennington III | c20acf6 | 2018-06-22 18:38:03 -0700 | [diff] [blame] | 88 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
William A. Kennington III | 6f57467 | 2018-06-27 11:19:03 -0700 | [diff] [blame] | 89 | AX_PTHREAD |
William A. Kennington III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 90 | |
| 91 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 92 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
William A. Kennington III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 93 | 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 III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 107 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 108 | |
William A. Kennington III | c20acf6 | 2018-06-22 18:38:03 -0700 | [diff] [blame] | 109 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 110 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
William A. Kennington III | c20acf6 | 2018-06-22 18:38:03 -0700 | [diff] [blame] | 111 | 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 III | c20acf6 | 2018-06-22 18:38:03 -0700 | [diff] [blame] | 116 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 117 | |
William A. Kennington III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 118 | 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 III | c20acf6 | 2018-06-22 18:38:03 -0700 | [diff] [blame] | 130 | |
| 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 III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 143 | ]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 144 | |
William A. Kennington III | 6c17d3d | 2018-06-19 18:34:43 -0700 | [diff] [blame] | 145 | # Check for valgrind |
William A. Kennington III | 387110b | 2018-08-21 19:23:19 -0700 | [diff] [blame] | 146 | AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) |
| 147 | m4_foreach([vgtool], [valgrind_tool_list], |
| 148 | [AX_VALGRIND_DFLT(vgtool, [off])]) |
| 149 | AX_VALGRIND_DFLT([memcheck], [on]) |
| 150 | AX_VALGRIND_CHECK |
| 151 | AM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) |
| 152 | m4_foreach([vgtool], [valgrind_tool_list], |
| 153 | [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) |
William A. Kennington III | 6c17d3d | 2018-06-19 18:34:43 -0700 | [diff] [blame] | 154 | |
William A. Kennington III | 592128c | 2018-06-19 18:34:17 -0700 | [diff] [blame] | 155 | # Code coverage |
William A. Kennington III | 387110b | 2018-08-21 19:23:19 -0700 | [diff] [blame] | 156 | AX_CODE_COVERAGE |
| 157 | AM_EXTRA_RECURSIVE_TARGETS([check-code-coverage]) |
William A. Kennington III | 592128c | 2018-06-19 18:34:17 -0700 | [diff] [blame] | 158 | |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 159 | AC_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 | ) |
| 162 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
| 163 | [Path to the OE SDK SYSROOT]) |
| 164 | AS_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 Feist | 284a0f9 | 2018-04-05 15:28:16 -0700 | [diff] [blame] | 177 | AC_ARG_ENABLE([boost], |
| 178 | AS_HELP_STRING([--enable-boost], [Enable building with boost.])) |
| 179 | AM_CONDITIONAL(BOOST, [test "x$enable_boost" = "xyes"]) |
| 180 | |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 181 | # Create configured output |
Brad Bishop | bba7f8c | 2016-11-10 09:32:58 -0500 | [diff] [blame] | 182 | AC_CONFIG_FILES([Makefile test/Makefile tools/Makefile tools/setup.py]) |
Patrick Williams | 4edb785 | 2017-07-03 11:50:11 -0500 | [diff] [blame] | 183 | AC_CONFIG_FILES([example/Makefile]) |
Adriana Kobylak | a1fb5e6 | 2017-01-30 11:41:19 -0600 | [diff] [blame] | 184 | AC_CONFIG_FILES([sdbusplus.pc]) |
Adriana Kobylak | fd43ef7 | 2017-02-12 09:12:37 -0600 | [diff] [blame] | 185 | AC_CONFIG_FILES([sdbusplus/bus.hpp]) |
| 186 | AC_CONFIG_FILES([sdbusplus/server.hpp]) |
| 187 | AC_CONFIG_FILES([tools/sdbusplus/templates/interface.mako.server.cpp]) |
| 188 | AC_CONFIG_FILES([tools/sdbusplus/templates/method.mako.prototype.hpp]) |
Adriana Kobylak | ee6ac69 | 2018-06-06 09:36:51 -0500 | [diff] [blame] | 189 | AC_CONFIG_FILES([tools/sdbusplus/templates/property.mako.prototype.hpp]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 190 | AC_OUTPUT |