blob: 7e7d28c6ffa953747e42dadc83e9002271f51cde [file] [log] [blame]
Vishwanatha81ee91f2016-08-30 17:17:13 +05301# Initialization
2AC_PREREQ([2.69])
3AC_INIT([phosphor-time-manager], [1.0], [https://github.com/openbmc/phosphor-time-manager/issues])
Lei YU2f9c0cc2017-01-20 14:02:03 +08004AC_LANG([C++])
Vishwanatha81ee91f2016-08-30 17:17:13 +05305AC_CONFIG_HEADERS([config.h])
6AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
Patrick Williamsf5211452016-11-09 21:58:38 -06007AM_SILENT_RULES([yes])
Vishwanatha81ee91f2016-08-30 17:17:13 +05308
Lei YU19b37ee2018-09-18 14:46:36 +08009# Use gcc-ar and gcc-ranlib for static libraries built with -flto
10AC_SUBST([AR], [${ac_tool_prefix}gcc-ar])
11AC_SUBST([RANLIB], [${ac_tool_prefix}gcc-ranlib])
12
Lei YU2f9c0cc2017-01-20 14:02:03 +080013# Checks for programs
Vishwanatha81ee91f2016-08-30 17:17:13 +053014AC_PROG_CXX
Vishwanatha81ee91f2016-08-30 17:17:13 +053015AM_PROG_AR
Vishwanatha81ee91f2016-08-30 17:17:13 +053016
Gunnar Mills7f25c532017-10-25 20:45:28 -050017# Suppress the --with-libtool-sysroot error
Lei YU2f9c0cc2017-01-20 14:02:03 +080018LT_INIT
19
20# Check for libraries
21PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221],,\
22 AC_MSG_ERROR(["Systemd required and not found"]))
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050023PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],,\
24 AC_MSG_ERROR(["Requires phosphor-dbus-interfaces package."]))
Lei YU2f9c0cc2017-01-20 14:02:03 +080025PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],,\
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050026 AC_MSG_ERROR(["Requires sdbusplus package."]))
27PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],,\
28 AC_MSG_ERROR(["Requires phosphor-logging package."]))
Lei YUbd024392018-09-10 10:34:56 +080029AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])])
Vishwanatha81ee91f2016-08-30 17:17:13 +053030
Patrick Williamsf5211452016-11-09 21:58:38 -060031# Check/set gtest specific functions.
Lei YUbd024392018-09-10 10:34:56 +080032PKG_CHECK_MODULES([GTEST], [gtest], [], [AC_MSG_NOTICE([gtest not found, tests will not build])])
33PKG_CHECK_MODULES([GMOCK], [gmock], [], [AC_MSG_NOTICE([gmock not found, tests will not build])])
34PKG_CHECK_MODULES([GTEST_MAIN], [gtest_main], [], [AC_MSG_NOTICE([gtest_main not found, tests will not build])])
Patrick Williamsf5211452016-11-09 21:58:38 -060035
Lei YU2f9c0cc2017-01-20 14:02:03 +080036# Test cases require SDK so only build if we're told to (and SDK is available)
Patrick Williamsf5211452016-11-09 21:58:38 -060037AC_ARG_ENABLE([oe-sdk],
38 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
39)
40AC_ARG_VAR(OECORE_TARGET_SYSROOT,
41 [Path to the OE SDK SYSROOT])
42AS_IF([test "x$enable_oe_sdk" == "xyes"],
43 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
44 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
45 )
46 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
47 [
48 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
49 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
50 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
51 ]
52 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
53)
54
Lei YU23d06af2017-07-11 17:22:17 +080055# Check for sdbus++ tool
56AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++])
57AS_IF([test "x$SDBUSPLUSPLUS" == "x"], AC_MSG_ERROR([Cannot find sdbus++]))
58
Lei YU2f9c0cc2017-01-20 14:02:03 +080059# Checks for typedefs, structures, and compiler characteristics.
Lei YU19b37ee2018-09-18 14:46:36 +080060AX_CXX_COMPILE_STDCXX_17([noext])
Lei YU2f9c0cc2017-01-20 14:02:03 +080061AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS])
62
63# DBUS interface
64AC_ARG_VAR(BUSNAME, [The Time Manager Dbus busname to own])
65AS_IF([test "x$BUSNAME" == "x"], [BUSNAME="xyz.openbmc_project.Time.Manager"])
66AC_DEFINE_UNQUOTED([BUSNAME], ["$BUSNAME"], [The Time Manager DBus busname to own])
67
68AC_ARG_VAR(OBJPATH_BMC, [The bmc epoch Dbus root])
69AS_IF([test "x$OBJPATH_BMC" == "x"], [OBJPATH_BMC="/xyz/openbmc_project/time/bmc"])
70AC_DEFINE_UNQUOTED([OBJPATH_BMC], ["$OBJPATH_BMC"], [The bmc epoch Dbus root])
71
72AC_ARG_VAR(OBJPATH_HOST, [The host epoch Dbus root])
73AS_IF([test "x$OBJPATH_HOST" == "x"], [OBJPATH_HOST="/xyz/openbmc_project/time/host"])
74AC_DEFINE_UNQUOTED([OBJPATH_HOST], ["$OBJPATH_HOST"], [The host epoch Dbus root])
75
Lei YUaf5abc52017-03-07 17:49:17 +080076AC_ARG_VAR(HOST_OFFSET_FILE, [The file to save host time offset])
77AS_IF([test "x$HOST_OFFSET_FILE" == "x"], [HOST_OFFSET_FILE="/var/lib/obmc/saved_host_offset"])
78AC_DEFINE_UNQUOTED([HOST_OFFSET_FILE], ["$HOST_OFFSET_FILE"], [The file to save host time offset])
79
Lei YU1cd42482018-07-24 10:40:59 +080080AC_ARG_VAR(DEFAULT_TIME_MODE, [The default time mode])
81AS_IF([test "x$DEFAULT_TIME_MODE" == "x"], [DEFAULT_TIME_MODE=Mode::Manual])
82AC_DEFINE_UNQUOTED([DEFAULT_TIME_MODE], [$DEFAULT_TIME_MODE], [The default time mode])
83
84AC_ARG_VAR(DEFAULT_TIME_OWNER, [The default time owner])
85AS_IF([test "x$DEFAULT_TIME_OWNER" == "x"], [DEFAULT_TIME_OWNER=Owner::Both])
86AC_DEFINE_UNQUOTED([DEFAULT_TIME_OWNER], [$DEFAULT_TIME_OWNER], [The default time owner])
Lei YU2f9c0cc2017-01-20 14:02:03 +080087
88AC_CONFIG_FILES([Makefile test/Makefile])
Vishwanatha81ee91f2016-08-30 17:17:13 +053089AC_OUTPUT