Jayanth Othayoth | 0aa0d11 | 2018-09-03 03:47:27 -0500 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
| 3 | AC_INIT([phosphor-certificate-manager], [1.0], [https://github.com/openbmc/phosphor-certificate-manager/issues]) |
| 4 | AC_LANG([C++]) |
| 5 | AC_CONFIG_HEADERS([config.h]) |
| 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) |
| 7 | AM_SILENT_RULES([yes]) |
| 8 | |
| 9 | # Checks for programs. |
| 10 | AC_PROG_CXX |
| 11 | AC_PROG_INSTALL |
| 12 | AC_PROG_MAKE_SET |
| 13 | |
| 14 | # Checks for library functions |
| 15 | LT_INIT # Required for systemd linking |
| 16 | |
| 17 | # Checks for typedefs, structures, and compiler characteristics. |
| 18 | AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) |
| 19 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
| 20 | |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 21 | # Check for libraries |
Patrick Venture | 8d100c1 | 2018-12-03 08:36:00 -0800 | [diff] [blame] | 22 | AX_CHECK_OPENSSL([], [AC_MSG_ERROR(["openssl required and not found"])]) |
Patrick Venture | 48e9d35 | 2018-12-03 08:41:26 -0800 | [diff] [blame] | 23 | AC_CHECK_HEADER(experimental/filesystem, [], |
| 24 | [AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs development package required])] |
| 25 | ) |
Patrick Venture | 426adad | 2019-02-13 15:07:46 -0800 | [diff] [blame] | 26 | PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces]) |
| 27 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus]) |
| 28 | PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging]) |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 29 | |
| 30 | # Code coverage |
| 31 | AX_CODE_COVERAGE |
| 32 | |
Patrick Venture | d51f103 | 2018-12-03 08:48:17 -0800 | [diff] [blame] | 33 | # Make it possible for users to choose if they want test support |
| 34 | # explicitly or not at all |
| 35 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 36 | [Build test cases])) |
| 37 | |
Marri Devender Rao | 947258d | 2018-09-25 10:52:24 -0500 | [diff] [blame] | 38 | # Check/set gtest specific functions. |
Patrick Venture | d51f103 | 2018-12-03 08:48:17 -0800 | [diff] [blame] | 39 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 40 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 41 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 42 | AX_PTHREAD |
| 43 | |
| 44 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 45 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 46 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 47 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 48 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 49 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 50 | ], [ |
| 51 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 52 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 53 | ]) |
| 54 | ]) |
| 55 | ], [ |
| 56 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 57 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 58 | ]) |
| 59 | ]) |
| 60 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 61 | |
| 62 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 63 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 64 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 65 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 66 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 67 | ]) |
| 68 | ]) |
| 69 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 70 | |
| 71 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 72 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 73 | AC_CHECK_LIB([gtest], [main], [ |
| 74 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 75 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 76 | ]) |
| 77 | ], [ |
| 78 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 79 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 80 | ]) |
| 81 | ]) |
| 82 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 83 | |
| 84 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 85 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 86 | AC_CHECK_LIB([gmock], [main], [ |
| 87 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 88 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 89 | ]) |
| 90 | ], [ |
| 91 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 92 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 93 | ]) |
| 94 | ]) |
| 95 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 96 | ]) |
Marri Devender Rao | 947258d | 2018-09-25 10:52:24 -0500 | [diff] [blame] | 97 | |
| 98 | AC_ARG_ENABLE([oe-sdk], |
| 99 | AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.]) |
| 100 | ) |
| 101 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
| 102 | [Path to the OE SDK SYSROOT]) |
| 103 | AS_IF([test "x$enable_oe_sdk" == "xyes"], |
| 104 | AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], |
| 105 | AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) |
| 106 | ) |
| 107 | AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) |
| 108 | [ |
| 109 | testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" |
| 110 | testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" |
| 111 | testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" |
| 112 | ] |
| 113 | AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) |
| 114 | ) |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 115 | AC_ARG_VAR(BUSNAME, [The D-Bus busname to own]) |
| 116 | AS_IF([test "x$BUSNAME" == "x"], [BUSNAME="xyz.openbmc_project.Certs.Manager"]) |
| 117 | AC_DEFINE_UNQUOTED([BUSNAME], ["$BUSNAME"], [The D-Bus busname to own]) |
| 118 | AC_ARG_VAR(OBJPATH, [The certificate manager D-Bus root]) |
| 119 | AS_IF([test "x$OBJPATH" == "x"], [OBJPATH="/xyz/openbmc_project/certs"]) |
| 120 | AC_DEFINE_UNQUOTED([OBJPATH], ["$OBJPATH"], [The certificate manager D-Bus root]) |
| 121 | |
Marri Devender Rao | f4d6348 | 2019-05-02 06:35:34 -0500 | [diff] [blame^] | 122 | AC_ARG_VAR(CSR_FILE_NAME, [The CSR file.]) |
| 123 | AS_IF([test "x$CSR_FILE_NAME" == "x"], [CSR_FILE_NAME="domain.csr"]) |
| 124 | AC_DEFINE_UNQUOTED([CSR_FILE_NAME], ["$CSR_FILE_NAME"], [The CSR file]) |
| 125 | |
Jayanth Othayoth | 0aa0d11 | 2018-09-03 03:47:27 -0500 | [diff] [blame] | 126 | # Create configured output |
Marri Devender Rao | 947258d | 2018-09-25 10:52:24 -0500 | [diff] [blame] | 127 | AC_CONFIG_FILES([Makefile test/Makefile]) |
Jayanth Othayoth | 0aa0d11 | 2018-09-03 03:47:27 -0500 | [diff] [blame] | 128 | AC_OUTPUT |