blob: 3da6d4b73cf6ee6cc25b165a2337c673c7570f64 [file] [log] [blame]
Patrick Venture4d49ae62018-09-17 11:35:32 -07001# Initialization
2AC_PREREQ([2.69])
Patrick Venture23ef59b2018-11-26 09:15:35 -08003AC_INIT([sys-ipmi], [0.1], [https://www.github.com/google-ipmi-sys/issues])
Patrick Venture4d49ae62018-09-17 11:35:32 -07004AC_LANG([C++])
5AC_CONFIG_HEADERS([config.h])
6AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
7AM_SILENT_RULES([yes])
8
9# Checks for programs.
10AC_PROG_CXX
11AM_PROG_AR
12AC_PROG_INSTALL
13AC_PROG_MAKE_SET
14
15# Checks for typedefs, structures, and compiler characteristics.
Patrick Venturec25a3df2018-09-17 12:11:19 -070016AX_CXX_COMPILE_STDCXX_17([noext])
Patrick Venture4d49ae62018-09-17 11:35:32 -070017AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
18
19# Checks for libraries.
Patrick Venturec6624652019-02-13 07:35:07 -080020PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
21PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
William A. Kennington III2c9e1622019-02-07 15:45:19 -080022PKG_CHECK_MODULES(
23 [LIBIPMID],
24 [libipmid],
25 [],
26 [AC_MSG_ERROR([Could not find libipmid...openbmc/phosphor-host-ipmid package required])]
27)
Patrick Venture3c7037a2018-11-21 21:40:50 -080028AC_CHECK_HEADER(
Patrick Venture575a55a2019-02-12 07:32:06 -080029 nlohmann/json.hpp,
30 [],
31 [AC_MSG_ERROR([Could not find nlohmann/json.hpp])]
32)
Patrick Venture4d49ae62018-09-17 11:35:32 -070033
34# Checks for library functions.
35LT_INIT # Required for systemd linking
36
Patrick Venture848b9382019-03-13 15:48:23 -070037# Make it possible for users to choose if they want test support
38# explicitly or not at all
39AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
40 [Build test cases]))
41
42# Check/set gtest specific functions.
43AS_IF([test "x$enable_tests" != "xno"], [
44 PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
45 PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
46 AX_PTHREAD
47
48 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
49 AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
50 AC_LANG_PUSH([C++])
51 AC_CHECK_HEADERS([gtest/gtest.h], [
52 AS_IF([test "x$GTEST_CFLAGS" = "x"], [
53 AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [
54 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS])
55 ], [
56 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS])
57 AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS])
58 ])
59 ])
60 ], [
61 AS_IF([test "x$enable_tests" = "xyes"], [
62 AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h])
63 ])
64 ])
65 AC_LANG_POP([C++])
66 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
67
68 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
69 AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
70 AC_LANG_PUSH([C++])
71 AC_CHECK_HEADERS([gmock/gmock.h], [], [
72 AS_IF([test "x$enable_tests" = "xyes"], [
73 AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
74 ])
75 ])
76 AC_LANG_POP([C++])
77 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
78
79 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
80 AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
81 AC_CHECK_LIB([gtest], [main], [
82 AS_IF([test "x$GTEST_LIBS" = "x"], [
83 AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS])
84 ])
85 ], [
86 AS_IF([test "x$enable_tests" = "xyes"], [
87 AC_MSG_ERROR([Testing enabled but couldn't find gtest libs])
88 ])
89 ])
90 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
91
92 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
93 AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
94 AC_CHECK_LIB([gmock], [main], [
95 AS_IF([test "x$GMOCK_LIBS" = "x"], [
96 AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
97 ])
98 ], [
99 AS_IF([test "x$enable_tests" = "xyes"], [
100 AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
101 ])
102 ])
103 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
104])
105
Patrick Venturef9a19b82018-09-18 10:03:24 -0700106PKG_PROG_PKG_CONFIG
107AC_ARG_WITH([systemdsystemunitdir],
108 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
109 [with_systemdsystemunitdir=auto])
110AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
111 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
112
113 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
114 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
115 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
116 with_systemdsystemunitdir=no],
117 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
118AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
119 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
120AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
121
Patrick Venture4d49ae62018-09-17 11:35:32 -0700122# Create configured output
Patrick Venture848b9382019-03-13 15:48:23 -0700123AC_CONFIG_FILES([Makefile test/Makefile])
Patrick Venture4d49ae62018-09-17 11:35:32 -0700124AC_OUTPUT