blob: 00fa5b6aedaa294420da9ea3531804d3361b4006 [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
Matthew Barthc6329c92016-11-15 11:13:37 -060010# Modify header template
11AH_TOP([#pragma once])
Matthew Barth66da92d2017-01-04 14:37:25 -060012AH_BOTTOM([#include "libmapper/workaround/systemd.h"])
Matthew Barthc6329c92016-11-15 11:13:37 -060013
Matthew Barth71222442016-10-04 16:10:01 -050014# Checks for programs.
15AC_PROG_CC
Matt Spinler62b36bd2017-06-02 12:15:59 -050016AC_PROG_CXX
Matthew Barth71222442016-10-04 16:10:01 -050017AM_PROG_AR
18AC_PROG_INSTALL
19AC_PROG_MAKE_SET
Matthew Barth4a6f9982016-11-18 10:25:57 -060020AC_PROG_AWK
Matthew Barth71222442016-10-04 16:10:01 -050021
22# Checks for libraries.
Patrick Venture12025cd2019-02-13 15:06:00 -080023PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
24PKG_CHECK_MODULES([TINYXML2], [tinyxml2])
Matthew Barth71222442016-10-04 16:10:01 -050025PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221])
Patrick Venture12025cd2019-02-13 15:06:00 -080026PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
Matthew Barth71222442016-10-04 16:10:01 -050027
28# Checks for header files.
29AC_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 Mauerya4936152018-10-03 09:55:46 -070032AX_CXX_COMPILE_STDCXX_17([noext])
Matt Spinler62b36bd2017-06-02 12:15:59 -050033AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CFLAGS CXXFLAGS])
Matthew Barth0570c692018-10-23 14:59:32 -050034
35# Checks for boost by the headers used.
36AC_CHECK_HEADER(boost/algorithm/string/predicate.hpp, ,[AC_MSG_ERROR([Could not find boost/algorithm/string/predicate.hpp])])
37AC_CHECK_HEADER(boost/container/flat_map.hpp, ,[AC_MSG_ERROR([Could not find boost/container/flat_map.hpp])])
38AC_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 -050039
40# Checks for library functions.
41LT_INIT([disable-static shared])
42
43# Check/set gtest specific functions.
44AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"])
45AC_SUBST(GTEST_CPPFLAGS)
46
Ed Tanous60520632018-06-11 17:46:52 -070047AC_ARG_ENABLE([oe-sdk],`
Matthew Barth71222442016-10-04 16:10:01 -050048 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
49)
50AC_ARG_VAR(OECORE_TARGET_SYSROOT,
51 [Path to the OE SDK SYSROOT])
52AS_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 Geissler3b025e62019-02-01 10:33:54 -060065# Make it possible for users to choose if they want test support
66# explicitly or not at all
67AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
68 [Build test cases]))
69
70 # Check/set gtest specific functions
71AS_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
131AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
132m4_foreach([vgtool], [valgrind_tool_list],
133 [AX_VALGRIND_DFLT(vgtool, [off])])
134AX_VALGRIND_DFLT([memcheck], [on])
135AX_VALGRIND_CHECK
136AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
137m4_foreach([vgtool], [valgrind_tool_list],
138 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
139
140# Code coverage
141AX_CODE_COVERAGE
142
143m4_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])])
146AX_ADD_AM_MACRO_STATIC([])
147
Matthew Barth71222442016-10-04 16:10:01 -0500148# Add defines to config header
149AC_DEFINE([MAPPER_BUSNAME], ["xyz.openbmc_project.ObjectMapper"], [Object mapper bus name])
150AC_DEFINE([MAPPER_INTERFACE], ["xyz.openbmc_project.ObjectMapper"], [Object mapper interface])
Leonel Gonzalez7fb0fe92017-03-09 15:27:36 -0600151AC_DEFINE([MAPPER_PATH], ["/xyz/openbmc_project/object_mapper"], [Object mapper DBUS path])
Matthew Barth71222442016-10-04 16:10:01 -0500152
Matthew Barthc6329c92016-11-15 11:13:37 -0600153# Workaround for unpatched systemd installs
154AC_ARG_ENABLE([unpatched-systemd],
155 AS_HELP_STRING([--enable-unpatched-systemd], [Enable unpatched systemd workarounds]))
156AS_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 Barth71222442016-10-04 16:10:01 -0500163# Create configured output
Kun Yi487948d2019-03-27 09:23:54 -0700164AC_CONFIG_FILES([Makefile fail-monitor/Makefile])
Matthew Barth71222442016-10-04 16:10:01 -0500165AC_OUTPUT