Pre-release version bump to 0.33.4
[platform/upstream/pixman.git] / 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], 33)
57 m4_define([pixman_micro], 4)
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([-Wno-unused-local-typedefs])
188 PIXMAN_CHECK_CFLAG([-fno-strict-aliasing])
189
190 dnl =========================================================================
191 dnl OpenMP for the test suite?
192 dnl
193
194 # Check for OpenMP support only when autoconf support that (require autoconf >=2.62)
195 OPENMP_CFLAGS=
196 m4_ifdef([AC_OPENMP], [AC_OPENMP])
197
198 if test "x$enable_openmp" = "xyes" && test "x$ac_cv_prog_c_openmp" = "xunsupported" ; then
199   AC_MSG_WARN([OpenMP support requested but found unsupported])
200 fi
201
202 dnl May not fail to link without -Wall -Werror added
203 dnl So try to link only when openmp is supported
204 dnl ac_cv_prog_c_openmp is not defined when --disable-openmp is used
205 if test "x$ac_cv_prog_c_openmp" != "xunsupported" && test "x$ac_cv_prog_c_openmp" != "x"; then
206   m4_define([openmp_test_program],[dnl
207   #include <stdio.h>
208
209   extern unsigned int lcg_seed;
210   #pragma omp threadprivate(lcg_seed)
211   unsigned int lcg_seed;
212
213   unsigned function(unsigned a, unsigned b)
214   {
215         lcg_seed ^= b;
216         return ((a + b) ^ a ) + lcg_seed;
217   }
218
219   int main(int argc, char **argv)
220   {
221         int i;
222         int n1 = 0, n2 = argc;
223         unsigned checksum = 0;
224         int verbose = argv != NULL;
225         unsigned (*test_function)(unsigned, unsigned);
226         test_function = function;
227         #pragma omp parallel for reduction(+:checksum) default(none) \
228                                         shared(n1, n2, test_function, verbose)
229         for (i = n1; i < n2; i++)
230         {
231                 unsigned crc = test_function (i, 0);
232                 if (verbose)
233                         printf ("%d: %08X\n", i, crc);
234                 checksum += crc;
235         }
236         printf("%u\n", checksum);
237         return 0;
238   }
239   ])
240
241   PIXMAN_LINK_WITH_ENV(
242         [CFLAGS="$OPENMP_CFLAGS" LDFLAGS="$OPENMP_CFLAGS"],
243         [openmp_test_program],
244         [have_openmp=yes],
245         [have_openmp=no])
246   if test "x$have_openmp" = "xyes" ; then
247     AC_DEFINE(USE_OPENMP, 1, [use OpenMP in the test suite])
248   fi
249 fi
250 AC_SUBST(OPENMP_CFLAGS)
251
252 dnl =========================================================================
253 dnl -fvisibility stuff
254
255 PIXMAN_CHECK_CFLAG([-fvisibility=hidden], [dnl
256 #if defined(__GNUC__) && (__GNUC__ >= 4)
257 #ifdef _WIN32
258 #error Have -fvisibility but it is ignored and generates a warning
259 #endif
260 #else
261 #error Need GCC 4.0 for visibility
262 #endif
263 ])
264
265 PIXMAN_CHECK_CFLAG([-xldscope=hidden], [dnl
266 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
267 #else
268 #error Need Sun Studio 8 for visibility
269 #endif
270 ])
271
272 dnl ===========================================================================
273 dnl Check for Loongson Multimedia Instructions
274
275 if test "x$LS_CFLAGS" = "x" ; then
276     LS_CFLAGS="-march=loongson2f"
277 fi
278
279 have_loongson_mmi=no
280 AC_MSG_CHECKING(whether to use Loongson MMI assembler)
281
282 xserver_save_CFLAGS=$CFLAGS
283 CFLAGS=" $LS_CFLAGS $CFLAGS -I$srcdir"
284 AC_LINK_IFELSE([AC_LANG_SOURCE([[
285 #ifndef __mips_loongson_vector_rev
286 #error "Loongson Multimedia Instructions are only available on Loongson"
287 #endif
288 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
289 #error "Need GCC >= 4.4 for Loongson MMI compilation"
290 #endif
291 #include "pixman/loongson-mmintrin.h"
292 int main () {
293     union {
294         __m64 v;
295         char c[8];
296     } a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} };
297     int b = 4;
298     __m64 c = _mm_srli_pi16 (a.v, b);
299     return 0;
300 }]])], have_loongson_mmi=yes)
301 CFLAGS=$xserver_save_CFLAGS
302
303 AC_ARG_ENABLE(loongson-mmi,
304    [AC_HELP_STRING([--disable-loongson-mmi],
305                    [disable Loongson MMI fast paths])],
306    [enable_loongson_mmi=$enableval], [enable_loongson_mmi=auto])
307
308 if test $enable_loongson_mmi = no ; then
309    have_loongson_mmi=disabled
310 fi
311
312 if test $have_loongson_mmi = yes ; then
313    AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia Instructions])
314 else
315    LS_CFLAGS=
316 fi
317
318 AC_MSG_RESULT($have_loongson_mmi)
319 if test $enable_loongson_mmi = yes && test $have_loongson_mmi = no ; then
320    AC_MSG_ERROR([Loongson MMI not detected])
321 fi
322
323 AM_CONDITIONAL(USE_LOONGSON_MMI, test $have_loongson_mmi = yes)
324
325 dnl ===========================================================================
326 dnl Check for MMX
327
328 if test "x$MMX_CFLAGS" = "x" ; then
329    if test "x$SUNCC" = "xyes"; then
330       # Sun Studio doesn't have an -xarch=mmx flag, so we have to use sse
331       # but if we're building 64-bit, mmx & sse support is on by default and
332       # -xarch=sse throws an error instead
333       if test "$AMD64_ABI" = "no" ; then
334          MMX_CFLAGS="-xarch=sse"
335       fi
336    else
337       MMX_CFLAGS="-mmmx -Winline"
338    fi
339 fi
340
341 have_mmx_intrinsics=no
342 AC_MSG_CHECKING(whether to use MMX intrinsics)
343 xserver_save_CFLAGS=$CFLAGS
344 CFLAGS="$MMX_CFLAGS $CFLAGS"
345 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
346 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
347 #error "Need GCC >= 3.4 for MMX intrinsics"
348 #endif
349 #include <mmintrin.h>
350 #include <xmmintrin.h>
351 int main () {
352     __m64 v = _mm_cvtsi32_si64 (1);
353     __m64 w;
354
355     /* Test some intrinsics from xmmintrin.h */
356     w = _mm_shuffle_pi16(v, 5);
357     w = _mm_mulhi_pu16(w, w);
358
359     return _mm_cvtsi64_si32 (v);
360 }]])], have_mmx_intrinsics=yes)
361 CFLAGS=$xserver_save_CFLAGS
362
363 AC_ARG_ENABLE(mmx,
364    [AC_HELP_STRING([--disable-mmx],
365                    [disable x86 MMX fast paths])],
366    [enable_mmx=$enableval], [enable_mmx=auto])
367
368 if test $enable_mmx = no ; then
369    have_mmx_intrinsics=disabled
370 fi
371
372 if test $have_mmx_intrinsics = yes ; then
373    AC_DEFINE(USE_X86_MMX, 1, [use x86 MMX compiler intrinsics])
374 else
375    MMX_CFLAGS=
376 fi
377
378 AC_MSG_RESULT($have_mmx_intrinsics)
379 if test $enable_mmx = yes && test $have_mmx_intrinsics = no ; then
380    AC_MSG_ERROR([x86 MMX intrinsics not detected])
381 fi
382
383 AM_CONDITIONAL(USE_X86_MMX, test $have_mmx_intrinsics = yes)
384
385 dnl ===========================================================================
386 dnl Check for SSE2
387
388 if test "x$SSE2_CFLAGS" = "x" ; then
389    if test "x$SUNCC" = "xyes"; then
390       # SSE2 is enabled by default in the Sun Studio 64-bit environment
391       if test "$AMD64_ABI" = "no" ; then
392          SSE2_CFLAGS="-xarch=sse2"
393       fi
394    else
395       SSE2_CFLAGS="-msse2 -Winline"
396    fi
397 fi
398
399 have_sse2_intrinsics=no
400 AC_MSG_CHECKING(whether to use SSE2 intrinsics)
401 xserver_save_CFLAGS=$CFLAGS
402 CFLAGS="$SSE2_CFLAGS $CFLAGS"
403
404 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
405 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
406 #   if !defined(__amd64__) && !defined(__x86_64__)
407 #      error "Need GCC >= 4.2 for SSE2 intrinsics on x86"
408 #   endif
409 #endif
410 #include <mmintrin.h>
411 #include <xmmintrin.h>
412 #include <emmintrin.h>
413 int main () {
414     __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
415         c = _mm_xor_si128 (a, b);
416     return 0;
417 }]])], have_sse2_intrinsics=yes)
418 CFLAGS=$xserver_save_CFLAGS
419
420 AC_ARG_ENABLE(sse2,
421    [AC_HELP_STRING([--disable-sse2],
422                    [disable SSE2 fast paths])],
423    [enable_sse2=$enableval], [enable_sse2=auto])
424
425 if test $enable_sse2 = no ; then
426    have_sse2_intrinsics=disabled
427 fi
428
429 if test $have_sse2_intrinsics = yes ; then
430    AC_DEFINE(USE_SSE2, 1, [use SSE2 compiler intrinsics])
431 fi
432
433 AC_MSG_RESULT($have_sse2_intrinsics)
434 if test $enable_sse2 = yes && test $have_sse2_intrinsics = no ; then
435    AC_MSG_ERROR([SSE2 intrinsics not detected])
436 fi
437
438 AM_CONDITIONAL(USE_SSE2, test $have_sse2_intrinsics = yes)
439
440 dnl ===========================================================================
441 dnl Check for SSSE3
442
443 if test "x$SSSE3_CFLAGS" = "x" ; then
444     SSSE3_CFLAGS="-mssse3 -Winline"
445 fi
446
447 have_ssse3_intrinsics=no
448 AC_MSG_CHECKING(whether to use SSSE3 intrinsics)
449 xserver_save_CFLAGS=$CFLAGS
450 CFLAGS="$SSSE3_CFLAGS $CFLAGS"
451
452 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
453 #include <mmintrin.h>
454 #include <xmmintrin.h>
455 #include <emmintrin.h>
456 #include <tmmintrin.h>
457 int main () {
458     __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
459     c = _mm_maddubs_epi16 (a, b);
460     return 0;
461 }]])], have_ssse3_intrinsics=yes)
462 CFLAGS=$xserver_save_CFLAGS
463
464 AC_ARG_ENABLE(ssse3,
465    [AC_HELP_STRING([--disable-ssse3],
466                    [disable SSSE3 fast paths])],
467    [enable_ssse3=$enableval], [enable_ssse3=auto])
468
469 if test $enable_ssse3 = no ; then
470    have_ssse3_intrinsics=disabled
471 fi
472
473 if test $have_ssse3_intrinsics = yes ; then
474    AC_DEFINE(USE_SSSE3, 1, [use SSSE3 compiler intrinsics])
475 fi
476
477 AC_MSG_RESULT($have_ssse3_intrinsics)
478 if test $enable_ssse3 = yes && test $have_ssse3_intrinsics = no ; then
479    AC_MSG_ERROR([SSSE3 intrinsics not detected])
480 fi
481
482 AM_CONDITIONAL(USE_SSSE3, test $have_ssse3_intrinsics = yes)
483
484 dnl ===========================================================================
485 dnl Other special flags needed when building code using MMX or SSE instructions
486 case $host_os in
487    solaris*)
488       # When building 32-bit binaries, apply a mapfile to ensure that the
489       # binaries aren't flagged as only able to run on MMX+SSE capable CPUs
490       # since they check at runtime before using those instructions.
491       # Not all linkers grok the mapfile format so we check for that first.
492       if test "$AMD64_ABI" = "no" ; then
493          use_hwcap_mapfile=no
494          AC_MSG_CHECKING(whether to use a hardware capability map file)
495          hwcap_save_LDFLAGS="$LDFLAGS"
496          HWCAP_LDFLAGS='-Wl,-M,$(srcdir)/solaris-hwcap.mapfile'
497          LDFLAGS="$LDFLAGS -Wl,-M,pixman/solaris-hwcap.mapfile"
498          AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
499                         use_hwcap_mapfile=yes,
500                         HWCAP_LDFLAGS="")
501          LDFLAGS="$hwcap_save_LDFLAGS"
502          AC_MSG_RESULT($use_hwcap_mapfile)
503       fi
504       if test "x$MMX_LDFLAGS" = "x" ; then
505          MMX_LDFLAGS="$HWCAP_LDFLAGS"
506       fi
507       if test "x$SSE2_LDFLAGS" = "x" ; then
508          SSE2_LDFLAGS="$HWCAP_LDFLAGS"
509       fi
510       ;;
511 esac
512
513 AC_SUBST(LS_CFLAGS)
514 AC_SUBST(IWMMXT_CFLAGS)
515 AC_SUBST(MMX_CFLAGS)
516 AC_SUBST(MMX_LDFLAGS)
517 AC_SUBST(SSE2_CFLAGS)
518 AC_SUBST(SSE2_LDFLAGS)
519 AC_SUBST(SSSE3_CFLAGS)
520
521 dnl ===========================================================================
522 dnl Check for VMX/Altivec
523 if test -n "`$CC -v 2>&1 | grep version | grep Apple`"; then
524     VMX_CFLAGS="-faltivec"
525 else
526     VMX_CFLAGS="-maltivec -mabi=altivec"
527 fi
528
529 have_vmx_intrinsics=no
530 AC_MSG_CHECKING(whether to use VMX/Altivec intrinsics)
531 xserver_save_CFLAGS=$CFLAGS
532 CFLAGS="$VMX_CFLAGS $CFLAGS"
533 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
534 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
535 #error "Need GCC >= 3.4 for sane altivec support"
536 #endif
537 #include <altivec.h>
538 int main () {
539     vector unsigned int v = vec_splat_u32 (1);
540     v = vec_sub (v, v);
541     return 0;
542 }]])], have_vmx_intrinsics=yes)
543 CFLAGS=$xserver_save_CFLAGS
544
545 AC_ARG_ENABLE(vmx,
546    [AC_HELP_STRING([--disable-vmx],
547                    [disable VMX fast paths])],
548    [enable_vmx=$enableval], [enable_vmx=auto])
549
550 if test $enable_vmx = no ; then
551    have_vmx_intrinsics=disabled
552 fi
553
554 if test $have_vmx_intrinsics = yes ; then
555    AC_DEFINE(USE_VMX, 1, [use VMX compiler intrinsics])
556 else
557    VMX_CFLAGS=
558 fi
559
560 AC_MSG_RESULT($have_vmx_intrinsics)
561 if test $enable_vmx = yes && test $have_vmx_intrinsics = no ; then
562    AC_MSG_ERROR([VMX intrinsics not detected])
563 fi
564
565 AC_SUBST(VMX_CFLAGS)
566
567 AM_CONDITIONAL(USE_VMX, test $have_vmx_intrinsics = yes)
568
569 dnl ==========================================================================
570 dnl Check if assembler is gas compatible and supports ARM SIMD instructions
571 have_arm_simd=no
572 AC_MSG_CHECKING(whether to use ARM SIMD assembler)
573 xserver_save_CFLAGS=$CFLAGS
574 CFLAGS="-x assembler-with-cpp $CFLAGS"
575 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
576 .text
577 .arch armv6
578 .object_arch armv4
579 .arm
580 .altmacro
581 #ifndef __ARM_EABI__
582 #error EABI is required (to be sure that calling conventions are compatible)
583 #endif
584 pld [r0]
585 uqadd8 r0, r0, r0]])], have_arm_simd=yes)
586 CFLAGS=$xserver_save_CFLAGS
587
588 AC_ARG_ENABLE(arm-simd,
589    [AC_HELP_STRING([--disable-arm-simd],
590                    [disable ARM SIMD fast paths])],
591    [enable_arm_simd=$enableval], [enable_arm_simd=auto])
592
593 if test $enable_arm_simd = no ; then
594    have_arm_simd=disabled
595 fi
596
597 if test $have_arm_simd = yes ; then
598    AC_DEFINE(USE_ARM_SIMD, 1, [use ARM SIMD assembly optimizations])
599 fi
600
601 AM_CONDITIONAL(USE_ARM_SIMD, test $have_arm_simd = yes)
602
603 AC_MSG_RESULT($have_arm_simd)
604 if test $enable_arm_simd = yes && test $have_arm_simd = no ; then
605    AC_MSG_ERROR([ARM SIMD intrinsics not detected])
606 fi
607
608 dnl ==========================================================================
609 dnl Check if assembler is gas compatible and supports NEON instructions
610 have_arm_neon=no
611 AC_MSG_CHECKING(whether to use ARM NEON assembler)
612 xserver_save_CFLAGS=$CFLAGS
613 CFLAGS="-x assembler-with-cpp $CFLAGS"
614 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
615 .text
616 .fpu neon
617 .arch armv7a
618 .object_arch armv4
619 .eabi_attribute 10, 0
620 .arm
621 .altmacro
622 #ifndef __ARM_EABI__
623 #error EABI is required (to be sure that calling conventions are compatible)
624 #endif
625 pld [r0]
626 vmovn.u16 d0, q0]])], have_arm_neon=yes)
627 CFLAGS=$xserver_save_CFLAGS
628
629 AC_ARG_ENABLE(arm-neon,
630    [AC_HELP_STRING([--disable-arm-neon],
631                    [disable ARM NEON fast paths])],
632    [enable_arm_neon=$enableval], [enable_arm_neon=auto])
633
634 if test $enable_arm_neon = no ; then
635    have_arm_neon=disabled
636 fi
637
638 if test $have_arm_neon = yes ; then
639    AC_DEFINE(USE_ARM_NEON, 1, [use ARM NEON assembly optimizations])
640 fi
641
642 AM_CONDITIONAL(USE_ARM_NEON, test $have_arm_neon = yes)
643
644 AC_MSG_RESULT($have_arm_neon)
645 if test $enable_arm_neon = yes && test $have_arm_neon = no ; then
646    AC_MSG_ERROR([ARM NEON intrinsics not detected])
647 fi
648
649 dnl ===========================================================================
650 dnl Check for IWMMXT
651
652 AC_ARG_ENABLE(arm-iwmmxt,
653    [AC_HELP_STRING([--disable-arm-iwmmxt],
654                    [disable ARM IWMMXT fast paths])],
655    [enable_iwmmxt=$enableval], [enable_iwmmxt=auto])
656
657 AC_ARG_ENABLE(arm-iwmmxt2,
658    [AC_HELP_STRING([--disable-arm-iwmmxt2],
659                    [build ARM IWMMXT fast paths with -march=iwmmxt instead of -march=iwmmxt2])],
660    [enable_iwmmxt2=$enableval], [enable_iwmmxt2=auto])
661
662 if test "x$IWMMXT_CFLAGS" = "x" ; then
663    IWMMXT_CFLAGS="-flax-vector-conversions -Winline -march=iwmmxt"
664    if test $enable_iwmmxt2 != no ; then
665       IWMMXT_CFLAGS="${IWMMXT_CFLAGS}2"
666    fi
667 fi
668
669 have_iwmmxt_intrinsics=no
670 AC_MSG_CHECKING(whether to use ARM IWMMXT intrinsics)
671 xserver_save_CFLAGS=$CFLAGS
672 CFLAGS="$CFLAGS $IWMMXT_CFLAGS"
673 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
674 #ifndef __arm__
675 #error "IWMMXT is only available on ARM"
676 #endif
677 #ifndef __IWMMXT__
678 #error "IWMMXT not enabled (with -march=iwmmxt)"
679 #endif
680 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
681 #error "Need GCC >= 4.8 for IWMMXT intrinsics"
682 #endif
683 #include <mmintrin.h>
684 int main () {
685         union {
686                 __m64 v;
687                 char c[8];
688         } a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} };
689         int b = 4;
690         __m64 c = _mm_srli_si64 (a.v, b);
691 }]])], have_iwmmxt_intrinsics=yes)
692 CFLAGS=$xserver_save_CFLAGS
693
694 if test $enable_iwmmxt = no ; then
695    have_iwmmxt_intrinsics=disabled
696 fi
697
698 if test $have_iwmmxt_intrinsics = yes ; then
699    AC_DEFINE(USE_ARM_IWMMXT, 1, [use ARM IWMMXT compiler intrinsics])
700 else
701    IWMMXT_CFLAGS=
702 fi
703
704 AC_MSG_RESULT($have_iwmmxt_intrinsics)
705 if test $enable_iwmmxt = yes && test $have_iwmmxt_intrinsics = no ; then
706    AC_MSG_ERROR([IWMMXT intrinsics not detected])
707 fi
708
709 AM_CONDITIONAL(USE_ARM_IWMMXT, test $have_iwmmxt_intrinsics = yes)
710
711 dnl ==========================================================================
712 dnl Check if assembler is gas compatible and supports MIPS DSPr2 instructions
713
714 have_mips_dspr2=no
715 AC_MSG_CHECKING(whether to use MIPS DSPr2 assembler)
716 xserver_save_CFLAGS=$CFLAGS
717 CFLAGS="-mdspr2 $CFLAGS"
718
719 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
720 #if !(defined(__mips__) &&  __mips_isa_rev >= 2)
721 #error MIPS DSPr2 is currently only available on MIPS32r2 platforms.
722 #endif
723 int
724 main ()
725 {
726     int c = 0, a = 0, b = 0;
727     __asm__ __volatile__ (
728         "precr.qb.ph %[c], %[a], %[b]          \n\t"
729         : [c] "=r" (c)
730         : [a] "r" (a), [b] "r" (b)
731     );
732     return c;
733 }]])], have_mips_dspr2=yes)
734 CFLAGS=$xserver_save_CFLAGS
735
736 AC_ARG_ENABLE(mips-dspr2,
737    [AC_HELP_STRING([--disable-mips-dspr2],
738                    [disable MIPS DSPr2 fast paths])],
739    [enable_mips_dspr2=$enableval], [enable_mips_dspr2=auto])
740
741 if test $enable_mips_dspr2 = no ; then
742    have_mips_dspr2=disabled
743 fi
744
745 if test $have_mips_dspr2 = yes ; then
746    AC_DEFINE(USE_MIPS_DSPR2, 1, [use MIPS DSPr2 assembly optimizations])
747 fi
748
749 AM_CONDITIONAL(USE_MIPS_DSPR2, test $have_mips_dspr2 = yes)
750
751 AC_MSG_RESULT($have_mips_dspr2)
752 if test $enable_mips_dspr2 = yes && test $have_mips_dspr2 = no ; then
753    AC_MSG_ERROR([MIPS DSPr2 instructions not detected])
754 fi
755
756 dnl =========================================================================================
757 dnl Check for GNU-style inline assembly support
758
759 have_gcc_inline_asm=no
760 AC_MSG_CHECKING(whether to use GNU-style inline assembler)
761 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
762 int main () {
763     /* Most modern architectures have a NOP instruction, so this is a fairly generic test. */
764         asm volatile ( "\tnop\n" : : : "cc", "memory" );
765     return 0;
766 }]])], have_gcc_inline_asm=yes)
767
768 AC_ARG_ENABLE(gcc-inline-asm,
769    [AC_HELP_STRING([--disable-gcc-inline-asm],
770                    [disable GNU-style inline assembler])],
771    [enable_gcc_inline_asm=$enableval], [enable_gcc_inline_asm=auto])
772
773 if test $enable_gcc_inline_asm = no ; then
774    have_gcc_inline_asm=disabled
775 fi
776
777 if test $have_gcc_inline_asm = yes ; then
778    AC_DEFINE(USE_GCC_INLINE_ASM, 1, [use GNU-style inline assembler])
779 fi
780
781 AC_MSG_RESULT($have_gcc_inline_asm)
782 if test $enable_gcc_inline_asm = yes && test $have_gcc_inline_asm = no ; then
783    AC_MSG_ERROR([GNU-style inline assembler not detected])
784 fi
785
786 AM_CONDITIONAL(USE_GCC_INLINE_ASM, test $have_gcc_inline_asm = yes)
787
788 dnl ==============================================
789 dnl Static test programs
790
791 AC_ARG_ENABLE(static-testprogs,
792    [AC_HELP_STRING([--enable-static-testprogs],
793                    [build test programs as static binaries [default=no]])],
794    [enable_static_testprogs=$enableval], [enable_static_testprogs=no])
795
796 TESTPROGS_EXTRA_LDFLAGS=
797 if test "x$enable_static_testprogs" = "xyes" ; then
798    TESTPROGS_EXTRA_LDFLAGS="-all-static"
799 fi
800 AC_SUBST(TESTPROGS_EXTRA_LDFLAGS)
801
802 dnl ==============================================
803 dnl Timers
804
805 AC_ARG_ENABLE(timers,
806    [AC_HELP_STRING([--enable-timers],
807                    [enable TIMER_BEGIN and TIMER_END macros [default=no]])],
808    [enable_timers=$enableval], [enable_timers=no])
809
810 if test $enable_timers = yes ; then 
811    AC_DEFINE(PIXMAN_TIMERS, 1, [enable TIMER_BEGIN/TIMER_END macros])
812 fi
813 AC_SUBST(PIXMAN_TIMERS)
814
815 dnl ===================================
816 dnl GTK+
817
818 AC_ARG_ENABLE(gtk,
819    [AC_HELP_STRING([--enable-gtk],
820                    [enable tests using GTK+ [default=auto]])],
821    [enable_gtk=$enableval], [enable_gtk=auto])
822
823 PKG_PROG_PKG_CONFIG
824
825 if test $enable_gtk = yes ; then
826    AC_CHECK_LIB([pixman-1], [pixman_version_string])
827    PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.16 pixman-1])
828 fi
829
830 if test $enable_gtk = auto ; then
831    AC_CHECK_LIB([pixman-1], [pixman_version_string], [enable_gtk=auto], [enable_gtk=no])
832 fi
833
834 if test $enable_gtk = auto ; then
835    PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.16 pixman-1], [enable_gtk=yes], [enable_gtk=no])
836 fi
837
838 AM_CONDITIONAL(HAVE_GTK, [test "x$enable_gtk" = xyes])
839
840 AC_SUBST(GTK_CFLAGS)
841 AC_SUBST(GTK_LIBS)
842
843 dnl =====================================
844 dnl posix_memalign, sigaction, alarm, gettimeofday
845
846 AC_CHECK_FUNC(posix_memalign, have_posix_memalign=yes, have_posix_memalign=no)
847 if test x$have_posix_memalign = xyes; then
848    AC_DEFINE(HAVE_POSIX_MEMALIGN, 1, [Whether we have posix_memalign()])
849 fi
850
851 AC_CHECK_FUNC(sigaction, have_sigaction=yes, have_sigaction=no)
852 if test x$have_sigaction = xyes; then
853    AC_DEFINE(HAVE_SIGACTION, 1, [Whether we have sigaction()])
854 fi
855
856 AC_CHECK_FUNC(alarm, have_alarm=yes, have_alarm=no)
857 if test x$have_alarm = xyes; then
858    AC_DEFINE(HAVE_ALARM, 1, [Whether we have alarm()])
859 fi
860
861 AC_CHECK_HEADER([sys/mman.h],
862    [AC_DEFINE(HAVE_SYS_MMAN_H, [1], [Define to 1 if we have <sys/mman.h>])])
863
864 AC_CHECK_FUNC(mmap, have_mmap=yes, have_mmap=no)
865 if test x$have_mmap = xyes; then
866    AC_DEFINE(HAVE_MMAP, 1, [Whether we have mmap()])
867 fi
868
869 AC_CHECK_FUNC(mprotect, have_mprotect=yes, have_mprotect=no)
870 if test x$have_mprotect = xyes; then
871    AC_DEFINE(HAVE_MPROTECT, 1, [Whether we have mprotect()])
872 fi
873
874 AC_CHECK_FUNC(getpagesize, have_getpagesize=yes, have_getpagesize=no)
875 if test x$have_getpagesize = xyes; then
876    AC_DEFINE(HAVE_GETPAGESIZE, 1, [Whether we have getpagesize()])
877 fi
878
879 AC_CHECK_HEADER([fenv.h],
880    [AC_DEFINE(HAVE_FENV_H, [1], [Define to 1 if we have <fenv.h>])])
881
882 AC_CHECK_LIB(m, feenableexcept, have_feenableexcept=yes, have_feenableexcept=no)
883 if test x$have_feenableexcept = xyes; then
884    AC_DEFINE(HAVE_FEENABLEEXCEPT, 1, [Whether we have feenableexcept()])
885 fi
886
887 AC_CHECK_DECL([FE_DIVBYZERO],
888         [AC_DEFINE(HAVE_FEDIVBYZERO, 1, [Whether we have FE_DIVBYZERO])],
889         [],
890         [[#include <fenv.h>]])
891
892 AC_CHECK_FUNC(gettimeofday, have_gettimeofday=yes, have_gettimeofday=no)
893 AC_CHECK_HEADER(sys/time.h, have_sys_time_h=yes, have_sys_time_h=no)
894 if test x$have_gettimeofday = xyes && test x$have_sys_time_h = xyes; then
895    AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Whether we have gettimeofday()])
896 fi
897
898 dnl =====================================
899 dnl Check for missing sqrtf() as, e.g., for Solaris 9
900
901 AC_SEARCH_LIBS([sqrtf], [m], [],
902                [AC_DEFINE([sqrtf], [sqrt],
903                           [Define to sqrt if you do not have the `sqrtf' function.])])
904
905 dnl =====================================
906 dnl Thread local storage
907
908 AC_MSG_CHECKING(for thread local storage (TLS) support)
909 AC_CACHE_VAL(ac_cv_tls, [
910     ac_cv_tls=none
911     keywords="__thread __declspec(thread)"
912     for kw in $keywords ; do
913         AC_TRY_COMPILE([
914 #if defined(__MINGW32__) && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
915 #error This MinGW version has broken __thread support
916 #endif
917 #ifdef __OpenBSD__
918 #error OpenBSD has broken __thread support
919 #endif
920
921 int $kw test;], [], [ac_cv_tls=$kw; break])
922     done
923 ])
924 AC_MSG_RESULT($ac_cv_tls)
925
926 if test "$ac_cv_tls" != "none"; then
927     AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [The compiler supported TLS storage class])
928 fi
929
930 dnl
931 dnl posix tls
932 dnl
933
934 m4_define([pthread_test_program],AC_LANG_SOURCE([[dnl
935 #include <stdlib.h>
936 #include <pthread.h>
937
938 static pthread_once_t once_control = PTHREAD_ONCE_INIT;
939 static pthread_key_t key;
940
941 static void
942 make_key (void)
943 {
944     pthread_key_create (&key, NULL);
945 }
946
947 int
948 main ()
949 {
950     void *value = NULL;
951
952     if (pthread_once (&once_control, make_key) != 0)
953     {
954         value = NULL;
955     }
956     else
957     {
958         value = pthread_getspecific (key);
959         if (!value)
960         {
961             value = malloc (100);
962             pthread_setspecific (key, value);
963         }
964     }
965     return 0;
966 }
967 ]]))
968
969 AC_DEFUN([PIXMAN_CHECK_PTHREAD],[dnl
970     if test "z$support_for_pthreads" != "zyes"; then
971         PIXMAN_LINK_WITH_ENV(
972                 [$1], [pthread_test_program],
973                 [PTHREAD_CFLAGS="$CFLAGS"
974                  PTHREAD_LIBS="$LIBS"
975                  PTHREAD_LDFLAGS="$LDFLAGS"
976                  support_for_pthreads=yes])
977     fi
978 ])
979
980 support_for_pthreads=no
981
982 AC_MSG_CHECKING(for pthreads)
983
984 PIXMAN_CHECK_PTHREAD([CFLAGS="-pthread"; LDFLAGS="-pthread"])
985 PIXMAN_CHECK_PTHREAD([CFLAGS="-D_REENTRANT"; LIBS="-lpthread"])
986 PIXMAN_CHECK_PTHREAD([CFLAGS="-D_REENTRANT"; LDFLAGS="-lroot"])
987     
988 if test $support_for_pthreads = yes; then
989     AC_DEFINE([HAVE_PTHREADS], [], [Whether pthreads is supported])
990     if test $ac_cv_tls = none ; then
991         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
992     fi
993 fi
994
995 AC_MSG_RESULT($support_for_pthreads)
996
997 AC_SUBST(TOOLCHAIN_SUPPORTS__THREAD)
998 AC_SUBST(HAVE_PTHREADS)
999 AC_SUBST(PTHREAD_LDFLAGS)
1000 AC_SUBST(PTHREAD_LIBS)
1001 AC_SUBST(PTHREAD_CFLAGS)
1002
1003 dnl =====================================
1004 dnl __attribute__((constructor))
1005
1006 support_for_attribute_constructor=no
1007
1008 AC_MSG_CHECKING(for __attribute__((constructor)))
1009 AC_LINK_IFELSE([AC_LANG_SOURCE([[
1010 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
1011 /* attribute 'constructor' is supported since gcc 2.7, but some compilers
1012  * may only pretend to be gcc, so let's try to actually use it
1013  */
1014 static int x = 1;
1015 static void __attribute__((constructor)) constructor_function () { x = 0; }
1016 int main (void) { return x; }
1017 #else
1018 #error not gcc or gcc version is older than 2.7
1019 #endif
1020 ]])], support_for_attribute_constructor=yes)
1021
1022 if test x$support_for_attribute_constructor = xyes; then
1023    AC_DEFINE([TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR],
1024              [],[Whether the tool chain supports __attribute__((constructor))])
1025 fi
1026
1027 AC_MSG_RESULT($support_for_attribute_constructor)
1028 AC_SUBST(TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR)
1029
1030 dnl =====================================
1031 dnl __float128
1032
1033 support_for_float128=no
1034
1035 AC_MSG_CHECKING(for __float128)
1036 AC_LINK_IFELSE([AC_LANG_SOURCE([[
1037 __float128 a = 1.0Q, b = 2.0Q; int main (void) { return a + b; }
1038 ]])], support_for_float128=yes)
1039
1040 if test x$support_for_float128 = xyes; then
1041    AC_DEFINE([HAVE_FLOAT128], [], [Whether the tool chain supports __float128])
1042 fi
1043
1044 AC_MSG_RESULT($support_for_float128)
1045
1046 dnl =====================================
1047 dnl __builtin_clz
1048
1049 support_for_builtin_clz=no
1050
1051 AC_MSG_CHECKING(for __builtin_clz)
1052 AC_LINK_IFELSE([AC_LANG_SOURCE([[
1053 unsigned int x = 11; int main (void) { return __builtin_clz(x); }
1054 ]])], support_for_builtin_clz=yes)
1055
1056 if test x$support_for_builtin_clz = xyes; then
1057    AC_DEFINE([HAVE_BUILTIN_CLZ], [], [Whether the compiler supports __builtin_clz])
1058 fi
1059
1060 AC_MSG_RESULT($support_for_builtin_clz)
1061
1062 dnl =====================================
1063 dnl GCC vector extensions
1064
1065 support_for_gcc_vector_extensions=no
1066
1067 AC_MSG_CHECKING(for GCC vector extensions)
1068 AC_LINK_IFELSE([AC_LANG_SOURCE([[
1069 unsigned int __attribute__ ((vector_size(16))) e, a, b;
1070 int main (void) { e = a - ((b << 27) + (b >> (32 - 27))) + 1; return e[0]; }
1071 ]])], support_for_gcc_vector_extensions=yes)
1072
1073 if test x$support_for_gcc_vector_extensions = xyes; then
1074    AC_DEFINE([HAVE_GCC_VECTOR_EXTENSIONS], [],
1075              [Whether the compiler supports GCC vector extensions])
1076 fi
1077
1078 AC_MSG_RESULT($support_for_gcc_vector_extensions)
1079
1080 dnl ==================
1081 dnl libpng
1082
1083 AC_ARG_ENABLE(libpng, AS_HELP_STRING([--enable-libpng], [Build support for libpng (default: auto)]),
1084                       [have_libpng=$enableval], [have_libpng=auto])
1085
1086 case x$have_libpng in
1087         xyes) PKG_CHECK_MODULES(PNG, [libpng]) ;;
1088         xno) ;;
1089         *) PKG_CHECK_MODULES(PNG, [libpng], have_libpng=yes, have_libpng=no) ;;
1090 esac
1091
1092 if test x$have_libpng = xyes; then
1093     AC_DEFINE([HAVE_LIBPNG], [1], [Whether we have libpng])
1094 fi
1095
1096 AC_SUBST(HAVE_LIBPNG)
1097
1098 AC_OUTPUT([pixman-1.pc
1099            pixman-1-uninstalled.pc
1100            Makefile
1101            pixman/Makefile
1102            pixman/pixman-version.h
1103            demos/Makefile
1104            test/Makefile])
1105
1106 m4_if(m4_eval(pixman_minor % 2), [1], [
1107    echo
1108    echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
1109    echo
1110    echo "      Thanks for testing this development snapshot of pixman. Please"
1111    echo "      report any problems you find, either by sending email to "
1112    echo
1113    echo "          pixman@lists.freedesktop.org"
1114    echo
1115    echo "      or by filing a bug at "
1116    echo
1117    echo "          https://bugs.freedesktop.org/enter_bug.cgi?product=pixman "
1118    echo
1119    echo "      If you are looking for a stable release of pixman, please note "
1120    echo "      that stable releases have _even_ minor version numbers. Ie., "
1121    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 "
1122    echo "      development snapshot that may contain bugs and experimental "
1123    echo "      features. "
1124    echo 
1125    echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
1126    echo
1127 ])