blob: 7ab3d7ad1101b6a862312c288ee307b77ea18124 [file] [log] [blame]
Matthew Barth71222442016-10-04 16:10:01 -05001# Initialization
2AC_PREREQ([2.69])
3AC_INIT([phosphor-objmgr], [1.0], [https://github.com/openbmc/phosphor-objmgr/issues])
Matt Spinler5eddf442019-04-10 10:08:56 -05004AC_CONFIG_HEADERS([config.h])
Matthew Barth71222442016-10-04 16:10:01 -05005AC_CONFIG_MACRO_DIR([m4])
Andrew Geissler3b025e62019-02-01 10:33:54 -06006AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign dist-xz])
Matthew Barth71222442016-10-04 16:10:01 -05007AM_SILENT_RULES([yes])
Matt Spinler62b36bd2017-06-02 12:15:59 -05008AC_LANG([C++])
Matthew Barth71222442016-10-04 16:10:01 -05009
10# Checks for programs.
11AC_PROG_CC
Matt Spinler62b36bd2017-06-02 12:15:59 -050012AC_PROG_CXX
Matthew Barth71222442016-10-04 16:10:01 -050013AM_PROG_AR
14AC_PROG_INSTALL
15AC_PROG_MAKE_SET
Matthew Barth4a6f9982016-11-18 10:25:57 -060016AC_PROG_AWK
Matthew Barth71222442016-10-04 16:10:01 -050017
18# Checks for libraries.
Patrick Venture12025cd2019-02-13 15:06:00 -080019PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
20PKG_CHECK_MODULES([TINYXML2], [tinyxml2])
Matthew Barth71222442016-10-04 16:10:01 -050021PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221])
Patrick Venture12025cd2019-02-13 15:06:00 -080022PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
Matthew Barth71222442016-10-04 16:10:01 -050023
24# Checks for header files.
25AC_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 Mauerya4936152018-10-03 09:55:46 -070028AX_CXX_COMPILE_STDCXX_17([noext])
Matt Spinler62b36bd2017-06-02 12:15:59 -050029AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CFLAGS CXXFLAGS])
Matthew Barth0570c692018-10-23 14:59:32 -050030
31# Checks for boost by the headers used.
32AC_CHECK_HEADER(boost/algorithm/string/predicate.hpp, ,[AC_MSG_ERROR([Could not find boost/algorithm/string/predicate.hpp])])
33AC_CHECK_HEADER(boost/container/flat_map.hpp, ,[AC_MSG_ERROR([Could not find boost/container/flat_map.hpp])])
34AC_CHECK_HEADER(boost/container/flat_set.hpp, ,[AC_MSG_ERROR([Could not find boost/container/flat_set.hpp])])
Matthew Barth71222442016-10-04 16:10:01 -050035
36# Checks for library functions.
37LT_INIT([disable-static shared])
38
39# Check/set gtest specific functions.
40AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"])
41AC_SUBST(GTEST_CPPFLAGS)
42
Ed Tanous60520632018-06-11 17:46:52 -070043AC_ARG_ENABLE([oe-sdk],`
Matthew Barth71222442016-10-04 16:10:01 -050044 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
45)
46AC_ARG_VAR(OECORE_TARGET_SYSROOT,
47 [Path to the OE SDK SYSROOT])
48AS_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 Geissler3b025e62019-02-01 10:33:54 -060061# Make it possible for users to choose if they want test support
62# explicitly or not at all
63AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
64 [Build test cases]))
65
66 # Check/set gtest specific functions
67AS_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
127AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
128m4_foreach([vgtool], [valgrind_tool_list],
129 [AX_VALGRIND_DFLT(vgtool, [off])])
130AX_VALGRIND_DFLT([memcheck], [on])
131AX_VALGRIND_CHECK
132AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
133m4_foreach([vgtool], [valgrind_tool_list],
134 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
135
136# Code coverage
137AX_CODE_COVERAGE
138
139m4_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])])
142AX_ADD_AM_MACRO_STATIC([])
143
Matthew Barth71222442016-10-04 16:10:01 -0500144# Add defines to config header
145AC_DEFINE([MAPPER_BUSNAME], ["xyz.openbmc_project.ObjectMapper"], [Object mapper bus name])
146AC_DEFINE([MAPPER_INTERFACE], ["xyz.openbmc_project.ObjectMapper"], [Object mapper interface])
Leonel Gonzalez7fb0fe92017-03-09 15:27:36 -0600147AC_DEFINE([MAPPER_PATH], ["/xyz/openbmc_project/object_mapper"], [Object mapper DBUS path])
Matthew Barth71222442016-10-04 16:10:01 -0500148
Matthew Barth71222442016-10-04 16:10:01 -0500149# Create configured output
Kun Yi487948d2019-03-27 09:23:54 -0700150AC_CONFIG_FILES([Makefile fail-monitor/Makefile])
Matthew Barth71222442016-10-04 16:10:01 -0500151AC_OUTPUT