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
|
AC_PREREQ(2.65)
# Tartan release version
m4_define(tartan_version_major, 0)
m4_define(tartan_version_minor, 4)
m4_define(tartan_version_micro, 0)
AC_INIT([Tartan],
[tartan_version_major.tartan_version_minor.tartan_version_micro],
[https://gitlab.freedesktop.org/tartan/tartan/issues/new],
[tartan],[http://www.freedesktop.org/software/tartan/])
AX_IS_RELEASE([git-directory])
# Debugging
AX_CHECK_ENABLE_DEBUG([no])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR([clang-plugin/plugin.cpp])
AC_CONFIG_HEADERS([config.h])
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([1.12 dist-xz no-dist-gzip check-news subdir-objects color-tests parallel-tests])
AM_SILENT_RULES([yes])
AC_PROG_CXX
AM_PROG_CC_C_O
AX_CXX_COMPILE_STDCXX_11()
LT_INIT([])
PKG_PROG_PKG_CONFIG
# Requirements
LLVM_REQS=4.0
GLIB_REQS=2.38 # TODO
GIO_REQS=2.38 # TODO
GIR_REQS=1.38.0 # TODO
# Tartan versioning
AC_SUBST([TARTAN_VERSION_MAJOR],tartan_version_major)
AC_SUBST([TARTAN_VERSION_MINOR],tartan_version_minor)
AC_SUBST([TARTAN_VERSION_MICRO],tartan_version_micro)
# Tartan pkg-config dependencies
TARTAN_PACKAGES="gobject-2.0 glib-2.0 >= $GLIB_REQS gio-2.0 >= $GIO_REQS \
gobject-introspection-1.0 >= $GIR_REQS"
AC_SUBST([TARTAN_PACKAGES])
PKG_CHECK_MODULES([TARTAN],[$TARTAN_PACKAGES])
# Tartan LLVM dependency
AC_PATH_PROG([LLVM_CONFIG],[llvm-config],"failed")
AS_IF([test $LLVM_CONFIG = "failed"],[
AC_MSG_ERROR([LLVM version $LLVM_REQS or later needed.])
])
AC_MSG_CHECKING([for LLVM])
# LLVM_REQS is either (e.g.) 3.5, 3.6svn or 3.4.2
req_major=`echo $LLVM_REQS | sed -E 's/([[0-9]]*)\.([[0-9]]*)(\.[[0-9]]*)?(svn)?/\1/'`
req_minor=`echo $LLVM_REQS | sed -E 's/([[0-9]]*)\.([[0-9]]*)(\.[[0-9]]*)?(svn)?/\2/'`
llvm_version=`$LLVM_CONFIG --version`
major=`echo $llvm_version | sed -E 's/([[0-9]]*)\.([[0-9]]*)(\.[[0-9]]*)?(svn)?/\1/'`
minor=`echo $llvm_version | sed -E 's/([[0-9]]*)\.([[0-9]]*)(\.[[0-9]]*)?(svn)?/\2/'`
AS_IF([test "$major" -gt "$req_major" -o \( "$major" -eq "$req_major" -a "$minor" -ge "$req_minor" \)],[
LLVM_CPPFLAGS=`$LLVM_CONFIG --cppflags | sed -e 's,-I/,-isystem /,' | sed -e 's,-isystem /usr/include,-I/usr/include,'`
LLVM_CXXFLAGS=`$LLVM_CONFIG --cxxflags | sed -e 's,-I/,-isystem /,' | sed -e 's,-isystem /usr/include,-I/usr/include,'`
LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
# Don't link against the LLVM libs because they're huge. All the symbols
# will be available when the plugin is loaded anyway.
#LLVM_LIBS=`$LLVM_CONFIG --libs`
LLVM_LIBS=''
LLVM_VERSION="$major.$minor" # don’t include the ‘svn’ suffix
AC_MSG_RESULT([yes])
],[
AC_MSG_ERROR([LLVM version $LLVM_REQS or later needed.])
])
AC_SUBST([LLVM_CPPFLAGS])
AC_SUBST([LLVM_CXXFLAGS])
AC_SUBST([LLVM_LDFLAGS])
AC_SUBST([LLVM_LIBS])
AC_SUBST([LLVM_VERSION])
AC_DEFINE_UNQUOTED([LLVM_CONFIG_VERSION],"$llvm_version",
[Configured LLVM version])
# Clang dependency (e.g. the clang-devel package on Fedora)
AC_LANG_PUSH([C++])
old_cppflags="$CPPFLAGS"
CPPFLAGS="$LLVM_CPPFLAGS $CPPFLAGS"
AC_CHECK_HEADER([clang/AST/Expr.h],[],[
AC_MSG_ERROR([Clang headers version $LLVM_REQS or later needed.])
])
CPPFLAGS="$old_cppflags"
AC_LANG_POP([C++])
# Internationalisation
GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST([GETTEXT_PACKAGE])
AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],"$GETTEXT_PACKAGE",
[The name of the gettext domain])
IT_PROG_INTLTOOL([0.40.0])
# Code coverage for unit tests
TARTAN_CODE_COVERAGE
# Compiler warnings
AX_COMPILER_FLAGS
# ChangeLog generation
AX_GENERATE_CHANGELOG
AC_CONFIG_FILES([
Makefile
po/Makefile.in
tests/Makefile
])
AC_OUTPUT
|