blob: 65942b634b0558f21c26354b0a6ce59fe3514997 [file] [log] [blame]
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +05301# Initialization
2AC_PREREQ([2.69])
3AC_INIT([phosphor-led-sysfs], [1.0], [https://github.com/openbmc/phosphor-led-sysfs/issues])
4AC_LANG([C++])
5AC_CONFIG_HEADERS([config.h])
Andrew Jefferyb6708c72019-08-01 15:54:28 +09306AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign dist-xz])
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +05307AM_SILENT_RULES([yes])
8
9# Checks for programs.
10AC_PROG_CXX
11AC_PROG_INSTALL
12AC_PROG_MAKE_SET
13
14# Checks for libraries.
15PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221])
16
17# Checks for typedefs, structures, and compiler characteristics.
Vernon Mauerye0844ff2018-10-04 10:34:50 -070018AX_CXX_COMPILE_STDCXX_17([noext])
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +053019AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
20
Vishwanatha Subbanna179b6712017-02-17 11:20:38 +053021# For libtools
22LT_INIT
23
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +053024# Checks for header files.
Vishwanatha Subbanna7f6e8092017-03-10 15:17:12 +053025PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],, [AC_MSG_ERROR([Could not find sdbusplus...openbmc/sdbusplus package required])])
Vishwanatha Subbannae0891732017-03-10 15:27:23 +053026PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],, [AC_MSG_ERROR([Could not find phosphor-dbus-interfaces...openbmc/phosphor-dbus-interfaces package required])])
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +053027
Vishwanatha Subbannac43e0af2021-03-26 00:32:05 -050028# check/enable oe-sdk
29AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"])
30AC_SUBST(GTEST_CPPFLAGS)
31AC_ARG_ENABLE([oe-sdk],
32 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
33)
34AC_ARG_VAR(OECORE_TARGET_SYSROOT,
35 [Path to the OE SDK SYSROOT])
36AS_IF([test "x$enable_oe_sdk" == "xyes"],
37 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
38 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
39 )
40 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
41 [
42 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
43 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
44 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
45 ]
46 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
47)
48
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +053049# Check/set gtest specific functions.
Andrew Jefferya607a0d2018-05-23 16:15:26 +093050AS_IF([test "x$enable_tests" != "xno"], [
51 PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
52 PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
53 AX_PTHREAD
54
55 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
56 AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
57 AC_LANG_PUSH([C++])
58 AC_CHECK_HEADERS([gtest/gtest.h], [
59 AS_IF([test "x$GTEST_CFLAGS" = "x"], [
60 AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [
61 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS])
62 ], [
63 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS])
64 AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS])
65 ])
66 ])
67 ], [
68 AS_IF([test "x$enable_tests" = "xyes"], [
69 AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h])
70 ])
71 ])
72 AC_LANG_POP([C++])
73 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
74
75 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
76 AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
77 AC_LANG_PUSH([C++])
78 AC_CHECK_HEADERS([gmock/gmock.h], [], [
79 AS_IF([test "x$enable_tests" = "xyes"], [
80 AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
81 ])
82 ])
83 AC_LANG_POP([C++])
84 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
85
86 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
87 AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
88 AC_CHECK_LIB([gtest], [main], [
89 AS_IF([test "x$GTEST_LIBS" = "x"], [
90 AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS])
91 ])
92 ], [
93 AS_IF([test "x$enable_tests" = "xyes"], [
94 AC_MSG_ERROR([Testing enabled but couldn't find gtest libs])
95 ])
96 ])
97 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
98
99 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
100 AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
101 AC_CHECK_LIB([gmock], [main], [
102 AS_IF([test "x$GMOCK_LIBS" = "x"], [
103 AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
104 ])
105 ], [
106 AS_IF([test "x$enable_tests" = "xyes"], [
107 AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
108 ])
109 ])
110 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
111])
112
113AX_CODE_COVERAGE
Andrew Jefferyb6708c72019-08-01 15:54:28 +0930114m4_ifdef([_AX_CODE_COVERAGE_RULES],
115 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
116 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
117AX_ADD_AM_MACRO_STATIC([])
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +0530118
119AC_ARG_VAR(BUSNAME, [The Dbus busname to own])
Vishwanatha Subbanna84ade672017-02-02 15:02:23 +0530120AS_IF([test "x$BUSNAME" == "x"], [BUSNAME="xyz.openbmc_project.LED.Controller"])
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +0530121AC_DEFINE_UNQUOTED([BUSNAME], ["$BUSNAME"], [The Dbus busname to own])
Vishwanatha Subbanna84ade672017-02-02 15:02:23 +0530122AC_ARG_VAR(OBJPATH, [The physical LED controller Dbus root])
123AS_IF([test "x$OBJPATH" == "x"], [OBJPATH="/xyz/openbmc_project/led/physical"])
124AC_DEFINE_UNQUOTED([OBJPATH], ["$OBJPATH"], [The physical LED controller Dbus root])
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +0530125
Vishwanatha Subbannaf9de54b2017-05-25 21:06:33 +0530126# Platform device path for led subsystem.
127AC_ARG_VAR(DEVPATH, [Physical led device path])
128AS_IF([test "x$DEVPATH" == "x"], [DEVPATH="/sys/class/leds/"])
129AC_DEFINE_UNQUOTED([DEVPATH], ["$DEVPATH"], [Physical led device path])
130
Vishwanatha Subbanna835571e2016-11-30 11:29:30 +0530131# Create configured output
132AC_CONFIG_FILES([Makefile])
133AC_OUTPUT