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 | |
| 10 | # Checks for programs. |
| 11 | AC_PROG_CXX |
| 12 | AM_PROG_AR |
| 13 | AC_PROG_INSTALL |
| 14 | AC_PROG_MAKE_SET |
| 15 | |
| 16 | # Checks for typedefs, structures, and compiler characteristics. |
Patrick Venture | f222cf5 | 2018-09-12 10:15:48 -0700 | [diff] [blame] | 17 | AX_CXX_COMPILE_STDCXX_17([noext]) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 18 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
| 19 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 20 | # Checks for library functions. |
Patrick Venture | 6c415c6 | 2018-11-14 14:01:36 -0800 | [diff] [blame] | 21 | LT_INIT([dlopen disable-static shared]) # Required for systemd linking |
Patrick Venture | 4dc584d | 2018-09-27 15:00:46 -0700 | [diff] [blame] | 22 | LT_LIB_DLLOAD |
| 23 | |
| 24 | # Checks for libraries. |
Patrick Venture | 97898c9 | 2019-02-13 07:43:45 -0800 | [diff] [blame] | 25 | PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging]) |
William A. Kennington III | acebece | 2019-02-07 15:15:44 -0800 | [diff] [blame] | 26 | PKG_CHECK_MODULES( |
| 27 | [LIBIPMID], |
| 28 | [libipmid], |
| 29 | [], |
| 30 | [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] | 31 | ) |
| 32 | AC_CHECK_HEADER( |
| 33 | experimental/filesystem, |
| 34 | [], |
| 35 | [AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs developement package required])] |
| 36 | ) |
Patrick Venture | 4dc584d | 2018-09-27 15:00:46 -0700 | [diff] [blame] | 37 | AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])]) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 38 | |
Patrick Venture | fb808d1 | 2019-03-06 13:16:30 -0800 | [diff] [blame^] | 39 | # Make it possible for users to choose if they want test support |
| 40 | # explicitly or not at all |
| 41 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 42 | [Build test cases])) |
| 43 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 44 | # Check/set gtest specific functions. |
Patrick Venture | fb808d1 | 2019-03-06 13:16:30 -0800 | [diff] [blame^] | 45 | AS_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 Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 107 | |
| 108 | # Add --enable-oe-sdk flag to configure script |
| 109 | AC_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. |
| 114 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
Patrick Venture | 5e70a6b | 2018-11-21 21:12:38 -0800 | [diff] [blame] | 115 | [Path to the OE SDK SYSROOT] |
| 116 | ) |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 117 | |
| 118 | # Configure OESDK_TESTCASE_FLAGS environment variable, which will be later |
| 119 | # used in test/Makefile.am |
| 120 | AS_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 Venture | 8aee057 | 2018-11-28 14:59:23 -0800 | [diff] [blame] | 133 | AC_ARG_VAR(BLOB_LIB_PATH, [The file path to search for libraries.]) |
| 134 | AS_IF([test "x$BLOB_LIB_PATH" == "x"], [BLOB_LIB_PATH="/usr/lib/blob-ipmid"]) |
| 135 | AC_DEFINE_UNQUOTED([BLOB_LIB_PATH], ["$BLOB_LIB_PATH"], [The file path to search for libraries.]) |
| 136 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 137 | # Create configured output |
| 138 | AC_CONFIG_FILES([Makefile test/Makefile]) |
| 139 | AC_OUTPUT |