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]) |
Lakshminarayana R. Kammath | 480f30d | 2020-05-21 10:02:28 -0500 | [diff] [blame] | 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror -Wno-portability foreign dist-xz]) |
| 7 | |
Jayanth Othayoth | 0aa0d11 | 2018-09-03 03:47:27 -0500 | [diff] [blame] | 8 | AM_SILENT_RULES([yes]) |
| 9 | |
| 10 | # Checks for programs. |
| 11 | AC_PROG_CXX |
| 12 | AC_PROG_INSTALL |
| 13 | AC_PROG_MAKE_SET |
| 14 | |
| 15 | # Checks for library functions |
| 16 | LT_INIT # Required for systemd linking |
| 17 | |
| 18 | # Checks for typedefs, structures, and compiler characteristics. |
| 19 | AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) |
| 20 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
| 21 | |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 22 | PKG_PROG_PKG_CONFIG |
| 23 | AC_ARG_WITH([systemdsystemunitdir], |
| 24 | [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])], |
| 25 | [], |
| 26 | [with_systemdsystemunitdir=auto] |
| 27 | ) |
| 28 | AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], |
| 29 | [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) |
| 30 | AS_IF([test "x$def_systemdsystemunitdir" = "x"], |
| 31 | [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], |
| 32 | [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])] |
| 33 | ) |
| 34 | with_systemdsystemunitdir=no], |
| 35 | [with_systemdsystemunitdir="$def_systemdsystemunitdir"] |
| 36 | )] |
| 37 | ) |
| 38 | AS_IF([test "x$with_systemdsystemunitdir" != "xno"], |
| 39 | [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])] |
| 40 | ) |
Anton D. Kachalov | 6dd1c2a | 2021-04-02 17:34:49 +0200 | [diff] [blame] | 41 | |
| 42 | AC_ARG_WITH([dbuspolicydir], |
| 43 | AS_HELP_STRING([--with-dbuspolicydir=DIR], [D-Bus policy directory]), |
| 44 | [], |
Patrick Williams | 4a9cb8e | 2021-10-04 12:08:55 -0500 | [diff] [blame] | 45 | [with_dbuspolicydir=${datadir}/dbus-1/system.d]) |
Anton D. Kachalov | 6dd1c2a | 2021-04-02 17:34:49 +0200 | [diff] [blame] | 46 | AS_IF([test "x$with_dbuspolicydir" != "xno"], |
| 47 | [AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])] |
| 48 | ) |
| 49 | |
| 50 | AC_ARG_ENABLE([bmcweb-cert-config], |
| 51 | AS_HELP_STRING([--enable-bmcweb-cert-config], [Install bmcweb cert configs]) |
| 52 | ) |
| 53 | AM_CONDITIONAL([ENABLE_BMCWEB_CERT_CONFIG], [test "x$enable_bmcweb_cert_config" == "xyes" ]) |
| 54 | |
| 55 | AC_ARG_ENABLE([nslcd-authority-cert-config], |
| 56 | AS_HELP_STRING([--enable-nslcd-authority-cert-config], [Install nslcd authority cert configs]) |
| 57 | ) |
| 58 | AM_CONDITIONAL([ENABLE_NSLCD_AUTHORITY_CERT_CONFIG], [test "x$enable_nslcd_authority_cert_config" == "xyes" ]) |
| 59 | |
| 60 | AC_ARG_ENABLE([codecoverage], |
| 61 | AS_HELP_STRING([--enable-code-coverage], [Enable code coverage checks]) |
| 62 | ) |
| 63 | AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test "x$enable_codecoverage" == "xyes" ]) |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 64 | |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 65 | # Check for libraries |
Patrick Venture | 8d100c1 | 2018-12-03 08:36:00 -0800 | [diff] [blame] | 66 | AX_CHECK_OPENSSL([], [AC_MSG_ERROR(["openssl required and not found"])]) |
Patrick Venture | 48e9d35 | 2018-12-03 08:41:26 -0800 | [diff] [blame] | 67 | AC_CHECK_HEADER(experimental/filesystem, [], |
| 68 | [AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs development package required])] |
| 69 | ) |
Patrick Venture | 426adad | 2019-02-13 15:07:46 -0800 | [diff] [blame] | 70 | PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces]) |
| 71 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus]) |
Marri Devender Rao | f468271 | 2019-03-19 05:00:28 -0500 | [diff] [blame] | 72 | PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus]) |
Patrick Venture | 426adad | 2019-02-13 15:07:46 -0800 | [diff] [blame] | 73 | PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging]) |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 74 | |
Patrick Venture | d51f103 | 2018-12-03 08:48:17 -0800 | [diff] [blame] | 75 | # Make it possible for users to choose if they want test support |
| 76 | # explicitly or not at all |
| 77 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 78 | [Build test cases])) |
| 79 | |
Lakshminarayana R. Kammath | 480f30d | 2020-05-21 10:02:28 -0500 | [diff] [blame] | 80 | # Make sure the default CFLAGS of `-O2 -g` don't override CODE_COVERAGE_CFLAGS |
| 81 | # It is important that this comes before AC_PROG_C{C,XX}, as we are attempting |
| 82 | # to stop them from populating default CFLAGS and CXXFLAGS. |
| 83 | AS_IF([test "x$enable_tests" = "xno"], [enable_code_coverage=no]) |
| 84 | AS_IF([test "x$enable_code_coverage" != "xno"], [ |
| 85 | AS_IF([test "x${CXXFLAGS+set}" != "xset"], [ |
| 86 | AC_SUBST(CXXFLAGS, [""]) |
| 87 | ]) |
| 88 | AS_IF([test "x${CFLAGS+set}" != "xset"], [ |
| 89 | AC_SUBST(CFLAGS, [""]) |
| 90 | ]) |
| 91 | ]) |
| 92 | |
Marri Devender Rao | 947258d | 2018-09-25 10:52:24 -0500 | [diff] [blame] | 93 | # Check/set gtest specific functions. |
Patrick Venture | d51f103 | 2018-12-03 08:48:17 -0800 | [diff] [blame] | 94 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 95 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 96 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 97 | AX_PTHREAD |
| 98 | |
| 99 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 100 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 101 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 102 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 103 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 104 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 105 | ], [ |
| 106 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 107 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 108 | ]) |
| 109 | ]) |
| 110 | ], [ |
| 111 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 112 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 113 | ]) |
| 114 | ]) |
| 115 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 116 | |
| 117 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 118 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 119 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 120 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 121 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 122 | ]) |
| 123 | ]) |
| 124 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 125 | |
| 126 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 127 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 128 | AC_CHECK_LIB([gtest], [main], [ |
| 129 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 130 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 131 | ]) |
| 132 | ], [ |
| 133 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 134 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 135 | ]) |
| 136 | ]) |
| 137 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 138 | |
| 139 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 140 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 141 | AC_CHECK_LIB([gmock], [main], [ |
| 142 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 143 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 144 | ]) |
| 145 | ], [ |
| 146 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 147 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 148 | ]) |
| 149 | ]) |
| 150 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 151 | ]) |
Marri Devender Rao | 947258d | 2018-09-25 10:52:24 -0500 | [diff] [blame] | 152 | |
Lakshminarayana R. Kammath | 480f30d | 2020-05-21 10:02:28 -0500 | [diff] [blame] | 153 | # Check for valgrind |
| 154 | AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) |
| 155 | m4_foreach([vgtool], [valgrind_tool_list], |
| 156 | [AX_VALGRIND_DFLT(vgtool, [off])]) |
| 157 | AX_VALGRIND_DFLT([memcheck], [on]) |
| 158 | AX_VALGRIND_CHECK |
| 159 | AM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) |
| 160 | m4_foreach([vgtool], [valgrind_tool_list], |
| 161 | [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) |
| 162 | |
| 163 | # Code coverage |
| 164 | AX_CODE_COVERAGE |
| 165 | m4_ifdef([_AX_CODE_COVERAGE_RULES], |
| 166 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])], |
| 167 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])]) |
| 168 | AX_ADD_AM_MACRO_STATIC([]) |
| 169 | |
Marri Devender Rao | 947258d | 2018-09-25 10:52:24 -0500 | [diff] [blame] | 170 | AC_ARG_ENABLE([oe-sdk], |
| 171 | AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.]) |
| 172 | ) |
| 173 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
| 174 | [Path to the OE SDK SYSROOT]) |
| 175 | AS_IF([test "x$enable_oe_sdk" == "xyes"], |
| 176 | AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], |
| 177 | AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) |
| 178 | ) |
| 179 | AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) |
| 180 | [ |
| 181 | testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" |
| 182 | testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" |
| 183 | testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" |
| 184 | ] |
| 185 | AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) |
| 186 | ) |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 187 | AC_ARG_VAR(BUSNAME, [The D-Bus busname to own]) |
| 188 | AS_IF([test "x$BUSNAME" == "x"], [BUSNAME="xyz.openbmc_project.Certs.Manager"]) |
| 189 | AC_DEFINE_UNQUOTED([BUSNAME], ["$BUSNAME"], [The D-Bus busname to own]) |
| 190 | AC_ARG_VAR(OBJPATH, [The certificate manager D-Bus root]) |
| 191 | AS_IF([test "x$OBJPATH" == "x"], [OBJPATH="/xyz/openbmc_project/certs"]) |
| 192 | AC_DEFINE_UNQUOTED([OBJPATH], ["$OBJPATH"], [The certificate manager D-Bus root]) |
| 193 | |
Marri Devender Rao | f4d6348 | 2019-05-02 06:35:34 -0500 | [diff] [blame] | 194 | AC_ARG_VAR(CSR_FILE_NAME, [The CSR file.]) |
| 195 | AS_IF([test "x$CSR_FILE_NAME" == "x"], [CSR_FILE_NAME="domain.csr"]) |
| 196 | AC_DEFINE_UNQUOTED([CSR_FILE_NAME], ["$CSR_FILE_NAME"], [The CSR file]) |
| 197 | |
Marri Devender Rao | f468271 | 2019-03-19 05:00:28 -0500 | [diff] [blame] | 198 | AC_ARG_VAR(PRIV_KEY_FILE_NAME, [The private key file.]) |
| 199 | AS_IF([test "x$PRIV_KEY_FILE_NAME" == "x"], [PRIV_KEY_FILE_NAME="privkey.pem"]) |
| 200 | AC_DEFINE_UNQUOTED([PRIV_KEY_FILE_NAME], ["$PRIV_KEY_FILE_NAME"], [The private key file]) |
| 201 | |
Ramesh Iyyar | c6e58c7 | 2019-07-16 08:52:47 -0500 | [diff] [blame] | 202 | AC_ARG_VAR(RSA_PRIV_KEY_FILE_NAME, [The rsa private key file.]) |
| 203 | AS_IF([test "x$RSA_PRIV_KEY_FILE_NAME" == "x"], [RSA_PRIV_KEY_FILE_NAME=".rsaprivkey.pem"]) |
| 204 | AC_DEFINE_UNQUOTED([RSA_PRIV_KEY_FILE_NAME], ["$RSA_PRIV_KEY_FILE_NAME"], [The rsa private key file]) |
| 205 | |
Zbigniew Lukwinski | 3b07b77 | 2019-10-09 11:43:34 +0200 | [diff] [blame] | 206 | AC_ARG_VAR(AUTHORITY_CERTIFICATES_LIMIT, [Authority certificates limit.]) |
| 207 | AS_IF([test "x$AUTHORITY_CERTIFICATES_LIMIT" == "x"], [AUTHORITY_CERTIFICATES_LIMIT=10]) |
| 208 | AC_DEFINE_UNQUOTED([AUTHORITY_CERTIFICATES_LIMIT], [$AUTHORITY_CERTIFICATES_LIMIT], [Authority certificates limit]) |
| 209 | |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 210 | AC_ARG_ENABLE([ca-cert-extension], |
| 211 | AS_HELP_STRING([--enable-ca-cert-extension], |
| 212 | [enable CA certificate manager \ |
| 213 | Only IBM specific]) |
| 214 | ) |
| 215 | |
| 216 | AM_CONDITIONAL([CA_CERT_EXTENSION], [test "x$enable_ca_cert_extension" == "xyes"]) |
| 217 | |
| 218 | AS_IF([test "x$enable_ca_cert_extension" == "xyes"], |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 219 | [AC_CONFIG_FILES([bmc-vmi-ca/Makefile])]) |
| 220 | |
Anton D. Kachalov | 6dd1c2a | 2021-04-02 17:34:49 +0200 | [diff] [blame] | 221 | AC_SUBST([dbuspolicydir], [$with_dbuspolicydir]) |
| 222 | |
Jayanth Othayoth | 0aa0d11 | 2018-09-03 03:47:27 -0500 | [diff] [blame] | 223 | # Create configured output |
Anton D. Kachalov | 6dd1c2a | 2021-04-02 17:34:49 +0200 | [diff] [blame] | 224 | AC_CONFIG_FILES([Makefile test/Makefile dist/Makefile]) |
Jayanth Othayoth | 0aa0d11 | 2018-09-03 03:47:27 -0500 | [diff] [blame] | 225 | AC_OUTPUT |