~ubuntu-branches/ubuntu/saucy/clamav/saucy-backports

« back to all changes in this revision

Viewing changes to .pc/0005-enable-llvm-jit-on-kfreebsd.patch/libclamav/c++/configure.ac

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-07-15 01:08:10 UTC
  • mfrom: (0.35.47 sid)
  • Revision ID: package-import@ubuntu.com-20140715010810-ru66ek4fun2iseba
Tags: 0.98.4+dfsg-2~ubuntu13.10.1
No-change backport to saucy (LP: #1341962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl   This program is free software; you can redistribute it and/or modify
 
2
dnl   it under the terms of the GNU General Public License as published by
 
3
dnl   the Free Software Foundation; either version 2 of the License, or
 
4
dnl   (at your option) any later version.
 
5
dnl
 
6
dnl   This program is distributed in the hope that it will be useful,
 
7
dnl   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
8
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
9
dnl   GNU General Public License for more details.
 
10
dnl
 
11
dnl   You should have received a copy of the GNU General Public License
 
12
dnl   along with this program; if not, write to the Free Software
 
13
dnl   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
14
dnl   MA 02110-1301, USA.
 
15
 
 
16
AC_PREREQ([2.59])
 
17
AC_INIT([libclamavc++],[devel],[http://bugs.clamav.net])
 
18
AC_CONFIG_AUX_DIR([config])
 
19
AC_CONFIG_MACRO_DIR([m4])
 
20
AC_CONFIG_HEADER([clamavcxx-config.h])
 
21
AC_CANONICAL_TARGET
 
22
AM_INIT_AUTOMAKE([1.9 -Wall -Wportability foreign no-define color-tests tar-pax])
 
23
AM_SILENT_RULES([yes])
 
24
 
 
25
cxxset=${CXXFLAGS+set}
 
26
AC_PROG_CXX
 
27
AC_C_BIGENDIAN
 
28
 
 
29
if test "$cxxset" != set; then
 
30
# don't use the default -O2 -g because -g bloats the C++ binaries too much
 
31
  CXXFLAGS="-O2"
 
32
fi
 
33
case "$target_os" in
 
34
solaris*)
 
35
  CXXFLAGS="$CXXFLAGS -include llvm/include/llvm/System/Solaris.h"
 
36
  AC_MSG_NOTICE([Building on Solaris])
 
37
  ;;
 
38
esac
 
39
 
 
40
AM_MAINTAINER_MODE
 
41
LT_INIT([disable-static])
 
42
if test "$GXX" != "yes"; then
 
43
    AC_MSG_ERROR([GNU C++ compiler not found, not building LLVM])
 
44
fi
 
45
 
 
46
AC_CHECK_GNU_MAKE
 
47
GMAKE="$llvm_cv_gnu_make_command"
 
48
AC_SUBST([GMAKE])
 
49
 
 
50
llvmconfig=
 
51
AC_ARG_WITH([system-llvm], AC_HELP_STRING([-with-system-llvm],
 
52
[Use system llvm instead of built-in, requires full path to llvm-config]),
 
53
[case "$withval" in
 
54
  yes)
 
55
    AC_MSG_ERROR([--with-system-llvm needs full path to llvm-config])
 
56
    ;;
 
57
  no) ;;
 
58
  *)
 
59
    llvmconfig="$withval"
 
60
    llvmver=`$llvmconfig --version`
 
61
 
 
62
    AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`])
 
63
    AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
 
64
    AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`])
 
65
    AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`])
 
66
    AC_MSG_NOTICE([Using external LLVM])
 
67
    AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS])
 
68
    AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS])
 
69
    AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS])
 
70
    ;;
 
71
  esac
 
72
])
 
73
 
 
74
AC_MSG_CHECKING([for supported LLVM version])
 
75
if test "x$llvmconfig" = "x"; then
 
76
    AC_CONFIG_SUBDIRS([llvm])
 
77
    llvmver=`llvm/configure --version | sed -n 1p | sed 's/llvm configure //'`
 
78
fi
 
79
 
 
80
llvmver_int=`echo "$llvmver" | sed -e 's/\([[0-9]]\)\.\([[0-9]]\).*/\1\2/g'`
 
81
 
 
82
if test $llvmver_int -lt 28; then
 
83
    AC_MSG_RESULT([no ($llvmver)])
 
84
    AC_MSG_ERROR([LLVM >= 2.8 required, but "$llvmver" found])
 
85
elif test $llvmver_int -gt 34; then
 
86
    AC_MSG_RESULT([no ($llvmver)])
 
87
    AC_MSG_ERROR([LLVM <= 3.4 required, but "$llvmver" found])
 
88
else
 
89
AC_MSG_RESULT([ok ($llvmver; $llvmver_int)])
 
90
fi
 
91
AC_SUBST([LLVM_VERSION], [$llvmver_int])
 
92
 
 
93
AC_ARG_ENABLE([llvm],AC_HELP_STRING([-enable-llvm],
 
94
                                    [Enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
 
95
                                    [enable_llvm=$enableval], [enable_llvm="auto"])
 
96
 
 
97
AC_ARG_ENABLE(optimized, AC_HELP_STRING([-enable-optimized],
 
98
              [Compile with optimizations enabled (default is YES)]),
 
99
              enable_optimized=$enableval, enable_optimized=default)
 
100
AM_CONDITIONAL(DEBUG_BUILD,[test "x$enable_optimized" = "xno"])
 
101
 
 
102
dnl Set configure args for subdir
 
103
if test "$enable_optimized" = "default"; then
 
104
    ac_configure_args="$ac_configure_args --enable-optimized"
 
105
fi
 
106
 
 
107
dnl Pretend that GNU make is available for LLVM, we don't use LLVM's buildsystem
 
108
dnl anyway (except for make check)
 
109
ac_configure_args="$ac_configure_args llvm_cv_gnu_make_command=make"
 
110
AC_ARG_ENABLE(all-jit-targets, AC_HELP_STRING([-enable-all-jit-targets],
 
111
              [Build all the targets that support JIT for testing (default NO)]),
 
112
              enable_alltargets=$enableval, enable_alltargets=no)
 
113
if test "$enable_alltargets" = "yes"; then
 
114
    new_args="$ac_configure_args --enable-targets=x86,powerpc --enable-bindings=none --enable-libffi=no --without-llvmgcc --without-llvmgxx"
 
115
else
 
116
    new_args="$ac_configure_args --enable-targets=host-only --enable-bindings=none --enable-libffi=no --without-llvmgcc --without-llvmgxx"
 
117
fi
 
118
ac_configure_args=`echo $new_args | sed -e 's/-Werror //g'`
 
119
 
 
120
if test "$enable_llvm" = "auto"; then
 
121
    dnl Do some sanity checks, and don't automatically build on platforms
 
122
    dnl that are not supported or have broken compilers.
 
123
    dnl The user can override this by specifying --enable-llvm=yes.
 
124
    AC_MSG_CHECKING([for supported C++ compiler version])
 
125
    gxx_version=`${CXX} -dumpversion` ||
 
126
    AC_MSG_ERROR([Unable to get GNU C++ compiler version])
 
127
    case "${gxx_version}" in
 
128
     [[03]].*)
 
129
        AC_MSG_ERROR([C++ compiler too old (${gxx_version})])
 
130
        ;;
 
131
     4.1.[[1]]*)
 
132
        AC_MSG_ERROR([C++ compiler is buggy])
 
133
        ;;
 
134
     *)
 
135
        AC_MSG_RESULT([ok (${gxx_version})])
 
136
    esac
 
137
 
 
138
    AC_MSG_CHECKING([for supported OS])
 
139
    case "$target_cpu" in
 
140
        i?86|amd64|x86_64|powerpc*)
 
141
            case "$target_os" in
 
142
                darwin*|freebsd*|openbsd*|netbsd*|dragonfly*|linux*|solaris*|win32*|mingw*)
 
143
                    AC_MSG_RESULT([ok ($target_cpu-$target_os)])
 
144
                    ;;
 
145
                *)
 
146
                    AC_MSG_ERROR([OS $target_os is not supported, not building LLVM])
 
147
                    ;;
 
148
            esac
 
149
            ;;
 
150
        alpha*|arm*)
 
151
            AC_MSG_ERROR([CPU support is untested, not building LLVM])
 
152
            ;;
 
153
        *)
 
154
            AC_MSG_ERROR([Unsupported CPU for JIT: $target_cpu, not building LLVM])
 
155
            ;;
 
156
    esac
 
157
fi
 
158
 
 
159
dnl bb #1971 - doesn't work with older libstdc++ version at link/runtime
 
160
AC_MSG_CHECKING([for working libstdc++])
 
161
AC_LANG_PUSH([C++])
 
162
AC_RUN_IFELSE(
 
163
    [AC_LANG_SOURCE([
 
164
        #include <iostream>
 
165
        int main()
 
166
        {
 
167
            // this causes an @GLIBCXX_3.4.9 symbol to be linked in -O2 mode
 
168
            std::cout << "test";
 
169
            return 0;
 
170
    }
 
171
    ])],[AC_MSG_RESULT([yes])],
 
172
    [AC_MSG_FAILURE([failed])],
 
173
[AC_LINK_IFELSE(
 
174
    [AC_LANG_SOURCE([
 
175
        #include <iostream>
 
176
        int main()
 
177
        {
 
178
            // this causes an @GLIBCXX_3.4.9 symbol to be linked in -O2 mode
 
179
            std::cout << "test";
 
180
            return 0;
 
181
        }
 
182
    ])], [AC_MSG_RESULT([yes])],
 
183
    [AC_MSG_FAILURE([failed])]
 
184
)])
 
185
AC_LANG_POP([C++])
 
186
 
 
187
build_x86=no
 
188
build_ppc=no
 
189
case "$target_cpu" in
 
190
    i?86|amd64|x86_64)
 
191
            build_x86=yes
 
192
            ;;
 
193
    powerpc*)
 
194
            build_ppc=yes
 
195
            ;;
 
196
esac
 
197
 
 
198
# FreeBSD is only one which needs something else than -pthread,
 
199
# according to the logic in ClamAV's main configure.in.
 
200
case "$target_os" in
 
201
freebsd[[45]]*)
 
202
    THREAD_LIBS="-pthread -lc_r"
 
203
    ;;
 
204
freebsd*)
 
205
    THREAD_LIBS="-lthr"
 
206
    ;;
 
207
darwin*)
 
208
    # none required
 
209
    THREAD_LIBS=
 
210
    ;;
 
211
 
 
212
*)
 
213
    THREAD_LIBS="-pthread"
 
214
esac
 
215
AC_SUBST([THREAD_LIBS])
 
216
 
 
217
if test "$enable_alltargets" = "yes"; then
 
218
        build_x86=yes
 
219
        build_ppc=yes
 
220
fi
 
221
if test "$ac_cv_c_bigendian" = "universal"; then
 
222
    AC_MSG_NOTICE([Universal build detected])
 
223
    build_x86=yes
 
224
    build_ppc=yes
 
225
fi
 
226
AC_MSG_NOTICE([Building X86 backend: $build_x86])
 
227
AC_MSG_NOTICE([Building PPC backend: $build_ppc])
 
228
AM_CONDITIONAL(BUILD_X86, [test "$build_x86" = "yes"])
 
229
AM_CONDITIONAL(BUILD_PPC, [test "$build_ppc" = "yes"])
 
230
 
 
231
AC_MSG_CHECKING([optional compiler flags])
 
232
CXX_FLAG_CHECK(NO_VARIADIC_MACROS, [-Wno-variadic-macros])
 
233
CXX_FLAG_CHECK(NO_MISSING_FIELD_INITIALIZERS, [-Wno-missing-field-initializers])
 
234
AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS])
 
235
 
 
236
AM_CONDITIONAL(BUILD_EXTERNAL_LLVM, [test -n "$llvmconfig"])
 
237
AM_CONDITIONAL(BUILD_LLVM3, [test -n "$llvmconfig" && test "$llvmver" != "2.9"])
 
238
 
 
239
AC_OUTPUT([
 
240
    Makefile
 
241
])