blob: 73960b5e1fd8f6508b1adfc873063af3739b5ca9 [file] [log] [blame]
Patrick Ventureef3aead2018-09-12 08:53:29 -07001# Initialization
2AC_PREREQ([2.69])
3AC_INIT([phosphor-ipmi-blobs], [1.0], [https://github.com/openbmc/phosphor-ipmi-blobs/issues])
4AC_LANG([C++])
5AC_CONFIG_HEADERS([config.h])
Patrick Venture540b64d2018-11-28 14:56:28 -08006AC_CONFIG_MACRO_DIRS([m4])
Patrick Ventureef3aead2018-09-12 08:53:29 -07007AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
8AM_SILENT_RULES([yes])
9
10# Checks for programs.
11AC_PROG_CXX
12AM_PROG_AR
13AC_PROG_INSTALL
14AC_PROG_MAKE_SET
15
16# Checks for typedefs, structures, and compiler characteristics.
Patrick Venturef222cf52018-09-12 10:15:48 -070017AX_CXX_COMPILE_STDCXX_17([noext])
Patrick Ventureef3aead2018-09-12 08:53:29 -070018AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
19
Patrick Ventureef3aead2018-09-12 08:53:29 -070020# Checks for library functions.
Patrick Venture6c415c62018-11-14 14:01:36 -080021LT_INIT([dlopen disable-static shared]) # Required for systemd linking
Patrick Venture4dc584d2018-09-27 15:00:46 -070022LT_LIB_DLLOAD
23
24# Checks for libraries.
Patrick Venture97898c92019-02-13 07:43:45 -080025PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
William A. Kennington IIIacebece2019-02-07 15:15:44 -080026PKG_CHECK_MODULES(
27 [LIBIPMID],
28 [libipmid],
29 [],
30 [AC_MSG_ERROR([Could not find libipmid...openbmc/phosphor-host-ipmid package required])]
Patrick Venture5e70a6b2018-11-21 21:12:38 -080031)
32AC_CHECK_HEADER(
33 experimental/filesystem,
34 [],
35 [AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs developement package required])]
36)
Patrick Venture4dc584d2018-09-27 15:00:46 -070037AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])])
Patrick Ventureef3aead2018-09-12 08:53:29 -070038
Patrick Venturefb808d12019-03-06 13:16:30 -080039# Make it possible for users to choose if they want test support
40# explicitly or not at all
41AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
42 [Build test cases]))
43
Patrick Ventureef3aead2018-09-12 08:53:29 -070044# Check/set gtest specific functions.
Patrick Venturefb808d12019-03-06 13:16:30 -080045AS_IF([test "x$enable_tests" != "xno"], [
46 PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
47 PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
48 AX_PTHREAD
49
50 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
51 AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
52 AC_LANG_PUSH([C++])
53 AC_CHECK_HEADERS([gtest/gtest.h], [
54 AS_IF([test "x$GTEST_CFLAGS" = "x"], [
55 AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [
56 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS])
57 ], [
58 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS])
59 AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS])
60 ])
61 ])
62 ], [
63 AS_IF([test "x$enable_tests" = "xyes"], [
64 AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h])
65 ])
66 ])
67 AC_LANG_POP([C++])
68 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
69
70 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
71 AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
72 AC_LANG_PUSH([C++])
73 AC_CHECK_HEADERS([gmock/gmock.h], [], [
74 AS_IF([test "x$enable_tests" = "xyes"], [
75 AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
76 ])
77 ])
78 AC_LANG_POP([C++])
79 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
80
81 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
82 AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
83 AC_CHECK_LIB([gtest], [main], [
84 AS_IF([test "x$GTEST_LIBS" = "x"], [
85 AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS])
86 ])
87 ], [
88 AS_IF([test "x$enable_tests" = "xyes"], [
89 AC_MSG_ERROR([Testing enabled but couldn't find gtest libs])
90 ])
91 ])
92 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
93
94 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
95 AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
96 AC_CHECK_LIB([gmock], [main], [
97 AS_IF([test "x$GMOCK_LIBS" = "x"], [
98 AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
99 ])
100 ], [
101 AS_IF([test "x$enable_tests" = "xyes"], [
102 AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
103 ])
104 ])
105 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
106])
Patrick Ventureef3aead2018-09-12 08:53:29 -0700107
108# Add --enable-oe-sdk flag to configure script
109AC_ARG_ENABLE([oe-sdk],
110 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
111)
112
113# Check for OECORE_TARGET_SYSROOT in the environment.
114AC_ARG_VAR(OECORE_TARGET_SYSROOT,
Patrick Venture5e70a6b2018-11-21 21:12:38 -0800115 [Path to the OE SDK SYSROOT]
116)
Patrick Ventureef3aead2018-09-12 08:53:29 -0700117
118# Configure OESDK_TESTCASE_FLAGS environment variable, which will be later
119# used in test/Makefile.am
120AS_IF([test "x$enable_oe_sdk" == "xyes"],
121 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
122 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
123 )
124 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
125 [
126 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
127 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
128 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
129 ]
130 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
131)
132
Patrick Venture8aee0572018-11-28 14:59:23 -0800133AC_ARG_VAR(BLOB_LIB_PATH, [The file path to search for libraries.])
134AS_IF([test "x$BLOB_LIB_PATH" == "x"], [BLOB_LIB_PATH="/usr/lib/blob-ipmid"])
135AC_DEFINE_UNQUOTED([BLOB_LIB_PATH], ["$BLOB_LIB_PATH"], [The file path to search for libraries.])
136
Patrick Ventureef3aead2018-09-12 08:53:29 -0700137# Create configured output
138AC_CONFIG_FILES([Makefile test/Makefile])
139AC_OUTPUT