Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
| 3 | AC_INIT([phosphor-led-sysfs], [1.0], [https://github.com/openbmc/phosphor-led-sysfs/issues]) |
| 4 | AC_LANG([C++]) |
| 5 | AC_CONFIG_HEADERS([config.h]) |
Andrew Jeffery | b6708c7 | 2019-08-01 15:54:28 +0930 | [diff] [blame] | 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign dist-xz]) |
Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 7 | AM_SILENT_RULES([yes]) |
| 8 | |
| 9 | # Checks for programs. |
| 10 | AC_PROG_CXX |
| 11 | AC_PROG_INSTALL |
| 12 | AC_PROG_MAKE_SET |
| 13 | |
| 14 | # Checks for libraries. |
| 15 | PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221]) |
| 16 | |
| 17 | # Checks for typedefs, structures, and compiler characteristics. |
Vernon Mauery | e0844ff | 2018-10-04 10:34:50 -0700 | [diff] [blame] | 18 | AX_CXX_COMPILE_STDCXX_17([noext]) |
Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 19 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
| 20 | |
Vishwanatha Subbanna | 179b671 | 2017-02-17 11:20:38 +0530 | [diff] [blame] | 21 | # For libtools |
| 22 | LT_INIT |
| 23 | |
Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 24 | # Checks for header files. |
Vishwanatha Subbanna | 7f6e809 | 2017-03-10 15:17:12 +0530 | [diff] [blame] | 25 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],, [AC_MSG_ERROR([Could not find sdbusplus...openbmc/sdbusplus package required])]) |
Vishwanatha Subbanna | e089173 | 2017-03-10 15:27:23 +0530 | [diff] [blame] | 26 | PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],, [AC_MSG_ERROR([Could not find phosphor-dbus-interfaces...openbmc/phosphor-dbus-interfaces package required])]) |
Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 27 | |
Vishwanatha Subbanna | c43e0af | 2021-03-26 00:32:05 -0500 | [diff] [blame] | 28 | # check/enable oe-sdk |
| 29 | AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"]) |
| 30 | AC_SUBST(GTEST_CPPFLAGS) |
| 31 | AC_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 | ) |
| 34 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
| 35 | [Path to the OE SDK SYSROOT]) |
| 36 | AS_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 Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 49 | # Check/set gtest specific functions. |
Andrew Jeffery | a607a0d | 2018-05-23 16:15:26 +0930 | [diff] [blame] | 50 | AS_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 | |
| 113 | AX_CODE_COVERAGE |
Andrew Jeffery | b6708c7 | 2019-08-01 15:54:28 +0930 | [diff] [blame] | 114 | m4_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])]) |
| 117 | AX_ADD_AM_MACRO_STATIC([]) |
Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 118 | |
| 119 | AC_ARG_VAR(BUSNAME, [The Dbus busname to own]) |
Vishwanatha Subbanna | 84ade67 | 2017-02-02 15:02:23 +0530 | [diff] [blame] | 120 | AS_IF([test "x$BUSNAME" == "x"], [BUSNAME="xyz.openbmc_project.LED.Controller"]) |
Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 121 | AC_DEFINE_UNQUOTED([BUSNAME], ["$BUSNAME"], [The Dbus busname to own]) |
Vishwanatha Subbanna | 84ade67 | 2017-02-02 15:02:23 +0530 | [diff] [blame] | 122 | AC_ARG_VAR(OBJPATH, [The physical LED controller Dbus root]) |
| 123 | AS_IF([test "x$OBJPATH" == "x"], [OBJPATH="/xyz/openbmc_project/led/physical"]) |
| 124 | AC_DEFINE_UNQUOTED([OBJPATH], ["$OBJPATH"], [The physical LED controller Dbus root]) |
Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 125 | |
Vishwanatha Subbanna | f9de54b | 2017-05-25 21:06:33 +0530 | [diff] [blame] | 126 | # Platform device path for led subsystem. |
| 127 | AC_ARG_VAR(DEVPATH, [Physical led device path]) |
| 128 | AS_IF([test "x$DEVPATH" == "x"], [DEVPATH="/sys/class/leds/"]) |
| 129 | AC_DEFINE_UNQUOTED([DEVPATH], ["$DEVPATH"], [Physical led device path]) |
| 130 | |
Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame] | 131 | # Create configured output |
| 132 | AC_CONFIG_FILES([Makefile]) |
| 133 | AC_OUTPUT |