Jeremy Kerr | b2ef62b | 2019-05-28 09:38:25 +0800 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
Andrew Jeffery | 8536cfc | 2020-06-13 00:33:55 +0930 | [diff] [blame] | 3 | AC_INIT([libmctp], 0.10, [https://github.com/openbmc/libmctp/issues]) |
Jeremy Kerr | b2ef62b | 2019-05-28 09:38:25 +0800 | [diff] [blame] | 4 | AC_CONFIG_HEADERS([config.h]) |
| 5 | AC_CONFIG_MACRO_DIRS([m4]) |
Andrew Jeffery | d09253f | 2020-02-26 11:00:37 +1030 | [diff] [blame] | 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror -Wno-portability foreign dist-xz]) |
Jeremy Kerr | b2ef62b | 2019-05-28 09:38:25 +0800 | [diff] [blame] | 7 | AM_SILENT_RULES([yes]) |
| 8 | |
| 9 | # Checks for programs. |
| 10 | AC_PROG_CC |
| 11 | AM_PROG_AR |
| 12 | AC_PROG_INSTALL |
| 13 | AC_PROG_MAKE_SET |
| 14 | |
| 15 | # libtool init |
| 16 | LT_INIT |
| 17 | |
Andrew Jeffery | 3286f17 | 2020-03-17 23:04:13 +1030 | [diff] [blame] | 18 | AC_CHECK_HEADERS_ONCE([endian.h]) |
Andrew Jeffery | 7b08721 | 2020-03-17 23:09:43 +1030 | [diff] [blame] | 19 | AC_CHECK_HEADERS_ONCE([unistd.h fcntl.h]) |
Andrew Jeffery | 3286f17 | 2020-03-17 23:04:13 +1030 | [diff] [blame] | 20 | |
Jeremy Kerr | 80971f8 | 2019-08-29 09:57:58 +0530 | [diff] [blame] | 21 | # pkg-config |
| 22 | PKG_PROG_PKG_CONFIG |
| 23 | PKG_INSTALLDIR |
Andrew Jeffery | 745b1d1 | 2021-05-11 11:14:53 +0930 | [diff] [blame] | 24 | PKG_CHECK_MODULES(udev, |
| 25 | udev, |
Andrew Jeffery | 9f5b47a | 2021-05-11 15:05:14 +0930 | [diff] [blame] | 26 | [PKG_CHECK_VAR(udevdir, udev, udevdir)], |
Andrew Jeffery | 745b1d1 | 2021-05-11 11:14:53 +0930 | [diff] [blame] | 27 | []) |
| 28 | |
Andrew Jeffery | 9f5b47a | 2021-05-11 15:05:14 +0930 | [diff] [blame] | 29 | AC_SUBST([udevrulesdir], [$udevdir/rules.d]) |
| 30 | |
Andrew Jeffery | 745b1d1 | 2021-05-11 11:14:53 +0930 | [diff] [blame] | 31 | AC_ARG_ENABLE([astlpc-raw-kcs], |
| 32 | [AS_HELP_STRING([--enable-astlpc-raw-kcs], |
| 33 | [Use udev rules to symlink raw-kcs device nodes for the astlpc binding])]) |
Andrew Jeffery | 9f5b47a | 2021-05-11 15:05:14 +0930 | [diff] [blame] | 34 | AM_CONDITIONAL([LIBMCTP_UDEV_RAW_KCS], [test -n "$udevdir" -a "x$enable_astlpc_raw_kcs" = "xyes"]) |
Andrew Jeffery | 745b1d1 | 2021-05-11 11:14:53 +0930 | [diff] [blame] | 35 | |
Xiaochao Ma | 1e496c8 | 2020-01-16 17:19:11 +0800 | [diff] [blame] | 36 | AC_ARG_WITH([systemdsystemunitdir], |
| 37 | [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])], |
| 38 | [], |
| 39 | [with_systemdsystemunitdir=auto] |
| 40 | ) |
| 41 | AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], |
| 42 | [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) |
| 43 | AS_IF([test "x$def_systemdsystemunitdir" = "x"], |
| 44 | [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], |
| 45 | [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])] |
| 46 | ) |
| 47 | with_systemdsystemunitdir=no], |
| 48 | [with_systemdsystemunitdir="$def_systemdsystemunitdir"] |
| 49 | )] |
| 50 | ) |
Andrew Jeffery | d4103f8 | 2021-06-16 14:39:36 +0930 | [diff] [blame] | 51 | |
| 52 | AC_CHECK_HEADER([systemd/sd-daemon.h], |
| 53 | [AC_DEFINE([HAVE_SYSTEMD_SD_DAEMON_H], [1], |
| 54 | [Define to 1 if you have <systemd/sd-daemon.h>.])], |
| 55 | []) |
| 56 | AC_CHECK_LIB([systemd], [sd_listen_fds]) |
Xiaochao Ma | 1e496c8 | 2020-01-16 17:19:11 +0800 | [diff] [blame] | 57 | AS_IF([test "x$with_systemdsystemunitdir" != "xno"], |
| 58 | [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])] |
| 59 | ) |
| 60 | AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) |
Jeremy Kerr | 80971f8 | 2019-08-29 09:57:58 +0530 | [diff] [blame] | 61 | |
Andrew Jeffery | 7b08721 | 2020-03-17 23:09:43 +1030 | [diff] [blame] | 62 | AC_ARG_WITH([syslog], |
| 63 | [AS_HELP_STRING([--with-syslog], [Support logging to syslog])], |
| 64 | [], |
| 65 | [with_syslog=check]) |
| 66 | |
| 67 | AS_IF([test "x$with_syslog" != "xno"], |
| 68 | [AC_COMPILE_IFELSE( |
| 69 | [AC_LANG_PROGRAM([[ |
| 70 | #include <stdarg.h> |
| 71 | #include <syslog.h> |
| 72 | |
| 73 | void check_vsyslog(int level, const char *fmt, ...) |
| 74 | { |
| 75 | va_list ap; |
| 76 | va_start(ap, fmt); |
| 77 | vsyslog(0, fmt, ap); |
| 78 | va_end(ap); |
| 79 | } |
| 80 | ]],[[ |
| 81 | check_vsyslog(0, "\n"); |
| 82 | ]])], |
| 83 | [AC_DEFINE([MCTP_HAVE_SYSLOG], [1], [Define to enable syslog])], |
| 84 | [])], |
| 85 | []) |
| 86 | |
| 87 | AC_ARG_WITH([fileio], |
| 88 | [AS_HELP_STRING([--with-fileio], |
| 89 | [Support interfaces based on file-descriptors])], |
| 90 | [], |
| 91 | [with_fileio=check]) |
| 92 | |
| 93 | AS_IF([test "x$with_fileio" = "xcheck"], |
| 94 | [AC_DEFINE([MCTP_HAVE_FILEIO], [(HAVE_UNISTD_H && HAVE_FCNTL_H)], |
| 95 | [Support interfaces based on file-descriptors])], |
| 96 | [AS_IF([test "x$with_fileio" = "xyes"], |
| 97 | [AC_DEFINE([MCTP_HAVE_FILEIO], [1], |
| 98 | [Support interfaces based on file-descriptors])], |
| 99 | [])]) |
| 100 | |
| 101 | AC_ARG_WITH([stdio], |
| 102 | [AS_HELP_STRING([--with-stdio], [Support logging to stdio])], |
| 103 | [], |
| 104 | [with_stdio=check]) |
| 105 | |
| 106 | AS_IF([test "x$with_stdio" != "xno"], |
| 107 | [AC_COMPILE_IFELSE( |
| 108 | [AC_LANG_PROGRAM([[ |
| 109 | #include <stdarg.h> |
| 110 | #include <stdio.h> |
| 111 | void check_vprintf(const char *fmt, ...) |
| 112 | { |
| 113 | va_list ap; |
| 114 | va_start(ap, fmt); |
| 115 | vprintf(fmt, ap); |
| 116 | va_end(ap); |
| 117 | } |
| 118 | ]],[[ |
| 119 | check_vprintf("\n"); |
| 120 | ]])], |
| 121 | [AC_DEFINE([MCTP_HAVE_STDIO], [1], [Define to enable stdio functions])], |
| 122 | [])], |
| 123 | []) |
| 124 | |
| 125 | AC_ARG_WITH([default-alloc], |
| 126 | [AS_HELP_STRING([--with-default-alloc], |
| 127 | [Use libc malloc and free for heap memory])], |
| 128 | [], |
| 129 | [with_default_alloc=check]) |
| 130 | |
| 131 | AS_IF([test "x$with_default_alloc" != "xno"], |
| 132 | [AC_LINK_IFELSE( |
| 133 | [AC_LANG_PROGRAM([[ |
| 134 | #include <stdlib.h> |
| 135 | ]], [[ |
| 136 | free(malloc(4096)); |
| 137 | ]])], |
| 138 | [AC_DEFINE([MCTP_DEFAULT_ALLOC], |
| 139 | [1], |
| 140 | [Define to use libc malloc and free for heap memory])], |
| 141 | [])], |
| 142 | []) |
Jeremy Kerr | c7e764a | 2019-05-28 16:49:03 +0800 | [diff] [blame] | 143 | |
| 144 | # Enable all bindings. AC_ARG_ENABLE in future. |
Jeremy Kerr | b2ef62b | 2019-05-28 09:38:25 +0800 | [diff] [blame] | 145 | AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true]) |
| 146 | AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true]) |
| 147 | |
Andrew Jeffery | 8d53b1c | 2020-05-29 08:43:04 +0930 | [diff] [blame] | 148 | # Check for valgrind |
| 149 | AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) |
| 150 | m4_foreach([vgtool], [valgrind_tool_list], |
| 151 | [AX_VALGRIND_DFLT(vgtool, [off])]) |
| 152 | AX_VALGRIND_DFLT([memcheck], [on]) |
| 153 | AX_VALGRIND_CHECK |
| 154 | AM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) |
| 155 | m4_foreach([vgtool], [valgrind_tool_list], |
| 156 | [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) |
| 157 | |
Andrew Jeffery | 7344ac2 | 2020-01-10 16:13:07 +1030 | [diff] [blame] | 158 | AX_CODE_COVERAGE |
| 159 | m4_ifdef([_AX_CODE_COVERAGE_RULES], |
| 160 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])], |
| 161 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])]) |
| 162 | AX_ADD_AM_MACRO_STATIC([]) |
| 163 | |
Andrew Jeffery | 745b1d1 | 2021-05-11 11:14:53 +0930 | [diff] [blame] | 164 | AC_CONFIG_FILES([Makefile libmctp.pc udev/rules.d/mctp0-raw-kcs3.rules |
| 165 | udev/rules.d/mctp0-raw-kcs4.rules]) |
Jeremy Kerr | b2ef62b | 2019-05-28 09:38:25 +0800 | [diff] [blame] | 166 | AC_OUTPUT |