blob: 28d517ed2e14481db896c71af5ad7fc1ec2f426d [file] [log] [blame]
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +08001# Initialization
2AC_PREREQ([2.69])
Andrew Jefferye750cbc2022-02-17 17:02:18 +10303AC_INIT([libmctp], 0.11, [https://github.com/openbmc/libmctp/issues])
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +08004AC_CONFIG_HEADERS([config.h])
5AC_CONFIG_MACRO_DIRS([m4])
Andrew Jefferyd09253f2020-02-26 11:00:37 +10306AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror -Wno-portability foreign dist-xz])
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +08007AM_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
Andrew Jeffery3286f172020-03-17 23:04:13 +103018AC_CHECK_HEADERS_ONCE([endian.h])
Andrew Jeffery7b087212020-03-17 23:09:43 +103019AC_CHECK_HEADERS_ONCE([unistd.h fcntl.h])
Andrew Jeffery3286f172020-03-17 23:04:13 +103020
Jeremy Kerr80971f82019-08-29 09:57:58 +053021# pkg-config
22PKG_PROG_PKG_CONFIG
23PKG_INSTALLDIR
Andrew Jeffery745b1d12021-05-11 11:14:53 +093024PKG_CHECK_MODULES(udev,
25 udev,
Andrew Jeffery9f5b47a2021-05-11 15:05:14 +093026 [PKG_CHECK_VAR(udevdir, udev, udevdir)],
Andrew Jeffery745b1d12021-05-11 11:14:53 +093027 [])
28
Andrew Jeffery9f5b47a2021-05-11 15:05:14 +093029AC_SUBST([udevrulesdir], [$udevdir/rules.d])
30
Andrew Jefferycad47302021-08-20 21:37:57 +093031AC_ARG_ENABLE([capture],
32 [AC_HELP_STRING([--enable-capture],
33 [Use libpcap to capture messages and packets])])
34AS_IF([test "x$enable_capture" = "xyes"],
35 [PKG_CHECK_MODULES(pcap, libpcap,
36 [AC_DEFINE([HAVE_PCAP], [1],
37 [Define to 1 if you have libpcap])],
38 [])],
39 [])
40AC_SUBST([pcap_CFLAGS])
41AC_SUBST([pcap_LIBS])
42AM_CONDITIONAL([HAVE_PCAP], [test "x$enable_capture" = "xyes"])
43
Andrew Jeffery745b1d12021-05-11 11:14:53 +093044AC_ARG_ENABLE([astlpc-raw-kcs],
45 [AS_HELP_STRING([--enable-astlpc-raw-kcs],
46 [Use udev rules to symlink raw-kcs device nodes for the astlpc binding])])
Andrew Jeffery9f5b47a2021-05-11 15:05:14 +093047AM_CONDITIONAL([LIBMCTP_UDEV_RAW_KCS], [test -n "$udevdir" -a "x$enable_astlpc_raw_kcs" = "xyes"])
Andrew Jeffery745b1d12021-05-11 11:14:53 +093048
Xiaochao Ma1e496c82020-01-16 17:19:11 +080049AC_ARG_WITH([systemdsystemunitdir],
50 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
51 [],
52 [with_systemdsystemunitdir=auto]
53)
54AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
55 [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
56 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
57 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
58 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]
59 )
60 with_systemdsystemunitdir=no],
61 [with_systemdsystemunitdir="$def_systemdsystemunitdir"]
62 )]
63)
Andrew Jefferyd4103f82021-06-16 14:39:36 +093064
65AC_CHECK_HEADER([systemd/sd-daemon.h],
66 [AC_DEFINE([HAVE_SYSTEMD_SD_DAEMON_H], [1],
67 [Define to 1 if you have <systemd/sd-daemon.h>.])],
68 [])
69AC_CHECK_LIB([systemd], [sd_listen_fds])
Xiaochao Ma1e496c82020-01-16 17:19:11 +080070AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
71 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]
72)
73AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
Jeremy Kerr80971f82019-08-29 09:57:58 +053074
Andrew Jeffery7b087212020-03-17 23:09:43 +103075AC_ARG_WITH([syslog],
76 [AS_HELP_STRING([--with-syslog], [Support logging to syslog])],
77 [],
78 [with_syslog=check])
79
80AS_IF([test "x$with_syslog" != "xno"],
81 [AC_COMPILE_IFELSE(
82 [AC_LANG_PROGRAM([[
83#include <stdarg.h>
84#include <syslog.h>
85
86void check_vsyslog(int level, const char *fmt, ...)
87{
88 va_list ap;
89 va_start(ap, fmt);
90 vsyslog(0, fmt, ap);
91 va_end(ap);
92}
93 ]],[[
94 check_vsyslog(0, "\n");
95 ]])],
96 [AC_DEFINE([MCTP_HAVE_SYSLOG], [1], [Define to enable syslog])],
97 [])],
98 [])
99
100AC_ARG_WITH([fileio],
101 [AS_HELP_STRING([--with-fileio],
102 [Support interfaces based on file-descriptors])],
103 [],
104 [with_fileio=check])
105
106AS_IF([test "x$with_fileio" = "xcheck"],
107 [AC_DEFINE([MCTP_HAVE_FILEIO], [(HAVE_UNISTD_H && HAVE_FCNTL_H)],
108 [Support interfaces based on file-descriptors])],
109 [AS_IF([test "x$with_fileio" = "xyes"],
110 [AC_DEFINE([MCTP_HAVE_FILEIO], [1],
111 [Support interfaces based on file-descriptors])],
112 [])])
113
114AC_ARG_WITH([stdio],
115 [AS_HELP_STRING([--with-stdio], [Support logging to stdio])],
116 [],
117 [with_stdio=check])
118
119AS_IF([test "x$with_stdio" != "xno"],
120 [AC_COMPILE_IFELSE(
121 [AC_LANG_PROGRAM([[
122#include <stdarg.h>
123#include <stdio.h>
124void check_vprintf(const char *fmt, ...)
125{
126 va_list ap;
127 va_start(ap, fmt);
128 vprintf(fmt, ap);
129 va_end(ap);
130}
131 ]],[[
132 check_vprintf("\n");
133 ]])],
134 [AC_DEFINE([MCTP_HAVE_STDIO], [1], [Define to enable stdio functions])],
135 [])],
136 [])
137
138AC_ARG_WITH([default-alloc],
139 [AS_HELP_STRING([--with-default-alloc],
140 [Use libc malloc and free for heap memory])],
141 [],
142 [with_default_alloc=check])
143
144AS_IF([test "x$with_default_alloc" != "xno"],
145 [AC_LINK_IFELSE(
146 [AC_LANG_PROGRAM([[
147#include <stdlib.h>
148 ]], [[
149free(malloc(4096));
150 ]])],
151 [AC_DEFINE([MCTP_DEFAULT_ALLOC],
152 [1],
153 [Define to use libc malloc and free for heap memory])],
154 [])],
155 [])
Jeremy Kerrc7e764a2019-05-28 16:49:03 +0800156
157# Enable all bindings. AC_ARG_ENABLE in future.
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +0800158AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true])
159AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true])
160
Andrew Jeffery8d53b1c2020-05-29 08:43:04 +0930161# Check for valgrind
162AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
163m4_foreach([vgtool], [valgrind_tool_list],
164 [AX_VALGRIND_DFLT(vgtool, [off])])
165AX_VALGRIND_DFLT([memcheck], [on])
166AX_VALGRIND_CHECK
167AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
168m4_foreach([vgtool], [valgrind_tool_list],
169 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
170
Andrew Jeffery7344ac22020-01-10 16:13:07 +1030171AX_CODE_COVERAGE
172m4_ifdef([_AX_CODE_COVERAGE_RULES],
173 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
174 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
175AX_ADD_AM_MACRO_STATIC([])
176
Andrew Jeffery745b1d12021-05-11 11:14:53 +0930177AC_CONFIG_FILES([Makefile libmctp.pc udev/rules.d/mctp0-raw-kcs3.rules
178 udev/rules.d/mctp0-raw-kcs4.rules])
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +0800179AC_OUTPUT