xref: /openbmc/libmctp/configure.ac (revision 745b1d15)
1# Initialization
2AC_PREREQ([2.69])
3AC_INIT([libmctp], 0.10, [https://github.com/openbmc/libmctp/issues])
4AC_CONFIG_HEADERS([config.h])
5AC_CONFIG_MACRO_DIRS([m4])
6AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror -Wno-portability foreign dist-xz])
7AM_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
18AC_CHECK_HEADERS_ONCE([endian.h])
19AC_CHECK_HEADERS_ONCE([unistd.h fcntl.h])
20
21# pkg-config
22PKG_PROG_PKG_CONFIG
23PKG_INSTALLDIR
24PKG_CHECK_MODULES(udev,
25                  udev,
26                  [PKG_CHECK_VAR(udevrulesdir, udev, udevdir)],
27                  [])
28
29AC_ARG_ENABLE([astlpc-raw-kcs],
30              [AS_HELP_STRING([--enable-astlpc-raw-kcs],
31                              [Use udev rules to symlink raw-kcs device nodes for the astlpc binding])])
32AM_CONDITIONAL([LIBMCTP_UDEV_RAW_KCS], [test -n "$udevrulesdir" -a "x$enable_astlpc_raw_kcs" = "xyes"])
33
34AC_ARG_WITH([systemdsystemunitdir],
35     [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
36     [],
37     [with_systemdsystemunitdir=auto]
38)
39AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
40    [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
41     AS_IF([test "x$def_systemdsystemunitdir" = "x"],
42           [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
43                  [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]
44            )
45            with_systemdsystemunitdir=no],
46           [with_systemdsystemunitdir="$def_systemdsystemunitdir"]
47     )]
48)
49AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
50      [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]
51)
52AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
53
54AC_ARG_WITH([syslog],
55            [AS_HELP_STRING([--with-syslog], [Support logging to syslog])],
56            [],
57            [with_syslog=check])
58
59AS_IF([test "x$with_syslog" != "xno"],
60      [AC_COMPILE_IFELSE(
61       [AC_LANG_PROGRAM([[
62#include <stdarg.h>
63#include <syslog.h>
64
65void check_vsyslog(int level, const char *fmt, ...)
66{
67    va_list ap;
68    va_start(ap, fmt);
69    vsyslog(0, fmt, ap);
70    va_end(ap);
71}
72        ]],[[
73    check_vsyslog(0, "\n");
74        ]])],
75       [AC_DEFINE([MCTP_HAVE_SYSLOG], [1], [Define to enable syslog])],
76       [])],
77      [])
78
79AC_ARG_WITH([fileio],
80            [AS_HELP_STRING([--with-fileio],
81                            [Support interfaces based on file-descriptors])],
82            [],
83            [with_fileio=check])
84
85AS_IF([test "x$with_fileio" = "xcheck"],
86      [AC_DEFINE([MCTP_HAVE_FILEIO], [(HAVE_UNISTD_H && HAVE_FCNTL_H)],
87                 [Support interfaces based on file-descriptors])],
88      [AS_IF([test "x$with_fileio" = "xyes"],
89             [AC_DEFINE([MCTP_HAVE_FILEIO], [1],
90                        [Support interfaces based on file-descriptors])],
91             [])])
92
93AC_ARG_WITH([stdio],
94            [AS_HELP_STRING([--with-stdio], [Support logging to stdio])],
95            [],
96            [with_stdio=check])
97
98AS_IF([test "x$with_stdio" != "xno"],
99      [AC_COMPILE_IFELSE(
100       [AC_LANG_PROGRAM([[
101#include <stdarg.h>
102#include <stdio.h>
103void check_vprintf(const char *fmt, ...)
104{
105    va_list ap;
106    va_start(ap, fmt);
107    vprintf(fmt, ap);
108    va_end(ap);
109}
110        ]],[[
111    check_vprintf("\n");
112        ]])],
113       [AC_DEFINE([MCTP_HAVE_STDIO], [1], [Define to enable stdio functions])],
114       [])],
115      [])
116
117AC_ARG_WITH([default-alloc],
118            [AS_HELP_STRING([--with-default-alloc],
119                            [Use libc malloc and free for heap memory])],
120            [],
121            [with_default_alloc=check])
122
123AS_IF([test "x$with_default_alloc" != "xno"],
124      [AC_LINK_IFELSE(
125       [AC_LANG_PROGRAM([[
126#include <stdlib.h>
127        ]], [[
128free(malloc(4096));
129        ]])],
130       [AC_DEFINE([MCTP_DEFAULT_ALLOC],
131                  [1],
132                  [Define to use libc malloc and free for heap memory])],
133       [])],
134      [])
135
136# Enable all bindings. AC_ARG_ENABLE in future.
137AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true])
138AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true])
139
140# Check for valgrind
141AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
142m4_foreach([vgtool], [valgrind_tool_list],
143    [AX_VALGRIND_DFLT(vgtool, [off])])
144AX_VALGRIND_DFLT([memcheck], [on])
145AX_VALGRIND_CHECK
146AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
147m4_foreach([vgtool], [valgrind_tool_list],
148    [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
149
150AX_CODE_COVERAGE
151m4_ifdef([_AX_CODE_COVERAGE_RULES],
152    [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
153    [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
154AX_ADD_AM_MACRO_STATIC([])
155
156AC_CONFIG_FILES([Makefile libmctp.pc udev/rules.d/mctp0-raw-kcs3.rules
157                 udev/rules.d/mctp0-raw-kcs4.rules])
158AC_OUTPUT
159