Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
| 3 | AC_INIT([phosphor-ipmi-ethstats], [1.0], [https://www.github.com/openbmc/phosphor-ipmi-ethstats/issues]) |
| 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. |
| 16 | AX_CXX_COMPILE_STDCXX_17([noext]) |
| 17 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
| 18 | |
| 19 | # Checks for libraries. |
William A. Kennington III | 539f03f | 2019-02-12 13:28:45 -0800 | [diff] [blame] | 20 | PKG_CHECK_MODULES([LIBIPMID], [libipmid]) |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 21 | AC_CHECK_HEADER(experimental/filesystem, ,[AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs developement package required])]) |
| 22 | |
| 23 | # Checks for library functions. |
| 24 | LT_INIT # Required for systemd linking |
| 25 | |
Patrick Venture | f1586f5 | 2019-03-18 10:41:22 -0700 | [diff] [blame^] | 26 | # Make it possible for users to choose if they want test support |
| 27 | # explicitly or not at all |
| 28 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 29 | [Build test cases])) |
| 30 | |
| 31 | # Check/set gtest specific functions. |
| 32 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 33 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 34 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 35 | AX_PTHREAD |
| 36 | |
| 37 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 38 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 39 | AC_LANG_PUSH([C++]) |
| 40 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 41 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 42 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 43 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 44 | ], [ |
| 45 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 46 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 47 | ]) |
| 48 | ]) |
| 49 | ], [ |
| 50 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 51 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 52 | ]) |
| 53 | ]) |
| 54 | AC_LANG_POP([C++]) |
| 55 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 56 | |
| 57 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 58 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 59 | AC_LANG_PUSH([C++]) |
| 60 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 61 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 62 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 63 | ]) |
| 64 | ]) |
| 65 | AC_LANG_POP([C++]) |
| 66 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 67 | |
| 68 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 69 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 70 | AC_CHECK_LIB([gtest], [main], [ |
| 71 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 72 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 73 | ]) |
| 74 | ], [ |
| 75 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 76 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 77 | ]) |
| 78 | ]) |
| 79 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 80 | |
| 81 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 82 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 83 | AC_CHECK_LIB([gmock], [main], [ |
| 84 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 85 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 86 | ]) |
| 87 | ], [ |
| 88 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 89 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 90 | ]) |
| 91 | ]) |
| 92 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 93 | ]) |
| 94 | |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 95 | # Do you want to install with the Google OEM Number as well. |
| 96 | AC_ARG_ENABLE([google], |
Patrick Venture | d72f8b5 | 2019-03-07 16:54:57 -0800 | [diff] [blame] | 97 | AS_HELP_STRING( |
| 98 | [--enable-google], [Enable registering with Google OEN.] |
| 99 | ) |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 100 | ) |
Patrick Venture | d72f8b5 | 2019-03-07 16:54:57 -0800 | [diff] [blame] | 101 | AM_CONDITIONAL(ENABLE_GOOGLE, [test "x$enable_google" = "xyes"]) |
| 102 | AS_IF([test "x$enable_google" = "xyes"], |
| 103 | [AC_DEFINE(ENABLE_GOOGLE, [1], [Register with Google OEN.])], |
| 104 | [AC_DEFINE(ENABLE_GOOGLE, [0], [Do not register with Google OEN.])] |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 105 | ) |
| 106 | |
| 107 | # Create configured output |
Patrick Venture | f1586f5 | 2019-03-18 10:41:22 -0700 | [diff] [blame^] | 108 | AC_CONFIG_FILES([Makefile test/Makefile]) |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 109 | AC_OUTPUT |