Pre-release version bump to 0.17.12
[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], 17)
57 m4_define([pixman_micro], 12)
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 for ARM SIMD instructions
366 ARM_SIMD_CFLAGS=""
367
368 have_arm_simd=no
369 AC_MSG_CHECKING(whether to use ARM SIMD assembler)
370 # check with default CFLAGS in case the toolchain turns on a sufficiently recent -mcpu=
371 AC_COMPILE_IFELSE([
372 int main () {
373     asm("uqadd8 r1, r1, r2");
374     return 0;
375 }], have_arm_simd=yes,
376     # check again with an explicit -mcpu= in case the toolchain defaults to an
377     # older one; note that uqadd8 isn't available in Thumb mode on arm1136j-s
378     # so we force ARM mode
379     ARM_SIMD_CFLAGS="-mcpu=arm1136j-s -marm"
380     xserver_save_CFLAGS=$CFLAGS
381     CFLAGS="$ARM_SIMD_CFLAGS $CFLAGS"
382     AC_COMPILE_IFELSE([
383     int main () {
384         asm("uqadd8 r1, r1, r2");
385         return 0;
386     }], have_arm_simd=yes)
387     CFLAGS=$xserver_save_CFLAGS)
388
389 AC_ARG_ENABLE(arm-simd,
390    [AC_HELP_STRING([--disable-arm-simd],
391                    [disable ARM SIMD fast paths])],
392    [enable_arm_simd=$enableval], [enable_arm_simd=auto])
393
394 if test $enable_arm_simd = no ; then
395    have_arm_simd=disabled
396 fi
397
398 if test $have_arm_simd = yes ; then
399    AC_DEFINE(USE_ARM_SIMD, 1, [use ARM SIMD compiler intrinsics])
400 else
401    ARM_SIMD_CFLAGS=
402 fi
403
404 AC_MSG_RESULT($have_arm_simd)
405 if test $enable_arm_simd = yes && test $have_arm_simd = no ; then
406    AC_MSG_ERROR([ARM SIMD intrinsics not detected])
407 fi
408
409 AC_SUBST(ARM_SIMD_CFLAGS)
410
411 AM_CONDITIONAL(USE_ARM_SIMD, test $have_arm_simd = yes)
412
413 dnl ==========================================================================
414 dnl Check if assembler is gas compatible and supports NEON instructions
415 have_arm_neon=no
416 AC_MSG_CHECKING(whether to use ARM NEON assembler)
417 xserver_save_CFLAGS=$CFLAGS
418 CFLAGS="-x assembler-with-cpp"
419 AC_COMPILE_IFELSE([[
420 .text
421 .fpu neon
422 .altmacro
423 #ifndef __ARM_EABI__
424 #error EABI is required (to be sure that calling conventions are compatible)
425 #endif
426 pld [r0]
427 vmovn.u16 d0, q0]], have_arm_neon=yes)
428 CFLAGS=$xserver_save_CFLAGS
429
430 AC_ARG_ENABLE(arm-neon,
431    [AC_HELP_STRING([--disable-arm-neon],
432                    [disable ARM NEON fast paths])],
433    [enable_arm_neon=$enableval], [enable_arm_neon=auto])
434
435 if test $enable_arm_neon = no ; then
436    have_arm_neon=disabled
437 fi
438
439 if test $have_arm_neon = yes ; then
440    AC_DEFINE(USE_ARM_NEON, 1, [use ARM NEON assembly optimizations])
441 fi
442
443 AM_CONDITIONAL(USE_ARM_NEON, test $have_arm_neon = yes)
444
445 AC_MSG_RESULT($have_arm_neon)
446 if test $enable_arm_neon = yes && test $have_arm_neon = no ; then
447    AC_MSG_ERROR([ARM NEON intrinsics not detected])
448 fi
449
450 dnl =========================================================================================
451 dnl Check for GNU-style inline assembly support
452
453 have_gcc_inline_asm=no
454 AC_MSG_CHECKING(whether to use GNU-style inline assembler)
455 AC_COMPILE_IFELSE([
456 int main () {
457     /* Most modern architectures have a NOP instruction, so this is a fairly generic test. */
458         asm volatile ( "\tnop\n" : : : "cc", "memory" );
459     return 0;
460 }], have_gcc_inline_asm=yes)
461
462 AC_ARG_ENABLE(gcc-inline-asm,
463    [AC_HELP_STRING([--disable-gcc-inline-asm],
464                    [disable GNU-style inline assembler])],
465    [enable_gcc_inline_asm=$enableval], [enable_gcc_inline_asm=auto])
466
467 if test $enable_gcc_inline_asm = no ; then
468    have_gcc_inline_asm=disabled
469 fi
470
471 if test $have_gcc_inline_asm = yes ; then
472    AC_DEFINE(USE_GCC_INLINE_ASM, 1, [use GNU-style inline assembler])
473 fi
474
475 AC_MSG_RESULT($have_gcc_inline_asm)
476 if test $enable_gcc_inline_asm = yes && test $have_gcc_inline_asm = no ; then
477    AC_MSG_ERROR([GNU-style inline assembler not detected])
478 fi
479
480 AM_CONDITIONAL(USE_GCC_INLINE_ASM, test $have_gcc_inline_asm = yes)
481
482 dnl ==============================================
483 dnl Timers
484
485 AC_ARG_ENABLE(timers,
486    [AC_HELP_STRING([--enable-timers],
487                    [enable TIMER_BEGIN and TIMER_END macros [default=no]])],
488    [enable_timers=$enableval], [enable_timers=no])
489
490 if test $enable_timers = yes ; then 
491    AC_DEFINE(PIXMAN_TIMERS, 1, [enable TIMER_BEGIN/TIMER_END macros])
492 fi
493 AC_SUBST(PIXMAN_TIMERS)
494
495 dnl ===================================
496 dnl GTK+
497
498 AC_ARG_ENABLE(gtk,
499    [AC_HELP_STRING([--enable-gtk],
500                    [enable tests using GTK+ [default=auto]])],
501    [enable_gtk=$enableval], [enable_gtk=auto])
502
503 PKG_PROG_PKG_CONFIG
504 if test $enable_gtk = auto ; then
505    PKG_CHECK_EXISTS([gtk+-2.0], [enable_gtk=yes], [enable_gtk=no])
506 fi
507 if test $enable_gtk = yes ; then
508    PKG_CHECK_MODULES(GTK, [gtk+-2.0])
509 fi
510
511 AM_CONDITIONAL(HAVE_GTK, [test "x$enable_gtk" = xyes])
512
513 AC_SUBST(GTK_CFLAGS)
514 AC_SUBST(GTK_LIBS)
515 AC_SUBST(DEP_CFLAGS)
516 AC_SUBST(DEP_LIBS)
517
518 dnl =====================================
519 dnl posix_memalign 
520
521 AC_CHECK_FUNC(posix_memalign, have_posix_memalign=yes, have_posix_memalign=no)
522 if test x$have_posix_memalign = xyes; then
523    AC_DEFINE(HAVE_POSIX_MEMALIGN, 1, [Whether we have posix_memalign()])
524 fi
525
526 dnl =====================================
527 dnl Thread local storage
528
529 support_for__thread=no
530
531 AC_MSG_CHECKING(for __thread)
532 AC_COMPILE_IFELSE([
533 __thread int x ;
534 int main () { return 0; }
535 ], support_for__thread=yes)
536
537 if test $support_for__thread = yes; then 
538    AC_DEFINE([TOOLCHAIN_SUPPORTS__THREAD],[],[Whether the tool chain supports __thread])
539 fi
540
541 AC_MSG_RESULT($support_for__thread)
542
543 dnl posix tls
544
545 if test $support_for__thread = no; then
546
547 support_for_pthread_setspecific=no
548    
549 AC_MSG_CHECKING(for pthread_setspecific)
550
551 save_LDFLAGS=$LDFLAGS
552
553 LDFLAGS="-pthread"
554
555 AC_LINK_IFELSE([
556 #include <pthread.h>
557
558 #include <stdlib.h>
559 #include <pthread.h>
560
561 static pthread_once_t once_control = PTHREAD_ONCE_INIT;
562 static pthread_key_t key;
563
564 static void
565 make_key (void)
566 {
567     pthread_key_create (&key, NULL);
568 }
569
570 int
571 main ()
572 {
573     void *value = NULL;
574     
575     if (pthread_once (&once_control, make_key) != 0)
576     {
577         value = NULL;
578     }
579     else
580     {
581         value = pthread_getspecific (key);
582         if (!value)
583         {
584             value = malloc (100);
585             pthread_setspecific (key, value);
586         }
587     }
588 }
589 ], support_for_pthread_setspecific=yes);
590
591 LDFLAGS=$save_LDFLAGS
592
593 if test $support_for_pthread_setspecific = yes; then
594    PTHREAD_LDFLAGS="-pthread"
595    AC_DEFINE([HAVE_PTHREAD_SETSPECIFIC], [], [Whether pthread_setspecific() is supported])
596 fi
597
598 AC_MSG_RESULT($support_for_pthread_setspecific);
599
600 fi
601
602 AC_SUBST(TOOLCHAIN_SUPPORTS__THREAD)
603 AC_SUBST(HAVE_PTHREAD_SETSPECIFIC)
604 AC_SUBST(PTHREAD_LDFLAGS)
605
606 AC_OUTPUT([pixman-1.pc
607            pixman-1-uninstalled.pc
608            Makefile
609            pixman/Makefile
610            pixman/pixman-version.h
611            test/Makefile])