blob: 1e8a419bb28692b1bd07f4eca95a9a2754da9409 [file] [log] [blame]
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +08001# Initialization
2AC_PREREQ([2.69])
Andrew Jeffery8536cfc2020-06-13 00:33:55 +09303AC_INIT([libmctp], 0.10, [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 Jeffery745b1d12021-05-11 11:14:53 +093031AC_ARG_ENABLE([astlpc-raw-kcs],
32 [AS_HELP_STRING([--enable-astlpc-raw-kcs],
33 [Use udev rules to symlink raw-kcs device nodes for the astlpc binding])])
Andrew Jeffery9f5b47a2021-05-11 15:05:14 +093034AM_CONDITIONAL([LIBMCTP_UDEV_RAW_KCS], [test -n "$udevdir" -a "x$enable_astlpc_raw_kcs" = "xyes"])
Andrew Jeffery745b1d12021-05-11 11:14:53 +093035
Xiaochao Ma1e496c82020-01-16 17:19:11 +080036AC_ARG_WITH([systemdsystemunitdir],
37 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
38 [],
39 [with_systemdsystemunitdir=auto]
40)
41AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
42 [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
43 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
44 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
45 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]
46 )
47 with_systemdsystemunitdir=no],
48 [with_systemdsystemunitdir="$def_systemdsystemunitdir"]
49 )]
50)
51AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
52 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]
53)
54AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
Jeremy Kerr80971f82019-08-29 09:57:58 +053055
Andrew Jeffery7b087212020-03-17 23:09:43 +103056AC_ARG_WITH([syslog],
57 [AS_HELP_STRING([--with-syslog], [Support logging to syslog])],
58 [],
59 [with_syslog=check])
60
61AS_IF([test "x$with_syslog" != "xno"],
62 [AC_COMPILE_IFELSE(
63 [AC_LANG_PROGRAM([[
64#include <stdarg.h>
65#include <syslog.h>
66
67void check_vsyslog(int level, const char *fmt, ...)
68{
69 va_list ap;
70 va_start(ap, fmt);
71 vsyslog(0, fmt, ap);
72 va_end(ap);
73}
74 ]],[[
75 check_vsyslog(0, "\n");
76 ]])],
77 [AC_DEFINE([MCTP_HAVE_SYSLOG], [1], [Define to enable syslog])],
78 [])],
79 [])
80
81AC_ARG_WITH([fileio],
82 [AS_HELP_STRING([--with-fileio],
83 [Support interfaces based on file-descriptors])],
84 [],
85 [with_fileio=check])
86
87AS_IF([test "x$with_fileio" = "xcheck"],
88 [AC_DEFINE([MCTP_HAVE_FILEIO], [(HAVE_UNISTD_H && HAVE_FCNTL_H)],
89 [Support interfaces based on file-descriptors])],
90 [AS_IF([test "x$with_fileio" = "xyes"],
91 [AC_DEFINE([MCTP_HAVE_FILEIO], [1],
92 [Support interfaces based on file-descriptors])],
93 [])])
94
95AC_ARG_WITH([stdio],
96 [AS_HELP_STRING([--with-stdio], [Support logging to stdio])],
97 [],
98 [with_stdio=check])
99
100AS_IF([test "x$with_stdio" != "xno"],
101 [AC_COMPILE_IFELSE(
102 [AC_LANG_PROGRAM([[
103#include <stdarg.h>
104#include <stdio.h>
105void check_vprintf(const char *fmt, ...)
106{
107 va_list ap;
108 va_start(ap, fmt);
109 vprintf(fmt, ap);
110 va_end(ap);
111}
112 ]],[[
113 check_vprintf("\n");
114 ]])],
115 [AC_DEFINE([MCTP_HAVE_STDIO], [1], [Define to enable stdio functions])],
116 [])],
117 [])
118
119AC_ARG_WITH([default-alloc],
120 [AS_HELP_STRING([--with-default-alloc],
121 [Use libc malloc and free for heap memory])],
122 [],
123 [with_default_alloc=check])
124
125AS_IF([test "x$with_default_alloc" != "xno"],
126 [AC_LINK_IFELSE(
127 [AC_LANG_PROGRAM([[
128#include <stdlib.h>
129 ]], [[
130free(malloc(4096));
131 ]])],
132 [AC_DEFINE([MCTP_DEFAULT_ALLOC],
133 [1],
134 [Define to use libc malloc and free for heap memory])],
135 [])],
136 [])
Jeremy Kerrc7e764a2019-05-28 16:49:03 +0800137
138# Enable all bindings. AC_ARG_ENABLE in future.
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +0800139AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true])
140AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true])
141
Andrew Jeffery8d53b1c2020-05-29 08:43:04 +0930142# Check for valgrind
143AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
144m4_foreach([vgtool], [valgrind_tool_list],
145 [AX_VALGRIND_DFLT(vgtool, [off])])
146AX_VALGRIND_DFLT([memcheck], [on])
147AX_VALGRIND_CHECK
148AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
149m4_foreach([vgtool], [valgrind_tool_list],
150 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
151
Andrew Jeffery7344ac22020-01-10 16:13:07 +1030152AX_CODE_COVERAGE
153m4_ifdef([_AX_CODE_COVERAGE_RULES],
154 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
155 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
156AX_ADD_AM_MACRO_STATIC([])
157
Andrew Jeffery745b1d12021-05-11 11:14:53 +0930158AC_CONFIG_FILES([Makefile libmctp.pc udev/rules.d/mctp0-raw-kcs3.rules
159 udev/rules.d/mctp0-raw-kcs4.rules])
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +0800160AC_OUTPUT