Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
Patrick Venture | 23ef59b | 2018-11-26 09:15:35 -0800 | [diff] [blame] | 3 | AC_INIT([sys-ipmi], [0.1], [https://www.github.com/google-ipmi-sys/issues]) |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 4 | AC_LANG([C++]) |
| 5 | AC_CONFIG_HEADERS([config.h]) |
| 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) |
| 7 | AM_SILENT_RULES([yes]) |
| 8 | |
| 9 | # Checks for programs. |
| 10 | AC_PROG_CXX |
| 11 | AM_PROG_AR |
| 12 | AC_PROG_INSTALL |
| 13 | AC_PROG_MAKE_SET |
| 14 | |
| 15 | # Checks for typedefs, structures, and compiler characteristics. |
Patrick Venture | c25a3df | 2018-09-17 12:11:19 -0700 | [diff] [blame] | 16 | AX_CXX_COMPILE_STDCXX_17([noext]) |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 17 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
| 18 | |
| 19 | # Checks for libraries. |
Patrick Venture | c662465 | 2019-02-13 07:35:07 -0800 | [diff] [blame] | 20 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus]) |
| 21 | PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging]) |
William A. Kennington III | 2c9e162 | 2019-02-07 15:45:19 -0800 | [diff] [blame] | 22 | PKG_CHECK_MODULES( |
| 23 | [LIBIPMID], |
| 24 | [libipmid], |
| 25 | [], |
| 26 | [AC_MSG_ERROR([Could not find libipmid...openbmc/phosphor-host-ipmid package required])] |
| 27 | ) |
Patrick Venture | 3c7037a | 2018-11-21 21:40:50 -0800 | [diff] [blame] | 28 | AC_CHECK_HEADER( |
Patrick Venture | 575a55a | 2019-02-12 07:32:06 -0800 | [diff] [blame] | 29 | nlohmann/json.hpp, |
| 30 | [], |
| 31 | [AC_MSG_ERROR([Could not find nlohmann/json.hpp])] |
| 32 | ) |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 33 | |
| 34 | # Checks for library functions. |
| 35 | LT_INIT # Required for systemd linking |
| 36 | |
Patrick Venture | 848b938 | 2019-03-13 15:48:23 -0700 | [diff] [blame^] | 37 | # Make it possible for users to choose if they want test support |
| 38 | # explicitly or not at all |
| 39 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 40 | [Build test cases])) |
| 41 | |
| 42 | # Check/set gtest specific functions. |
| 43 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 44 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 45 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 46 | AX_PTHREAD |
| 47 | |
| 48 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 49 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 50 | AC_LANG_PUSH([C++]) |
| 51 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 52 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 53 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 54 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 55 | ], [ |
| 56 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 57 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 58 | ]) |
| 59 | ]) |
| 60 | ], [ |
| 61 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 62 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 63 | ]) |
| 64 | ]) |
| 65 | AC_LANG_POP([C++]) |
| 66 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 67 | |
| 68 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 69 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 70 | AC_LANG_PUSH([C++]) |
| 71 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 72 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 73 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 74 | ]) |
| 75 | ]) |
| 76 | AC_LANG_POP([C++]) |
| 77 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 78 | |
| 79 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 80 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 81 | AC_CHECK_LIB([gtest], [main], [ |
| 82 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 83 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 84 | ]) |
| 85 | ], [ |
| 86 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 87 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 88 | ]) |
| 89 | ]) |
| 90 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 91 | |
| 92 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 93 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 94 | AC_CHECK_LIB([gmock], [main], [ |
| 95 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 96 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 97 | ]) |
| 98 | ], [ |
| 99 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 100 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 101 | ]) |
| 102 | ]) |
| 103 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 104 | ]) |
| 105 | |
Patrick Venture | f9a19b8 | 2018-09-18 10:03:24 -0700 | [diff] [blame] | 106 | PKG_PROG_PKG_CONFIG |
| 107 | AC_ARG_WITH([systemdsystemunitdir], |
| 108 | [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],, |
| 109 | [with_systemdsystemunitdir=auto]) |
| 110 | AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [ |
| 111 | def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) |
| 112 | |
| 113 | AS_IF([test "x$def_systemdsystemunitdir" = "x"], |
| 114 | [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], |
| 115 | [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]) |
| 116 | with_systemdsystemunitdir=no], |
| 117 | [with_systemdsystemunitdir="$def_systemdsystemunitdir"])]) |
| 118 | AS_IF([test "x$with_systemdsystemunitdir" != "xno"], |
| 119 | [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]) |
| 120 | AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) |
| 121 | |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 122 | # Create configured output |
Patrick Venture | 848b938 | 2019-03-13 15:48:23 -0700 | [diff] [blame^] | 123 | AC_CONFIG_FILES([Makefile test/Makefile]) |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 124 | AC_OUTPUT |