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 | ) |
Patrick Venture | b15d654 | 2019-03-07 12:09:51 -0800 | [diff] [blame^] | 45 | PKG_CHECK_MODULES( |
| 46 | [IPMIBLOB], |
| 47 | [ipmiblob], |
| 48 | [], |
| 49 | [AC_MSG_ERROR( |
| 50 | [Could not find ipmiblob...openbmc/ipmi-blob-tool package required]) |
| 51 | ] |
| 52 | ) |
Patrick Venture | 4dc584d | 2018-09-27 15:00:46 -0700 | [diff] [blame] | 53 | AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])]) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 54 | |
Patrick Venture | fb808d1 | 2019-03-06 13:16:30 -0800 | [diff] [blame] | 55 | # Make it possible for users to choose if they want test support |
| 56 | # explicitly or not at all |
| 57 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 58 | [Build test cases])) |
| 59 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 60 | # Check/set gtest specific functions. |
Patrick Venture | fb808d1 | 2019-03-06 13:16:30 -0800 | [diff] [blame] | 61 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 62 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 63 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 64 | AX_PTHREAD |
| 65 | |
| 66 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 67 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 68 | AC_LANG_PUSH([C++]) |
| 69 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 70 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 71 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 72 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 73 | ], [ |
| 74 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 75 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 76 | ]) |
| 77 | ]) |
| 78 | ], [ |
| 79 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 80 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 81 | ]) |
| 82 | ]) |
| 83 | AC_LANG_POP([C++]) |
| 84 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 85 | |
| 86 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 87 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 88 | AC_LANG_PUSH([C++]) |
| 89 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 90 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 91 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 92 | ]) |
| 93 | ]) |
| 94 | AC_LANG_POP([C++]) |
| 95 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 96 | |
| 97 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 98 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 99 | AC_CHECK_LIB([gtest], [main], [ |
| 100 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 101 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 102 | ]) |
| 103 | ], [ |
| 104 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 105 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 106 | ]) |
| 107 | ]) |
| 108 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 109 | |
| 110 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 111 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 112 | AC_CHECK_LIB([gmock], [main], [ |
| 113 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 114 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 115 | ]) |
| 116 | ], [ |
| 117 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 118 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 119 | ]) |
| 120 | ]) |
| 121 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 122 | ]) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 123 | |
Patrick Venture | fd4cdea | 2019-03-07 07:38:28 -0800 | [diff] [blame] | 124 | # Check for valgrind |
| 125 | AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) |
| 126 | m4_foreach([vgtool], [valgrind_tool_list], |
| 127 | [AX_VALGRIND_DFLT(vgtool, [off])]) |
| 128 | AX_VALGRIND_DFLT([memcheck], [on]) |
| 129 | AX_VALGRIND_CHECK |
| 130 | AM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) |
| 131 | m4_foreach([vgtool], [valgrind_tool_list], |
| 132 | [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) |
| 133 | |
Patrick Venture | a2efc76 | 2019-03-06 13:23:42 -0800 | [diff] [blame] | 134 | # Code coverage |
| 135 | AX_CODE_COVERAGE |
| 136 | AM_EXTRA_RECURSIVE_TARGETS([check-code-coverage]) |
| 137 | AS_IF([test "x$CODE_COVERAGE_ENABLED" = "xyes"], [ |
| 138 | AX_APPEND_COMPILE_FLAGS([-DHAVE_GCOV], [CODE_COVERAGE_CPPFLAGS]) |
| 139 | ]) |
| 140 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 141 | # Add --enable-oe-sdk flag to configure script |
| 142 | AC_ARG_ENABLE([oe-sdk], |
| 143 | AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.]) |
| 144 | ) |
| 145 | |
| 146 | # Check for OECORE_TARGET_SYSROOT in the environment. |
| 147 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
Patrick Venture | 5e70a6b | 2018-11-21 21:12:38 -0800 | [diff] [blame] | 148 | [Path to the OE SDK SYSROOT] |
| 149 | ) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 150 | |
| 151 | # Configure OESDK_TESTCASE_FLAGS environment variable, which will be later |
| 152 | # used in test/Makefile.am |
| 153 | AS_IF([test "x$enable_oe_sdk" == "xyes"], |
| 154 | AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], |
| 155 | AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) |
| 156 | ) |
| 157 | AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) |
| 158 | [ |
| 159 | testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" |
| 160 | testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" |
| 161 | testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" |
| 162 | ] |
| 163 | AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) |
| 164 | ) |
| 165 | |
Patrick Venture | 8aee057 | 2018-11-28 14:59:23 -0800 | [diff] [blame] | 166 | AC_ARG_VAR(BLOB_LIB_PATH, [The file path to search for libraries.]) |
| 167 | AS_IF([test "x$BLOB_LIB_PATH" == "x"], [BLOB_LIB_PATH="/usr/lib/blob-ipmid"]) |
| 168 | AC_DEFINE_UNQUOTED([BLOB_LIB_PATH], ["$BLOB_LIB_PATH"], [The file path to search for libraries.]) |
| 169 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 170 | # Create configured output |
| 171 | AC_CONFIG_FILES([Makefile test/Makefile]) |
| 172 | AC_OUTPUT |