blob: bbf1c0ac24c4d6b828e8d7d1ef4964e1ff32a511 [file] [log] [blame]
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +08001# Initialization
Andrew Jeffery895083b2023-10-06 23:15:01 +10302AC_PREREQ([2.71])
3AC_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 Jeffery9f5b47a2021-05-11 15:05:14 +093024
Andrew Jefferycad47302021-08-20 21:37:57 +093025AC_ARG_ENABLE([capture],
Andrew Jeffery895083b2023-10-06 23:15:01 +103026 [AS_HELP_STRING([--enable-capture],[Use libpcap to capture messages and packets])])
Andrew Jefferycad47302021-08-20 21:37:57 +093027AS_IF([test "x$enable_capture" = "xyes"],
28 [PKG_CHECK_MODULES(pcap, libpcap,
29 [AC_DEFINE([HAVE_PCAP], [1],
30 [Define to 1 if you have libpcap])],
31 [])],
32 [])
33AC_SUBST([pcap_CFLAGS])
34AC_SUBST([pcap_LIBS])
35AM_CONDITIONAL([HAVE_PCAP], [test "x$enable_capture" = "xyes"])
36
Xiaochao Ma1e496c82020-01-16 17:19:11 +080037AC_ARG_WITH([systemdsystemunitdir],
38 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
39 [],
40 [with_systemdsystemunitdir=auto]
41)
42AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
43 [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
44 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
45 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
46 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]
47 )
48 with_systemdsystemunitdir=no],
49 [with_systemdsystemunitdir="$def_systemdsystemunitdir"]
50 )]
51)
Andrew Jefferyd4103f82021-06-16 14:39:36 +093052
53AC_CHECK_HEADER([systemd/sd-daemon.h],
54 [AC_DEFINE([HAVE_SYSTEMD_SD_DAEMON_H], [1],
55 [Define to 1 if you have <systemd/sd-daemon.h>.])],
56 [])
57AC_CHECK_LIB([systemd], [sd_listen_fds])
Xiaochao Ma1e496c82020-01-16 17:19:11 +080058AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
59 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]
60)
61AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
Jeremy Kerr80971f82019-08-29 09:57:58 +053062
Andrew Jeffery7b087212020-03-17 23:09:43 +103063AC_ARG_WITH([syslog],
64 [AS_HELP_STRING([--with-syslog], [Support logging to syslog])],
65 [],
66 [with_syslog=check])
67
68AS_IF([test "x$with_syslog" != "xno"],
69 [AC_COMPILE_IFELSE(
70 [AC_LANG_PROGRAM([[
71#include <stdarg.h>
72#include <syslog.h>
73
74void check_vsyslog(int level, const char *fmt, ...)
75{
76 va_list ap;
77 va_start(ap, fmt);
78 vsyslog(0, fmt, ap);
79 va_end(ap);
80}
81 ]],[[
82 check_vsyslog(0, "\n");
83 ]])],
84 [AC_DEFINE([MCTP_HAVE_SYSLOG], [1], [Define to enable syslog])],
85 [])],
86 [])
87
88AC_ARG_WITH([fileio],
89 [AS_HELP_STRING([--with-fileio],
90 [Support interfaces based on file-descriptors])],
91 [],
92 [with_fileio=check])
93
94AS_IF([test "x$with_fileio" = "xcheck"],
95 [AC_DEFINE([MCTP_HAVE_FILEIO], [(HAVE_UNISTD_H && HAVE_FCNTL_H)],
96 [Support interfaces based on file-descriptors])],
97 [AS_IF([test "x$with_fileio" = "xyes"],
98 [AC_DEFINE([MCTP_HAVE_FILEIO], [1],
99 [Support interfaces based on file-descriptors])],
100 [])])
101
102AC_ARG_WITH([stdio],
103 [AS_HELP_STRING([--with-stdio], [Support logging to stdio])],
104 [],
105 [with_stdio=check])
106
107AS_IF([test "x$with_stdio" != "xno"],
108 [AC_COMPILE_IFELSE(
109 [AC_LANG_PROGRAM([[
110#include <stdarg.h>
111#include <stdio.h>
112void check_vprintf(const char *fmt, ...)
113{
114 va_list ap;
115 va_start(ap, fmt);
116 vprintf(fmt, ap);
117 va_end(ap);
118}
119 ]],[[
120 check_vprintf("\n");
121 ]])],
122 [AC_DEFINE([MCTP_HAVE_STDIO], [1], [Define to enable stdio functions])],
123 [])],
124 [])
125
126AC_ARG_WITH([default-alloc],
127 [AS_HELP_STRING([--with-default-alloc],
128 [Use libc malloc and free for heap memory])],
129 [],
130 [with_default_alloc=check])
131
132AS_IF([test "x$with_default_alloc" != "xno"],
133 [AC_LINK_IFELSE(
134 [AC_LANG_PROGRAM([[
135#include <stdlib.h>
136 ]], [[
137free(malloc(4096));
138 ]])],
139 [AC_DEFINE([MCTP_DEFAULT_ALLOC],
140 [1],
141 [Define to use libc malloc and free for heap memory])],
142 [])],
143 [])
Jeremy Kerrc7e764a2019-05-28 16:49:03 +0800144
145# Enable all bindings. AC_ARG_ENABLE in future.
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +0800146AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true])
147AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true])
148
Andrew Jeffery8d53b1c2020-05-29 08:43:04 +0930149# Check for valgrind
150AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
151m4_foreach([vgtool], [valgrind_tool_list],
152 [AX_VALGRIND_DFLT(vgtool, [off])])
153AX_VALGRIND_DFLT([memcheck], [on])
154AX_VALGRIND_CHECK
155AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
156m4_foreach([vgtool], [valgrind_tool_list],
157 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
158
Andrew Jeffery7344ac22020-01-10 16:13:07 +1030159AX_CODE_COVERAGE
160m4_ifdef([_AX_CODE_COVERAGE_RULES],
161 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
162 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
163AX_ADD_AM_MACRO_STATIC([])
164
Konstantin Aladyshev400766f2023-09-07 15:57:25 +0300165AC_CONFIG_FILES([Makefile libmctp.pc])
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +0800166AC_OUTPUT