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]) |
| 9 | |
William A. Kennington III | 592128c | 2018-06-19 18:34:17 -0700 | [diff] [blame] | 10 | # 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. |
| 13 | AS_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 Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 22 | # Checks for programs. |
Patrick Williams | 83a9d0b | 2016-11-04 17:06:13 -0500 | [diff] [blame] | 23 | AC_PROG_CXX |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 24 | AC_PROG_CC |
| 25 | AM_PROG_AR |
| 26 | AC_PROG_INSTALL |
| 27 | AC_PROG_MAKE_SET |
| 28 | |
Brad Bishop | bba7f8c | 2016-11-10 09:32:58 -0500 | [diff] [blame] | 29 | # setup sdbus++ |
| 30 | AM_PATH_PYTHON([2.7], [AC_SUBST([PYTHON], [echo "$PYTHON"])]) |
| 31 | AC_SUBST([PYTHONDIR], ${pythondir}) |
| 32 | AS_IF([test "$PYTHON" != :], [have_python=yes], [have_python=no]) |
| 33 | |
| 34 | AC_ARG_ENABLE([sdbuspp], |
| 35 | AS_HELP_STRING([--disable-sdbuspp], [Disable sdbus++])) |
| 36 | |
| 37 | AS_IF([test "x$enable_sdbuspp" != "xno"], |
| 38 | [AS_IF([test "x$have_python" = "xno"], [AC_MSG_ERROR([sdbus++ requires python])])]) |
| 39 | |
| 40 | AM_CONDITIONAL([WANT_SDBUSPP], [test "x$enable_sdbuspp" != "xno"]) |
| 41 | |
Brad Bishop | 14275cf | 2016-11-10 16:24:48 -0500 | [diff] [blame] | 42 | # setup libsdbusplus |
Brad Bishop | 5e70389 | 2017-02-10 11:52:48 -0500 | [diff] [blame] | 43 | AX_PKG_CHECK_MODULES( |
| 44 | [SYSTEMD], |
| 45 | [libsystemd >= 221], |
| 46 | [], |
| 47 | [have_systemd=yes], |
| 48 | [have_systemd=no]) |
Brad Bishop | 14275cf | 2016-11-10 16:24:48 -0500 | [diff] [blame] | 49 | AC_ARG_ENABLE([libsdbusplus], |
| 50 | AS_HELP_STRING([--disable-libsdbusplus], [Disable libsdbusplus])) |
| 51 | |
| 52 | AS_IF([test "x$enable_libsdbusplus" != "xno"], |
| 53 | [AS_IF([test "x$have_systemd" = "xno"], [AC_MSG_ERROR([libsdbusplus requires systemd])])]) |
| 54 | |
| 55 | AM_CONDITIONAL([WANT_LIBSDBUSPLUS], [test "x$enable_libsdbusplus" != "xno"]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 56 | |
Adriana Kobylak | fd43ef7 | 2017-02-12 09:12:37 -0600 | [diff] [blame] | 57 | # setup transaction |
| 58 | AC_ARG_ENABLE([transaction], |
| 59 | AS_HELP_STRING([--enable-transaction], [Enable transaction id support.])) |
| 60 | AC_ARG_VAR(WANT_TRANSACTION, [Enable transaction id support.]) |
| 61 | AS_IF([test "x$enable_transaction" = "xyes"], \ |
| 62 | [WANT_TRANSACTION="1"], \ |
| 63 | [WANT_TRANSACTION="0"]) |
| 64 | AM_CONDITIONAL([WANT_TRANSACTION], [test "x$enable_transaction" = "xyes"]) |
| 65 | |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 66 | # Checks for header files. |
Patrick Williams | ab7de32 | 2017-01-06 15:14:45 -0600 | [diff] [blame] | 67 | AS_IF([test "x$enable_libsdbusplus" != "xno"], |
Gunnar Mills | a4b4a0b | 2018-04-08 14:30:38 -0500 | [diff] [blame] | 68 | [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] | 69 | |
| 70 | # Checks for typedefs, structures, and compiler characteristics. |
Patrick Williams | ab7de32 | 2017-01-06 15:14:45 -0600 | [diff] [blame] | 71 | AS_IF([test "x$enable_libsdbusplus" != "xno"], |
Brad Bishop | 14275cf | 2016-11-10 16:24:48 -0500 | [diff] [blame] | 72 | [AX_CXX_COMPILE_STDCXX_14([noext])]) |
Patrick Williams | 83a9d0b | 2016-11-04 17:06:13 -0500 | [diff] [blame] | 73 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CFLAGS]) |
| 74 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 75 | |
| 76 | # Checks for library functions. |
| 77 | LT_INIT # Removes 'unrecognized options: --with-libtool-sysroot' |
| 78 | |
William A. Kennington III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 79 | # Make it possible for users to choose if they want test support |
| 80 | # explicitly or not at all |
| 81 | AC_ARG_ENABLE([tests], [Whether we should build test cases]) |
| 82 | |
| 83 | # Legacy tests require pthread support |
| 84 | AS_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 Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 92 | # Check/set gtest specific functions. |
William A. Kennington III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 93 | AS_IF([test "x$enable_tests" != "xno"], [ |
William A. Kennington III | 40c2279 | 2018-06-29 16:21:17 -0700 | [diff] [blame] | 94 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
William A. Kennington III | c20acf6 | 2018-06-22 18:38:03 -0700 | [diff] [blame] | 95 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
William A. Kennington III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 96 | |
| 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 III | c20acf6 | 2018-06-22 18:38:03 -0700 | [diff] [blame] | 117 | 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 III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 128 | 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 III | c20acf6 | 2018-06-22 18:38:03 -0700 | [diff] [blame] | 140 | |
| 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 III | b4b3247 | 2018-06-21 16:38:47 -0700 | [diff] [blame] | 153 | ]) |
Patrick Williams | 5e0b681 | 2016-11-04 16:45:33 -0500 | [diff] [blame] | 154 | |
William A. Kennington III | 592128c | 2018-06-19 18:34:17 -0700 | [diff] [blame] | 155 | # Code coverage |
| 156 | AX_CODE_COVERAGE |
| 157 | AM_EXTRA_RECURSIVE_TARGETS([check-code-coverage]) |
| 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 |