1 dnl Copyright 2005 Red Hat, Inc.
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.
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.
21 dnl Process this file with autoconf to create configure.
25 # Pixman versioning scheme
27 # - The version in git has an odd MICRO version number
29 # - Released versions both development and stable have an even MICRO
32 # - Released development versions have an odd MINOR number
34 # - Released stable versions have an even MINOR number
36 # - Versions that break ABI must have a new MAJOR number
38 # - If you break the ABI, then at least this must be done:
42 # - In the first development release where you break ABI, find
43 # all instances of "pixman-n" and change them to pixman-(n+1)
45 # This needs to be done at least in
50 # This ensures that binary incompatible versions can be installed
51 # in parallel. See http://www106.pair.com/rhp/parallel.html for
55 m4_define([pixman_major], 0)
56 m4_define([pixman_minor], 19)
57 m4_define([pixman_micro], 1)
59 m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro])
61 AC_INIT(pixman, pixman_version, "pixman@lists.freedesktop.org", pixman)
62 AM_INIT_AUTOMAKE([foreign dist-bzip2])
64 # Suppress verbose compile lines
65 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
67 AM_CONFIG_HEADER(config.h)
71 test_CFLAGS=${CFLAGS+set} # We may override autoconf default CFLAGS.
76 AC_CHECK_FUNCS([getisax])
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
85 save_LDFLAGS="$LDFLAGS"
91 AC_LINK_IFELSE([$2], [$3], [$4])
93 LDFLAGS="$save_LDFLAGS"
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"])
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
106 if test $SUNCC = yes && \
107 test "$test_CFLAGS" == "" && \
108 test "$CFLAGS" = "-g"
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:
117 # pixman-$(pixman_major).0.minor.micro
119 m4_define([lt_current], [pixman_minor])
120 m4_define([lt_revision], [pixman_micro])
121 m4_define([lt_age], [pixman_minor])
123 LT_VERSION_INFO="lt_current:lt_revision:lt_age"
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)
132 AC_SUBST(LT_VERSION_INFO)
134 # Check for dependencies
135 #PKG_CHECK_MODULES(DEP, x11)
138 if test "x$GCC" = "xyes"; then
141 *[\ \ ]-Wall[\ \ ]*) ;;
142 *) CFLAGS="$CFLAGS -Wall" ;;
146 *[\ \ ]-fno-strict-aliasing[\ \ ]*) ;;
147 *) CFLAGS="$CFLAGS -fno-strict-aliasing" ;;
150 fi changequote([,])dnl
152 AC_PATH_PROG(PERL, perl, no)
153 if test "x$PERL" = xno; then
154 AC_MSG_ERROR([Perl is required to build pixman.])
158 dnl =========================================================================
159 dnl OpenMP for the test suite?
162 # Check for OpenMP support (only supported by autoconf >=2.62)
164 m4_ifdef([AC_OPENMP], [AC_OPENMP])
166 m4_define([openmp_test_program],[dnl
169 extern unsigned int lcg_seed;
170 #pragma omp threadprivate(lcg_seed)
171 unsigned int lcg_seed;
173 unsigned function(unsigned a, unsigned b)
176 return ((a + b) ^ a ) + lcg_seed;
179 int main(int argc, char **argv)
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++)
191 unsigned crc = test_function (i, 0);
193 printf ("%d: %08X\n", i, crc);
196 printf("%u\n", checksum);
201 PIXMAN_LINK_WITH_ENV(
202 [CFLAGS="$OPENMP_CFLAGS" LDFLAGS="$OPENMP_CFLAGS"],
203 [openmp_test_program],
206 if test "x$have_openmp" = "xyes"; then
207 AC_DEFINE(USE_OPENMP, 1, [use OpenMP in the test suite])
211 AC_SUBST(OPENMP_CFLAGS)
213 dnl =========================================================================
214 dnl -fvisibility stuff
217 AC_MSG_CHECKING(for -fvisibility)
219 #if defined(__GNUC__) && (__GNUC__ >= 4)
221 error Need GCC 4.0 for visibility
223 int main () { return 0; }
226 if test "x$have_gcc4" = "xyes"; then
227 CFLAGS="$CFLAGS -fvisibility=hidden"
229 AC_MSG_RESULT($have_gcc4)
232 AC_MSG_CHECKING([for -xldscope (Sun compilers)])
234 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
236 error Need Sun Studio 8 for visibility
238 int main () { return 0; }
239 ], have_sunstudio8=yes)
241 if test "x$have_sunstudio8" = "xyes"; then
242 CFLAGS="$CFLAGS -xldscope=hidden"
244 AC_MSG_RESULT($have_sunstudio8)
246 dnl ===========================================================================
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"
258 MMX_CFLAGS="-mmmx -Winline"
262 have_mmx_intrinsics=no
263 AC_MSG_CHECKING(whether to use MMX intrinsics)
264 xserver_save_CFLAGS=$CFLAGS
265 CFLAGS="$MMX_CFLAGS $CFLAGS"
267 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
268 error "Need GCC >= 3.4 for MMX intrinsics"
270 #include <mmintrin.h>
272 __m64 v = _mm_cvtsi32_si64 (1);
273 return _mm_cvtsi64_si32 (v);
274 }], have_mmx_intrinsics=yes)
275 CFLAGS=$xserver_save_CFLAGS
278 [AC_HELP_STRING([--disable-mmx],
279 [disable MMX fast paths])],
280 [enable_mmx=$enableval], [enable_mmx=auto])
282 if test $enable_mmx = no ; then
283 have_mmx_intrinsics=disabled
286 if test $have_mmx_intrinsics = yes ; then
287 AC_DEFINE(USE_MMX, 1, [use MMX compiler intrinsics])
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])
297 AM_CONDITIONAL(USE_MMX, test $have_mmx_intrinsics = yes)
299 dnl ===========================================================================
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"
309 SSE2_CFLAGS="-mmmx -msse2 -Winline"
313 have_sse2_intrinsics=no
314 AC_MSG_CHECKING(whether to use SSE2 intrinsics)
315 xserver_save_CFLAGS=$CFLAGS
316 CFLAGS="$SSE2_CFLAGS $CFLAGS"
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"
324 #include <mmintrin.h>
325 #include <xmmintrin.h>
326 #include <emmintrin.h>
328 __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
329 c = _mm_xor_si128 (a, b);
331 }], have_sse2_intrinsics=yes)
332 CFLAGS=$xserver_save_CFLAGS
335 [AC_HELP_STRING([--disable-sse2],
336 [disable SSE2 fast paths])],
337 [enable_sse2=$enableval], [enable_sse2=auto])
339 if test $enable_sse2 = no ; then
340 have_sse2_intrinsics=disabled
343 if test $have_sse2_intrinsics = yes ; then
344 AC_DEFINE(USE_SSE2, 1, [use SSE2 compiler intrinsics])
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])
352 AM_CONDITIONAL(USE_SSE2, test $have_sse2_intrinsics = yes)
354 dnl ===========================================================================
355 dnl Other special flags needed when building code using MMX or SSE instructions
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
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,
371 LDFLAGS="$hwcap_save_LDFLAGS"
372 AC_MSG_RESULT($use_hwcap_mapfile)
374 if test "x$MMX_LDFLAGS" = "x" ; then
375 MMX_LDFLAGS="$HWCAP_LDFLAGS"
377 if test "x$SSE2_LDFLAGS" = "x" ; then
378 SSE2_LDFLAGS="$HWCAP_LDFLAGS"
384 AC_SUBST(MMX_LDFLAGS)
385 AC_SUBST(SSE2_CFLAGS)
386 AC_SUBST(SSE2_LDFLAGS)
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"
393 VMX_CFLAGS="-maltivec -mabi=altivec"
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"
401 #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
402 error "Need GCC >= 3.4 for sane altivec support"
406 vector unsigned int v = vec_splat_u32 (1);
409 }], have_vmx_intrinsics=yes)
410 CFLAGS=$xserver_save_CFLAGS
413 [AC_HELP_STRING([--disable-vmx],
414 [disable VMX fast paths])],
415 [enable_vmx=$enableval], [enable_vmx=auto])
417 if test $enable_vmx = no ; then
418 have_vmx_intrinsics=disabled
421 if test $have_vmx_intrinsics = yes ; then
422 AC_DEFINE(USE_VMX, 1, [use VMX compiler intrinsics])
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])
434 AM_CONDITIONAL(USE_VMX, test $have_vmx_intrinsics = yes)
436 dnl ==========================================================================
437 dnl Check if assembler is gas compatible and supports ARM SIMD instructions
439 AC_MSG_CHECKING(whether to use ARM SIMD assembler)
440 xserver_save_CFLAGS=$CFLAGS
441 CFLAGS="-x assembler-with-cpp $CFLAGS"
449 #error EABI is required (to be sure that calling conventions are compatible)
452 uqadd8 r0, r0, r0]], have_arm_simd=yes)
453 CFLAGS=$xserver_save_CFLAGS
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])
460 if test $enable_arm_simd = no ; then
461 have_arm_simd=disabled
464 if test $have_arm_simd = yes ; then
465 AC_DEFINE(USE_ARM_SIMD, 1, [use ARM SIMD assembly optimizations])
468 AM_CONDITIONAL(USE_ARM_SIMD, test $have_arm_simd = yes)
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])
475 dnl ==========================================================================
476 dnl Check if assembler is gas compatible and supports NEON instructions
478 AC_MSG_CHECKING(whether to use ARM NEON assembler)
479 xserver_save_CFLAGS=$CFLAGS
480 CFLAGS="-x assembler-with-cpp $CFLAGS"
486 .eabi_attribute 10, 0
490 #error EABI is required (to be sure that calling conventions are compatible)
493 vmovn.u16 d0, q0]], have_arm_neon=yes)
494 CFLAGS=$xserver_save_CFLAGS
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])
501 if test $enable_arm_neon = no ; then
502 have_arm_neon=disabled
505 if test $have_arm_neon = yes ; then
506 AC_DEFINE(USE_ARM_NEON, 1, [use ARM NEON assembly optimizations])
509 AM_CONDITIONAL(USE_ARM_NEON, test $have_arm_neon = yes)
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])
516 dnl =========================================================================================
517 dnl Check for GNU-style inline assembly support
519 have_gcc_inline_asm=no
520 AC_MSG_CHECKING(whether to use GNU-style inline assembler)
523 /* Most modern architectures have a NOP instruction, so this is a fairly generic test. */
524 asm volatile ( "\tnop\n" : : : "cc", "memory" );
526 }], have_gcc_inline_asm=yes)
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])
533 if test $enable_gcc_inline_asm = no ; then
534 have_gcc_inline_asm=disabled
537 if test $have_gcc_inline_asm = yes ; then
538 AC_DEFINE(USE_GCC_INLINE_ASM, 1, [use GNU-style inline assembler])
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])
546 AM_CONDITIONAL(USE_GCC_INLINE_ASM, test $have_gcc_inline_asm = yes)
548 dnl ==============================================
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])
556 if test $enable_timers = yes ; then
557 AC_DEFINE(PIXMAN_TIMERS, 1, [enable TIMER_BEGIN/TIMER_END macros])
559 AC_SUBST(PIXMAN_TIMERS)
561 dnl ===================================
565 [AC_HELP_STRING([--enable-gtk],
566 [enable tests using GTK+ [default=auto]])],
567 [enable_gtk=$enableval], [enable_gtk=auto])
570 if test $enable_gtk = auto ; then
571 PKG_CHECK_EXISTS([gtk+-2.0], [enable_gtk=yes], [enable_gtk=no])
573 if test $enable_gtk = yes ; then
574 PKG_CHECK_MODULES(GTK, [gtk+-2.0])
577 AM_CONDITIONAL(HAVE_GTK, [test "x$enable_gtk" = xyes])
584 dnl =====================================
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()])
592 dnl =====================================
593 dnl Thread local storage
595 support_for__thread=no
597 AC_MSG_CHECKING(for __thread)
600 #error MinGW has broken __thread support
603 #error OpenBSD has broken __thread support
605 static __thread int x ;
606 int main () { x = 123; return x; }
607 ], support_for__thread=yes)
609 if test $support_for__thread = yes; then
610 AC_DEFINE([TOOLCHAIN_SUPPORTS__THREAD],[],[Whether the tool chain supports __thread])
613 AC_MSG_RESULT($support_for__thread)
619 m4_define([pthread_test_program],[dnl
623 static pthread_once_t once_control = PTHREAD_ONCE_INIT;
624 static pthread_key_t key;
629 pthread_key_create (&key, NULL);
637 if (pthread_once (&once_control, make_key) != 0)
643 value = pthread_getspecific (key);
646 value = malloc (100);
647 pthread_setspecific (key, value);
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"
660 PTHREAD_LDFLAGS="$LDFLAGS"
661 support_for_pthread_setspecific=yes])
665 if test $support_for__thread = no; then
666 support_for_pthread_setspecific=no
668 AC_MSG_CHECKING(for pthread_setspecific)
670 PIXMAN_CHECK_PTHREAD([CFLAGS="-D_REENTRANT"; LIBS="-lpthread"])
671 PIXMAN_CHECK_PTHREAD([CFLAGS="-pthread"; LDFLAGS="-pthread"])
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])
678 AC_MSG_RESULT($support_for_pthread_setspecific);
681 AC_SUBST(TOOLCHAIN_SUPPORTS__THREAD)
682 AC_SUBST(HAVE_PTHREAD_SETSPECIFIC)
683 AC_SUBST(PTHREAD_LDFLAGS)
684 AC_SUBST(PTHREAD_LIBS)
686 AC_OUTPUT([pixman-1.pc
687 pixman-1-uninstalled.pc
690 pixman/pixman-version.h