blob: bb32ad69199943e9595f75730453a8632f51727a [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)
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050026PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],,\
27 AC_MSG_ERROR(["Requires phosphor-dbus-interfaces package."]))
28PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],,
29 AC_MSG_ERROR(["Requires sdbusplus package."]))
30PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],,\
31 AC_MSG_ERROR(["Requires phosphor-logging package."]))
32
33# Code coverage
34AX_CODE_COVERAGE
35
Patrick Ventured51f1032018-12-03 08:48:17 -080036# Make it possible for users to choose if they want test support
37# explicitly or not at all
38AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
39 [Build test cases]))
40
Marri Devender Rao947258d2018-09-25 10:52:24 -050041# Check/set gtest specific functions.
Patrick Ventured51f1032018-12-03 08:48:17 -080042AS_IF([test "x$enable_tests" != "xno"], [
43 PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
44 PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
45 AX_PTHREAD
46
47 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
48 AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
49 AC_CHECK_HEADERS([gtest/gtest.h], [
50 AS_IF([test "x$GTEST_CFLAGS" = "x"], [
51 AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [
52 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS])
53 ], [
54 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS])
55 AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS])
56 ])
57 ])
58 ], [
59 AS_IF([test "x$enable_tests" = "xyes"], [
60 AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h])
61 ])
62 ])
63 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
64
65 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
66 AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
67 AC_CHECK_HEADERS([gmock/gmock.h], [], [
68 AS_IF([test "x$enable_tests" = "xyes"], [
69 AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
70 ])
71 ])
72 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
73
74 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
75 AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
76 AC_CHECK_LIB([gtest], [main], [
77 AS_IF([test "x$GTEST_LIBS" = "x"], [
78 AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS])
79 ])
80 ], [
81 AS_IF([test "x$enable_tests" = "xyes"], [
82 AC_MSG_ERROR([Testing enabled but couldn't find gtest libs])
83 ])
84 ])
85 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
86
87 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
88 AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
89 AC_CHECK_LIB([gmock], [main], [
90 AS_IF([test "x$GMOCK_LIBS" = "x"], [
91 AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
92 ])
93 ], [
94 AS_IF([test "x$enable_tests" = "xyes"], [
95 AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
96 ])
97 ])
98 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
99])
Marri Devender Rao947258d2018-09-25 10:52:24 -0500100
101AC_ARG_ENABLE([oe-sdk],
102 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
103)
104AC_ARG_VAR(OECORE_TARGET_SYSROOT,
105 [Path to the OE SDK SYSROOT])
106AS_IF([test "x$enable_oe_sdk" == "xyes"],
107 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
108 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
109 )
110 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
111 [
112 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
113 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
114 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
115 ]
116 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
117)
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -0500118AC_ARG_VAR(BUSNAME, [The D-Bus busname to own])
119AS_IF([test "x$BUSNAME" == "x"], [BUSNAME="xyz.openbmc_project.Certs.Manager"])
120AC_DEFINE_UNQUOTED([BUSNAME], ["$BUSNAME"], [The D-Bus busname to own])
121AC_ARG_VAR(OBJPATH, [The certificate manager D-Bus root])
122AS_IF([test "x$OBJPATH" == "x"], [OBJPATH="/xyz/openbmc_project/certs"])
123AC_DEFINE_UNQUOTED([OBJPATH], ["$OBJPATH"], [The certificate manager D-Bus root])
124
Jayanth Othayoth0aa0d112018-09-03 03:47:27 -0500125# Create configured output
Marri Devender Rao947258d2018-09-25 10:52:24 -0500126AC_CONFIG_FILES([Makefile test/Makefile])
Jayanth Othayoth0aa0d112018-09-03 03:47:27 -0500127AC_OUTPUT