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