blob: 29a348523ed6e4096ede8be4139f2917c7ab67c9 [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])
Lakshminarayana R. Kammath480f30d2020-05-21 10:02:28 -05006AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror -Wno-portability foreign dist-xz])
7
Jayanth Othayoth0aa0d112018-09-03 03:47:27 -05008AM_SILENT_RULES([yes])
9
10# Checks for programs.
11AC_PROG_CXX
12AC_PROG_INSTALL
13AC_PROG_MAKE_SET
14
15# Checks for library functions
16LT_INIT # Required for systemd linking
17
18# Checks for typedefs, structures, and compiler characteristics.
19AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
20AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
21
Ravi Tejaa49895e2020-06-16 03:57:58 -050022PKG_PROG_PKG_CONFIG
23AC_ARG_WITH([systemdsystemunitdir],
24 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
25 [],
26 [with_systemdsystemunitdir=auto]
27)
28AS_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)
38AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
39 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]
40)
41AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
42
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050043# Check for libraries
Patrick Venture8d100c12018-12-03 08:36:00 -080044AX_CHECK_OPENSSL([], [AC_MSG_ERROR(["openssl required and not found"])])
Patrick Venture48e9d352018-12-03 08:41:26 -080045AC_CHECK_HEADER(experimental/filesystem, [],
46 [AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs development package required])]
47)
Patrick Venture426adad2019-02-13 15:07:46 -080048PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces])
49PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
Marri Devender Raof4682712019-03-19 05:00:28 -050050PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus])
Patrick Venture426adad2019-02-13 15:07:46 -080051PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050052
Patrick Ventured51f1032018-12-03 08:48:17 -080053# Make it possible for users to choose if they want test support
54# explicitly or not at all
55AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
56 [Build test cases]))
57
Lakshminarayana R. Kammath480f30d2020-05-21 10:02:28 -050058# Make sure the default CFLAGS of `-O2 -g` don't override CODE_COVERAGE_CFLAGS
59# It is important that this comes before AC_PROG_C{C,XX}, as we are attempting
60# to stop them from populating default CFLAGS and CXXFLAGS.
61AS_IF([test "x$enable_tests" = "xno"], [enable_code_coverage=no])
62AS_IF([test "x$enable_code_coverage" != "xno"], [
63 AS_IF([test "x${CXXFLAGS+set}" != "xset"], [
64 AC_SUBST(CXXFLAGS, [""])
65 ])
66 AS_IF([test "x${CFLAGS+set}" != "xset"], [
67 AC_SUBST(CFLAGS, [""])
68 ])
69])
70
Marri Devender Rao947258d2018-09-25 10:52:24 -050071# Check/set gtest specific functions.
Patrick Ventured51f1032018-12-03 08:48:17 -080072AS_IF([test "x$enable_tests" != "xno"], [
73 PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
74 PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
75 AX_PTHREAD
76
77 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
78 AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
79 AC_CHECK_HEADERS([gtest/gtest.h], [
80 AS_IF([test "x$GTEST_CFLAGS" = "x"], [
81 AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [
82 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS])
83 ], [
84 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS])
85 AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS])
86 ])
87 ])
88 ], [
89 AS_IF([test "x$enable_tests" = "xyes"], [
90 AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h])
91 ])
92 ])
93 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
94
95 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
96 AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
97 AC_CHECK_HEADERS([gmock/gmock.h], [], [
98 AS_IF([test "x$enable_tests" = "xyes"], [
99 AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
100 ])
101 ])
102 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
103
104 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
105 AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
106 AC_CHECK_LIB([gtest], [main], [
107 AS_IF([test "x$GTEST_LIBS" = "x"], [
108 AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS])
109 ])
110 ], [
111 AS_IF([test "x$enable_tests" = "xyes"], [
112 AC_MSG_ERROR([Testing enabled but couldn't find gtest libs])
113 ])
114 ])
115 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
116
117 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
118 AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
119 AC_CHECK_LIB([gmock], [main], [
120 AS_IF([test "x$GMOCK_LIBS" = "x"], [
121 AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
122 ])
123 ], [
124 AS_IF([test "x$enable_tests" = "xyes"], [
125 AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
126 ])
127 ])
128 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
129])
Marri Devender Rao947258d2018-09-25 10:52:24 -0500130
Lakshminarayana R. Kammath480f30d2020-05-21 10:02:28 -0500131# Check for valgrind
132AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
133m4_foreach([vgtool], [valgrind_tool_list],
134 [AX_VALGRIND_DFLT(vgtool, [off])])
135AX_VALGRIND_DFLT([memcheck], [on])
136AX_VALGRIND_CHECK
137AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
138m4_foreach([vgtool], [valgrind_tool_list],
139 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
140
141# Code coverage
142AX_CODE_COVERAGE
143m4_ifdef([_AX_CODE_COVERAGE_RULES],
144 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
145 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
146AX_ADD_AM_MACRO_STATIC([])
147
Marri Devender Rao947258d2018-09-25 10:52:24 -0500148AC_ARG_ENABLE([oe-sdk],
149 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
150)
151AC_ARG_VAR(OECORE_TARGET_SYSROOT,
152 [Path to the OE SDK SYSROOT])
153AS_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)
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -0500165AC_ARG_VAR(BUSNAME, [The D-Bus busname to own])
166AS_IF([test "x$BUSNAME" == "x"], [BUSNAME="xyz.openbmc_project.Certs.Manager"])
167AC_DEFINE_UNQUOTED([BUSNAME], ["$BUSNAME"], [The D-Bus busname to own])
168AC_ARG_VAR(OBJPATH, [The certificate manager D-Bus root])
169AS_IF([test "x$OBJPATH" == "x"], [OBJPATH="/xyz/openbmc_project/certs"])
170AC_DEFINE_UNQUOTED([OBJPATH], ["$OBJPATH"], [The certificate manager D-Bus root])
171
Marri Devender Raof4d63482019-05-02 06:35:34 -0500172AC_ARG_VAR(CSR_FILE_NAME, [The CSR file.])
173AS_IF([test "x$CSR_FILE_NAME" == "x"], [CSR_FILE_NAME="domain.csr"])
174AC_DEFINE_UNQUOTED([CSR_FILE_NAME], ["$CSR_FILE_NAME"], [The CSR file])
175
Marri Devender Raof4682712019-03-19 05:00:28 -0500176AC_ARG_VAR(PRIV_KEY_FILE_NAME, [The private key file.])
177AS_IF([test "x$PRIV_KEY_FILE_NAME" == "x"], [PRIV_KEY_FILE_NAME="privkey.pem"])
178AC_DEFINE_UNQUOTED([PRIV_KEY_FILE_NAME], ["$PRIV_KEY_FILE_NAME"], [The private key file])
179
Ramesh Iyyarc6e58c72019-07-16 08:52:47 -0500180AC_ARG_VAR(RSA_PRIV_KEY_FILE_NAME, [The rsa private key file.])
181AS_IF([test "x$RSA_PRIV_KEY_FILE_NAME" == "x"], [RSA_PRIV_KEY_FILE_NAME=".rsaprivkey.pem"])
182AC_DEFINE_UNQUOTED([RSA_PRIV_KEY_FILE_NAME], ["$RSA_PRIV_KEY_FILE_NAME"], [The rsa private key file])
183
Zbigniew Lukwinski3b07b772019-10-09 11:43:34 +0200184AC_ARG_VAR(AUTHORITY_CERTIFICATES_LIMIT, [Authority certificates limit.])
185AS_IF([test "x$AUTHORITY_CERTIFICATES_LIMIT" == "x"], [AUTHORITY_CERTIFICATES_LIMIT=10])
186AC_DEFINE_UNQUOTED([AUTHORITY_CERTIFICATES_LIMIT], [$AUTHORITY_CERTIFICATES_LIMIT], [Authority certificates limit])
187
Ravi Tejaa49895e2020-06-16 03:57:58 -0500188AC_ARG_ENABLE([ca-cert-extension],
189 AS_HELP_STRING([--enable-ca-cert-extension],
190 [enable CA certificate manager \
191 Only IBM specific])
192)
193
194AM_CONDITIONAL([CA_CERT_EXTENSION], [test "x$enable_ca_cert_extension" == "xyes"])
195
196AS_IF([test "x$enable_ca_cert_extension" == "xyes"],
197 [AX_APPEND_COMPILE_FLAGS([-DCA_CERT_EXTENSION])],
198 [AC_CONFIG_FILES([bmc-vmi-ca/Makefile])])
199
Jayanth Othayoth0aa0d112018-09-03 03:47:27 -0500200# Create configured output
Marri Devender Rao947258d2018-09-25 10:52:24 -0500201AC_CONFIG_FILES([Makefile test/Makefile])
Jayanth Othayoth0aa0d112018-09-03 03:47:27 -0500202AC_OUTPUT