Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
| 3 | AC_INIT([phosphor-ipmi-blobs], [1.0], [https://github.com/openbmc/phosphor-ipmi-blobs/issues]) |
| 4 | AC_LANG([C++]) |
| 5 | AC_CONFIG_HEADERS([config.h]) |
Patrick Venture | 540b64d | 2018-11-28 14:56:28 -0800 | [diff] [blame] | 6 | AC_CONFIG_MACRO_DIRS([m4]) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 7 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) |
| 8 | AM_SILENT_RULES([yes]) |
| 9 | |
Patrick Venture | a2efc76 | 2019-03-06 13:23:42 -0800 | [diff] [blame] | 10 | # Make sure the default CFLAGS of `-O2 -g` don't override CODE_COVERAGE_CFLAGS |
| 11 | # It is important that this comes before AC_PROG_C{C,XX}, as we are attempting |
| 12 | # to stop them from populating default CFLAGS and CXXFLAGS. |
| 13 | AS_IF([test "x$enable_tests" = "xno"], [enable_code_coverage=no]) |
| 14 | AS_IF([test "x$enable_code_coverage" != "xno"], [ |
| 15 | AS_IF([test "x${CXXFLAGS+set}" != "xset"], [ |
| 16 | AC_SUBST(CXXFLAGS, [""]) |
| 17 | ]) |
| 18 | AS_IF([test "x${CFLAGS+set}" != "xset"], [ |
| 19 | AC_SUBST(CFLAGS, [""]) |
| 20 | ]) |
| 21 | ]) |
| 22 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 23 | # Checks for programs. |
| 24 | AC_PROG_CXX |
| 25 | AM_PROG_AR |
| 26 | AC_PROG_INSTALL |
| 27 | AC_PROG_MAKE_SET |
| 28 | |
| 29 | # Checks for typedefs, structures, and compiler characteristics. |
Patrick Venture | f222cf5 | 2018-09-12 10:15:48 -0700 | [diff] [blame] | 30 | AX_CXX_COMPILE_STDCXX_17([noext]) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 31 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
| 32 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 33 | # Checks for library functions. |
Patrick Venture | 6c415c6 | 2018-11-14 14:01:36 -0800 | [diff] [blame] | 34 | LT_INIT([dlopen disable-static shared]) # Required for systemd linking |
Patrick Venture | 4dc584d | 2018-09-27 15:00:46 -0700 | [diff] [blame] | 35 | LT_LIB_DLLOAD |
| 36 | |
| 37 | # Checks for libraries. |
Patrick Venture | 97898c9 | 2019-02-13 07:43:45 -0800 | [diff] [blame] | 38 | PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging]) |
William A. Kennington III | acebece | 2019-02-07 15:15:44 -0800 | [diff] [blame] | 39 | PKG_CHECK_MODULES( |
| 40 | [LIBIPMID], |
| 41 | [libipmid], |
| 42 | [], |
| 43 | [AC_MSG_ERROR([Could not find libipmid...openbmc/phosphor-host-ipmid package required])] |
Patrick Venture | 5e70a6b | 2018-11-21 21:12:38 -0800 | [diff] [blame] | 44 | ) |
| 45 | AC_CHECK_HEADER( |
| 46 | experimental/filesystem, |
| 47 | [], |
| 48 | [AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs developement package required])] |
| 49 | ) |
Patrick Venture | 4dc584d | 2018-09-27 15:00:46 -0700 | [diff] [blame] | 50 | AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])]) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 51 | |
Patrick Venture | fb808d1 | 2019-03-06 13:16:30 -0800 | [diff] [blame] | 52 | # Make it possible for users to choose if they want test support |
| 53 | # explicitly or not at all |
| 54 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 55 | [Build test cases])) |
| 56 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 57 | # Check/set gtest specific functions. |
Patrick Venture | fb808d1 | 2019-03-06 13:16:30 -0800 | [diff] [blame] | 58 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 59 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 60 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 61 | AX_PTHREAD |
| 62 | |
| 63 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 64 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 65 | AC_LANG_PUSH([C++]) |
| 66 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 67 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 68 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 69 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 70 | ], [ |
| 71 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 72 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 73 | ]) |
| 74 | ]) |
| 75 | ], [ |
| 76 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 77 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 78 | ]) |
| 79 | ]) |
| 80 | AC_LANG_POP([C++]) |
| 81 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 82 | |
| 83 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 84 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 85 | AC_LANG_PUSH([C++]) |
| 86 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 87 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 88 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 89 | ]) |
| 90 | ]) |
| 91 | AC_LANG_POP([C++]) |
| 92 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 93 | |
| 94 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 95 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 96 | AC_CHECK_LIB([gtest], [main], [ |
| 97 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 98 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 99 | ]) |
| 100 | ], [ |
| 101 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 102 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 103 | ]) |
| 104 | ]) |
| 105 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 106 | |
| 107 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 108 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 109 | AC_CHECK_LIB([gmock], [main], [ |
| 110 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 111 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 112 | ]) |
| 113 | ], [ |
| 114 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 115 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 116 | ]) |
| 117 | ]) |
| 118 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 119 | ]) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 120 | |
Patrick Venture | fd4cdea | 2019-03-07 07:38:28 -0800 | [diff] [blame^] | 121 | # Check for valgrind |
| 122 | AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) |
| 123 | m4_foreach([vgtool], [valgrind_tool_list], |
| 124 | [AX_VALGRIND_DFLT(vgtool, [off])]) |
| 125 | AX_VALGRIND_DFLT([memcheck], [on]) |
| 126 | AX_VALGRIND_CHECK |
| 127 | AM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) |
| 128 | m4_foreach([vgtool], [valgrind_tool_list], |
| 129 | [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) |
| 130 | |
Patrick Venture | a2efc76 | 2019-03-06 13:23:42 -0800 | [diff] [blame] | 131 | # Code coverage |
| 132 | AX_CODE_COVERAGE |
| 133 | AM_EXTRA_RECURSIVE_TARGETS([check-code-coverage]) |
| 134 | AS_IF([test "x$CODE_COVERAGE_ENABLED" = "xyes"], [ |
| 135 | AX_APPEND_COMPILE_FLAGS([-DHAVE_GCOV], [CODE_COVERAGE_CPPFLAGS]) |
| 136 | ]) |
| 137 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 138 | # Add --enable-oe-sdk flag to configure script |
| 139 | AC_ARG_ENABLE([oe-sdk], |
| 140 | AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.]) |
| 141 | ) |
| 142 | |
| 143 | # Check for OECORE_TARGET_SYSROOT in the environment. |
| 144 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
Patrick Venture | 5e70a6b | 2018-11-21 21:12:38 -0800 | [diff] [blame] | 145 | [Path to the OE SDK SYSROOT] |
| 146 | ) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 147 | |
| 148 | # Configure OESDK_TESTCASE_FLAGS environment variable, which will be later |
| 149 | # used in test/Makefile.am |
| 150 | AS_IF([test "x$enable_oe_sdk" == "xyes"], |
| 151 | AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], |
| 152 | AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) |
| 153 | ) |
| 154 | AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) |
| 155 | [ |
| 156 | testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" |
| 157 | testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" |
| 158 | testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" |
| 159 | ] |
| 160 | AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) |
| 161 | ) |
| 162 | |
Patrick Venture | 8aee057 | 2018-11-28 14:59:23 -0800 | [diff] [blame] | 163 | AC_ARG_VAR(BLOB_LIB_PATH, [The file path to search for libraries.]) |
| 164 | AS_IF([test "x$BLOB_LIB_PATH" == "x"], [BLOB_LIB_PATH="/usr/lib/blob-ipmid"]) |
| 165 | AC_DEFINE_UNQUOTED([BLOB_LIB_PATH], ["$BLOB_LIB_PATH"], [The file path to search for libraries.]) |
| 166 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 167 | # Create configured output |
| 168 | AC_CONFIG_FILES([Makefile test/Makefile]) |
| 169 | AC_OUTPUT |