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 |
Xiaochao Ma | 1e496c8 | 2020-01-16 17:19:11 +0800 | [diff] [blame] | 24 | AC_ARG_WITH([systemdsystemunitdir], |
| 25 | [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])], |
| 26 | [], |
| 27 | [with_systemdsystemunitdir=auto] |
| 28 | ) |
| 29 | AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], |
| 30 | [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) |
| 31 | AS_IF([test "x$def_systemdsystemunitdir" = "x"], |
| 32 | [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], |
| 33 | [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])] |
| 34 | ) |
| 35 | with_systemdsystemunitdir=no], |
| 36 | [with_systemdsystemunitdir="$def_systemdsystemunitdir"] |
| 37 | )] |
| 38 | ) |
| 39 | AS_IF([test "x$with_systemdsystemunitdir" != "xno"], |
| 40 | [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])] |
| 41 | ) |
| 42 | AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) |
Jeremy Kerr | 80971f8 | 2019-08-29 09:57:58 +0530 | [diff] [blame] | 43 | |
Andrew Jeffery | 7b08721 | 2020-03-17 23:09:43 +1030 | [diff] [blame] | 44 | AC_ARG_WITH([syslog], |
| 45 | [AS_HELP_STRING([--with-syslog], [Support logging to syslog])], |
| 46 | [], |
| 47 | [with_syslog=check]) |
| 48 | |
| 49 | AS_IF([test "x$with_syslog" != "xno"], |
| 50 | [AC_COMPILE_IFELSE( |
| 51 | [AC_LANG_PROGRAM([[ |
| 52 | #include <stdarg.h> |
| 53 | #include <syslog.h> |
| 54 | |
| 55 | void check_vsyslog(int level, const char *fmt, ...) |
| 56 | { |
| 57 | va_list ap; |
| 58 | va_start(ap, fmt); |
| 59 | vsyslog(0, fmt, ap); |
| 60 | va_end(ap); |
| 61 | } |
| 62 | ]],[[ |
| 63 | check_vsyslog(0, "\n"); |
| 64 | ]])], |
| 65 | [AC_DEFINE([MCTP_HAVE_SYSLOG], [1], [Define to enable syslog])], |
| 66 | [])], |
| 67 | []) |
| 68 | |
| 69 | AC_ARG_WITH([fileio], |
| 70 | [AS_HELP_STRING([--with-fileio], |
| 71 | [Support interfaces based on file-descriptors])], |
| 72 | [], |
| 73 | [with_fileio=check]) |
| 74 | |
| 75 | AS_IF([test "x$with_fileio" = "xcheck"], |
| 76 | [AC_DEFINE([MCTP_HAVE_FILEIO], [(HAVE_UNISTD_H && HAVE_FCNTL_H)], |
| 77 | [Support interfaces based on file-descriptors])], |
| 78 | [AS_IF([test "x$with_fileio" = "xyes"], |
| 79 | [AC_DEFINE([MCTP_HAVE_FILEIO], [1], |
| 80 | [Support interfaces based on file-descriptors])], |
| 81 | [])]) |
| 82 | |
| 83 | AC_ARG_WITH([stdio], |
| 84 | [AS_HELP_STRING([--with-stdio], [Support logging to stdio])], |
| 85 | [], |
| 86 | [with_stdio=check]) |
| 87 | |
| 88 | AS_IF([test "x$with_stdio" != "xno"], |
| 89 | [AC_COMPILE_IFELSE( |
| 90 | [AC_LANG_PROGRAM([[ |
| 91 | #include <stdarg.h> |
| 92 | #include <stdio.h> |
| 93 | void check_vprintf(const char *fmt, ...) |
| 94 | { |
| 95 | va_list ap; |
| 96 | va_start(ap, fmt); |
| 97 | vprintf(fmt, ap); |
| 98 | va_end(ap); |
| 99 | } |
| 100 | ]],[[ |
| 101 | check_vprintf("\n"); |
| 102 | ]])], |
| 103 | [AC_DEFINE([MCTP_HAVE_STDIO], [1], [Define to enable stdio functions])], |
| 104 | [])], |
| 105 | []) |
| 106 | |
| 107 | AC_ARG_WITH([default-alloc], |
| 108 | [AS_HELP_STRING([--with-default-alloc], |
| 109 | [Use libc malloc and free for heap memory])], |
| 110 | [], |
| 111 | [with_default_alloc=check]) |
| 112 | |
| 113 | AS_IF([test "x$with_default_alloc" != "xno"], |
| 114 | [AC_LINK_IFELSE( |
| 115 | [AC_LANG_PROGRAM([[ |
| 116 | #include <stdlib.h> |
| 117 | ]], [[ |
| 118 | free(malloc(4096)); |
| 119 | ]])], |
| 120 | [AC_DEFINE([MCTP_DEFAULT_ALLOC], |
| 121 | [1], |
| 122 | [Define to use libc malloc and free for heap memory])], |
| 123 | [])], |
| 124 | []) |
Jeremy Kerr | c7e764a | 2019-05-28 16:49:03 +0800 | [diff] [blame] | 125 | |
| 126 | # Enable all bindings. AC_ARG_ENABLE in future. |
Jeremy Kerr | b2ef62b | 2019-05-28 09:38:25 +0800 | [diff] [blame] | 127 | AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true]) |
| 128 | AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true]) |
| 129 | |
Andrew Jeffery | 8d53b1c | 2020-05-29 08:43:04 +0930 | [diff] [blame] | 130 | # Check for valgrind |
| 131 | AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) |
| 132 | m4_foreach([vgtool], [valgrind_tool_list], |
| 133 | [AX_VALGRIND_DFLT(vgtool, [off])]) |
| 134 | AX_VALGRIND_DFLT([memcheck], [on]) |
| 135 | AX_VALGRIND_CHECK |
| 136 | AM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) |
| 137 | m4_foreach([vgtool], [valgrind_tool_list], |
| 138 | [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) |
| 139 | |
Andrew Jeffery | 7344ac2 | 2020-01-10 16:13:07 +1030 | [diff] [blame] | 140 | AX_CODE_COVERAGE |
| 141 | m4_ifdef([_AX_CODE_COVERAGE_RULES], |
| 142 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])], |
| 143 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])]) |
| 144 | AX_ADD_AM_MACRO_STATIC([]) |
| 145 | |
Jeremy Kerr | 80971f8 | 2019-08-29 09:57:58 +0530 | [diff] [blame] | 146 | AC_CONFIG_FILES([Makefile libmctp.pc]) |
Jeremy Kerr | b2ef62b | 2019-05-28 09:38:25 +0800 | [diff] [blame] | 147 | AC_OUTPUT |