Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
| 3 | AC_INIT([phosphor-objmgr], [1.0], [https://github.com/openbmc/phosphor-objmgr/issues]) |
Matt Spinler | 5eddf44 | 2019-04-10 10:08:56 -0500 | [diff] [blame] | 4 | AC_CONFIG_HEADERS([config.h]) |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 5 | AC_CONFIG_MACRO_DIR([m4]) |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign dist-xz]) |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 7 | AM_SILENT_RULES([yes]) |
Matt Spinler | 62b36bd | 2017-06-02 12:15:59 -0500 | [diff] [blame] | 8 | AC_LANG([C++]) |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 9 | |
| 10 | # Checks for programs. |
| 11 | AC_PROG_CC |
Matt Spinler | 62b36bd | 2017-06-02 12:15:59 -0500 | [diff] [blame] | 12 | AC_PROG_CXX |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 13 | AM_PROG_AR |
| 14 | AC_PROG_INSTALL |
| 15 | AC_PROG_MAKE_SET |
Matthew Barth | 4a6f998 | 2016-11-18 10:25:57 -0600 | [diff] [blame] | 16 | AC_PROG_AWK |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 17 | |
| 18 | # Checks for libraries. |
Patrick Venture | 12025cd | 2019-02-13 15:06:00 -0800 | [diff] [blame] | 19 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus]) |
| 20 | PKG_CHECK_MODULES([TINYXML2], [tinyxml2]) |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 21 | PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221]) |
Patrick Venture | 12025cd | 2019-02-13 15:06:00 -0800 | [diff] [blame] | 22 | PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging]) |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 23 | |
| 24 | # Checks for header files. |
| 25 | AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd development package required])]) |
| 26 | |
| 27 | # Checks for typedefs, structures, and compiler characteristics. |
Vernon Mauery | a493615 | 2018-10-03 09:55:46 -0700 | [diff] [blame] | 28 | AX_CXX_COMPILE_STDCXX_17([noext]) |
Matt Spinler | 62b36bd | 2017-06-02 12:15:59 -0500 | [diff] [blame] | 29 | AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CFLAGS CXXFLAGS]) |
Matthew Barth | 0570c69 | 2018-10-23 14:59:32 -0500 | [diff] [blame] | 30 | |
| 31 | # Checks for boost by the headers used. |
| 32 | AC_CHECK_HEADER(boost/algorithm/string/predicate.hpp, ,[AC_MSG_ERROR([Could not find boost/algorithm/string/predicate.hpp])]) |
| 33 | AC_CHECK_HEADER(boost/container/flat_map.hpp, ,[AC_MSG_ERROR([Could not find boost/container/flat_map.hpp])]) |
| 34 | AC_CHECK_HEADER(boost/container/flat_set.hpp, ,[AC_MSG_ERROR([Could not find boost/container/flat_set.hpp])]) |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 35 | |
| 36 | # Checks for library functions. |
| 37 | LT_INIT([disable-static shared]) |
| 38 | |
| 39 | # Check/set gtest specific functions. |
| 40 | AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"]) |
| 41 | AC_SUBST(GTEST_CPPFLAGS) |
| 42 | |
Ed Tanous | 6052063 | 2018-06-11 17:46:52 -0700 | [diff] [blame] | 43 | AC_ARG_ENABLE([oe-sdk],` |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 44 | AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.]) |
| 45 | ) |
| 46 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
| 47 | [Path to the OE SDK SYSROOT]) |
| 48 | AS_IF([test "x$enable_oe_sdk" == "xyes"], |
| 49 | AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], |
| 50 | AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) |
| 51 | ) |
| 52 | AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) |
| 53 | [ |
| 54 | testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" |
| 55 | testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" |
| 56 | testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" |
| 57 | ] |
| 58 | AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) |
| 59 | ) |
| 60 | |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 61 | # Make it possible for users to choose if they want test support |
| 62 | # explicitly or not at all |
| 63 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 64 | [Build test cases])) |
| 65 | |
| 66 | # Check/set gtest specific functions |
| 67 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 68 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 69 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 70 | AX_PTHREAD |
| 71 | |
| 72 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 73 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 74 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 75 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 76 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 77 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 78 | ], [ |
| 79 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 80 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 81 | ]) |
| 82 | ]) |
| 83 | ], [ |
| 84 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 85 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 86 | ]) |
| 87 | ]) |
| 88 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 89 | |
| 90 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 91 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 92 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 93 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 94 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 95 | ]) |
| 96 | ]) |
| 97 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 98 | |
| 99 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 100 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 101 | AC_CHECK_LIB([gtest], [main], [ |
| 102 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 103 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 104 | ]) |
| 105 | ], [ |
| 106 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 107 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 108 | ]) |
| 109 | ]) |
| 110 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 111 | |
| 112 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 113 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 114 | AC_CHECK_LIB([gmock], [main], [ |
| 115 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 116 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 117 | ]) |
| 118 | ], [ |
| 119 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 120 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 121 | ]) |
| 122 | ]) |
| 123 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 124 | ]) |
| 125 | |
| 126 | # Check for valgrind |
| 127 | AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) |
| 128 | m4_foreach([vgtool], [valgrind_tool_list], |
| 129 | [AX_VALGRIND_DFLT(vgtool, [off])]) |
| 130 | AX_VALGRIND_DFLT([memcheck], [on]) |
| 131 | AX_VALGRIND_CHECK |
| 132 | AM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) |
| 133 | m4_foreach([vgtool], [valgrind_tool_list], |
| 134 | [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) |
| 135 | |
| 136 | # Code coverage |
| 137 | AX_CODE_COVERAGE |
| 138 | |
| 139 | m4_ifdef([_AX_CODE_COVERAGE_RULES], |
| 140 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])], |
| 141 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])]) |
| 142 | AX_ADD_AM_MACRO_STATIC([]) |
| 143 | |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 144 | # Add defines to config header |
| 145 | AC_DEFINE([MAPPER_BUSNAME], ["xyz.openbmc_project.ObjectMapper"], [Object mapper bus name]) |
| 146 | AC_DEFINE([MAPPER_INTERFACE], ["xyz.openbmc_project.ObjectMapper"], [Object mapper interface]) |
Leonel Gonzalez | 7fb0fe9 | 2017-03-09 15:27:36 -0600 | [diff] [blame] | 147 | AC_DEFINE([MAPPER_PATH], ["/xyz/openbmc_project/object_mapper"], [Object mapper DBUS path]) |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 148 | |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 149 | # Create configured output |
Kun Yi | 487948d | 2019-03-27 09:23:54 -0700 | [diff] [blame] | 150 | AC_CONFIG_FILES([Makefile fail-monitor/Makefile]) |
Matthew Barth | 7122244 | 2016-10-04 16:10:01 -0500 | [diff] [blame] | 151 | AC_OUTPUT |