Check that the OpenMP pragmas don't cause link errors.
[profile/ivi/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 even MICRO 
30 #     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], 19)
57 m4_define([pixman_micro], 1)
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 AM_CONFIG_HEADER(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(
81 dnl     CFLAGS=... LDFLAGS=... LIBS=...,
82 dnl     program, true-action, false-action)
83 AC_DEFUN([PIXMAN_LINK_WITH_ENV],[dnl
84         save_CFLAGS="$CFLAGS"
85         save_LDFLAGS="$LDFLAGS"
86         save_LIBS="$LIBS"
87         CFLAGS=""
88         LDFLAGS=""
89         LIBS=""
90         $1
91         AC_LINK_IFELSE([$2], [$3], [$4])
92         CFLAGS="$save_CFLAGS"
93         LDFLAGS="$save_LDFLAGS"
94         LIBS="$save_LIBS"
95 ])
96
97 AC_CHECK_SIZEOF(long)
98
99 # Checks for Sun Studio compilers
100 AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
101 AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"])
102
103 # Default CFLAGS to -O -g rather than just the -g from AC_PROG_CC
104 # if we're using Sun Studio and neither the user nor a config.site
105 # has set CFLAGS.
106 if test $SUNCC = yes &&                 \
107    test "$test_CFLAGS" == "" &&         \
108    test "$CFLAGS" = "-g"
109 then
110   CFLAGS="-O -g"
111 fi
112
113
114 # We ignore pixman_major in the version here because the major version should
115 # always be encoded in the actual library name. Ie., the soname is:
116 #
117 #      pixman-$(pixman_major).0.minor.micro
118 #
119 m4_define([lt_current], [pixman_minor])
120 m4_define([lt_revision], [pixman_micro])
121 m4_define([lt_age], [pixman_minor])
122
123 LT_VERSION_INFO="lt_current:lt_revision:lt_age"
124
125 PIXMAN_VERSION_MAJOR=pixman_major()
126 AC_SUBST(PIXMAN_VERSION_MAJOR)
127 PIXMAN_VERSION_MINOR=pixman_minor()
128 AC_SUBST(PIXMAN_VERSION_MINOR)
129 PIXMAN_VERSION_MICRO=pixman_micro()
130 AC_SUBST(PIXMAN_VERSION_MICRO)
131
132 AC_SUBST(LT_VERSION_INFO)
133
134 # Check for dependencies
135 #PKG_CHECK_MODULES(DEP, x11)
136
137 changequote(,)dnl
138 if test "x$GCC" = "xyes"; then
139
140   case " $CFLAGS " in
141   *[\ \ ]-Wall[\ \      ]*) ;;
142   *) CFLAGS="$CFLAGS -Wall" ;;
143   esac 
144
145   case " $CFLAGS " in
146   *[\ \ ]-fno-strict-aliasing[\ \       ]*) ;;
147   *) CFLAGS="$CFLAGS -fno-strict-aliasing" ;;
148   esac
149
150 fi changequote([,])dnl
151
152 AC_PATH_PROG(PERL, perl, no)
153 if test "x$PERL" = xno; then
154     AC_MSG_ERROR([Perl is required to build pixman.])
155 fi
156 AC_SUBST(PERL)
157
158 dnl =========================================================================
159 dnl OpenMP for the test suite?
160 dnl
161
162 # Check for OpenMP support (only supported by autoconf >=2.62)
163 OPENMP_CFLAGS=
164 m4_ifdef([AC_OPENMP], [AC_OPENMP])
165
166 m4_define([openmp_test_program],[dnl
167 #include <stdio.h>
168
169 extern unsigned int lcg_seed;
170 #pragma omp threadprivate(lcg_seed)
171 unsigned int lcg_seed;
172
173 unsigned function(unsigned a, unsigned b)
174 {
175         lcg_seed ^= b;
176         return ((a + b) ^ a ) + lcg_seed;
177 }
178
179 int main(int argc, char **argv)
180 {
181         int i;
182         int n1 = 0, n2 = argc;
183         unsigned checksum = 0;
184         int verbose = argv != NULL;
185         unsigned (*test_function)(unsigned, unsigned);
186         test_function = function;
187     #pragma omp parallel for reduction(+:checksum) default(none) \
188                                         shared(n1, n2, test_function, verbose)
189         for (i = n1; i < n2; i++)
190         {
191                 unsigned crc = test_function (i, 0);
192                 if (verbose)
193                         printf ("%d: %08X\n", i, crc);
194                 checksum += crc;
195         }
196         printf("%u\n", checksum);
197         return 0;
198 }
199 ])
200
201 PIXMAN_LINK_WITH_ENV(
202         [CFLAGS="$OPENMP_CFLAGS" LDFLAGS="$OPENMP_CFLAGS"],
203         [openmp_test_program],
204         [have_openmp=yes],
205         [have_openmp=no])
206 if test "x$have_openmp" = "xyes"; then
207    AC_DEFINE(USE_OPENMP, 1, [use OpenMP in the test suite])
208 else
209    OPENMP_CFLAGS=""
210 fi
211 AC_SUBST(OPENMP_CFLAGS)
212
213 dnl =========================================================================
214 dnl -fvisibility stuff
215
216 have_gcc4=no
217 AC_MSG_CHECKING(for -fvisibility)
218 AC_COMPILE_IFELSE([
219 #if defined(__GNUC__) && (__GNUC__ >= 4)
220 #else
221 error Need GCC 4.0 for visibility
222 #endif
223 int main () { return 0; } 
224 ], have_gcc4=yes)
225
226 if test "x$have_gcc4" = "xyes"; then
227    CFLAGS="$CFLAGS -fvisibility=hidden"
228 fi
229 AC_MSG_RESULT($have_gcc4)
230
231 have_sunstudio8=no
232 AC_MSG_CHECKING([for -xldscope (Sun compilers)])
233 AC_COMPILE_IFELSE([
234 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
235 #else
236 error Need Sun Studio 8 for visibility
237 #endif
238 int main () { return 0; } 
239 ], have_sunstudio8=yes)
240
241 if test "x$have_sunstudio8" = "xyes"; then
242    CFLAGS="$CFLAGS -xldscope=hidden"
243 fi
244 AC_MSG_RESULT($have_sunstudio8)
245
246 dnl ===========================================================================
247 dnl Check for MMX
248
249 if test "x$MMX_CFLAGS" = "x" ; then
250    if test "x$SUNCC" = "xyes"; then
251       # Sun Studio doesn't have an -xarch=mmx flag, so we have to use sse
252       # but if we're building 64-bit, mmx & sse support is on by default and
253       # -xarch=sse throws an error instead
254       if test "$AMD64_ABI" = "no" ; then
255          MMX_CFLAGS="-xarch=sse"
256       fi
257    else
258       MMX_CFLAGS="-mmmx -Winline"
259    fi
260 fi
261
262 have_mmx_intrinsics=no
263 AC_MSG_CHECKING(whether to use MMX intrinsics)
264 xserver_save_CFLAGS=$CFLAGS
265 CFLAGS="$MMX_CFLAGS $CFLAGS"
266 AC_COMPILE_IFELSE([
267 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
268 error "Need GCC >= 3.4 for MMX intrinsics"
269 #endif
270 #include <mmintrin.h>
271 int main () {
272     __m64 v = _mm_cvtsi32_si64 (1);
273     return _mm_cvtsi64_si32 (v);
274 }], have_mmx_intrinsics=yes)
275 CFLAGS=$xserver_save_CFLAGS
276
277 AC_ARG_ENABLE(mmx,
278    [AC_HELP_STRING([--disable-mmx],
279                    [disable MMX fast paths])],
280    [enable_mmx=$enableval], [enable_mmx=auto])
281
282 if test $enable_mmx = no ; then
283    have_mmx_intrinsics=disabled
284 fi
285
286 if test $have_mmx_intrinsics = yes ; then
287    AC_DEFINE(USE_MMX, 1, [use MMX compiler intrinsics])
288 else
289    MMX_CFLAGS=
290 fi
291
292 AC_MSG_RESULT($have_mmx_intrinsics)
293 if test $enable_mmx = yes && test $have_mmx_intrinsics = no ; then
294    AC_MSG_ERROR([MMX intrinsics not detected])
295 fi
296
297 AM_CONDITIONAL(USE_MMX, test $have_mmx_intrinsics = yes)
298
299 dnl ===========================================================================
300 dnl Check for SSE2
301
302 if test "x$SSE2_CFLAGS" = "x" ; then
303    if test "x$SUNCC" = "xyes"; then
304       # SSE2 is enabled by default in the Sun Studio 64-bit environment
305       if test "$AMD64_ABI" = "no" ; then
306          SSE2_CFLAGS="-xarch=sse2"
307       fi
308    else
309       SSE2_CFLAGS="-mmmx -msse2 -Winline"
310    fi
311 fi
312
313 have_sse2_intrinsics=no
314 AC_MSG_CHECKING(whether to use SSE2 intrinsics)
315 xserver_save_CFLAGS=$CFLAGS
316 CFLAGS="$SSE2_CFLAGS $CFLAGS"
317
318 AC_COMPILE_IFELSE([
319 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
320 #   if !defined(__amd64__) && !defined(__x86_64__)
321 #      error "Need GCC >= 4.2 for SSE2 intrinsics on x86"
322 #   endif
323 #endif
324 #include <mmintrin.h>
325 #include <xmmintrin.h>
326 #include <emmintrin.h>
327 int main () {
328     __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
329         c = _mm_xor_si128 (a, b);
330     return 0;
331 }], have_sse2_intrinsics=yes)
332 CFLAGS=$xserver_save_CFLAGS
333
334 AC_ARG_ENABLE(sse2,
335    [AC_HELP_STRING([--disable-sse2],
336                    [disable SSE2 fast paths])],
337    [enable_sse2=$enableval], [enable_sse2=auto])
338
339 if test $enable_sse2 = no ; then
340    have_sse2_intrinsics=disabled
341 fi
342
343 if test $have_sse2_intrinsics = yes ; then
344    AC_DEFINE(USE_SSE2, 1, [use SSE2 compiler intrinsics])
345 fi
346
347 AC_MSG_RESULT($have_sse2_intrinsics)
348 if test $enable_sse2 = yes && test $have_sse2_intrinsics = no ; then
349    AC_MSG_ERROR([SSE2 intrinsics not detected])
350 fi
351
352 AM_CONDITIONAL(USE_SSE2, test $have_sse2_intrinsics = yes)
353
354 dnl ===========================================================================
355 dnl Other special flags needed when building code using MMX or SSE instructions
356 case $host_os in
357    solaris*)
358       # When building 32-bit binaries, apply a mapfile to ensure that the
359       # binaries aren't flagged as only able to run on MMX+SSE capable CPUs
360       # since they check at runtime before using those instructions.
361       # Not all linkers grok the mapfile format so we check for that first.
362       if test "$AMD64_ABI" = "no" ; then
363          use_hwcap_mapfile=no
364          AC_MSG_CHECKING(whether to use a hardware capability map file)
365          hwcap_save_LDFLAGS="$LDFLAGS"
366          HWCAP_LDFLAGS='-Wl,-M,$(srcdir)/solaris-hwcap.mapfile'
367          LDFLAGS="$LDFLAGS -Wl,-M,pixman/solaris-hwcap.mapfile"
368          AC_LINK_IFELSE([int main() { return 0; }],
369                         use_hwcap_mapfile=yes,
370                         HWCAP_LDFLAGS="")
371          LDFLAGS="$hwcap_save_LDFLAGS"
372          AC_MSG_RESULT($use_hwcap_mapfile)
373       fi
374       if test "x$MMX_LDFLAGS" = "x" ; then
375          MMX_LDFLAGS="$HWCAP_LDFLAGS"
376       fi
377       if test "x$SSE2_LDFLAGS" = "x" ; then
378          SSE2_LDFLAGS="$HWCAP_LDFLAGS"
379       fi
380       ;;
381 esac
382
383 AC_SUBST(MMX_CFLAGS)
384 AC_SUBST(MMX_LDFLAGS)
385 AC_SUBST(SSE2_CFLAGS)
386 AC_SUBST(SSE2_LDFLAGS)
387
388 dnl ===========================================================================
389 dnl Check for VMX/Altivec
390 if test -n "`$CC -v 2>&1 | grep version | grep Apple`"; then
391     VMX_CFLAGS="-faltivec"
392 else
393     VMX_CFLAGS="-maltivec -mabi=altivec"
394 fi
395
396 have_vmx_intrinsics=no
397 AC_MSG_CHECKING(whether to use VMX/Altivec intrinsics)
398 xserver_save_CFLAGS=$CFLAGS
399 CFLAGS="$VMX_CFLAGS $CFLAGS"
400 AC_COMPILE_IFELSE([
401 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
402 error "Need GCC >= 3.4 for sane altivec support"
403 #endif
404 #include <altivec.h>
405 int main () {
406     vector unsigned int v = vec_splat_u32 (1);
407     v = vec_sub (v, v);
408     return 0;
409 }], have_vmx_intrinsics=yes)
410 CFLAGS=$xserver_save_CFLAGS
411
412 AC_ARG_ENABLE(vmx,
413    [AC_HELP_STRING([--disable-vmx],
414                    [disable VMX fast paths])],
415    [enable_vmx=$enableval], [enable_vmx=auto])
416
417 if test $enable_vmx = no ; then
418    have_vmx_intrinsics=disabled
419 fi
420
421 if test $have_vmx_intrinsics = yes ; then
422    AC_DEFINE(USE_VMX, 1, [use VMX compiler intrinsics])
423 else
424    VMX_CFLAGS=
425 fi
426
427 AC_MSG_RESULT($have_vmx_intrinsics)
428 if test $enable_vmx = yes && test $have_vmx_intrinsics = no ; then
429    AC_MSG_ERROR([VMX intrinsics not detected])
430 fi
431
432 AC_SUBST(VMX_CFLAGS)
433
434 AM_CONDITIONAL(USE_VMX, test $have_vmx_intrinsics = yes)
435
436 dnl ==========================================================================
437 dnl Check if assembler is gas compatible and supports ARM SIMD instructions
438 have_arm_simd=no
439 AC_MSG_CHECKING(whether to use ARM SIMD assembler)
440 xserver_save_CFLAGS=$CFLAGS
441 CFLAGS="-x assembler-with-cpp $CFLAGS"
442 AC_COMPILE_IFELSE([[
443 .text
444 .arch armv6
445 .object_arch armv4
446 .arm
447 .altmacro
448 #ifndef __ARM_EABI__
449 #error EABI is required (to be sure that calling conventions are compatible)
450 #endif
451 pld [r0]
452 uqadd8 r0, r0, r0]], have_arm_simd=yes)
453 CFLAGS=$xserver_save_CFLAGS
454
455 AC_ARG_ENABLE(arm-simd,
456    [AC_HELP_STRING([--disable-arm-simd],
457                    [disable ARM SIMD fast paths])],
458    [enable_arm_simd=$enableval], [enable_arm_simd=auto])
459
460 if test $enable_arm_simd = no ; then
461    have_arm_simd=disabled
462 fi
463
464 if test $have_arm_simd = yes ; then
465    AC_DEFINE(USE_ARM_SIMD, 1, [use ARM SIMD assembly optimizations])
466 fi
467
468 AM_CONDITIONAL(USE_ARM_SIMD, test $have_arm_simd = yes)
469
470 AC_MSG_RESULT($have_arm_simd)
471 if test $enable_arm_simd = yes && test $have_arm_simd = no ; then
472    AC_MSG_ERROR([ARM SIMD intrinsics not detected])
473 fi
474
475 dnl ==========================================================================
476 dnl Check if assembler is gas compatible and supports NEON instructions
477 have_arm_neon=no
478 AC_MSG_CHECKING(whether to use ARM NEON assembler)
479 xserver_save_CFLAGS=$CFLAGS
480 CFLAGS="-x assembler-with-cpp $CFLAGS"
481 AC_COMPILE_IFELSE([[
482 .text
483 .fpu neon
484 .arch armv7a
485 .object_arch armv4
486 .eabi_attribute 10, 0
487 .arm
488 .altmacro
489 #ifndef __ARM_EABI__
490 #error EABI is required (to be sure that calling conventions are compatible)
491 #endif
492 pld [r0]
493 vmovn.u16 d0, q0]], have_arm_neon=yes)
494 CFLAGS=$xserver_save_CFLAGS
495
496 AC_ARG_ENABLE(arm-neon,
497    [AC_HELP_STRING([--disable-arm-neon],
498                    [disable ARM NEON fast paths])],
499    [enable_arm_neon=$enableval], [enable_arm_neon=auto])
500
501 if test $enable_arm_neon = no ; then
502    have_arm_neon=disabled
503 fi
504
505 if test $have_arm_neon = yes ; then
506    AC_DEFINE(USE_ARM_NEON, 1, [use ARM NEON assembly optimizations])
507 fi
508
509 AM_CONDITIONAL(USE_ARM_NEON, test $have_arm_neon = yes)
510
511 AC_MSG_RESULT($have_arm_neon)
512 if test $enable_arm_neon = yes && test $have_arm_neon = no ; then
513    AC_MSG_ERROR([ARM NEON intrinsics not detected])
514 fi
515
516 dnl =========================================================================================
517 dnl Check for GNU-style inline assembly support
518
519 have_gcc_inline_asm=no
520 AC_MSG_CHECKING(whether to use GNU-style inline assembler)
521 AC_COMPILE_IFELSE([
522 int main () {
523     /* Most modern architectures have a NOP instruction, so this is a fairly generic test. */
524         asm volatile ( "\tnop\n" : : : "cc", "memory" );
525     return 0;
526 }], have_gcc_inline_asm=yes)
527
528 AC_ARG_ENABLE(gcc-inline-asm,
529    [AC_HELP_STRING([--disable-gcc-inline-asm],
530                    [disable GNU-style inline assembler])],
531    [enable_gcc_inline_asm=$enableval], [enable_gcc_inline_asm=auto])
532
533 if test $enable_gcc_inline_asm = no ; then
534    have_gcc_inline_asm=disabled
535 fi
536
537 if test $have_gcc_inline_asm = yes ; then
538    AC_DEFINE(USE_GCC_INLINE_ASM, 1, [use GNU-style inline assembler])
539 fi
540
541 AC_MSG_RESULT($have_gcc_inline_asm)
542 if test $enable_gcc_inline_asm = yes && test $have_gcc_inline_asm = no ; then
543    AC_MSG_ERROR([GNU-style inline assembler not detected])
544 fi
545
546 AM_CONDITIONAL(USE_GCC_INLINE_ASM, test $have_gcc_inline_asm = yes)
547
548 dnl ==============================================
549 dnl Timers
550
551 AC_ARG_ENABLE(timers,
552    [AC_HELP_STRING([--enable-timers],
553                    [enable TIMER_BEGIN and TIMER_END macros [default=no]])],
554    [enable_timers=$enableval], [enable_timers=no])
555
556 if test $enable_timers = yes ; then 
557    AC_DEFINE(PIXMAN_TIMERS, 1, [enable TIMER_BEGIN/TIMER_END macros])
558 fi
559 AC_SUBST(PIXMAN_TIMERS)
560
561 dnl ===================================
562 dnl GTK+
563
564 AC_ARG_ENABLE(gtk,
565    [AC_HELP_STRING([--enable-gtk],
566                    [enable tests using GTK+ [default=auto]])],
567    [enable_gtk=$enableval], [enable_gtk=auto])
568
569 PKG_PROG_PKG_CONFIG
570 if test $enable_gtk = auto ; then
571    PKG_CHECK_EXISTS([gtk+-2.0], [enable_gtk=yes], [enable_gtk=no])
572 fi
573 if test $enable_gtk = yes ; then
574    PKG_CHECK_MODULES(GTK, [gtk+-2.0])
575 fi
576
577 AM_CONDITIONAL(HAVE_GTK, [test "x$enable_gtk" = xyes])
578
579 AC_SUBST(GTK_CFLAGS)
580 AC_SUBST(GTK_LIBS)
581 AC_SUBST(DEP_CFLAGS)
582 AC_SUBST(DEP_LIBS)
583
584 dnl =====================================
585 dnl posix_memalign 
586
587 AC_CHECK_FUNC(posix_memalign, have_posix_memalign=yes, have_posix_memalign=no)
588 if test x$have_posix_memalign = xyes; then
589    AC_DEFINE(HAVE_POSIX_MEMALIGN, 1, [Whether we have posix_memalign()])
590 fi
591
592 dnl =====================================
593 dnl Thread local storage
594
595 support_for__thread=no
596
597 AC_MSG_CHECKING(for __thread)
598 AC_LINK_IFELSE([
599 #ifdef __MINGW32__
600 #error MinGW has broken __thread support
601 #endif
602 #ifdef __OpenBSD__
603 #error OpenBSD has broken __thread support
604 #endif
605 static __thread int x ;
606 int main () { x = 123; return x; }
607 ], support_for__thread=yes)
608
609 if test $support_for__thread = yes; then 
610    AC_DEFINE([TOOLCHAIN_SUPPORTS__THREAD],[],[Whether the tool chain supports __thread])
611 fi
612
613 AC_MSG_RESULT($support_for__thread)
614
615 dnl
616 dnl posix tls
617 dnl
618
619 m4_define([pthread_test_program],[dnl
620 #include <stdlib.h>
621 #include <pthread.h>
622
623 static pthread_once_t once_control = PTHREAD_ONCE_INIT;
624 static pthread_key_t key;
625
626 static void
627 make_key (void)
628 {
629     pthread_key_create (&key, NULL);
630 }
631
632 int
633 main ()
634 {
635     void *value = NULL;
636
637     if (pthread_once (&once_control, make_key) != 0)
638     {
639         value = NULL;
640     }
641     else
642     {
643         value = pthread_getspecific (key);
644         if (!value)
645         {
646             value = malloc (100);
647             pthread_setspecific (key, value);
648         }
649     }
650     return 0;
651 }
652 ])
653
654 AC_DEFUN([PIXMAN_CHECK_PTHREAD],[dnl
655     if test "z$support_for_pthread_setspecific" != "zyes"; then
656         PIXMAN_LINK_WITH_ENV(
657                 [$1], [pthread_test_program],
658                 [PTHREAD_CFLAGS="$CFLAGS"
659                  PTHREAD_LIBS="$LIBS"
660                  PTHREAD_LDFLAGS="$LDFLAGS"
661                  support_for_pthread_setspecific=yes])
662     fi
663 ])
664
665 if test $support_for__thread = no; then
666     support_for_pthread_setspecific=no
667
668     AC_MSG_CHECKING(for pthread_setspecific)
669
670     PIXMAN_CHECK_PTHREAD([CFLAGS="-D_REENTRANT"; LIBS="-lpthread"])
671     PIXMAN_CHECK_PTHREAD([CFLAGS="-pthread"; LDFLAGS="-pthread"])
672
673     if test $support_for_pthread_setspecific = yes; then
674         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
675         AC_DEFINE([HAVE_PTHREAD_SETSPECIFIC], [], [Whether pthread_setspecific() is supported])
676     fi
677
678     AC_MSG_RESULT($support_for_pthread_setspecific);
679 fi
680
681 AC_SUBST(TOOLCHAIN_SUPPORTS__THREAD)
682 AC_SUBST(HAVE_PTHREAD_SETSPECIFIC)
683 AC_SUBST(PTHREAD_LDFLAGS)
684 AC_SUBST(PTHREAD_LIBS)
685
686 AC_OUTPUT([pixman-1.pc
687            pixman-1-uninstalled.pc
688            Makefile
689            pixman/Makefile
690            pixman/pixman-version.h
691            test/Makefile])