1b2ef62baSJeremy Kerr# Initialization 2*895083b5SAndrew JefferyAC_PREREQ([2.71]) 3*895083b5SAndrew JefferyAC_INIT([libmctp],[0.11],[https://github.com/openbmc/libmctp/issues]) 4b2ef62baSJeremy KerrAC_CONFIG_HEADERS([config.h]) 5b2ef62baSJeremy KerrAC_CONFIG_MACRO_DIRS([m4]) 6d09253f0SAndrew JefferyAM_INIT_AUTOMAKE([subdir-objects -Wall -Werror -Wno-portability foreign dist-xz]) 7b2ef62baSJeremy KerrAM_SILENT_RULES([yes]) 8b2ef62baSJeremy Kerr 9b2ef62baSJeremy Kerr# Checks for programs. 10b2ef62baSJeremy KerrAC_PROG_CC 11b2ef62baSJeremy KerrAM_PROG_AR 12b2ef62baSJeremy KerrAC_PROG_INSTALL 13b2ef62baSJeremy KerrAC_PROG_MAKE_SET 14b2ef62baSJeremy Kerr 15b2ef62baSJeremy Kerr# libtool init 16b2ef62baSJeremy KerrLT_INIT 17b2ef62baSJeremy Kerr 183286f176SAndrew JefferyAC_CHECK_HEADERS_ONCE([endian.h]) 197b08721eSAndrew JefferyAC_CHECK_HEADERS_ONCE([unistd.h fcntl.h]) 203286f176SAndrew Jeffery 2180971f84SJeremy Kerr# pkg-config 2280971f84SJeremy KerrPKG_PROG_PKG_CONFIG 2380971f84SJeremy KerrPKG_INSTALLDIR 249f5b47a5SAndrew Jeffery 25cad47301SAndrew JefferyAC_ARG_ENABLE([capture], 26*895083b5SAndrew Jeffery [AS_HELP_STRING([--enable-capture],[Use libpcap to capture messages and packets])]) 27cad47301SAndrew JefferyAS_IF([test "x$enable_capture" = "xyes"], 28cad47301SAndrew Jeffery [PKG_CHECK_MODULES(pcap, libpcap, 29cad47301SAndrew Jeffery [AC_DEFINE([HAVE_PCAP], [1], 30cad47301SAndrew Jeffery [Define to 1 if you have libpcap])], 31cad47301SAndrew Jeffery [])], 32cad47301SAndrew Jeffery []) 33cad47301SAndrew JefferyAC_SUBST([pcap_CFLAGS]) 34cad47301SAndrew JefferyAC_SUBST([pcap_LIBS]) 35cad47301SAndrew JefferyAM_CONDITIONAL([HAVE_PCAP], [test "x$enable_capture" = "xyes"]) 36cad47301SAndrew Jeffery 371e496c8bSXiaochao MaAC_ARG_WITH([systemdsystemunitdir], 381e496c8bSXiaochao Ma [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])], 391e496c8bSXiaochao Ma [], 401e496c8bSXiaochao Ma [with_systemdsystemunitdir=auto] 411e496c8bSXiaochao Ma) 421e496c8bSXiaochao MaAS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], 431e496c8bSXiaochao Ma [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) 441e496c8bSXiaochao Ma AS_IF([test "x$def_systemdsystemunitdir" = "x"], 451e496c8bSXiaochao Ma [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], 461e496c8bSXiaochao Ma [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])] 471e496c8bSXiaochao Ma ) 481e496c8bSXiaochao Ma with_systemdsystemunitdir=no], 491e496c8bSXiaochao Ma [with_systemdsystemunitdir="$def_systemdsystemunitdir"] 501e496c8bSXiaochao Ma )] 511e496c8bSXiaochao Ma) 52d4103f8fSAndrew Jeffery 53d4103f8fSAndrew JefferyAC_CHECK_HEADER([systemd/sd-daemon.h], 54d4103f8fSAndrew Jeffery [AC_DEFINE([HAVE_SYSTEMD_SD_DAEMON_H], [1], 55d4103f8fSAndrew Jeffery [Define to 1 if you have <systemd/sd-daemon.h>.])], 56d4103f8fSAndrew Jeffery []) 57d4103f8fSAndrew JefferyAC_CHECK_LIB([systemd], [sd_listen_fds]) 581e496c8bSXiaochao MaAS_IF([test "x$with_systemdsystemunitdir" != "xno"], 591e496c8bSXiaochao Ma [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])] 601e496c8bSXiaochao Ma) 611e496c8bSXiaochao MaAM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) 6280971f84SJeremy Kerr 637b08721eSAndrew JefferyAC_ARG_WITH([syslog], 647b08721eSAndrew Jeffery [AS_HELP_STRING([--with-syslog], [Support logging to syslog])], 657b08721eSAndrew Jeffery [], 667b08721eSAndrew Jeffery [with_syslog=check]) 677b08721eSAndrew Jeffery 687b08721eSAndrew JefferyAS_IF([test "x$with_syslog" != "xno"], 697b08721eSAndrew Jeffery [AC_COMPILE_IFELSE( 707b08721eSAndrew Jeffery [AC_LANG_PROGRAM([[ 717b08721eSAndrew Jeffery#include <stdarg.h> 727b08721eSAndrew Jeffery#include <syslog.h> 737b08721eSAndrew Jeffery 747b08721eSAndrew Jefferyvoid check_vsyslog(int level, const char *fmt, ...) 757b08721eSAndrew Jeffery{ 767b08721eSAndrew Jeffery va_list ap; 777b08721eSAndrew Jeffery va_start(ap, fmt); 787b08721eSAndrew Jeffery vsyslog(0, fmt, ap); 797b08721eSAndrew Jeffery va_end(ap); 807b08721eSAndrew Jeffery} 817b08721eSAndrew Jeffery ]],[[ 827b08721eSAndrew Jeffery check_vsyslog(0, "\n"); 837b08721eSAndrew Jeffery ]])], 847b08721eSAndrew Jeffery [AC_DEFINE([MCTP_HAVE_SYSLOG], [1], [Define to enable syslog])], 857b08721eSAndrew Jeffery [])], 867b08721eSAndrew Jeffery []) 877b08721eSAndrew Jeffery 887b08721eSAndrew JefferyAC_ARG_WITH([fileio], 897b08721eSAndrew Jeffery [AS_HELP_STRING([--with-fileio], 907b08721eSAndrew Jeffery [Support interfaces based on file-descriptors])], 917b08721eSAndrew Jeffery [], 927b08721eSAndrew Jeffery [with_fileio=check]) 937b08721eSAndrew Jeffery 947b08721eSAndrew JefferyAS_IF([test "x$with_fileio" = "xcheck"], 957b08721eSAndrew Jeffery [AC_DEFINE([MCTP_HAVE_FILEIO], [(HAVE_UNISTD_H && HAVE_FCNTL_H)], 967b08721eSAndrew Jeffery [Support interfaces based on file-descriptors])], 977b08721eSAndrew Jeffery [AS_IF([test "x$with_fileio" = "xyes"], 987b08721eSAndrew Jeffery [AC_DEFINE([MCTP_HAVE_FILEIO], [1], 997b08721eSAndrew Jeffery [Support interfaces based on file-descriptors])], 1007b08721eSAndrew Jeffery [])]) 1017b08721eSAndrew Jeffery 1027b08721eSAndrew JefferyAC_ARG_WITH([stdio], 1037b08721eSAndrew Jeffery [AS_HELP_STRING([--with-stdio], [Support logging to stdio])], 1047b08721eSAndrew Jeffery [], 1057b08721eSAndrew Jeffery [with_stdio=check]) 1067b08721eSAndrew Jeffery 1077b08721eSAndrew JefferyAS_IF([test "x$with_stdio" != "xno"], 1087b08721eSAndrew Jeffery [AC_COMPILE_IFELSE( 1097b08721eSAndrew Jeffery [AC_LANG_PROGRAM([[ 1107b08721eSAndrew Jeffery#include <stdarg.h> 1117b08721eSAndrew Jeffery#include <stdio.h> 1127b08721eSAndrew Jefferyvoid check_vprintf(const char *fmt, ...) 1137b08721eSAndrew Jeffery{ 1147b08721eSAndrew Jeffery va_list ap; 1157b08721eSAndrew Jeffery va_start(ap, fmt); 1167b08721eSAndrew Jeffery vprintf(fmt, ap); 1177b08721eSAndrew Jeffery va_end(ap); 1187b08721eSAndrew Jeffery} 1197b08721eSAndrew Jeffery ]],[[ 1207b08721eSAndrew Jeffery check_vprintf("\n"); 1217b08721eSAndrew Jeffery ]])], 1227b08721eSAndrew Jeffery [AC_DEFINE([MCTP_HAVE_STDIO], [1], [Define to enable stdio functions])], 1237b08721eSAndrew Jeffery [])], 1247b08721eSAndrew Jeffery []) 1257b08721eSAndrew Jeffery 1267b08721eSAndrew JefferyAC_ARG_WITH([default-alloc], 1277b08721eSAndrew Jeffery [AS_HELP_STRING([--with-default-alloc], 1287b08721eSAndrew Jeffery [Use libc malloc and free for heap memory])], 1297b08721eSAndrew Jeffery [], 1307b08721eSAndrew Jeffery [with_default_alloc=check]) 1317b08721eSAndrew Jeffery 1327b08721eSAndrew JefferyAS_IF([test "x$with_default_alloc" != "xno"], 1337b08721eSAndrew Jeffery [AC_LINK_IFELSE( 1347b08721eSAndrew Jeffery [AC_LANG_PROGRAM([[ 1357b08721eSAndrew Jeffery#include <stdlib.h> 1367b08721eSAndrew Jeffery ]], [[ 1377b08721eSAndrew Jefferyfree(malloc(4096)); 1387b08721eSAndrew Jeffery ]])], 1397b08721eSAndrew Jeffery [AC_DEFINE([MCTP_DEFAULT_ALLOC], 1407b08721eSAndrew Jeffery [1], 1417b08721eSAndrew Jeffery [Define to use libc malloc and free for heap memory])], 1427b08721eSAndrew Jeffery [])], 1437b08721eSAndrew Jeffery []) 144c7e764a2SJeremy Kerr 145c7e764a2SJeremy Kerr# Enable all bindings. AC_ARG_ENABLE in future. 146b2ef62baSJeremy KerrAM_CONDITIONAL([LIBMCTP_BINDING_serial], [true]) 147b2ef62baSJeremy KerrAM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true]) 148b2ef62baSJeremy Kerr 1498d53b1c3SAndrew Jeffery# Check for valgrind 1508d53b1c3SAndrew JefferyAS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) 1518d53b1c3SAndrew Jefferym4_foreach([vgtool], [valgrind_tool_list], 1528d53b1c3SAndrew Jeffery [AX_VALGRIND_DFLT(vgtool, [off])]) 1538d53b1c3SAndrew JefferyAX_VALGRIND_DFLT([memcheck], [on]) 1548d53b1c3SAndrew JefferyAX_VALGRIND_CHECK 1558d53b1c3SAndrew JefferyAM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) 1568d53b1c3SAndrew Jefferym4_foreach([vgtool], [valgrind_tool_list], 1578d53b1c3SAndrew Jeffery [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) 1588d53b1c3SAndrew Jeffery 1597344ac2aSAndrew JefferyAX_CODE_COVERAGE 1607344ac2aSAndrew Jefferym4_ifdef([_AX_CODE_COVERAGE_RULES], 1617344ac2aSAndrew Jeffery [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])], 1627344ac2aSAndrew Jeffery [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])]) 1637344ac2aSAndrew JefferyAX_ADD_AM_MACRO_STATIC([]) 1647344ac2aSAndrew Jeffery 165400766f9SKonstantin AladyshevAC_CONFIG_FILES([Makefile libmctp.pc]) 166b2ef62baSJeremy KerrAC_OUTPUT 167