blob: 0aa9a590f35a0c2dfae49389f1f1d870c2bbe2e3 [file] [log] [blame]
Patrick Ventured26fff42018-09-18 15:37:59 -07001# Initialization
2AC_PREREQ([2.69])
3AC_INIT([phosphor-ipmi-ethstats], [1.0], [https://www.github.com/openbmc/phosphor-ipmi-ethstats/issues])
4AC_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.
16AX_CXX_COMPILE_STDCXX_17([noext])
17AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
18
19# Checks for libraries.
William A. Kennington III539f03f2019-02-12 13:28:45 -080020PKG_CHECK_MODULES([LIBIPMID], [libipmid])
Patrick Ventured26fff42018-09-18 15:37:59 -070021AC_CHECK_HEADER(experimental/filesystem, ,[AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs developement package required])])
22
23# Checks for library functions.
24LT_INIT # Required for systemd linking
25
Patrick Venturef1586f52019-03-18 10:41:22 -070026# Make it possible for users to choose if they want test support
27# explicitly or not at all
28AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
29 [Build test cases]))
30
31 # Check/set gtest specific functions.
32AS_IF([test "x$enable_tests" != "xno"], [
33 PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
34 PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
35 AX_PTHREAD
36
37 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
38 AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
39 AC_LANG_PUSH([C++])
40 AC_CHECK_HEADERS([gtest/gtest.h], [
41 AS_IF([test "x$GTEST_CFLAGS" = "x"], [
42 AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [
43 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS])
44 ], [
45 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS])
46 AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS])
47 ])
48 ])
49 ], [
50 AS_IF([test "x$enable_tests" = "xyes"], [
51 AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h])
52 ])
53 ])
54 AC_LANG_POP([C++])
55 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
56
57 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
58 AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
59 AC_LANG_PUSH([C++])
60 AC_CHECK_HEADERS([gmock/gmock.h], [], [
61 AS_IF([test "x$enable_tests" = "xyes"], [
62 AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
63 ])
64 ])
65 AC_LANG_POP([C++])
66 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
67
68 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
69 AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
70 AC_CHECK_LIB([gtest], [main], [
71 AS_IF([test "x$GTEST_LIBS" = "x"], [
72 AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS])
73 ])
74 ], [
75 AS_IF([test "x$enable_tests" = "xyes"], [
76 AC_MSG_ERROR([Testing enabled but couldn't find gtest libs])
77 ])
78 ])
79 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
80
81 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
82 AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
83 AC_CHECK_LIB([gmock], [main], [
84 AS_IF([test "x$GMOCK_LIBS" = "x"], [
85 AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
86 ])
87 ], [
88 AS_IF([test "x$enable_tests" = "xyes"], [
89 AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
90 ])
91 ])
92 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
93])
94
Patrick Ventured26fff42018-09-18 15:37:59 -070095# Do you want to install with the Google OEM Number as well.
96AC_ARG_ENABLE([google],
Patrick Ventured72f8b52019-03-07 16:54:57 -080097 AS_HELP_STRING(
98 [--enable-google], [Enable registering with Google OEN.]
99 )
Patrick Ventured26fff42018-09-18 15:37:59 -0700100)
Patrick Ventured72f8b52019-03-07 16:54:57 -0800101AM_CONDITIONAL(ENABLE_GOOGLE, [test "x$enable_google" = "xyes"])
102AS_IF([test "x$enable_google" = "xyes"],
103 [AC_DEFINE(ENABLE_GOOGLE, [1], [Register with Google OEN.])],
104 [AC_DEFINE(ENABLE_GOOGLE, [0], [Do not register with Google OEN.])]
Patrick Ventured26fff42018-09-18 15:37:59 -0700105)
106
107# Create configured output
Patrick Venturef1586f52019-03-18 10:41:22 -0700108AC_CONFIG_FILES([Makefile test/Makefile])
Patrick Ventured26fff42018-09-18 15:37:59 -0700109AC_OUTPUT