File: configure.in

package info (click to toggle)
afterstep 2.2.12-18.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,184 kB
  • sloc: ansic: 201,695; sh: 5,894; xml: 3,721; makefile: 2,094; perl: 1,558; cpp: 811
file content (785 lines) | stat: -rw-r--r-- 25,083 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
dnl# -*- sh -*-
dnl# Process this file with autoconf to produce a configure script.
dnl#
dnl#Copyright (c) 1998 Michal Vitecek <fuf@fuf.sh.cvut.cz>
dnl#Copyright (c) 2001,1998 Sasha Vasko <sasha at aftercode.net>
dnl#Copyright (c) 1998 Juergen Sawinski <Juergen.Sawinski@urz.uni-heidelberg.de>
dnl#Copyright (c) 1997 1998 Guylhem AZNAR <guylhem@oeil.qc.ca>

AC_INIT(libAfterImage,1.21,as-bugs@afterstep.org,libAfterImage.tar)

AC_CONFIG_HEADER(config.h:config.h.in)

version=$PACKAGE_VERSION
version_major="1"
lib_name="LIBAFTERIMAGE"
lib_file_name=$PACKAGE_NAME

dnl# Setup command-line options

dnl# we need the standard prefixes defined early
test "x$prefix" = xNONE && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix="$prefix"
eval "mandir=$mandir"
eval "libdir=$libdir"
eval "includedir=$includedir"
eval "datarootdir=$datarootdir"

dnl# compile-time switches
AC_ARG_ENABLE(i18n,			[  --enable-i18n            support I18N [no] ],enable_i18n=$enableval,enable_i18n="no")
AC_ARG_ENABLE(xlocale,		[  --enable-xlocale         using X_LOCALE [no] ],enable_xlocale=$enableval,enable_xlocale="no")
AC_ARG_WITH(locale,			[  --with-locale=LOCALE     locale name you want to use ],with_locale=$withval,with_locale="")
AC_ARG_ENABLE(staticlibs,   [  --enable-staticlibs      enable linking to libAfterImage statically [yes] ],enable_staticlibs=$enableval,enable_staticlibs="yes")
AC_ARG_ENABLE(sharedlibs,   [  --enable-sharedlibs      enable linking to libAfterImage dynamically [no] ],enable_sharedlibs=$enableval,enable_sharedlibs="no")

AC_ARG_ENABLE(gdb,			[  --enable-gdb             add gdb symbols (-g) (for debugging) [no] ],enable_gdb=$enableval,enable_gdb="no")
AC_ARG_ENABLE(warn,			[  --enable-warn            turn on more compiler warnings (for debugging) [no] ],enable_warn=$enableval,enable_warn="no")
AC_ARG_ENABLE(gprof,		[  --enable-gprof           add gprof symbols (-pg) (for debugging) [no] ],enable_gprof=$enableval,enable_gprof="no")
AC_ARG_ENABLE(audit,		[  --enable-audit           memory usage audit (for debugging) [no] ],enable_audit=$enableval,enable_audit="no")
AC_ARG_ENABLE(shmimage,		[  --enable-shmimage        enable usage of MIT shared memory extension for image transfer [no] ],enable_shmimage=$enableval,enable_shmimage="no")
AC_ARG_ENABLE(shaping,		[  --enable-shaping        enable usage of MIT shaped windows extension [yes] ],enable_shaping=$enableval,enable_shaping="yes")
AC_ARG_ENABLE(glx,		[  --enable-glx            enable usage of GLX extension [no] ],enable_glx=$enableval,enable_glx="no")

AC_ARG_ENABLE(mmx_optimization,
							[  --enable-mmx-optimization  enable utilization of MMX instruction set to speed up imaging operations [yes] ],enable_mmx_optimization=$enableval,enable_mmx_optimization="yes")

AC_ARG_WITH(jpeg,		    [  --with-jpeg              support JPEG image format [yes]])
AC_ARG_WITH(jpeg_includes,  [  --with-jpeg-includes=DIR use JPEG includes in DIR], jpeg_includes="$withval", jpeg_includes=no)
AC_ARG_WITH(builtin_jpeg,   [  --with-builtin-jpeg      use included JPEG  library [no]],with_builtin_jpeg="$withval",with_builtin_jpeg=no)
AC_ARG_WITH(png,		    [  --with-png               support PNG image format [yes]])
AC_ARG_WITH(png_includes,   [  --with-png-includes=DIR  use PNG includes in DIR], png_includes="$withval", png_includes=no)
AC_ARG_WITH(builtin_png,    [  --with-builtin-png       use included PNG library [no]],with_builtin_png="$withval",with_builtin_png=no)
AC_ARG_WITH(builtin_zlib,   [  --with-builtin-zlib      use included libZ library (needed for PNG) [no]],with_builtin_zlib="$withval",with_builtin_zlib=no)
AC_ARG_WITH(tiff,		    [  --with-tiff              support TIFF image format [yes]])
AC_ARG_WITH(tiff_includes,  [  --with-tiff-includes=DIR use TIFF includes in DIR], tiff_includes="$withval", tiff_includes=no)
AC_ARG_WITH(svg,		    [  --with-svg               support SVG image format via librsvg [yes]])

AC_ARG_WITH(xpm,	    	[  --with-xpm               support XPM image format [yes]])
dnl# libXPM should not be used as an obsolete software !
with_builtin_xpm=$with_xpm
dnl# AC_ARG_WITH(builtin_xpm,    [  --with-builtin-xpm       use builtin XPM parsing/handling instead of libXpm [yes]])
dnl# AC_ARG_WITH(xpm_includes,   [  --with-xpm-includes=DIR  use libXpm includes in DIR( when builtin XPM handling is disabled )], xpm_includes="$withval", xpm_includes=no)

dnl# standard libgif/ungif should not be used and considered obsolete!
dnl# AC_ARG_WITH(ungif,		    [  --with-ungif             support Uncompressed GIF image format using libungif [no]],with_ungif="$withval",with_ungif=no)
dnl# AC_ARG_WITH(gif,		    [  --with-gif               support GIF image format using libgif   [no]],with_gif="$withval",with_gif=no)
dnl# AC_ARG_WITH(gif_includes,   [  --with-gif-includes=DIR  use GIF includes in DIR], gif_includes="$withval", gif_includes=no)
with_ungif=no
with_gif=no
with_gif_includes=no
AC_ARG_WITH(builtin_gif,    [  --with-builtin-gif               support Uncompressed GIF image format using builtin libgif [yes]],with_builtin_gif="$withval",with_builtin_gif=yes)


AC_ARG_WITH(ttf,		    [  --with-ttf               support True Type Fonts via FreeType library [yes]])
AC_ARG_WITH(ttf_includes,   [  --with-ttf-includes=DIR  use FreeType includes in DIR], ttf_includes="$withval", ttf_includes=no)

AC_ARG_WITH(afterbase,		    [  --with-afterbase               use libAfterBase library of basic functionality [yes]],with_afterbase="$withval",with_afterbase=yes)
AC_ARG_WITH(afterbase_includes, [  --with-afterbase-includes=DIR  use libAfterBase includes in DIR],afterbase_includes="$withval",afterbase_includes=no)

dnl# Check for compiler tools

AC_PROG_CC
AC_PROG_LN_S
dnl# AC_SUBST(CC)
dnl# AC_SUBST(GCC)


AC_CYGWIN
AC_CANONICAL_TARGET

RDYNAMIC="-rdynamic"

case "$target" in
    *i?86*OpenUNIX*)
		RDYNAMIC="-Wl,-Bexport"
		;;
    *i?86*sco*)
		RDYNAMIC="-Wl,-Bexport"
		;;
    *aix*)
		RDYNAMIC="-Wl,-bexpall"
		;;
    *i?86*freebsd*)
		RDYNAMIC=""
		;;
    hppa*)
		RDYNAMIC="-Wl,-E"
		;;
    i?86*solaris*)
		RDYNAMIC=""
		;;
    sparc*solaris*)
		RDYNAMIC="-Wl,-export-dynamic"
		;;
    *-apple-darwin*)
		RDYNAMIC="-Wl,-Sn"
		;;
    *ppc* | *powerpc*)
		RDYNAMIC=""
		;;
    *)
esac

#debian# if test "x$CYGWIN" = "xno" -a "x$GCC" = "xyes" ; then
#debian#   if test -z "`echo $CFLAGS | grep '\-fPIC' 2> /dev/null`" ; then
#debian#   	CFLAGS="$CFLAGS -fPIC"
#debian#   fi
#debian# fi


if test "x$FROM_AFTERSTEP_CONFIGURE" = "xyes"; then

dnl# AfterSTep already checked everything for us
	aaa=bbb
	dnl#  AC_PROG_INSTALL
    AC_SUBST(INSTALL)
    AC_SUBST(INSTALL_PROGRAM)
    AC_SUBST(INSTALL_DATA)
    AC_SUBST(INSTALL_LIB)
    AC_SUBST(RANLIB)
    AC_SUBST(RM)
    AC_SUBST(MV)
    AC_SUBST(CP)
    AC_SUBST(MKDIR)
    AC_SUBST(PERL)
    AC_SUBST(FIND)
    AC_SUBST(XARGS)
    AC_SUBST(LDCONFIG)
    AC_SUBST(LEX)
    AC_SUBST(LEXLIB)
    AC_SUBST(YACC)
    if test "x$have_shmimage" = "xyes"; then
		AC_DEFINE(XSHMIMAGE)
    fi
    if test "x$have_shaping" = "xyes"; then
		AC_DEFINE(SHAPE)
    fi

else

dnl# we are alone - have to do all the checks ourselves :
	dnl# Add -fPIC for IA64 compilation

	dnl# Add -g
	if test "x$enable_gdb" = "xyes"; then
  		if ! test -n "`echo $CFLAGS' ' | grep '\-g ' 2> /dev/null`" ; then
			CFLAGS="$CFLAGS -g -w"
  		fi
	else
  		DIRTY_CFLAGS="$CFLAGS"
  		CFLAGS="-DNO_DEBUG_OUTPUT"
  		for f in $DIRTY_CFLAGS; do 
        		if test "x$f" != "x-g"; then
	   		CFLAGS="$CFLAGS $f"
			fi	 
  		done
	fi
	dnl# Add -pg
	if test "x$enable_gprof" = "xyes"; then
	  CFLAGS="$CFLAGS -pg"
	  LDFLAGS="$LDFLAGS -pg"
	fi
	dnl# Add lots more warnings
	if test "x$enable_warn" = "xyes"; then
	  CFLAGS="$CFLAGS -Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wbad-function-cast -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wconversion -Wcomment -Wcast-align -Winline -Wshadow -Wredundant-decls"
	fi
	AC_PROG_INSTALL
	dnl# if the path to the install program is relative, make it absolute
	currdir=`pwd`
	INSTALL=`echo $INSTALL|sed -e "s@\^\.\.@${currdir}@" -e "s@^autoconf@${currdir}/autoconf@"`
	INSTALL_PROGRAM=`echo $INSTALL_PROGRAM|sed -e "s@\^\.\.@${currdir}@" -e "s@^autoconf@${currdir}/autoconf@"`
	INSTALL_DATA=`echo $INSTALL_DATA|sed -e "s@\^\.\.@${currdir}@" -e "s@^autoconf@${currdir}/autoconf@"`
	INSTALL_LIB=`echo $INSTALL_LIB|sed -e "s@\^\.\.@${currdir}@" -e "s@^autoconf@${currdir}/autoconf@"`

	AC_PROG_RANLIB
	AC_PATH_PROG(RM, rm, rm)
	AC_PATH_PROG(MV, mv, mv)
	AC_PATH_PROG(CP, cp, cp)
	AC_PATH_PROG(MKDIR, mkdir, mkdir)
	AC_PATH_PROG(PERL, perl, perl)
	AC_PATH_PROG(FIND, find, find)
	AC_PATH_PROG(XARGS, xargs, xargs)
	AC_PATH_PROG(LDCONFIG, ldconfig, ldconfig, $PATH:/sbin:/usr/local/sbin)
fi

if test "x$enable_gdb" = "xno"; then
		DIRTY_CFLAGS="$CFLAGS"
  		CFLAGS="-O3"
  		for f in $DIRTY_CFLAGS; do 
       		if test "x$f" != "x-O2" -a "x$f" != "x-O3" -a "x$f" != "x-O"; then
		   		CFLAGS="$CFLAGS $f"
			fi	 
  		done
fi


MMX_CFLAGS="-mmmx -Winline --param inline-unit-growth=10000 --param large-function-growth=10000"
have_mmx_intrinsics=no

dnl# Check for MMX :
if test "x$enable_mmx_optimization" = "xyes"; then
  	AC_MSG_CHECKING(for MMX support)
  
  	save_CFLAGS=$CFLAGS
  	CFLAGS="$CFLAGS $MMX_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
#error "Need GCC >= 3.4 for MMX intrinsics"
#endif
#include <mmintrin.h>
int main () {
    __m64 v = _mm_cvtsi32_si64 (1);
    __m64 w = _mm_slli_si64 (v, 1);
	v = _mm_add_pi32 (v, w);  /* paddd */
    v = _mm_srl_pi32 (v, w);  /* psrld */
    return _mm_cvtsi64_si32 (v);
}])], have_mmx_intrinsics=yes)

	AC_MSG_RESULT($have_mmx_intrinsics)
	CFLAGS=$save_CFLAGS
fi

if test $have_mmx_intrinsics = yes ; then
	AC_DEFINE(HAVE_MMX,1,[Define if CPU supports MMX instructions])
else 
   MMX_CFLAGS=
fi
AC_SUBST(MMX_CFLAGS)

dnl# Check for X :
dnl# check for X, if top level configure script did not do that yet :
afterimage_x_support=yes
if test "x$PATH_XTRA_CHECKED" != "xyes"; then
	AC_PATH_XTRA
else
  if test "x$have_x" != "xyes"; then
	  AC_DEFINE(X_DISPLAY_MISSING)
	  afterimage_x_support=no
  fi

fi

user_ldflags=$LDFLAGS

if test "x$have_x" = "xyes"; then
  x_libs="$X_LIBS $X_EXTRA_LIBS $X_PRE_LIBS"
  if test "x$user_ldflags" = "x"; then
  	full_x_libs=$x_libs
  else
	full_x_libs="$user_ldflags $x_libs"
  fi
  AC_CHECK_LIB(X11, XOpenDisplay, [x_libs="-lX11 $x_libs"],,$full_x_libs)
fi



dnl# some standard checks :
dnl# let's check for endiannes of our box
AC_C_BIGENDIAN
AC_C_INLINE
AC_CHECK_TYPES([long long])

dnl# Check for headers
AC_HEADER_TIME
AC_CHECK_HEADERS(sys/wait.h sys/time.h malloc.h stdlib.h unistd.h stddef.h stdarg.h errno.h)

dnl# Check for X shaped window extension
have_shmimage=no
have_xext_lib=no
if test "x$enable_shmimage" = "xyes"; then
	AC_CHECK_LIB(Xext, XShmCreateImage, [have_shmimage=yes],,$full_x_libs)
	if test "x$have_shmimage" = "xyes"; then
		AC_CHECK_HEADER(sys/ipc.h,,[have_shmimage=no])
	fi
	if test "x$have_shmimage" = "xyes"; then
		AC_CHECK_HEADER(sys/shm.h,,[have_shmimage=no])
	fi
	if test "x$have_shmimage" = "xyes"; then
		have_xext_lib=yes
		AC_DEFINE(XSHMIMAGE,1,[Define if support for shared memory XImages is available])
	fi
fi

dnl# Check for X shaped window extension
HAVESHAPE="NOSHAPE"
if test "x$enable_shaping" = "xyes"; then
  	AC_CHECK_LIB(Xext, XShapeCombineMask, [have_xext_lib=yes;AC_DEFINE(SHAPE,1,Support for shaped windows)],,$full_x_libs)
fi

if test "x$enable_glx" = "xyes"; then
  	AC_CHECK_LIB(GL, glDrawPixels, [x_libs="$x_libs -lGL";AC_DEFINE(HAVE_GLX,1,Support for OpenGL extension)],,$full_x_libs)
fi


if test "x$have_xext_lib" = "xyes"; then
    x_libs="$x_libs -lXext"
fi

dnl# Check for graphics libraries :

image_format="xpm"

AFTERIMAGE_LIBS=$x_libs

if test "$with_xpm" = no; then
  have_xpm=disabled
else
  if test "$with_builtin_xpm" = no; then
  	SAVED_CFLAGS=$CPPFLAGS
  	if test "x$xpm_includes" != "xno"; then
		XPM_CFLAGS="-I$xpm_includes"
		CPPFLAGS="$CPPFLAGS $XPM_CFLAGS"
  	fi
	have_libxpm=no
  	AC_CHECK_HEADER(xpm.h,have_libxpm=yes)
	if test "x$have_libxpm" = "xno"; then
		AC_CHECK_HEADER(X11/xpm.h,have_libxpm_x11="yes")
		if test "x$have_libxpm_x11" = "xyes"; then
			 AC_DEFINE(HAVE_LIBXPM_X11,1,[Define if support for XPM images should be through libXpm library in Xlib])
			 have_libxpm=yes
		fi
	fi
  	if test "x$have_libxpm" = "xyes"; then
		AC_DEFINE(HAVE_XPM,1,[Define if support for XPM images is desired])
		AC_DEFINE(HAVE_LIBXPM,1,[Define if support for XPM images should be through libXpm])
		AFTERIMAGE_LIBS="$AFTERIMAGE_LIBS -lXpm"
        fi
  	CPPFLAGS=$SAVED_CFLAGS
  else
	AC_DEFINE(HAVE_XPM,1,[Define if support for XPM images is desired])
	XPM_CFLAGS=
  fi
fi
AC_SUBST(XPM_CFLAGS)

JPEG_OBJS=
ZLIB_OBJS=
PNG_OBJS=

have_jpeg=

if test "$with_jpeg" = no; then
  have_jpeg=disabled
else
  SAVED_CFLAGS=$CPPFLAGS
  if test "x$jpeg_includes" != "xno"; then
	JPEG_CFLAGS="-I$jpeg_includes"
	CPPFLAGS="$CPPFLAGS $JPEG_CFLAGS"
  fi
  if test "with_builtin_jpeg" = yes -a ! -f libjpeg/jpeglib.h; then
  	with_builtin_jpeg=no
  fi
  if test "$with_builtin_jpeg" = no; then
	  AC_CHECK_HEADER(jpeglib.h,have_jpeg=yes)
  fi
  if test "$have_jpeg" = yes; then
	AC_DEFINE(HAVE_JPEG,1,[Define if libjpeg is available]) 
	AFTERIMAGE_LIBS="$AFTERIMAGE_LIBS -ljpeg"
  else
	AC_MSG_CHECKING(built-in JPEG library) 
	if test -f libjpeg/jpeglib.h; then
		JPEG_OBJS='$(LIBJPEG_OBJS)'
		AC_DEFINE(HAVE_JPEG,1,[Define if libjpeg is available]) 
		AC_DEFINE(HAVE_BUILTIN_JPEG,1,[Define if using builtin libjpeg]) 
		AC_MSG_RESULT(yes)
	else
		AC_MSG_RESULT(no)
	fi
   fi	
  CPPFLAGS=$SAVED_CFLAGS
fi
AC_SUBST(JPEG_CFLAGS)

dnl# these check are needed by built-in jpeg library : 
AC_DEFINE(HAVE_PROTOTYPES,1,We always use function prototypes - not supporting old compilers)
AC_CHECK_TYPE(unsigned char)
AC_CHECK_TYPE(unsigned short)
AC_C_CONST
AC_C_CHAR_UNSIGNED

have_png=no
have_zlib=no

if test "$with_png" = no; then
  have_png=disabled
else
  SAVED_CFLAGS=$CPPFLAGS
  if test "$png_includes" != no; then
	PNG_CFLAGS="-I$png_includes"
	CPPFLAGS="$CPPFLAGS $PNG_CFLAGS"
  fi
  if test "$with_builtin_png" = yes -a ! -f libpng/png.h; then 
  	  with_builtin_png=no
  fi
  if test "$with_builtin_zlib" = yes -a ! -f zlib/zlib.h; then 
  	  with_builtin_zlib=no
  fi
  
  if test "$with_builtin_png" = no; then
	  AC_CHECK_HEADER(png.h,[have_png=yes with_builtin_zlib=no])
  fi
  if test "$with_builtin_zlib" = no; then
	  AC_CHECK_HEADERS(zlib.h,[have_zlib=yes],[have_zlib=no])
  fi
  if test "$have_png" = yes; then
        AC_MSG_CHECKING(for png_get_sRGB in png.h)
        AC_EGREP_HEADER(png_get_sRGB,png.h,,have_png=no)
        AC_MSG_RESULT($have_png)
  fi
  if test "$have_png" = yes; then
        AC_DEFINE(HAVE_PNG,1,[Define if libpng is available])
        AFTERIMAGE_LIBS="$AFTERIMAGE_LIBS -lpng"
        image_format="png"
  else 
	AC_MSG_CHECKING(built-in PNG library) 
	if test -f libpng/png.h; then
		PNG_OBJS='$(LIBPNG_OBJS)'	
	        AC_DEFINE(HAVE_PNG,1,[Define if libpng is available])
        	AC_DEFINE(HAVE_BUILTIN_PNG,1,[Define if using builtin libpng])
		AC_MSG_RESULT(yes)	     
		if test "$have_zlib" = no; then 
			AC_MSG_CHECKING(built-in ZLIB library) 
			if test -f zlib/zlib.h; then
				ZLIB_OBJS='$(ZLIB_OBJS)'
				AC_MSG_RESULT(yes)	     
			else
				AC_MSG_RESULT(no)	     
			fi
		fi
		image_format="png"
		have_png=yes
	else
		AC_MSG_RESULT(no)
	fi
  fi
  CPPFLAGS=$SAVED_CFLAGS
fi
AC_SUBST(PNG_CFLAGS)
dnl# This is required by built in versions of zlib and libpng : 

dnl# Test for libungif first :
have_gif=no
if test "$with_gif$with_ungif" = nono; then
  have_gif=disabled
else
  SAVED_CFLAGS=$CPPFLAGS
  if test "$gif_includes" != no; then
	GIF_CFLAGS="-I$gif_includes"
	CPPFLAGS="$CPPFLAGS $GIF_CFLAGS"
  fi
  AC_CHECK_HEADER(gif_lib.h,have_gif=yes)
  CPPFLAGS=$SAVED_CFLAGS
  if test "x$have_gif" = "xyes"; then
	AC_DEFINE(HAVE_GIF,1,[Define if libgif is available])
	if test "$with_gif" = no; then
		AFTERIMAGE_LIBS="$AFTERIMAGE_LIBS -lungif"
	else
		AFTERIMAGE_LIBS="$AFTERIMAGE_LIBS -lgif"
	fi
  fi
fi

if test "x$have_gif" != "xyes"; then
	if test "x$with_builtin_gif" = "xyes"; then
		AC_MSG_CHECKING(using built-in UNGIF library) 
		if test -f libungif/gif_lib.h; then
			UNGIF_OBJS='$(LIBUNGIF_OBJS)'	
			AC_DEFINE(HAVE_GIF,1,[Define if libgif/ungif is available])
        		AC_DEFINE(HAVE_BUILTIN_UNGIF,1,[Define if using builtin libgif])
			AC_MSG_RESULT(yes)	     
			have_gif=yes
		else
			AC_MSG_RESULT(no)
		fi
	fi
fi

AC_SUBST(GIF_CFLAGS)

dnl# Test for libtiff :

if test "$with_tiff" = no; then
  have_tiff=disabled
else
  SAVED_CFLAGS=$CPPFLAGS
  if test "$tiff_includes" != no; then
	TIFF_CFLAGS="-I$tiff_includes"
	CPPFLAGS="$CPPFLAGS $TIFF_CFLAGS"
  fi
  AC_CHECK_HEADER(tiffio.h,[AC_DEFINE(HAVE_TIFF,1,[Define if libtiff is available]) AFTERIMAGE_LIBS="-ltiff $AFTERIMAGE_LIBS" have_tiff=yes])
  CPPFLAGS=$SAVED_CFLAGS
fi
AC_SUBST(TIFF_CFLAGS)

if test "$have_tiff" = yes -o "$have_png" = yes ; then
  if test "x$ZLIB_OBJS" = "x" -a "$have_zlib" = yes; then 
	  AFTERIMAGE_LIBS="$AFTERIMAGE_LIBS -lz"
  fi
fi

have_svg=
if test "$with_svg" = no; then
	have_svg=disabled
else
	if test -z "$PKG_CONFIG"; then
    		AC_PATH_TOOL(PKG_CONFIG, pkg-config,no)
	fi
	if test "$PKG_CONFIG" = "no" ; then
		AC_MSG_CHECKING(if librsvg 2.0 is available)
		AC_MSG_RESULT(pkg-config is not found. Cannot check for librsvg 2.0.)
		have_svg=no
	else
		have_svg=yes
		pkg_modules="librsvg-2.0 >= 2.0.0"
		
		PKG_CHECK_MODULES(SVG,[$pkg_modules],,[have_svg=no])
		
		if test "x$have_svg" = "xyes"; then
			AC_DEFINE(HAVE_SVG,1,librsvg v.2.0 or higher is available )
			AFTERIMAGE_LIBS="$SVG_LIBS $AFTERIMAGE_LIBS"
		fi
	fi
fi

AC_SUBST(SVG_CFLAGS)

dnl# we always need libm since we now call exp() in gaussian blur
AFTERIMAGE_LIBS="$AFTERIMAGE_LIBS -lm"

dnl# check for libfreetype

TTF_CFLAGS=

if test "x$with_ttf" = "xno"; then
  have_ttf=disabled
elif test "$PKG_CONFIG" = "no" ; then
  AC_MSG_CHECKING(if TTF support is available)
  AC_MSG_RESULT(pkg-config is not found. Cannot check for TTF support)
  have_ttf=disabled
else
  if test "x$ttf_includes" = "xno"; then

    PKG_CHECK_MODULES(TTF,[freetype2],[have_ttf=maybe],[have_ttf=no])

    if test "x$have_ttf" = "xmaybe"; then
	  saved_CPPFLAGS=$CPPFLAGS
	  saved_CFLAGS=$CFLAGS
	  CPPFLAGS="$TTF_CFLAGS $CPPFLAGS"
	  CFLAGS="$CFLAGS $TTF_CFLAGS $XPM_CFLAGS $JPEG_CFLAGS $PNG_CFLAGS $GIF_CFLAGS $TIFF_CFLAGS $SVG_CFLAGS $X_CFLAGS"
	  have_ft2build=no
	  AC_CHECK_HEADERS(ft2build.h,[have_ft2build=yes])
	  AC_MSG_CHECKING( freetype/freetype.h )
	  have_ttf=no
          have_freetype_freetype=no
	  have_freetype=no
	  AC_EGREP_HEADER(FT_Face,freetype/freetype.h,
	                  [have_freetype_freetype=yes],
	                  [AC_MSG_RESULT(no);AC_MSG_CHECKING(freetype.h); \
                                             AC_EGREP_HEADER(FT_Face,freetype.h,
					                   [have_freetype=yes], AC_MSG_RESULT(no))]
					  )
	  if test "x$have_ft2build" = "xno" ; then
    	  	if test "x$have_freetype_freetype" = "xyes" ; then
			AC_TRY_COMPILE([#include <freetype/freetype.h>],
                            	[FT_Face f;],
	                   	[have_ttf=yes],AC_MSG_RESULT(no))
	  	elif test "x$have_freetype" = "xyes" ; then
			AC_TRY_COMPILE([#include <freetype.h>],
                            	[FT_Face f;],
	                   	[have_ttf=yes],AC_MSG_RESULT(no))
	  	fi;
	  elif test "x$have_freetype_freetype" = "xyes" ; then
		AC_TRY_COMPILE([#include <ft2build.h> 
			    #include <freetype/freetype.h>],
                            [FT_Face f;],
	                [have_ttf=yes],AC_MSG_RESULT(no))
	  elif test "x$have_freetype" = "xyes" ; then
		AC_TRY_COMPILE([#include <ft2build.h>
			#include <freetype.h>],
                        [FT_Face f;],
	                [have_ttf=yes],AC_MSG_RESULT(no))
	  fi;		       
    	  if test "x$have_ttf" = "xyes" ; then
		AC_DEFINE(HAVE_FREETYPE,1,[Define if libFreeType is available])
		if test "x$have_freetype_freetype" = "xyes" ; then 
			AC_DEFINE(HAVE_FREETYPE_FREETYPE,1,[Define if libFreeType has freetype.h in freetype/ ])
		fi;
                AC_MSG_RESULT(yes)
	  fi;
	  CPPFLAGS=$saved_CPPFLAGS
	  CFLAGS=$saved_CFLAGS
    else
		enable_ttf=no ;
		AC_MSG_CHECKING(if TTF support is available)
		AC_MSG_RESULT(none found, ttf disabled)
		echo "You have to install FreeType libary in order to be able to use TTF fonts."
        have_ttf=no
    fi;
  else
	TTF_CFLAGS=$ttf_includes
	AC_DEFINE(HAVE_FREETYPE,1,[Define if libFreeType is available])
    have_ttf=yes
  fi
  if test "$have_ttf" = yes; then
	  AFTERIMAGE_LIBS="$TTF_LIBS $AFTERIMAGE_LIBS"
  fi
fi;
AC_SUBST(TTF_CFLAGS)

AC_SUBST(JPEG_OBJS)
AC_SUBST(ZLIB_OBJS)
AC_SUBST(PNG_OBJS)
AC_SUBST(UNGIF_OBJS)

AFTERIMAGE_LIBS_EXTERNAL=$AFTERIMAGE_LIBS
AC_SUBST(AFTERIMAGE_LIBS_EXTERNAL)

USE_DEFAULT_AFTERBASE=0
AFTERBASE_INCS_PATH=
if test "x$with_afterbase" != "xno"; then
  AC_MSG_CHECKING(libAfterBase headers in ../libAfterBase)
  have_afterbase=yes
  if test "x$afterbase_includes" = "xno"; then
	  if test -r "../libAfterBase/astypes.h"; then
	    AC_MSG_RESULT(yes)
		AFTERBASE_INCS_PATH="../"
	  else
	    AC_MSG_RESULT(no)
 	    AC_CHECK_HEADER(libAfterBase/astypes.h,[USE_DEFAULT_AFTERBASE=1],[have_afterbase=no])
	  fi
  else
	  AFTERBASE_INCS_PATH="$afterbase_includes/"
      AC_MSG_RESULT($AFTERBASE_INCS_PATH)
  fi
else
  AC_MSG_CHECKING(libAfterBase)
fi

AFTERBASE_C=afterbase.o
HAVE_AFTERBASE_FLAG=0
if test "x$have_afterbase" = "xyes"; then
    HAVE_AFTERBASE_FLAG=1
	AFTERBASE_C=
	if test "x$CYGWIN" = "xno" -a "x$GCC" = "xyes" ; then
dnl# rdynamic is only useable if we have libAfterBase's backtrace functionality
		user_ldflags="$user_ldflags $RDYNAMIC"
  	fi
    if test "x$have_x" != "xyes" -a "x$have_gif" = "xyes"; then
    	AFTERIMAGE_LIBS="$AFTERIMAGE_LIBS -lAfterBase"
    else
    	AFTERIMAGE_LIBS="-lAfterBase $AFTERIMAGE_LIBS"
    fi
    if test -r "../libAfterBase/astypes.h"; then
    	AFTERIMAGE_APPS_LIBS="-L../ -L../../libAfterBase -lAfterImage $AFTERIMAGE_LIBS"
    	AFTERIMAGE_TEST_LIBS="-L./ -L../libAfterBase -lAfterImage $AFTERIMAGE_LIBS"
    	AFTERIMAGE_LIB_LIBS="-L./ -L../libAfterBase $AFTERIMAGE_LIBS"
    else
    	AFTERIMAGE_APPS_LIBS="-L../ -L$libdir -lAfterImage $AFTERIMAGE_LIBS"
    	AFTERIMAGE_TEST_LIBS="-L./ -L$libdir -lAfterImage $AFTERIMAGE_LIBS"
    	AFTERIMAGE_LIB_LIBS="-L./ -L$libdir $AFTERIMAGE_LIBS"
    fi
    AC_DEFINE(HAVE_AFTERBASE,1,[Define if libAfterBase is available])
else
	AFTERIMAGE_APPS_LIBS="-L../ -lAfterImage $AFTERIMAGE_LIBS_EXTERNAL"
	AFTERIMAGE_TEST_LIBS="-L./ -lAfterImage $AFTERIMAGE_LIBS_EXTERNAL"
	AFTERIMAGE_LIB_LIBS="-L./ $AFTERIMAGE_LIBS_EXTERNAL"
	if test "$with_afterbase" = "no"; then
	    AC_MSG_RESULT(disabled)
	fi
	AC_HEADER_DIRENT
	AC_CHECK_HEADERS(sys/dirent.h)
fi
AC_SUBST(AFTERBASE_INCS_PATH)
AC_SUBST(USE_DEFAULT_AFTERBASE)
AC_SUBST(HAVE_AFTERBASE_FLAG)
AC_SUBST(AFTERBASE_C)
AC_SUBST(have_afterbase)
AC_SUBST(AFTERIMAGE_APPS_LIBS)
AC_SUBST(AFTERIMAGE_TEST_LIBS)
AC_SUBST(AFTERIMAGE_LIB_LIBS)
AC_SUBST(afterimage_x_support)

dnl# finalizing libs listing :

CLEAN_AFTERIMAGE_LIBS=
for L in $AFTERIMAGE_LIBS; do
  if test "$L" != "-L$libdir"; then
	  CLEAN_AFTERIMAGE_LIBS="$CLEAN_AFTERIMAGE_LIBS $L"
  fi
done
AFTERIMAGE_LIBS="-L$libdir -lAfterImage $CLEAN_AFTERIMAGE_LIBS"
AC_SUBST(AFTERIMAGE_LIBS)

if test "x$enable_staticlibs" = "xyes"; then
   LIBPROG='$(LIB_STATIC)'
   LIBINSTALL="install.static"
   LIBUNINSTALL="install.static"
else
   enable_sharedlibs="yes"
fi
if test "x$enable_sharedlibs" = "xyes"; then
	if test "x$CYGWIN" = "xyes" ; then
	   tmp='$(LIB_SHARED_CYG)'
	   tmp2='install.cyg'
	else
	   tmp='$(LIB_SHARED)'
	   tmp2='install.dyn'
	fi
   	LIBPROG="$LIBPROG $tmp"
   	LIBINSTALL="$LIBINSTALL $tmp2"
    LIBUNINSTALL="uninstall.static un$tmp2"
fi

dnl# define X_LOCALE.  need Linux, NetBSD and etc.
if test "x$enable_xlocale" = "xyes"; then
  DEFINE_XLOCALE="-DX_LOCALE"
fi

dnl# Translate enable_* from "yes/no" to "1/0" (for configure.h)

if test "x$enable_i18n" = "xyes"; then AC_DEFINE(I18N,1,[Define if locale support in X is needed]) fi
if test "x$enable_audit" = "xyes"; then AC_DEFINE(DEBUG_ALLOCS,1,[Define if memory allocation logging and debugging is desired]) fi

dnl# Variable strings declaration

AC_SUBST(image_format)

AC_SUBST(CFLAGS)
AC_SUBST(version)
AC_SUBST(version_major)
AC_SUBST(lib_name)
AC_SUBST(lib_file_name)
AC_SUBST(with_afterdir)
AC_SUBST(with_locale)
AC_SUBST(user_ldflags)
AC_SUBST(x_libs)
AC_SUBST(X_CFLAGS)
AC_SUBST(LIBPROG)
AC_SUBST(LIBINSTALL)
AC_SUBST(DEFINE_XLOCALE)
AC_SUBST(PERL)

dnl# Write results
dnl# Common parts of the Makefile

LIBAFTERIMAGEFILES=.shared
AC_SUBST_FILE(LIBAFTERIMAGEFILES)

APPSDEPS=
if test -d apps ; 	then   
  APPSDEPS='$(APPS_DEPS)'
  AC_CONFIG_FILES([apps/Makefile]) 
fi

if test -d aftershow ; 	then   
  AC_CONFIG_FILES([aftershow/Makefile]) 
fi

AC_SUBST(APPSDEPS)

AC_OUTPUT(Makefile \
afterbase.h \
afterimage-libs \
afterimage-config)

chmod 755 afterimage-libs