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