-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
122 lines (102 loc) · 3.77 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#AC_PREREQ(2.60)
m4_include(m4/version.m4)
AC_INIT(yamldt, m4_defn([VERSION_NUMBER]), [email protected])
AC_CONFIG_MACRO_DIR([m4])
AC_REVISION([VERSION_NUMBER])
AC_CONFIG_SRCDIR([yamldt.c])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AM_EXTRA_RECURSIVE_TARGETS([validate])
# enable maintainer mode by default
AM_MAINTAINER_MODE([enable])
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
# Checks for libraries.
AM_PROG_LIBTOOL
# libyaml
LIBYAML_REQUIRED_VERSION=0.1
PKG_CHECK_MODULES(LIBYAML, yaml-0.1 >= $LIBYAML_REQUIRED_VERSION,[])
if $PKG_CONFIG --atleast-version "0.1" yaml-0.1 ; then
AC_DEFINE([HAVE_LIBYAML_H], [], [Have libyaml])
have_libyaml=true
else
have_libyaml=false
fi
AM_CONDITIONAL([HAVE_LIBYAML], [test x$have_libyaml = xtrue])
# We don't need YAML support in DTC anymore
# check whether a dtc exists in the path
AC_PATH_PROGS_FEATURE_CHECK([DTC], [dtc],
[[ echo '/dts-v1/; / { };' | \
$ac_path_DTC -I dts -O dtb - -o - 2>/dev/null >/dev/null && \
ac_cv_path_DTC=$ac_path_DTC ac_path_DTC_found=:]])
AC_SUBST([DTC], [$ac_cv_path_DTC])
# check if we can run DTC
AM_CONDITIONAL([RUN_DTC], [test x$ac_cv_path_DTC != x])
AM_COND_IF([RUN_DTC], [can_RUN_DTC=yes], [can_RUN_DTC=no])
if test x$can_RUN_DTC = xyes ; then
AC_MSG_RESULT([$ac_cv_path_DTC])
else
AC_MSG_RESULT([not found])
fi
AC_CHECK_HEADERS([elf.h], [has_ELF_H=true], [has_ELF_H=false])
AC_CHECK_HEADERS([libelf.h], [has_LIBELF_H=true], [has_LIBELF_H=false])
# libelf (we only need the headers)
# On debian/ubuntu libelf is not in pkg-config so...
if test x$has_LIBELF_H = xtrue ; then
AM_CONDITIONAL([HAVE_LIBELF], [test x$have_libelf = xtrue])
AC_ARG_VAR([LIBELF_CFLAGS], "")
AC_ARG_VAR([LIBELF_LIBS], "")
else
LIBELF_REQUIRED_VERSION=0.8
PKG_CHECK_MODULES(LIBELF, libelf >= $LIBELF_REQUIRED_VERSION,[])
if $PKG_CONFIG --atleast-version "0.8" libelf ; then
AC_DEFINE([HAVE_LIBELF_H], [], [Have libelf])
have_libelf=true
else
have_libelf=false
fi
fi
AM_CONDITIONAL([HAVE_LIBELF], [test x$have_libelf = xtrue])
AC_MSG_CHECKING([for ebpf compiler])
# eBPF compiler available?
AC_PATH_PROGS_FEATURE_CHECK([EBPFCC], [clang-5.0 clang-4.0 clang-3.9 clang],
[[ echo 'unsigned long long entry(void *mem) { return 1; }' | \
$ac_path_EBPFCC 2>/dev/null -ffreestanding -x c -c -O2 -target bpf - -o /dev/null && \
ac_cv_path_EBPFCC=$ac_path_EBPFCC ac_path_EBPFCC_found=:]])
AC_SUBST([EBPFCC], [$ac_cv_path_EBPFCC])
# check if we can run CLANG
AM_CONDITIONAL([RUN_EBPFCC], [test x$ac_cv_path_EBPFCC != x])
AM_COND_IF([RUN_EBPFCC], [can_RUN_EBPFCC=yes], [can_RUN_EBPFCC=no])
if test x$can_RUN_EBPFCC = xyes ; then
AC_MSG_RESULT([$ac_cv_path_EBPFCC])
else
AC_MSG_RESULT([not found])
fi
# check if we can execute ebpf
AC_MSG_CHECKING([whether we can execute ebpf programs])
AM_CONDITIONAL([EXEC_EBPF], [test x$have_libelf = xtrue -o x$has_ELF_H = xtrue])
AM_COND_IF([EXEC_EBPF], [can_EXEC_EBPF=yes], [can_EXEC_EBPF=no])
AC_MSG_RESULT([$can_EXEC_EBPF])
if test x$can_EXEC_EBPF = xyes ; then
AC_DEFINE([CAN_RUN_EBPF], [], [can run ebpf])
fi
# copy subdirs to allow foreign builds to work
cp_subdirs=
AM_CONDITIONAL([COPY_PORT], [ test x$srcdir != "x." ])
AM_COND_IF([COPY_PORT], [ cp_subdirs="${cp_subdirs} include port" ])
AM_CONDITIONAL([COPY_TESTS], [ test x$srcdir != "x." -a x$can_RUN_DTC = xyes ])
AM_COND_IF([COPY_TESTS], [ cp_subdirs="${cp_subdirs} test-suite"])
AC_CONFIG_COMMANDS_POST([\
abs_srcdir=`cd $srcdir && pwd`; \
if test "x$cp_subdirs" != x -a "x$abs_srcdir" != x ; then
for subdir in $cp_subdirs; do \
cp -as "${abs_srcdir}/${subdir}" "${subdir}"; \
done; \
fi; \
])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT