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