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