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