blob: 6b361245783099fde040b4469fd19e429db9783d [file] [log] [blame]
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +08001# Initialization
2AC_PREREQ([2.69])
3AC_INIT([libmctp], 0.9, [https://github.com/openbmc/libmctp/issues])
4AC_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
Xiaochao Ma1e496c82020-01-16 17:19:11 +080024AC_ARG_WITH([systemdsystemunitdir],
25 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
26 [],
27 [with_systemdsystemunitdir=auto]
28)
29AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
30 [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
31 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
32 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
33 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]
34 )
35 with_systemdsystemunitdir=no],
36 [with_systemdsystemunitdir="$def_systemdsystemunitdir"]
37 )]
38)
39AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
40 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]
41)
42AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
Jeremy Kerr80971f82019-08-29 09:57:58 +053043
Andrew Jeffery7b087212020-03-17 23:09:43 +103044AC_ARG_WITH([syslog],
45 [AS_HELP_STRING([--with-syslog], [Support logging to syslog])],
46 [],
47 [with_syslog=check])
48
49AS_IF([test "x$with_syslog" != "xno"],
50 [AC_COMPILE_IFELSE(
51 [AC_LANG_PROGRAM([[
52#include <stdarg.h>
53#include <syslog.h>
54
55void check_vsyslog(int level, const char *fmt, ...)
56{
57 va_list ap;
58 va_start(ap, fmt);
59 vsyslog(0, fmt, ap);
60 va_end(ap);
61}
62 ]],[[
63 check_vsyslog(0, "\n");
64 ]])],
65 [AC_DEFINE([MCTP_HAVE_SYSLOG], [1], [Define to enable syslog])],
66 [])],
67 [])
68
69AC_ARG_WITH([fileio],
70 [AS_HELP_STRING([--with-fileio],
71 [Support interfaces based on file-descriptors])],
72 [],
73 [with_fileio=check])
74
75AS_IF([test "x$with_fileio" = "xcheck"],
76 [AC_DEFINE([MCTP_HAVE_FILEIO], [(HAVE_UNISTD_H && HAVE_FCNTL_H)],
77 [Support interfaces based on file-descriptors])],
78 [AS_IF([test "x$with_fileio" = "xyes"],
79 [AC_DEFINE([MCTP_HAVE_FILEIO], [1],
80 [Support interfaces based on file-descriptors])],
81 [])])
82
83AC_ARG_WITH([stdio],
84 [AS_HELP_STRING([--with-stdio], [Support logging to stdio])],
85 [],
86 [with_stdio=check])
87
88AS_IF([test "x$with_stdio" != "xno"],
89 [AC_COMPILE_IFELSE(
90 [AC_LANG_PROGRAM([[
91#include <stdarg.h>
92#include <stdio.h>
93void check_vprintf(const char *fmt, ...)
94{
95 va_list ap;
96 va_start(ap, fmt);
97 vprintf(fmt, ap);
98 va_end(ap);
99}
100 ]],[[
101 check_vprintf("\n");
102 ]])],
103 [AC_DEFINE([MCTP_HAVE_STDIO], [1], [Define to enable stdio functions])],
104 [])],
105 [])
106
107AC_ARG_WITH([default-alloc],
108 [AS_HELP_STRING([--with-default-alloc],
109 [Use libc malloc and free for heap memory])],
110 [],
111 [with_default_alloc=check])
112
113AS_IF([test "x$with_default_alloc" != "xno"],
114 [AC_LINK_IFELSE(
115 [AC_LANG_PROGRAM([[
116#include <stdlib.h>
117 ]], [[
118free(malloc(4096));
119 ]])],
120 [AC_DEFINE([MCTP_DEFAULT_ALLOC],
121 [1],
122 [Define to use libc malloc and free for heap memory])],
123 [])],
124 [])
Jeremy Kerrc7e764a2019-05-28 16:49:03 +0800125
126# Enable all bindings. AC_ARG_ENABLE in future.
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +0800127AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true])
128AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true])
129
Andrew Jeffery8d53b1c2020-05-29 08:43:04 +0930130# Check for valgrind
131AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
132m4_foreach([vgtool], [valgrind_tool_list],
133 [AX_VALGRIND_DFLT(vgtool, [off])])
134AX_VALGRIND_DFLT([memcheck], [on])
135AX_VALGRIND_CHECK
136AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
137m4_foreach([vgtool], [valgrind_tool_list],
138 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
139
Andrew Jeffery7344ac22020-01-10 16:13:07 +1030140AX_CODE_COVERAGE
141m4_ifdef([_AX_CODE_COVERAGE_RULES],
142 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
143 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
144AX_ADD_AM_MACRO_STATIC([])
145
Jeremy Kerr80971f82019-08-29 09:57:58 +0530146AC_CONFIG_FILES([Makefile libmctp.pc])
Jeremy Kerrb2ef62b2019-05-28 09:38:25 +0800147AC_OUTPUT