1# Initialization 2AC_PREREQ([2.69]) 3AC_INIT([libmctp], 0.9, [https://github.com/openbmc/libmctp/issues]) 4AC_CONFIG_HEADERS([config.h]) 5AC_CONFIG_MACRO_DIRS([m4]) 6AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror -Wno-portability foreign dist-xz]) 7AM_SILENT_RULES([yes]) 8 9# Checks for programs. 10AC_PROG_CC 11AM_PROG_AR 12AC_PROG_INSTALL 13AC_PROG_MAKE_SET 14 15# libtool init 16LT_INIT 17 18AC_CHECK_HEADERS_ONCE([endian.h]) 19AC_CHECK_HEADERS_ONCE([unistd.h fcntl.h]) 20 21# pkg-config 22PKG_PROG_PKG_CONFIG 23PKG_INSTALLDIR 24AC_ARG_WITH([systemdsystemunitdir], 25 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])], 26 [], 27 [with_systemdsystemunitdir=auto] 28) 29AS_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) 39AS_IF([test "x$with_systemdsystemunitdir" != "xno"], 40 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])] 41) 42AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) 43 44AC_ARG_WITH([syslog], 45 [AS_HELP_STRING([--with-syslog], [Support logging to syslog])], 46 [], 47 [with_syslog=check]) 48 49AS_IF([test "x$with_syslog" != "xno"], 50 [AC_COMPILE_IFELSE( 51 [AC_LANG_PROGRAM([[ 52#include <stdarg.h> 53#include <syslog.h> 54 55void 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 69AC_ARG_WITH([fileio], 70 [AS_HELP_STRING([--with-fileio], 71 [Support interfaces based on file-descriptors])], 72 [], 73 [with_fileio=check]) 74 75AS_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 83AC_ARG_WITH([stdio], 84 [AS_HELP_STRING([--with-stdio], [Support logging to stdio])], 85 [], 86 [with_stdio=check]) 87 88AS_IF([test "x$with_stdio" != "xno"], 89 [AC_COMPILE_IFELSE( 90 [AC_LANG_PROGRAM([[ 91#include <stdarg.h> 92#include <stdio.h> 93void 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 107AC_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 113AS_IF([test "x$with_default_alloc" != "xno"], 114 [AC_LINK_IFELSE( 115 [AC_LANG_PROGRAM([[ 116#include <stdlib.h> 117 ]], [[ 118free(malloc(4096)); 119 ]])], 120 [AC_DEFINE([MCTP_DEFAULT_ALLOC], 121 [1], 122 [Define to use libc malloc and free for heap memory])], 123 [])], 124 []) 125 126# Enable all bindings. AC_ARG_ENABLE in future. 127AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true]) 128AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true]) 129 130# Check for valgrind 131AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) 132m4_foreach([vgtool], [valgrind_tool_list], 133 [AX_VALGRIND_DFLT(vgtool, [off])]) 134AX_VALGRIND_DFLT([memcheck], [on]) 135AX_VALGRIND_CHECK 136AM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) 137m4_foreach([vgtool], [valgrind_tool_list], 138 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) 139 140AX_CODE_COVERAGE 141m4_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])]) 144AX_ADD_AM_MACRO_STATIC([]) 145 146AC_CONFIG_FILES([Makefile libmctp.pc]) 147AC_OUTPUT 148