Add qemu 2.4.0
[kvmfornfv.git] / qemu / pixman / configure.ac
1 dnl  Copyright 2005 Red Hat, Inc.
2 dnl 
3 dnl  Permission to use, copy, modify, distribute, and sell this software and its
4 dnl  documentation for any purpose is hereby granted without fee, provided that
5 dnl  the above copyright notice appear in all copies and that both that
6 dnl  copyright notice and this permission notice appear in supporting
7 dnl  documentation, and that the name of Red Hat not be used in
8 dnl  advertising or publicity pertaining to distribution of the software without
9 dnl  specific, written prior permission.  Red Hat makes no
10 dnl  representations about the suitability of this software for any purpose.  It
11 dnl  is provided "as is" without express or implied warranty.
12 dnl 
13 dnl  RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
14 dnl  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
15 dnl  EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
16 dnl  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
17 dnl  DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 dnl  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 dnl  PERFORMANCE OF THIS SOFTWARE.
20 dnl
21 dnl Process this file with autoconf to create configure.
22
23 AC_PREREQ([2.57])
24
25 #   Pixman versioning scheme
26 #
27 #   - The version in git has an odd MICRO version number
28 #
29 #   - Released versions, both development and stable, have an
30 #     even MICRO version number
31 #
32 #   - Released development versions have an odd MINOR number
33 #
34 #   - Released stable versions have an even MINOR number
35 #
36 #   - Versions that break ABI must have a new MAJOR number
37 #
38 #   - If you break the ABI, then at least this must be done:
39 #
40 #        - increment MAJOR
41 #
42 #        - In the first development release where you break ABI, find
43 #          all instances of "pixman-n" and change them to pixman-(n+1)
44 #
45 #          This needs to be done at least in 
46 #                    configure.ac
47 #                    all Makefile.am's
48 #                    pixman-n.pc.in
49 #
50 #      This ensures that binary incompatible versions can be installed
51 #      in parallel.  See http://www106.pair.com/rhp/parallel.html for
52 #      more information
53 #
54
55 m4_define([pixman_major], 0)
56 m4_define([pixman_minor], 32)
57 m4_define([pixman_micro], 6)
58
59 m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro])
60
61 AC_INIT(pixman, pixman_version, [pixman@lists.freedesktop.org], pixman)
62 AM_INIT_AUTOMAKE([foreign dist-bzip2])
63
64 # Suppress verbose compile lines
65 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
66
67 AC_CONFIG_HEADERS(config.h)
68
69 AC_CANONICAL_HOST
70
71 test_CFLAGS=${CFLAGS+set} # We may override autoconf default CFLAGS.
72
73 AC_PROG_CC
74 AM_PROG_AS
75 AC_PROG_LIBTOOL
76 AC_CHECK_FUNCS([getisax])
77 AC_C_BIGENDIAN
78 AC_C_INLINE
79
80 dnl PIXMAN_LINK_WITH_ENV(env-setup, program, true-action, false-action)
81 dnl
82 dnl Compiles and links the given program in the environment setup by env-setup
83 dnl and executes true-action on success and false-action on failure.
84 AC_DEFUN([PIXMAN_LINK_WITH_ENV],[dnl
85         save_CFLAGS="$CFLAGS"
86         save_LDFLAGS="$LDFLAGS"
87         save_LIBS="$LIBS"
88         CFLAGS=""
89         LDFLAGS=""
90         LIBS=""
91         $1
92         CFLAGS="$save_CFLAGS $CFLAGS"
93         LDFLAGS="$save_LDFLAGS $LDFLAGS"
94         LIBS="$save_LIBS $LIBS"
95         AC_LINK_IFELSE(
96                 [AC_LANG_SOURCE([$2])],
97                 [pixman_cc_stderr=`test -f conftest.err && cat conftest.err`
98                  pixman_cc_flag=yes],
99                 [pixman_cc_stderr=`test -f conftest.err && cat conftest.err`
100                  pixman_cc_flag=no])
101
102         if test "x$pixman_cc_stderr" != "x"; then
103                 pixman_cc_flag=no
104         fi
105
106         if test "x$pixman_cc_flag" = "xyes"; then
107                 ifelse([$3], , :, [$3])
108         else
109                 ifelse([$4], , :, [$4])
110         fi
111         CFLAGS="$save_CFLAGS"
112         LDFLAGS="$save_LDFLAGS"
113         LIBS="$save_LIBS"
114 ])
115
116 dnl Find a -Werror for catching warnings.
117 WERROR=
118 for w in -Werror -errwarn; do
119     if test "z$WERROR" = "z"; then
120         AC_MSG_CHECKING([whether the compiler supports $w])
121         PIXMAN_LINK_WITH_ENV(
122                 [CFLAGS=$w],
123                 [int main(int c, char **v) { (void)c; (void)v; return 0; }],
124                 [WERROR=$w; yesno=yes], [yesno=no])
125         AC_MSG_RESULT($yesno)
126     fi
127 done
128
129 dnl PIXMAN_CHECK_CFLAG(flag, [program])
130 dnl  Adds flag to CFLAGS if the given program links without warnings or errors.
131 AC_DEFUN([PIXMAN_CHECK_CFLAG], [dnl
132         AC_MSG_CHECKING([whether the compiler supports $1])
133         PIXMAN_LINK_WITH_ENV(
134                 [CFLAGS="$WERROR $1"],
135                 [$2
136                  int main(int c, char **v) { (void)c; (void)v; return 0; }
137                 ],
138                 [_yesno=yes],
139                 [_yesno=no])
140         if test "x$_yesno" = xyes; then
141            CFLAGS="$CFLAGS $1"
142         fi
143         AC_MSG_RESULT($_yesno)
144 ])
145
146 AC_CHECK_SIZEOF(long)
147
148 # Checks for Sun Studio compilers
149 AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
150 AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"])
151
152 # Default CFLAGS to -O -g rather than just the -g from AC_PROG_CC
153 # if we're using Sun Studio and neither the user nor a config.site
154 # has set CFLAGS.
155 if test $SUNCC = yes &&                 \
156    test "x$test_CFLAGS" = "x" &&        \
157    test "$CFLAGS" = "-g"
158 then
159   CFLAGS="-O -g"
160 fi
161
162
163 # We ignore pixman_major in the version here because the major version should
164 # always be encoded in the actual library name. Ie., the soname is:
165 #
166 #      pixman-$(pixman_major).0.minor.micro
167 #
168 m4_define([lt_current], [pixman_minor])
169 m4_define([lt_revision], [pixman_micro])
170 m4_define([lt_age], [pixman_minor])
171
172 LT_VERSION_INFO="lt_current:lt_revision:lt_age"
173
174 PIXMAN_VERSION_MAJOR=pixman_major()
175 AC_SUBST(PIXMAN_VERSION_MAJOR)
176 PIXMAN_VERSION_MINOR=pixman_minor()
177 AC_SUBST(PIXMAN_VERSION_MINOR)
178 PIXMAN_VERSION_MICRO=pixman_micro()
179 AC_SUBST(PIXMAN_VERSION_MICRO)
180
181 AC_SUBST(LT_VERSION_INFO)
182
183 # Check for dependencies
184
185 PIXMAN_CHECK_CFLAG([-Wall])
186 PIXMAN_CHECK_CFLAG([-Wdeclaration-after-statement])
187 PIXMAN_CHECK_CFLAG([-fno-strict-aliasing])
188
189 dnl =========================================================================
190 dnl OpenMP for the test suite?
191 dnl
192
193 # Check for OpenMP support only when autoconf support that (require autoconf >=2.62)
194 OPENMP_CFLAGS=
195 m4_ifdef([AC_OPENMP], [AC_OPENMP])
196
197 if test "x$enable_openmp" = "xyes" && test "x$ac_cv_prog_c_openmp" = "xunsupported" ; then
198   AC_MSG_WARN([OpenMP support requested but found unsupported])
199 fi
200
201 dnl May not fail to link without -Wall -Werror added
202 dnl So try to link only when openmp is supported
203 dnl ac_cv_prog_c_openmp is not defined when --disable-openmp is used
204 if test "x$ac_cv_prog_c_openmp" != "xunsupported" && test "x$ac_cv_prog_c_openmp" != "x"; then
205   m4_define([openmp_test_program],[dnl
206   #include <stdio.h>
207
208   extern unsigned int lcg_seed;
209   #pragma omp threadprivate(lcg_seed)
210   unsigned int lcg_seed;
211
212   unsigned function(unsigned a, unsigned b)
213   {
214         lcg_seed ^= b;
215         return ((a + b) ^ a ) + lcg_seed;
216   }
217
218   int main(int argc, char **argv)
219   {
220         int i;
221         int n1 = 0, n2 = argc;
222         unsigned checksum = 0;
223         int verbose = argv != NULL;
224         unsigned (*test_function)(unsigned, unsigned);
225         test_function = function;
226         #pragma omp parallel for reduction(+:checksum) default(none) \
227                                         shared(n1, n2, test_function, verbose)
228         for (i = n1; i < n2; i++)
229         {
230                 unsigned crc = test_function (i, 0);
231                 if (verbose)
232                         printf ("%d: %08X\n", i, crc);
233                 checksum += crc;
234         }
235         printf("%u\n", checksum);
236         return 0;
237   }
238   ])
239
240   PIXMAN_LINK_WITH_ENV(
241         [CFLAGS="$OPENMP_CFLAGS" LDFLAGS="$OPENMP_CFLAGS"],
242         [openmp_test_program],
243         [have_openmp=yes],
244         [have_openmp=no])
245   if test "x$have_openmp" = "xyes" ; then
246     AC_DEFINE(USE_OPENMP, 1, [use OpenMP in the test suite])
247   fi
248 fi
249 AC_SUBST(OPENMP_CFLAGS)
250
251 dnl =========================================================================
252 dnl -fvisibility stuff
253
254 PIXMAN_CHECK_CFLAG([-fvisibility=hidden], [dnl
255 #if defined(__GNUC__) && (__GNUC__ >= 4)
256 #ifdef _WIN32
257 #error Have -fvisibility but it is ignored and generates a warning
258 #endif
259 #else
260 #error Need GCC 4.0 for visibility
261 #endif
262 ])
263
264 PIXMAN_CHECK_CFLAG([-xldscope=hidden], [dnl
265 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
266 #else
267 #error Need Sun Studio 8 for visibility
268 #endif
269 ])
270
271 dnl ===========================================================================
272 dnl Check for Loongson Multimedia Instructions
273
274 if test "x$LS_CFLAGS" = "x" ; then
275     LS_CFLAGS="-march=loongson2f"
276 fi
277
278 have_loongson_mmi=no
279 AC_MSG_CHECKING(whether to use Loongson MMI assembler)
280
281 xserver_save_CFLAGS=$CFLAGS
282 CFLAGS=" $LS_CFLAGS $CFLAGS -I$srcdir"
283 AC_LINK_IFELSE([AC_LANG_SOURCE([[
284 #ifndef __mips_loongson_vector_rev
285 #error "Loongson Multimedia Instructions are only available on Loongson"
286 #endif
287 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
288 #error "Need GCC >= 4.4 for Loongson MMI compilation"
289 #endif
290 #include "pixman/loongson-mmintrin.h"
291 int main () {
292     union {
293         __m64 v;
294         char c[8];
295     } a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} };
296     int b = 4;
297     __m64 c = _mm_srli_pi16 (a.v, b);
298     return 0;
299 }]])], have_loongson_mmi=yes)
300 CFLAGS=$xserver_save_CFLAGS
301
302 AC_ARG_ENABLE(loongson-mmi,
303    [AC_HELP_STRING([--disable-loongson-mmi],
304                    [disable Loongson MMI fast paths])],
305    [enable_loongson_mmi=$enableval], [enable_loongson_mmi=auto])
306
307 if test $enable_loongson_mmi = no ; then
308    have_loongson_mmi=disabled
309 fi
310
311 if test $have_loongson_mmi = yes ; then
312    AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia Instructions])
313 else
314    LS_CFLAGS=
315 fi
316
317 AC_MSG_RESULT($have_loongson_mmi)
318 if test $enable_loongson_mmi = yes && test $have_loongson_mmi = no ; then
319    AC_MSG_ERROR([Loongson MMI not detected])
320 fi
321
322 AM_CONDITIONAL(USE_LOONGSON_MMI, test $have_loongson_mmi = yes)
323
324 dnl ===========================================================================
325 dnl Check for MMX
326
327 if test "x$MMX_CFLAGS" = "x" ; then
328    if test "x$SUNCC" = "xyes"; then
329       # Sun Studio doesn't have an -xarch=mmx flag, so we have to use sse
330       # but if we're building 64-bit, mmx & sse support is on by default and
331       # -xarch=sse throws an error instead
332       if test "$AMD64_ABI" = "no" ; then
333          MMX_CFLAGS="-xarch=sse"
334       fi
335    else
336       MMX_CFLAGS="-mmmx -Winline"
337    fi
338 fi
339
340 have_mmx_intrinsics=no
341 AC_MSG_CHECKING(whether to use MMX intrinsics)
342 xserver_save_CFLAGS=$CFLAGS
343 CFLAGS="$MMX_CFLAGS $CFLAGS"
344 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
345 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
346 #error "Need GCC >= 3.4 for MMX intrinsics"
347 #endif
348 #include <mmintrin.h>
349 int main () {
350     __m64 v = _mm_cvtsi32_si64 (1);
351     __m64 w;
352
353     /* Some versions of clang will choke on K */
354     asm ("pshufw %2, %1, %0\n\t"
355         : "=y" (w)
356         : "y" (v), "K" (5)
357     );
358
359     /* Some versions of clang will choke on this */
360     asm ("pmulhuw %1, %0\n\t"
361         : "+y" (w)
362         : "y" (v)
363     );
364
365     return _mm_cvtsi64_si32 (v);
366 }]])], have_mmx_intrinsics=yes)
367 CFLAGS=$xserver_save_CFLAGS
368
369 AC_ARG_ENABLE(mmx,
370    [AC_HELP_STRING([--disable-mmx],
371                    [disable x86 MMX fast paths])],
372    [enable_mmx=$enableval], [enable_mmx=auto])
373
374 if test $enable_mmx = no ; then
375    have_mmx_intrinsics=disabled
376 fi
377
378 if test $have_mmx_intrinsics = yes ; then
379    AC_DEFINE(USE_X86_MMX, 1, [use x86 MMX compiler intrinsics])
380 else
381    MMX_CFLAGS=
382 fi
383
384 AC_MSG_RESULT($have_mmx_intrinsics)
385 if test $enable_mmx = yes && test $have_mmx_intrinsics = no ; then
386    AC_MSG_ERROR([x86 MMX intrinsics not detected])
387 fi
388
389 AM_CONDITIONAL(USE_X86_MMX, test $have_mmx_intrinsics = yes)
390
391 dnl ===========================================================================
392 dnl Check for SSE2
393
394 if test "x$SSE2_CFLAGS" = "x" ; then
395    if test "x$SUNCC" = "xyes"; then
396       # SSE2 is enabled by default in the Sun Studio 64-bit environment
397       if test "$AMD64_ABI" = "no" ; then
398          SSE2_CFLAGS="-xarch=sse2"
399       fi
400    else
401       SSE2_CFLAGS="-msse2 -Winline"
402    fi
403 fi
404
405 have_sse2_intrinsics=no
406 AC_MSG_CHECKING(whether to use SSE2 intrinsics)
407 xserver_save_CFLAGS=$CFLAGS
408 CFLAGS="$SSE2_CFLAGS $CFLAGS"
409
410 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
411 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
412 #   if !defined(__amd64__) && !defined(__x86_64__)
413 #      error "Need GCC >= 4.2 for SSE2 intrinsics on x86"
414 #   endif
415 #endif
416 #include <mmintrin.h>
417 #include <xmmintrin.h>
418 #include <emmintrin.h>
419 int main () {
420     __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
421         c = _mm_xor_si128 (a, b);
422     return 0;
423 }]])], have_sse2_intrinsics=yes)
424 CFLAGS=$xserver_save_CFLAGS
425
426 AC_ARG_ENABLE(sse2,
427    [AC_HELP_STRING([--disable-sse2],
428                    [disable SSE2 fast paths])],
429    [enable_sse2=$enableval], [enable_sse2=auto])
430
431 if test $enable_sse2 = no ; then
432    have_sse2_intrinsics=disabled
433 fi
434
435 if test $have_sse2_intrinsics = yes ; then
436    AC_DEFINE(USE_SSE2, 1, [use SSE2 compiler intrinsics])
437 fi
438
439 AC_MSG_RESULT($have_sse2_intrinsics)
440 if test $enable_sse2 = yes && test $have_sse2_intrinsics = no ; then
441    AC_MSG_ERROR([SSE2 intrinsics not detected])
442 fi
443
444 AM_CONDITIONAL(USE_SSE2, test $have_sse2_intrinsics = yes)
445
446 dnl ===========================================================================
447 dnl Check for SSSE3
448
449 if test "x$SSSE3_CFLAGS" = "x" ; then
450     SSSE3_CFLAGS="-mssse3 -Winline"
451 fi
452
453 have_ssse3_intrinsics=no
454 AC_MSG_CHECKING(whether to use SSSE3 intrinsics)
455 xserver_save_CFLAGS=$CFLAGS
456 CFLAGS="$SSSE3_CFLAGS $CFLAGS"
457
458 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
459 #include <mmintrin.h>
460 #include <xmmintrin.h>
461 #include <emmintrin.h>
462 #include <tmmintrin.h>
463 int main () {
464     __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
465     c = _mm_maddubs_epi16 (a, b);
466     return 0;
467 }]])], have_ssse3_intrinsics=yes)
468 CFLAGS=$xserver_save_CFLAGS
469
470 AC_ARG_ENABLE(ssse3,
471    [AC_HELP_STRING([--disable-ssse3],
472                    [disable SSSE3 fast paths])],
473    [enable_ssse3=$enableval], [enable_ssse3=auto])
474
475 if test $enable_ssse3 = no ; then
476    have_ssse3_intrinsics=disabled
477 fi
478
479 if test $have_ssse3_intrinsics = yes ; then
480    AC_DEFINE(USE_SSSE3, 1, [use SSSE3 compiler intrinsics])
481 fi
482
483 AC_MSG_RESULT($have_ssse3_intrinsics)
484 if test $enable_ssse3 = yes && test $have_ssse3_intrinsics = no ; then
485    AC_MSG_ERROR([SSSE3 intrinsics not detected])
486 fi
487
488 AM_CONDITIONAL(USE_SSSE3, test $have_ssse3_intrinsics = yes)
489
490 dnl ===========================================================================
491 dnl Other special flags needed when building code using MMX or SSE instructions
492 case $host_os in
493    solaris*)
494       # When building 32-bit binaries, apply a mapfile to ensure that the
495       # binaries aren't flagged as only able to run on MMX+SSE capable CPUs
496       # since they check at runtime before using those instructions.
497       # Not all linkers grok the mapfile format so we check for that first.
498       if test "$AMD64_ABI" = "no" ; then
499          use_hwcap_mapfile=no
500          AC_MSG_CHECKING(whether to use a hardware capability map file)
501          hwcap_save_LDFLAGS="$LDFLAGS"
502          HWCAP_LDFLAGS='-Wl,-M,$(srcdir)/solaris-hwcap.mapfile'
503          LDFLAGS="$LDFLAGS -Wl,-M,pixman/solaris-hwcap.mapfile"
504          AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
505                         use_hwcap_mapfile=yes,
506                         HWCAP_LDFLAGS="")
507          LDFLAGS="$hwcap_save_LDFLAGS"
508          AC_MSG_RESULT($use_hwcap_mapfile)
509       fi
510       if test "x$MMX_LDFLAGS" = "x" ; then
511          MMX_LDFLAGS="$HWCAP_LDFLAGS"
512       fi
513       if test "x$SSE2_LDFLAGS" = "x" ; then
514          SSE2_LDFLAGS="$HWCAP_LDFLAGS"
515       fi
516       ;;
517 esac
518
519 AC_SUBST(LS_CFLAGS)
520 AC_SUBST(IWMMXT_CFLAGS)
521 AC_SUBST(MMX_CFLAGS)
522 AC_SUBST(MMX_LDFLAGS)
523 AC_SUBST(SSE2_CFLAGS)
524 AC_SUBST(SSE2_LDFLAGS)
525 AC_SUBST(SSSE3_CFLAGS)
526
527 dnl ===========================================================================
528 dnl Check for VMX/Altivec
529 if test -n "`$CC -v 2>&1 | grep version | grep Apple`"; then
530     VMX_CFLAGS="-faltivec"
531 else
532     VMX_CFLAGS="-maltivec -mabi=altivec"
533 fi
534
535 have_vmx_intrinsics=no
536 AC_MSG_CHECKING(whether to use VMX/Altivec intrinsics)
537 xserver_save_CFLAGS=$CFLAGS
538 CFLAGS="$VMX_CFLAGS $CFLAGS"
539 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
540 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
541 #error "Need GCC >= 3.4 for sane altivec support"
542 #endif
543 #include <altivec.h>
544 int main () {
545     vector unsigned int v = vec_splat_u32 (1);
546     v = vec_sub (v, v);
547     return 0;
548 }]])], have_vmx_intrinsics=yes)
549 CFLAGS=$xserver_save_CFLAGS
550
551 AC_ARG_ENABLE(vmx,
552    [AC_HELP_STRING([--disable-vmx],
553                    [disable VMX fast paths])],
554    [enable_vmx=$enableval], [enable_vmx=auto])
555
556 if test $enable_vmx = no ; then
557    have_vmx_intrinsics=disabled
558 fi
559
560 if test $have_vmx_intrinsics = yes ; then
561    AC_DEFINE(USE_VMX, 1, [use VMX compiler intrinsics])
562 else
563    VMX_CFLAGS=
564 fi
565
566 AC_MSG_RESULT($have_vmx_intrinsics)
567 if test $enable_vmx = yes && test $have_vmx_intrinsics = no ; then
568    AC_MSG_ERROR([VMX intrinsics not detected])
569 fi
570
571 AC_SUBST(VMX_CFLAGS)
572
573 AM_CONDITIONAL(USE_VMX, test $have_vmx_intrinsics = yes)
574
575 dnl ==========================================================================
576 dnl Check if assembler is gas compatible and supports ARM SIMD instructions
577 have_arm_simd=no
578 AC_MSG_CHECKING(whether to use ARM SIMD assembler)
579 xserver_save_CFLAGS=$CFLAGS
580 CFLAGS="-x assembler-with-cpp $CFLAGS"
581 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
582 .text
583 .arch armv6
584 .object_arch armv4
585 .arm
586 .altmacro
587 #ifndef __ARM_EABI__
588 #error EABI is required (to be sure that calling conventions are compatible)
589 #endif
590 pld [r0]
591 uqadd8 r0, r0, r0]])], have_arm_simd=yes)
592 CFLAGS=$xserver_save_CFLAGS
593
594 AC_ARG_ENABLE(arm-simd,
595    [AC_HELP_STRING([--disable-arm-simd],
596                    [disable ARM SIMD fast paths])],
597    [enable_arm_simd=$enableval], [enable_arm_simd=auto])
598
599 if test $enable_arm_simd = no ; then
600    have_arm_simd=disabled
601 fi
602
603 if test $have_arm_simd = yes ; then
604    AC_DEFINE(USE_ARM_SIMD, 1, [use ARM SIMD assembly optimizations])
605 fi
606
607 AM_CONDITIONAL(USE_ARM_SIMD, test $have_arm_simd = yes)
608
609 AC_MSG_RESULT($have_arm_simd)
610 if test $enable_arm_simd = yes && test $have_arm_simd = no ; then
611    AC_MSG_ERROR([ARM SIMD intrinsics not detected])
612 fi
613
614 dnl ==========================================================================
615 dnl Check if assembler is gas compatible and supports NEON instructions
616 have_arm_neon=no
617 AC_MSG_CHECKING(whether to use ARM NEON assembler)
618 xserver_save_CFLAGS=$CFLAGS
619 CFLAGS="-x assembler-with-cpp $CFLAGS"
620 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
621 .text
622 .fpu neon
623 .arch armv7a
624 .object_arch armv4
625 .eabi_attribute 10, 0
626 .arm
627 .altmacro
628 #ifndef __ARM_EABI__
629 #error EABI is required (to be sure that calling conventions are compatible)
630 #endif
631 pld [r0]
632 vmovn.u16 d0, q0]])], have_arm_neon=yes)
633 CFLAGS=$xserver_save_CFLAGS
634
635 AC_ARG_ENABLE(arm-neon,
636    [AC_HELP_STRING([--disable-arm-neon],
637                    [disable ARM NEON fast paths])],
638    [enable_arm_neon=$enableval], [enable_arm_neon=auto])
639
640 if test $enable_arm_neon = no ; then
641    have_arm_neon=disabled
642 fi
643
644 if test $have_arm_neon = yes ; then
645    AC_DEFINE(USE_ARM_NEON, 1, [use ARM NEON assembly optimizations])
646 fi
647
648 AM_CONDITIONAL(USE_ARM_NEON, test $have_arm_neon = yes)
649
650 AC_MSG_RESULT($have_arm_neon)
651 if test $enable_arm_neon = yes && test $have_arm_neon = no ; then
652    AC_MSG_ERROR([ARM NEON intrinsics not detected])
653 fi
654
655 dnl ===========================================================================
656 dnl Check for IWMMXT
657
658 AC_ARG_ENABLE(arm-iwmmxt,
659    [AC_HELP_STRING([--disable-arm-iwmmxt],
660                    [disable ARM IWMMXT fast paths])],
661    [enable_iwmmxt=$enableval], [enable_iwmmxt=auto])
662
663 AC_ARG_ENABLE(arm-iwmmxt2,
664    [AC_HELP_STRING([--disable-arm-iwmmxt2],
665                    [build ARM IWMMXT fast paths with -march=iwmmxt instead of -march=iwmmxt2])],
666    [enable_iwmmxt2=$enableval], [enable_iwmmxt2=auto])
667
668 if test "x$IWMMXT_CFLAGS" = "x" ; then
669    IWMMXT_CFLAGS="-flax-vector-conversions -Winline -march=iwmmxt"
670    if test $enable_iwmmxt2 != no ; then
671       IWMMXT_CFLAGS="${IWMMXT_CFLAGS}2"
672    fi
673 fi
674
675 have_iwmmxt_intrinsics=no
676 AC_MSG_CHECKING(whether to use ARM IWMMXT intrinsics)
677 xserver_save_CFLAGS=$CFLAGS
678 CFLAGS="$CFLAGS $IWMMXT_CFLAGS"
679 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
680 #ifndef __arm__
681 #error "IWMMXT is only available on ARM"
682 #endif
683 #ifndef __IWMMXT__
684 #error "IWMMXT not enabled (with -march=iwmmxt)"
685 #endif
686 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
687 #error "Need GCC >= 4.8 for IWMMXT intrinsics"
688 #endif
689 #include <mmintrin.h>
690 int main () {
691         union {
692                 __m64 v;
693                 char c[8];
694         } a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} };
695         int b = 4;
696         __m64 c = _mm_srli_si64 (a.v, b);
697 }]])], have_iwmmxt_intrinsics=yes)
698 CFLAGS=$xserver_save_CFLAGS
699
700 if test $enable_iwmmxt = no ; then
701    have_iwmmxt_intrinsics=disabled
702 fi
703
704 if test $have_iwmmxt_intrinsics = yes ; then
705    AC_DEFINE(USE_ARM_IWMMXT, 1, [use ARM IWMMXT compiler intrinsics])
706 else
707    IWMMXT_CFLAGS=
708 fi
709
710 AC_MSG_RESULT($have_iwmmxt_intrinsics)
711 if test $enable_iwmmxt = yes && test $have_iwmmxt_intrinsics = no ; then
712    AC_MSG_ERROR([IWMMXT intrinsics not detected])
713 fi
714
715 AM_CONDITIONAL(USE_ARM_IWMMXT, test $have_iwmmxt_intrinsics = yes)
716
717 dnl ==========================================================================
718 dnl Check if assembler is gas compatible and supports MIPS DSPr2 instructions
719
720 have_mips_dspr2=no
721 AC_MSG_CHECKING(whether to use MIPS DSPr2 assembler)
722 xserver_save_CFLAGS=$CFLAGS
723 CFLAGS="-mdspr2 $CFLAGS"
724
725 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
726 #if !(defined(__mips__) &&  __mips_isa_rev >= 2)
727 #error MIPS DSPr2 is currently only available on MIPS32r2 platforms.
728 #endif
729 int
730 main ()
731 {
732     int c = 0, a = 0, b = 0;
733     __asm__ __volatile__ (
734         "precr.qb.ph %[c], %[a], %[b]          \n\t"
735         : [c] "=r" (c)
736         : [a] "r" (a), [b] "r" (b)
737     );
738     return c;
739 }]])], have_mips_dspr2=yes)
740 CFLAGS=$xserver_save_CFLAGS
741
742 AC_ARG_ENABLE(mips-dspr2,
743    [AC_HELP_STRING([--disable-mips-dspr2],
744                    [disable MIPS DSPr2 fast paths])],
745    [enable_mips_dspr2=$enableval], [enable_mips_dspr2=auto])
746
747 if test $enable_mips_dspr2 = no ; then
748    have_mips_dspr2=disabled
749 fi
750
751 if test $have_mips_dspr2 = yes ; then
752    AC_DEFINE(USE_MIPS_DSPR2, 1, [use MIPS DSPr2 assembly optimizations])
753 fi
754
755 AM_CONDITIONAL(USE_MIPS_DSPR2, test $have_mips_dspr2 = yes)
756
757 AC_MSG_RESULT($have_mips_dspr2)
758 if test $enable_mips_dspr2 = yes && test $have_mips_dspr2 = no ; then
759    AC_MSG_ERROR([MIPS DSPr2 instructions not detected])
760 fi
761
762 dnl =========================================================================================
763 dnl Check for GNU-style inline assembly support
764
765 have_gcc_inline_asm=no
766 AC_MSG_CHECKING(whether to use GNU-style inline assembler)
767 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
768 int main () {
769     /* Most modern architectures have a NOP instruction, so this is a fairly generic test. */
770         asm volatile ( "\tnop\n" : : : "cc", "memory" );
771     return 0;
772 }]])], have_gcc_inline_asm=yes)
773
774 AC_ARG_ENABLE(gcc-inline-asm,
775    [AC_HELP_STRING([--disable-gcc-inline-asm],
776                    [disable GNU-style inline assembler])],
777    [enable_gcc_inline_asm=$enableval], [enable_gcc_inline_asm=auto])
778
779 if test $enable_gcc_inline_asm = no ; then
780    have_gcc_inline_asm=disabled
781 fi
782
783 if test $have_gcc_inline_asm = yes ; then
784    AC_DEFINE(USE_GCC_INLINE_ASM, 1, [use GNU-style inline assembler])
785 fi
786
787 AC_MSG_RESULT($have_gcc_inline_asm)
788 if test $enable_gcc_inline_asm = yes && test $have_gcc_inline_asm = no ; then
789    AC_MSG_ERROR([GNU-style inline assembler not detected])
790 fi
791
792 AM_CONDITIONAL(USE_GCC_INLINE_ASM, test $have_gcc_inline_asm = yes)
793
794 dnl ==============================================
795 dnl Static test programs
796
797 AC_ARG_ENABLE(static-testprogs,
798    [AC_HELP_STRING([--enable-static-testprogs],
799                    [build test programs as static binaries [default=no]])],
800    [enable_static_testprogs=$enableval], [enable_static_testprogs=no])
801
802 TESTPROGS_EXTRA_LDFLAGS=
803 if test "x$enable_static_testprogs" = "xyes" ; then
804    TESTPROGS_EXTRA_LDFLAGS="-all-static"
805 fi
806 AC_SUBST(TESTPROGS_EXTRA_LDFLAGS)
807
808 dnl ==============================================
809 dnl Timers
810
811 AC_ARG_ENABLE(timers,
812    [AC_HELP_STRING([--enable-timers],
813                    [enable TIMER_BEGIN and TIMER_END macros [default=no]])],
814    [enable_timers=$enableval], [enable_timers=no])
815
816 if test $enable_timers = yes ; then 
817    AC_DEFINE(PIXMAN_TIMERS, 1, [enable TIMER_BEGIN/TIMER_END macros])
818 fi
819 AC_SUBST(PIXMAN_TIMERS)
820
821 dnl ===================================
822 dnl GTK+
823
824 AC_ARG_ENABLE(gtk,
825    [AC_HELP_STRING([--enable-gtk],
826                    [enable tests using GTK+ [default=auto]])],
827    [enable_gtk=$enableval], [enable_gtk=auto])
828
829 PKG_PROG_PKG_CONFIG
830
831 if test $enable_gtk = yes ; then
832    AC_CHECK_LIB([pixman-1], [pixman_version_string])
833    PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.16 pixman-1])
834 fi
835
836 if test $enable_gtk = auto ; then
837    AC_CHECK_LIB([pixman-1], [pixman_version_string], [enable_gtk=auto], [enable_gtk=no])
838 fi
839
840 if test $enable_gtk = auto ; then
841    PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.16 pixman-1], [enable_gtk=yes], [enable_gtk=no])
842 fi
843
844 AM_CONDITIONAL(HAVE_GTK, [test "x$enable_gtk" = xyes])
845
846 AC_SUBST(GTK_CFLAGS)
847 AC_SUBST(GTK_LIBS)
848
849 dnl =====================================
850 dnl posix_memalign, sigaction, alarm, gettimeofday
851
852 AC_CHECK_FUNC(posix_memalign, have_posix_memalign=yes, have_posix_memalign=no)
853 if test x$have_posix_memalign = xyes; then
854    AC_DEFINE(HAVE_POSIX_MEMALIGN, 1, [Whether we have posix_memalign()])
855 fi
856
857 AC_CHECK_FUNC(sigaction, have_sigaction=yes, have_sigaction=no)
858 if test x$have_sigaction = xyes; then
859    AC_DEFINE(HAVE_SIGACTION, 1, [Whether we have sigaction()])
860 fi
861
862 AC_CHECK_FUNC(alarm, have_alarm=yes, have_alarm=no)
863 if test x$have_alarm = xyes; then
864    AC_DEFINE(HAVE_ALARM, 1, [Whether we have alarm()])
865 fi
866
867 AC_CHECK_HEADER([sys/mman.h],
868    [AC_DEFINE(HAVE_SYS_MMAN_H, [1], [Define to 1 if we have <sys/mman.h>])])
869
870 AC_CHECK_FUNC(mmap, have_mmap=yes, have_mmap=no)
871 if test x$have_mmap = xyes; then
872    AC_DEFINE(HAVE_MMAP, 1, [Whether we have mmap()])
873 fi
874
875 AC_CHECK_FUNC(mprotect, have_mprotect=yes, have_mprotect=no)
876 if test x$have_mprotect = xyes; then
877    AC_DEFINE(HAVE_MPROTECT, 1, [Whether we have mprotect()])
878 fi
879
880 AC_CHECK_FUNC(getpagesize, have_getpagesize=yes, have_getpagesize=no)
881 if test x$have_getpagesize = xyes; then
882    AC_DEFINE(HAVE_GETPAGESIZE, 1, [Whether we have getpagesize()])
883 fi
884
885 AC_CHECK_HEADER([fenv.h],
886    [AC_DEFINE(HAVE_FENV_H, [1], [Define to 1 if we have <fenv.h>])])
887
888 AC_CHECK_LIB(m, feenableexcept, have_feenableexcept=yes, have_feenableexcept=no)
889 if test x$have_feenableexcept = xyes; then
890    AC_DEFINE(HAVE_FEENABLEEXCEPT, 1, [Whether we have feenableexcept()])
891 fi
892
893 AC_CHECK_FUNC(gettimeofday, have_gettimeofday=yes, have_gettimeofday=no)
894 AC_CHECK_HEADER(sys/time.h, have_sys_time_h=yes, have_sys_time_h=no)
895 if test x$have_gettimeofday = xyes && test x$have_sys_time_h = xyes; then
896    AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Whether we have gettimeofday()])
897 fi
898
899 dnl =====================================
900 dnl Check for missing sqrtf() as, e.g., for Solaris 9
901
902 AC_SEARCH_LIBS([sqrtf], [m], [],
903                [AC_DEFINE([sqrtf], [sqrt],
904                           [Define to sqrt if you do not have the `sqrtf' function.])])
905
906 dnl =====================================
907 dnl Thread local storage
908
909 AC_MSG_CHECKING(for thread local storage (TLS) support)
910 AC_CACHE_VAL(ac_cv_tls, [
911     ac_cv_tls=none
912     keywords="__thread __declspec(thread)"
913     for kw in $keywords ; do
914         AC_TRY_COMPILE([
915 #if defined(__MINGW32__) && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
916 #error This MinGW version has broken __thread support
917 #endif
918 #ifdef __OpenBSD__
919 #error OpenBSD has broken __thread support
920 #endif
921
922 int $kw test;], [], [ac_cv_tls=$kw; break])
923     done
924 ])
925 AC_MSG_RESULT($ac_cv_tls)
926
927 if test "$ac_cv_tls" != "none"; then
928     AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [The compiler supported TLS storage class])
929 fi
930
931 dnl
932 dnl posix tls
933 dnl
934
935 m4_define([pthread_test_program],AC_LANG_SOURCE([[dnl
936 #include <stdlib.h>
937 #include <pthread.h>
938
939 static pthread_once_t once_control = PTHREAD_ONCE_INIT;
940 static pthread_key_t key;
941
942 static void
943 make_key (void)
944 {
945     pthread_key_create (&key, NULL);
946 }
947
948 int
949 main ()
950 {
951     void *value = NULL;
952
953     if (pthread_once (&once_control, make_key) != 0)
954     {
955         value = NULL;
956     }
957     else
958     {
959         value = pthread_getspecific (key);
960         if (!value)
961         {
962             value = malloc (100);
963             pthread_setspecific (key, value);
964         }
965     }
966     return 0;
967 }
968 ]]))
969
970 AC_DEFUN([PIXMAN_CHECK_PTHREAD],[dnl
971     if test "z$support_for_pthreads" != "zyes"; then
972         PIXMAN_LINK_WITH_ENV(
973                 [$1], [pthread_test_program],
974                 [PTHREAD_CFLAGS="$CFLAGS"
975                  PTHREAD_LIBS="$LIBS"
976                  PTHREAD_LDFLAGS="$LDFLAGS"
977                  support_for_pthreads=yes])
978     fi
979 ])
980
981 support_for_pthreads=no
982
983 AC_MSG_CHECKING(for pthreads)
984
985 PIXMAN_CHECK_PTHREAD([CFLAGS="-pthread"; LDFLAGS="-pthread"])
986 PIXMAN_CHECK_PTHREAD([CFLAGS="-D_REENTRANT"; LIBS="-lpthread"])
987 PIXMAN_CHECK_PTHREAD([CFLAGS="-D_REENTRANT"; LDFLAGS="-lroot"])
988     
989 if test $support_for_pthreads = yes; then
990     AC_DEFINE([HAVE_PTHREADS], [], [Whether pthreads is supported])
991     if test $ac_cv_tls = none ; then
992         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
993     fi
994 fi
995
996 AC_MSG_RESULT($support_for_pthreads)
997
998 AC_SUBST(TOOLCHAIN_SUPPORTS__THREAD)
999 AC_SUBST(HAVE_PTHREADS)
1000 AC_SUBST(PTHREAD_LDFLAGS)
1001 AC_SUBST(PTHREAD_LIBS)
1002 AC_SUBST(PTHREAD_CFLAGS)
1003
1004 dnl =====================================
1005 dnl __attribute__((constructor))
1006
1007 support_for_attribute_constructor=no
1008
1009 AC_MSG_CHECKING(for __attribute__((constructor)))
1010 AC_LINK_IFELSE([AC_LANG_SOURCE([[
1011 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
1012 /* attribute 'constructor' is supported since gcc 2.7, but some compilers
1013  * may only pretend to be gcc, so let's try to actually use it
1014  */
1015 static int x = 1;
1016 static void __attribute__((constructor)) constructor_function () { x = 0; }
1017 int main (void) { return x; }
1018 #else
1019 #error not gcc or gcc version is older than 2.7
1020 #endif
1021 ]])], support_for_attribute_constructor=yes)
1022
1023 if test x$support_for_attribute_constructor = xyes; then
1024    AC_DEFINE([TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR],
1025              [],[Whether the tool chain supports __attribute__((constructor))])
1026 fi
1027
1028 AC_MSG_RESULT($support_for_attribute_constructor)
1029 AC_SUBST(TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR)
1030
1031 dnl =====================================
1032 dnl __float128
1033
1034 support_for_float128=no
1035
1036 AC_MSG_CHECKING(for __float128)
1037 AC_LINK_IFELSE([AC_LANG_SOURCE([[
1038 __float128 a = 1.0Q, b = 2.0Q; int main (void) { return a + b; }
1039 ]])], support_for_float128=yes)
1040
1041 if test x$support_for_float128 = xyes; then
1042    AC_DEFINE([HAVE_FLOAT128], [], [Whether the tool chain supports __float128])
1043 fi
1044
1045 AC_MSG_RESULT($support_for_float128)
1046
1047 dnl =====================================
1048 dnl __builtin_clz
1049
1050 support_for_builtin_clz=no
1051
1052 AC_MSG_CHECKING(for __builtin_clz)
1053 AC_LINK_IFELSE([AC_LANG_SOURCE([[
1054 unsigned int x = 11; int main (void) { return __builtin_clz(x); }
1055 ]])], support_for_builtin_clz=yes)
1056
1057 if test x$support_for_builtin_clz = xyes; then
1058    AC_DEFINE([HAVE_BUILTIN_CLZ], [], [Whether the compiler supports __builtin_clz])
1059 fi
1060
1061 AC_MSG_RESULT($support_for_builtin_clz)
1062
1063 dnl =====================================
1064 dnl GCC vector extensions
1065
1066 support_for_gcc_vector_extensions=no
1067
1068 AC_MSG_CHECKING(for GCC vector extensions)
1069 AC_LINK_IFELSE([AC_LANG_SOURCE([[
1070 unsigned int __attribute__ ((vector_size(16))) e, a, b;
1071 int main (void) { e = a - ((b << 27) + (b >> (32 - 27))) + 1; return e[0]; }
1072 ]])], support_for_gcc_vector_extensions=yes)
1073
1074 if test x$support_for_gcc_vector_extensions = xyes; then
1075    AC_DEFINE([HAVE_GCC_VECTOR_EXTENSIONS], [],
1076              [Whether the compiler supports GCC vector extensions])
1077 fi
1078
1079 AC_MSG_RESULT($support_for_gcc_vector_extensions)
1080
1081 dnl ==================
1082 dnl libpng
1083
1084 AC_ARG_ENABLE(libpng, AS_HELP_STRING([--enable-libpng], [Build support for libpng (default: auto)]),
1085                       [have_libpng=$enableval], [have_libpng=auto])
1086
1087 case x$have_libpng in
1088         xyes) PKG_CHECK_MODULES(PNG, [libpng]) ;;
1089         xno) ;;
1090         *) PKG_CHECK_MODULES(PNG, [libpng], have_libpng=yes, have_libpng=no) ;;
1091 esac
1092
1093 if test x$have_libpng = xyes; then
1094     AC_DEFINE([HAVE_LIBPNG], [1], [Whether we have libpng])
1095 fi
1096
1097 AC_SUBST(HAVE_LIBPNG)
1098
1099 AC_OUTPUT([pixman-1.pc
1100            pixman-1-uninstalled.pc
1101            Makefile
1102            pixman/Makefile
1103            pixman/pixman-version.h
1104            demos/Makefile
1105            test/Makefile])
1106
1107 m4_if(m4_eval(pixman_minor % 2), [1], [
1108    echo
1109    echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
1110    echo
1111    echo "      Thanks for testing this development snapshot of pixman. Please"
1112    echo "      report any problems you find, either by sending email to "
1113    echo
1114    echo "          pixman@lists.freedesktop.org"
1115    echo
1116    echo "      or by filing a bug at "
1117    echo
1118    echo "          https://bugs.freedesktop.org/enter_bug.cgi?product=pixman "
1119    echo
1120    echo "      If you are looking for a stable release of pixman, please note "
1121    echo "      that stable releases have _even_ minor version numbers. Ie., "
1122    echo "      pixman-0.]m4_eval(pixman_minor & ~1)[.x are stable releases, whereas pixman-$PIXMAN_VERSION_MAJOR.$PIXMAN_VERSION_MINOR.$PIXMAN_VERSION_MICRO is a "
1123    echo "      development snapshot that may contain bugs and experimental "
1124    echo "      features. "
1125    echo 
1126    echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
1127    echo
1128 ])