File: configure.in

package info (click to toggle)
imview 1.1.9c-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,076 kB
  • ctags: 4,780
  • sloc: cpp: 28,836; sh: 2,624; ansic: 1,818; makefile: 731; exp: 112; python: 88
file content (1061 lines) | stat: -rw-r--r-- 32,201 bytes parent folder | download | duplicates (4)
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
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
dnl
dnl
dnl Configure file for Imview 1.1.x
dnl
dnl Imview is hard to configure because is uses a lot of advanced features
dnl such as TCP/IP sockets, shared memory & semaphores (sysv and/or posix)
dnl threading and a gui system. Moreover it is portable to Win32 in spite 
dnl of all that, and I need it available on Linux, Solaris, Tru64 and win2k 
dnl at the very least, and across a relatively wide variety of C++ compilers, 
dnl a language that keeps evolving. On top of that I like to support cross-compiling
dnl of the win32 version from Linux/Unix, for efficiency reasons. In other words
dnl this configure.in file is a nightmare. You have been warned!
dnl
dnl Here are a few gotchas:
dnl
dnl LIBS is not used at compilation time, only at configure time.
dnl all the various optional LIBS are substituted in the makefile in 
dnl increments (MATHLIB, IMGLIB, etc).
dnl




dnl Disabling caching 
dnl I'll want to re-enable it once it all works... (i.e: never Hugues Talbot	 8 May 2003)
define([AC_CACHE_LOAD], )dnl
define([AC_CACHE_SAVE], )dnl


dnl Process this file with autoconf to produce a configure script.
dnl Any file will do, this is to check that the srcdir is correct
AC_INIT(io/cpostscript.cxx)
AC_CANONICAL_SYSTEM

# generate configure header
AC_CONFIG_HEADER(imcfg.h) # the name config.h is used everywhere these days

# Set version
MAJOR_VERSION=1
MINOR_VERSION=1
MICRO_VERSION=9 # ball is now rolling

echo "configuring Imview $MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION"
AC_SUBST(MAJOR_VERSION)dnl
AC_SUBST(MINOR_VERSION)dnl
AC_SUBST(MICRO_VERSION)dnl

# Branch tag
BRANCH_TAG=rel-1-1-0
echo "Branch $BRANCH_TAG"
AC_SUBST(BRANCH_TAG)

# start of the real thing

# we need the version number, actually
AC_DEFINE_UNQUOTED(IMVIEW_MAJOR, $MAJOR_VERSION)
AC_DEFINE_UNQUOTED(IMVIEW_MINOR, $MINOR_VERSION)
AC_DEFINE_UNQUOTED(IMVIEW_MICRO, $MICRO_VERSION)

#
# we need the default prefix!
#
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'


dnl This stuff is hand-generated
dnl And heavily pinched from FLTK's autoconf stuff
dnl BEGIN Hugues' block

#dnl Use C++ as the test language.
# AC_LANG_CPLUSPLUS

# does not seem to work...
#AC_ARG_VAR ($CC," C compiler of choice")
#AC_ARG_VAR ($CXX, "C++ compiler of choice")

# location of FLTK library
AC_ARG_WITH(fltk-dir,
[  --with-fltk-dir=[DIR]   location of the FLTK distribution directory to use.],
[fltk_dist=$withval],
[fltk_dist=""])

# Enable prof-based profiling support
AC_ARG_ENABLE(prof,
              [  --enable-prof           enable prof source profiling support [default=disable]],
              [with_prof=$enableval],
              [with_prof='no'])

# Enable gprof-based profiling support
AC_ARG_ENABLE(gprof,
              [  --enable-gprof          enable gprof source profiling support [default=disable]],
              [with_gprof=$enableval],
              [with_gprof='no'])

# Enable gcov-based profiling support
AC_ARG_ENABLE(gcov,
              [  --enable-gcov           enable gcov source profiling support [default=disable]],
              [with_gcov=$enableval],
              [with_gcov='no'])

with_profiling='no'
if test "$with_prof" = 'yes' || test "$with_gprof" = 'yes' || test "$with_gcov" = 'yes'
then
  with_profiling='yes'
fi

# Enable use of double-buffering windows. Doesn't work everywhere yet
AC_ARG_ENABLE(dblbuf,
              [  --enable-dblbuf         enable use of double-buffered windows [default=disable]],
              [with_dblbuf=$enableval],
              [with_dblbuf='no'])


# diverse optional libraries
AC_ARG_WITH(jpeg,
              [  --without-jpeg          disable native JPEG support [default=enable]],
              [with_jpeg=$withval],
              [with_jpeg='yes'])

AC_ARG_WITH(tiff,
              [  --without-tiff          disable native TIFF support [default=enable]],
              [with_tiff=$withval],
              [with_tiff='yes'])

AC_ARG_WITH(magick,
              [  --without-magick        disable ImageMagick support [default=enable]],
              [with_magick=$withval],
              [with_magick='yes'])

AC_ARG_WITH(pink,
              [  --without-pink          disable PINK support [default=enable]],
              [with_pink=$withval],
              [with_pink='yes'])

# the native chooser is MUCH nicer
AC_ARG_WITH(native-chooser,
	      [  --without-native-chooser disable experimental native chooser [default=enable]],
	      [with_native_chooser=$withval],
	      [with_native_chooser='yes'])

dnl# Clear debugging flags and only enable debugging if the user asks for
dnl# it.

DEBUGFLAG=""
PICFLAG=0
CFLAGS="${CFLAGS:=}"
CXXFLAGS="${CXXFLAGS:=}"

AC_ARG_ENABLE(debug, 
		[  --enable-debug          turn on debugging [default=disable]], \
		[with_debug=$enableval],
		[with_debug='no'])

if test "$with_debug" != "no"
then
#	[if eval "test x$enable_debug = xyes"; then DEBUGFLAG="-g " ; fi])
	DEBUGFLAG="-g "
fi		


# Enable support for image server
AC_ARG_WITH(server,
              	[  --without-server        disable image server [default=with]],
              	[with_server=$withval],
              	[with_server='yes'])


# enable support for SYSV type shared memory (not shared library!)
AC_ARG_WITH(sysv-ipc,
		[  --without-sysv-ipc      disable Unix SYSV shared memory support [default=with]],
		[with_sysv_ipc=$withval],
		[with_sysv_ipc='yes'])

# enable support for POSIX type shared memory (not shared library!)
AC_ARG_WITH(posix-ipc,
		[  --without-posix-ipc     disable Unix POSIX shared memory support [default=with]],
		[with_posix_ipc=$withval],
		[with_posix_ipc='yes'])


# if server is disabled, so is SYSV and POSIX
if test "$with_server" != "yes" ; then
	with_sysv_ipc="no"
	with_posix_ipc="no"
fi


dnl# save the user-definable options, so that the user can check at the end
dnl# if they worked!
save_prof=$with_prof
save_gprof=$with_gprof
save_gcov=$with_gcov
save_jpeg=$with_jpeg
save_tiff=$with_tiff
save_magick=$with_magick
save_pink=$with_pink
save_native_chooser=$with_native_chooser
save_debug=$with_debug
save_server=$with_server
save_sysv_ipc=$with_sysv_ipc
save_posix_ipc=$with_posix_ipc
save_dblbuf=$with_dblbuf

# Evaluate shell variable equivalents to Makefile directory variables
eval "eval BIN_DIR=$bindir"
eval "eval DATA_DIR=$datadir"
eval "eval INCLUDE_DIR=$includedir"
eval "eval LIB_DIR=$libdir"

srcdirfull=`cd $srcdir && pwd`

# so that we also look where the software will be installed (the `local' /usr/local...)
LDFLAGS="$LDFLAGS -L$LIB_DIR"
CPPFLAGS="$CPPFLAGS -I. "


# by default we build for Unix and we need X.
have_x="yes"
have_carbon="no" # Carbon environment
have_wingdi="no" # Windows GDI
exec_extension="" # Unix executable are not known by their extention
# use the host type
LIBXTRA=""

# trying for a `standard' echo
ECHO=echo
# other standard commands
CP=/bin/cp
MV=/bin/mv

#needed to work around a bug in mingw
START=""


dnl Check for presence of FLTK helper application
AC_CHECK_PROG(have_fltk_config, fltk-config, "yes", "no",${fltk_dist}:$PATH)
if test "$have_fltk_config" != "yes"
then
	echo "*** Fltk-config was not found!"
	echo "*** You need to upgrade FLTK to version 1.1.x, exiting"
	exit 1
fi


dnl Find location of FLTK libs & include files, etc
if test "$fltk_dist" != "" 
then
	dnl User gave location of library to use
	my_fltk_config=${fltk_dist}/fltk-config
	fltk_config_name=`$my_fltk_config --libs` # that's pre-installation, no good
	fltk_cfg_nm=`echo $fltk_config_name | sed 's%.*/lib\(fltk.*\).a%\1%'` # short name still OK
	fltk_config_name=${fltk_dist}/lib/lib${fltk_cfg_nm}.a
	fltk_images_name=${fltk_dist}/lib/lib${fltk_cfg_nm}_images.a
	dnl Extra include flags
	fltk_include_flags=`$my_fltk_config --use-images --cxxflags`
	LDFLAGS="-L${fltk_dist}/lib $LDFLAGS"
	CPPFLAGS="-I${fltk_dist} $fltk_include_flags $CPPFLAGS"
	FLUID=${START}${fltk_dist}/fluid/fluid
	dnl no check for library, we trust what the user gave us
	FLTKLIB=" $fltk_images_name $fltk_config_name"
	fltklib=fltk
	# one more hack for the road... This is needed to get the `framework` information on macos
	LDFLAGS="$LDFLAGS `$my_fltk_config --ldflags`"
else
	dnl Must find out where FLTK is, if present
	dnl Since we know that we have fltk-config, use it for flags...
	my_fltk_config=fltk-config
	fltk_config_name=`$my_fltk_config --libs` # long path	
	fltk_cfg_nm=`echo $fltk_config_name | sed 's%.*/lib\(fltk.*\).a%\1%'` # short name
	fltk_images_name=`$my_fltk_config --libs | sed 's/\(.*fltk\)\(\.a$\)/\1_images.a/'`
	dnl extra include flags
	fltk_include_flags=`$my_fltk_config --use-images --cxxflags`
	FLUID=${START}fluid
	dnl Include extra library (FLTK-1.1.x) for handling various image formats.
	LDFLAGS="$LDFLAGS `$my_fltk_config --use-images --ldstaticflags`"
	Cppflags="$CPPFLAGS $fltk_include_flags"
	FLTKLIB="`$my_fltk_config --use-images --ldstaticflags`"
	fltklib=$fltk_cfg_name
fi

dnl Are we using X?
fltk_x11_ldflags=`$my_fltk_config --ldflags | grep '\-lX11'`
if test "$fltk_x11_ldflags" != "" ; then
   fltk_uses_x11=yes
else
   fltk_uses_x11=no
fi
	

FLTK_CONFIG=$my_fltk_config
AC_SUBST(FLTK_CONFIG)


case $target in 
        *linux*)
		# our favourite platform :-)
		CPPFLAGS="-DLinux $CPPFLAGS"
		;;

	*dec-osf*)
		# Compaq Tru64, aka DEC Unix, aka OSF1
		CPPFLAGS="-DOSF1 $CPPFLAGS"
		;;

	*sun-solaris2*)
		# Sun Solaris. Broken X headers are no fun
		CPPFLAGS="-DSolaris -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ $CPPFLAGS"
		# Sun POSIX IPC does not allow paths under /tmp
		AC_DEFINE(POSIX_IPC_PREFIX, "/")
		# Solaris /usr/bin/echo does not understand `-n'
		ECHO=/usr/ucb/echo 
		;;

	*pc-mingw32*)
		# MINGW32. Nothing special, but no X!
		have_x="no"
		have_wingdi="yes"
		exec_extension=".exe" # Windows executable are `.exe' files.
		CPPFLAGS="$CPPFLAGS -O2" # my compiler doesn't produce correct executable unless optimizing!
		WINTHREAD="pthreadGC" # use the pthread-win32 without structured exceptions.
		START="/bin/start " # to be able non-mingw GUI applications like fluid, NOTE: space is important		
		LDFLAGS="$LDFLAGS -mwindows -lole32 -luuid -lcomctl32 -lwsock32 -lsupc++"
		;;

	*i686-pc-cygwin)
		# MINGW32. Nothing special, but no X!
		have_x="no"
		have_wingdi="yes"
		exec_extension=".exe" # Windows executable are `.exe' files.
		CPPFLAGS="$CPPFLAGS -O2 -mwin32" # my compiler doesn't produce correct executable unless optimizing!
		WINTHREAD="pthread"
		;;

	*darwin*)
		# Mac OS/X
		echo "*** Oooh, MacOS/X"
		if test "$fltk_uses_x11" = "no" ; then
		   echo "*** Using Carbon too" 
		   have_x="no" # use Carbon instead
		   have_carbon="yes"
		   CPPFLAGS="-DMACOSX_CARBON $CPPFLAGS"
		else
		   echo "*** Still using X11"
		fi
		# assume presence of fink
		# not sure this is necessary, as we now use fltk-config
		CPPFLAGS="-DDARWIN -O2 -I/sw/include $CPPFLAGS"
		LDFLAGS="$LDFLAGS -L/sw/lib"
		if test "$with_magick" = "yes" ; then
		    echo "Silencing magick warnings at link time"
		    LDFLAGS="$LDFLAGS -Xlinker -multiply_defined -Xlinker suppress"
		    echo "*** You might see a lot of warnings at link time if your version"
		    echo "*** of ImageMagick embeds symbols from various other standard libraries"
		    echo "*** such as libjpeg or libz. This is pretty harmless." 
		fi
		CP=/Developer/Tools/CpMac
		MV=/Developer/Tools/MvMac	   
		;;
		

	*)
		echo "*** A platform I haven't tried! Some definitions might be lacking"
		echo "*** Please contribute your changes if any required."
		echo "*** mailto: Hugues.Talbot@cmis.CSIRO.AU"
		;;
esac

AC_SUBST(CP)
AC_SUBST(MV)
EEXT=$exec_extension
AC_SUBST(EEXT)

dnl Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB


if test "$RANLIB" != ":"; then
  LIBCOMMAND="ar cr"
else
  LIBCOMMAND="ar crs"
fi

AC_PROG_MAKE_SET

dnl Find out compiler quirks
dnl http://research.cys.de/autoconf-archive
AC_CXX_MEMBER_TEMPLATES
AC_CXX_TEMPLATE_KEYWORD_QUALIFIER
AC_CXX_TEMPLATES_AS_TEMPLATE_ARGUMENTS
AC_CXX_DEFAULT_TEMPLATE_PARAMETERS
AC_CXX_STD_CHAR_TRAITS

dnl home-brewed compiler error detection
AC_CXX_TEMPLATE_CAST_ARRAY


dnl Checks for header files.
AC_HEADER_DIRENT


AC_CHECK_HEADER(sys/select.h)
AC_CHECK_HEADER(winsock.h)

dnl Check for socken_t in accept
AC_ACCEPT_USES_SOCKLEN_T

AC_CHECK_FUNC(scandir,
    if test "$uname" = "SunOS"; then
        echo Not using Solaris scandir BSD emulation function.
    else
        AC_DEFINE(HAVE_SCANDIR)
    fi)

AC_CHECK_FUNC(vsnprintf,
    if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
        echo Not using built-in vsnprintf function because you are running HP-UX 10.20.
    else
        AC_DEFINE(HAVE_VSNPRINTF)
    fi)

AC_CHECK_FUNC(snprintf,
    if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
        echo Not using built-in snprintf function because you are running HP-UX 10.20.
    else
        AC_DEFINE(HAVE_SNPRINTF)
    fi)

AC_CHECK_FUNCS(vsprintf)

dnl # checks for a reasonable wait function that takes sub-second argument
AC_CHECK_FUNCS(usleep nanosleep)

if test "$have_x" = "yes" ; then
	dnl some headers might be poorly defined, in particular regarding X11 headers and Solaris (things have improved lately)
	# Check for X	
# This macro causes an unused dependency to libXt. In Debian, the fltk
# build dependency should pull in all the needed X gunk, but no more.
# - TI 2006-07-06
#	AC_PATH_XTRA
# Adding empty X_EXTRA_LIBS
	AC_SUBST(X_EXTRA_LIBS, "")

	echo "Ignoring libraries \"$X_PRE_LIBS\" requested by configure."
	dnl# LIBS="$LIBS$X_LIBS$X_PRE_LIBS"
	if test "$with_magick" != "no" ; then
		# this seems to be sufficient somehow	
		# as Magick will include the right libraries and flags already
		XLIBS="-lX11 -lXext -lXpm"
	else
		# I'm not sure how reliable this is...
		XLIBS="$X_LIBS -lX11 -lXext -lXpm"
	fi
	# LIBS="$LIBS$X_LIBS"
	CFLAGS="$CFLAGS $X_CFLAGS"
	CPPFLAGS="$CPPFLAGS $X_CFLAGS"
	AC_SUBST(XLIBS)	
	# check for some incorrect X11 headers
	AC_CXX_X11_HEADER_PERMISSIVE
	# check for Xinerama
	AC_X11_HAS_XINERAMA
	XLIBS="$XLIBS $XINERAMA"
fi

MAKEDEPEND="\$(CXX) -M"

dnl# add warnings to compiler switches:
dnl# do this last so messing with switches does not break tests
if test -n "$GXX"; then
    GCC_ACCEPTS_INCLUDE_DIR # this will add -I$INCLUDE_DIR if the compiler does not complain about it.

    CFLAGS="-Wall $CFLAGS"
    # GNU C++ is sometimes missing bits of the STL
    AC_CXX_STRSTREAM
    # other bits for g++
    CXXFLAGS="-Wall -Wno-return-type -Wno-unknown-pragmas $CXXFLAGS"
    if test -z "$DEBUGFLAG"; then
        CFLAGS="-O2 $CFLAGS"
        CXXFLAGS="-O2 $CXXFLAGS"
    else
	CFLAGS="$DEBUGFLAG $CFLAGS"
	CXXFLAGS="$DEBUGFLAG $CXXFLAGS"
    fi
else
    case `(uname) 2>/dev/null` in
        IRIX*)
            # Running some flavor of IRIX; see which version and
            # set things up according...
            if test "$uversion" -ge 62; then
                # We are running IRIX 6.2 or higher; uncomment the following
                # lines if you don't have IDO 7.2 or higher:
                #
                #     CXX="CC -n32"
                #     CC="cc -n32"
                #     LD="ld -n32"
                #     MAKEDEPEND="CC -M"

                echo "FOR BEST RESULTS BEFORE COMPILING: setenv SGI_ABI -n32"
                # -woff 3322 is necessary due to errors in Xlib headers on IRIX
                CFLAGS="-fullwarn $CFLAGS"
                CXXFLAGS="-fullwarn -woff 1685,3322 $CXXFLAGS"
            else
                CXXFLAGS="+w +pp $CXXFLAGS"
            fi
            if test -z "$DEBUGFLAG"; then
                CFLAGS="-O2 $CFLAGS"
                CXXFLAGS="-O2 $CXXFLAGS"
            fi
            ;;
        HP-UX*)
            # Running HP-UX; these options should work for the HP compilers.
            if test -z "$DEBUGFLAG"; then
                CFLAGS="+O2 $CFLAGS"
                CXXFLAGS="+O2 +W336,501,736,740,749,829 $CXXFLAGS"
            fi
            ;;
        SunOS*)
            # Solaris
            if test -z "$DEBUGFLAG"; then
                CFLAGS="-O"
                CXXFLAGS="-O"
            fi
            ;;
	OSF*)
	    # DEC Unix (Compaq silly tru64)
	    if test -z "$DEBUGFLAG"; then
		CFLAGS="-O2 -Olimit 2000 $CFLAGS"
		CXXFLAGS="-ttimestamp -O2 -Olimit 2000 $CXXFLAGS"
	    else 
		CFLAGS="$DEBUGFLAG $CFLAGS"
		CXXFLAGS="$DEBUGFLAG $CXXFLAGS"
            fi
	
	    CFLAGS="$CFLAGS -I${prefix}/include"
	    CXXFLAGS="$CXXFLAGS -I${prefix}/include"

	    LIBCOMMAND="/usr/bin/ar cr" # make sure we use the system's archiver. GNU's not compatible with cxx	
	    # we need the IOStream library, and we enable ALL the compiler messages
	    CXXFLAGS="-w1 -D__USE_STD_IOSTREAM $CXXFLAGS"
	    # the CXX compiler requires this when using automated template 
	    # instantiation.	    
	    LIBXTRA="cxx_repository/*.o"
	    ;;
	
	Linux*)
	    # test for the Intel compiler
	    if test "$CXX" = "icc" ; then
		if test -z "$DEBUGFLAG"; then
                	CFLAGS="-O2 -w1"
                	CXXFLAGS="-O2"
            	fi
	    else
		echo "+++ Unknown compiler, using safe optimization flags"
            	if test -z "$DEBUGFLAG"; then
                	CFLAGS="-O"
                	CXXFLAGS="-O"
            	fi
	    fi
            ;;

	Darwin*)
	    # Mac OS/X, where cc is really gcc
	    # assume presence of fink
	    ;;

        *)
            # Running some other operating system; inform the user they
            # should contribute the necessary options to fltk-bugs@easysw.com...
	    echo "+++ Untried platform"
            echo "+++ Building Imview with default compiler flags; contact"
            echo "+++ hut66au at gmail dot com with uname and compiler options needed"
            echo "+++ for your platform, or set the CFLAGS and CXXFLAGS options"
            echo "+++ before running configure."
            ;;
    esac
fi

dnl extra stuff needed by some compilers (such as CXX under DEC Unix, for automated
dnl template instanciation, that occurs using the STL)
AC_SUBST(LIBXTRA)


#
# Find math library
#
MATHLIB=''
AC_CHECK_LIB(m,sqrt,MATHLIB=" -lm",,)
LIBS="$LIBS $MATHLIB" # -lm is needed almost everywhere
AC_SUBST(MATHLIB)

dnl These library are problematic?
dnl Checks for libraries.
dnl We do not use OpenGL, but sometimes fltk may require it.
#AC_CHECK_LIB(GL, main)


dnl Checking for correct version
dnl 

$ECHO -n "Checking for fltk version: "
majorver=`(${FLUID} -o /tmp/toto -c /dev/null ; grep 'version' /tmp/toto | awk '{printf("%.0f\n", $NF)}' )`
minorver=`( grep 'version' /tmp/toto | awk '{printf("%0.f\n", ($NF-int($NF)) * 100)}' )`
patchver=`( grep 'version' /tmp/toto | awk '{printf("%0.f\n", 100*((($NF-int($NF))*100)-int(($NF-int($NF))*100)))}' )`
rm /tmp/toto # clean up
if test $majorver -eq 1 -a $minorver -ge 1
then
	echo "... OK"
else
	echo ""
	echo "*** Please select FLTK version 1.1.x"
	echo "*** NOTE that FLTK 2.0 or greater is not supported yet..."
	echo "*** FLTK 1.0.x is only supported by imview-1.0.x or lesser"
	exit 1
fi

fltk_alt_suff=`echo $CXX | sed 's%/%_%g'`
echo "Alternative libfltk name: " libfltk_${fltk_alt_suff}.a
echo "Configured libfltk name:  " $fltk_config_name

AC_SUBST(FLUID)
AC_SUBST(FLTKLIB)

dnl add extra flags for linking
xtra_cflags=`$my_fltk_config --cflags`
xtra_ldflags=`$my_fltk_config --ldflags`
if test "$have_wingdi" = 'yes' ; then
	echo "Building for the Windows GDI"
	CPPFLAGS="$CPPFLAGS ${xtra_cflags}"
	XLIBS="$XLIBS ${xtra_ldflags}"
fi

if test "$have_macos" = 'yes' ; then
   	echo "Building for MacOS Carbon environment"
	XLIBS="$XLIBS -framework Carbon -framework ApplicationServices"	
fi


dnl See if we need the True-Type renderer
need_Xft=`$my_fltk_config --ldflags | grep Xft`
echo -n "Testing if $fltklib needs True Type rendering"
if test "$need_Xft" != ""
then 
	echo "... Yes"
	FLTKEXTRA="$FLTKEXTRA -lXft"	
else
	echo "... No"
fi

AC_SUBST(FLTKEXTRA)

dnl PThreads. Very very very useful!
dnl Without them, no server!
THREADLIB=''
if test "$with_server" != 'no'
then
   # Unix
  if test "$have_x" != "no" -o "$have_carbon" != "no" ; then
    echo "Testing for Unix threads"
    echo "Standard Pthreads:"
	AC_CHECK_LIB(pthread,pthread_attr_init,
      		[AC_DEFINE(HAVE_PTHREADS, 1,Define if you have Posix thread methods.)
       		THREADLIB="-lpthread"
       		THREADDEF="-D_REENTRANT"], 	
			echo "Old DEC threads:"
			AC_CHECK_LIB(pthreads, pthread_attr_create,
				[AC_DEFINE(HAVE_DECTHREADS, 1,Define if you have DEC unix thread methods, very close to pthreads.)
       				AC_DEFINE(HAVE_PTHREADS, 1, We fake the Pthreads.)
				THREADLIB="-lpthreads"],
				 with_server="no"; echo "*** The server would not be able to run",
			),
		)
  else # for Windows we use a compatibility library, slightly different name
    echo "Testing for windows compatible pthreads"
    AC_CHECK_LIB(${WINTHREAD},pthread_attr_init,
      [AC_DEFINE(HAVE_PTHREADS, 1,Define if you have Posix thread methods.)
       THREADLIB="-l${WINTHREAD}"
       THREADDEF=""], with_server="no"; echo "*** The server would not be able to run",)
  fi
#  LIBS="$THREADLIB $LIBS"
  CPPFLAGS="$THREADDEF $CPPFLAGS"
fi
AC_SUBST(THREADLIB)

dnl Check for Unix SYSV shared memory and semaphores IPC.
if test "$with_sysv_ipc" != "no"
then
	AC_CHECK_FUNC(ftok, 
		AC_DEFINE(HAVE_SYSV_IPC, 1,Define if you have Unix SYSV IPC.),
		with_sysv_ipc='no')
   CPPFLAGS="$SYSVDEF $CPPFLAGS"
fi

dnl Check for POSIX IPC
if test "$with_posix_ipc" != "no"
then
	POSIX_IPC_LIB=''
	AC_CHECK_LIB(rt,shm_open,
		[SAVELIBS=$LIBS
		 LIBS="$LIBS -lrt"
		 $ECHO -n "checking if the POSIX semaphores actually work... "
		 AC_TRY_RUN([
#include <stdio.h>
#include <errno.h>
#include <semaphore.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#ifdef Solaris
#define TESTPATH "/px_ipc_test"
#else
#define TESTPATH "/tmp/px_ipc_test"
#endif
int main()
{
 sem_t *sem;
 int    err;
 fputs("testpath = " TESTPATH, stderr);
 sem=sem_open(TESTPATH, O_RDWR | O_CREAT, 0600,0);
 if (sem == SEM_FAILED) {
   perror("semtest, sem_open failed:");
   exit(1);
 }
 if ((err = sem_close(sem)) != 0) {
   perror("semtest, sem_close failed:");
   return(err);
 }
 if ((err = sem_unlink(TESTPATH)) != 0) {
   perror("semtest, sem_unlink failed:");
 }
 return(err);
}
	],
	[echo "yes" 
	 AC_DEFINE(HAVE_POSIX_IPC) POSIX_IPC_LIB="-lrt"],
	[echo "no" 
	 POSIX_IPC_LIB=""
	 with_posix_ipc=no],
	[echo "no (cross-compiling)" 
	POSIX_IPC_LIB=""
	with_posix_ipc=no])
		LIBS=$SAVELIBS], with_posix_ipc=no)
	AC_SUBST(POSIX_IPC_LIB)
fi

dnl ImageMagick is very useful, but optional
dnl Moreover the API keeps changing and that's really annoying.

# Use pkg-config instead of Magick-config (-TI 2005-12-01)
if test "$with_magick" != "no"
then
	MAGICKLIB=''
	# check if we can find the configuration utility
#	AC_CHECK_PROG(HAVE_MAGICK_CONFIG, Magick-config, "yes", "no")
	HAVE_MAGICK_CONFIG="yes"
	if test "$HAVE_MAGICK_CONFIG" != "no"
	then
		# verify that Magick associated libraries are not incompatible
#		if test "$have_x" != "yes" -a "`Magick-config --libs | grep X11`" != "" ; then
		if test "$have_x" != "yes" ; then
		# conflict
			echo "Magick library conflicts with requested absence of X11 library usage"
			with_magick=no
		else
			# this might turn really ugly
#			CPPFLAGS="$CPPFLAGS "`Magick-config --cppflags`
#			LDFLAGS="$LDFLAGS "`Magick-config --ldflags`
#			IMLIBS="$IMLIBS "`Magick-config --libs`
                        MAGICKNAME=$(pkg-config ImageMagick --libs-only-l | sed 's/-l//')
                        CPPFLAGS="$CPPFLAGS "`pkg-config ImageMagick --cflags`
			LDFLAGS="$LDFLAGS "`pkg-config ImageMagick --libs-only-L`
			IMLIBS="$IMLIBS "`pkg-config ImageMagick --libs`
			# we are not finished: we must check we have the correct version
			AC_CHECK_LIB($MAGICKNAME, DispatchImage, 
				AC_DEFINE(HAVE_MAGICK) MAGICKLIB=" -l$MAGICKNAME",
				MAGICKLIB="",
				$IMLIBS)
			if test "$MAGICKLIB" != " -l$MAGICKNAME" ; then
				echo "Magick library found, but version is incorrect, we need version 5.x ; 6.x is not supported at this stage."
				with_magick="no"
			else			
				# check if ImageMagick uses the new exception structure
				AC_MAGICK_REASON
               		        # check if ImageMagick uses InitMagick now
               	        	AC_MAGICK_INIT
               	        	# check if some extra arguments are required
				AC_MAGICK_NEEDS_MORE_EXCEPTION
			fi
		fi
	else
		echo "*** Magick-config not found in path!"
		with_magick="no"
	fi
fi


# ZLIB is not an option, required by some libraries
ZLIB=""
AC_CHECK_LIB(z, gzopen, AC_DEFINE(HAVE_LIBZ) ZLIB=" -lz")
if test "$ZLIB" == ""
then
	## second chance
	AC_CHECK_LIB(fltk_z, gzopen, AC_DEFINE(HAVE_LIBZ) ZLIB=" -lfltk_z")
fi

dnl JPEG Library, also optional, maybe needed by Magick
if test "$with_jpeg" != "no"
then
	JPEGLIB=''
	if test "$fltk_image_name" != ""
	then
		AC_CHECK_LIB(jpeg, jpeg_write_raw_data,  AC_DEFINE(HAVE_JPEG) JPEGLIB=" -ljpeg", with_jpeg=no)
	else
		# jpeg is normally compiled with the images libs
		AC_CHECK_LIB(fltk_jpeg, jpeg_write_raw_data, AC_DEFINE(HAVE_JPEG) JPEGLIB=" -lfltk_jpeg",
			AC_CHECK_LIB(jpeg, jpeg_write_raw_data,  AC_DEFINE(HAVE_JPEG) JPEGLIB=" -ljpeg", with_jpeg=no))
		
	fi
	AC_SUBST(JPEGLIB)

fi

dnl TIFF library, you know the deal by now
if test "$with_tiff" != "no"
then
	TIFFLIB=''
	AC_CHECK_LIB(tiff, TIFFClose, AC_DEFINE(HAVE_TIFF) TIFFLIB=" -ltiff", with_tiff=no, ${JPEGLIB} ${ZLIB})
	AC_SUBST(TIFFLIB)
fi

dnl PINK support, requires no library, but the declaration of a Macro
if test "$with_pink" != "no"
then
	AC_DEFINE(HAVE_PINK_PGM_EXTENSIONS)
fi 

dnl Native chooser support
if test "$with_native_chooser" != "no"
then
	AC_CHECK_HEADER(FL/Fl_Native_File_Chooser.H, AC_DEFINE(HAVE_NATIVE_CHOOSER))
fi

# check for libpng as well, this is not a choice at this point, 
# it may be required by libfltk_image.a
PNGLIB=''
if test "$ZLIB" != "" 
then
	AC_CHECK_LIB(png, png_read_rows, AC_DEFINE(HAVE_PNG) PNGLIB=" -lpng", ,${ZLIB})
	if test "$PNGLIB" == ""
	then
		## second chance
		AC_CHECK_LIB(flt_png, png_read_rows, AC_DEFINE(HAVE_PNG) PNGLIB=" -lfltk_png", ,${ZLIB})
	fi
	AC_SUBST(PNGLIB)
fi

dnl Create the `image lib' variable
IMLIBS="$IMLIBS $TIFFLIB $JPEGLIB $PNGLIB $ZLIB"
AC_SUBST(IMLIBS)


dnl Installation stuff
eval PrefPath="${DATA_DIR}/imview/"
AC_DEFINE_UNQUOTED(PrefPath,"$PrefPath",Define directory where preference and .lut files will live.)

# optional
#dnl Replace `main' with a function in -lefence:
#AC_CHECK_LIB(efence, main)
dnl Replace `main' with a function in -lgdi32:
#AC_CHECK_LIB(gdi32, main)
dnl Replace `main' with a function in -lgen:
#AC_CHECK_LIB(gen, main)
dnl Replace `main' with a function in -lnsl:
#AC_CHECK_LIB(nsl, main)
dnl Replace `main' with a function in -lpthread32:
#AC_CHECK_LIB(pthread32, main)
dnl Replace `main' with a function in -lsocket:
#AC_CHECK_LIB(socket, main)
dnl Replace `main' with a function in -luser32:
#AC_CHECK_LIB(user32, main)
dnl Replace `main' with a function in -lwsock32:
#AC_CHECK_LIB(wsock32, main)


# Add '-p' if prof source profiling support enabled
if test "$with_prof" = 'yes'
then
  CFLAGS="-p $CFLAGS"
  LDFLAGS="-p $LDFLAGS"
fi

# Add '-pg' if gprof source profiling support enabled
if test "$with_gprof" = 'yes'
then
  CFLAGS="-pg $CFLAGS"
  LDFLAGS="-pg $LDFLAGS"
fi

# Add '-ftest-coverage -fprofile-arcs' if gcov source profiling support enabled
# This is a gcc-specific feature
if test "$with_gcov" = 'yes'
then
  CFLAGS="-ftest-coverage -fprofile-arcs  $CFLAGS"
  LDFLAGS="-ftest-coverage -fprofile-arcs $LDFLAGS"
fi

# use double-buffering?
if test "$with_dblbuf" = 'yes'
then
        AC_DEFINE(IMVIEW_USES_DBLBUF)
fi


#dnl For these we go back to using the C language, as c++ 2.95 has become way too picky
#dnl 
#AC_LANG_C

#AC_C_INLINE this is creating more problem than it is solving
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/time.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM

dnl Checks for library functions.
#AC_FUNC_SETVBUF_REVERSED
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(select socket)
AC_CHECK_FUNCS(getcwd strdup strerror strstr strtol uname)

dnl some substitutions
AC_SUBST(LIBCOMMAND)
AC_SUBST(MAKEDEPEND)


AC_OUTPUT(fluid/Makefile server/Makefile io/Makefile Makefile imview.list, echo timestamp > stamp-h)


echo ""

echo "Imview is configured as follows. Please verify that this"
echo "configuration matches your expectations."
echo ""
echo "Host system type : $host"
echo "Target system    : $target"
echo ""
echo "Option            Configure option        Configured value"
echo "----------------------------------------------------------"
echo "System            --with-server=$save_server		$with_server"
echo "                  --with-sysv-ipc=$save_sysv_ipc		$with_sysv_ipc"
echo "                  --with-posix-ipc=$save_posix_ipc		$with_posix_ipc"
echo "----------------------------------------------------------"
echo "Compiling options --with-prof=$save_prof		$with_prof"
echo "                  --with-gprof=$save_gprof		$with_gprof"
echo "                  --with-gcov=$save_gcov		$with_gcov"
echo "                  --enable-debug=$save_debug		$with_debug"
echo "------------------------------------------------------------"
echo "JPEG              --with-jpeg=$save_jpeg		$with_jpeg"
echo "TIFF              --with-tiff=$save_tiff		$with_tiff"
echo "MAGICK            --with-magick=$save_magick		$with_magick"
echo "PINK              --with-pink=$save_pink      		$with_pink"
echo "Native Chooser    --with-native-chooser=$save_native_chooser	$with_native_chooser"

echo ""

if test "$save_server" != "$with_server" ; then
	echo "** Warning: Imview cannot be configured with the default server option"
fi

if test "$save_sysv_ipc" != "$with_sysv_ipc" ; then
	echo "** Warning: Imview cannot be configured with the default SYSV IPC option"
fi

if test "$save_posix_ipc" != "$with_posix_ipc" ; then
	echo "** Warning: Imview cannot be configured with the default POSIX IPC option"
	if test "$with_sysv_ipc" = "yes" ; then
		echo "** Warning: But you will be fine with the SYSV IPC, no worries."
		echo ""
	fi
fi

if test "$save_jpeg" != "$with_jpeg" ; then
	echo "** Warning: Imview cannot be configured with the desired JPEG option"
fi

if test "$save_tiff" != "$with_tiff" ; then
	echo "** Warning: Imview cannot be configured with the desired TIFF option"
fi

if test "$save_magick" != "$with_magick" ; then
	echo "** Warning: Imview cannot be configured with the desired Magick option"
fi

if test "$ac_cv_cxx_standard_char_traits" = "no" \
	-o "$ac_cv_cxx_default_template_parameters" = "no"  \
	-o "$ac_cv_cxx_templates_as_template_arguments" = "no"  ; then
	echo "** Warning: Your C++ compiler is not ISO compliant enough,"
	echo "** Warning: this configuration is unsupported."
	echo "** Warning: See prerequisites in INSTALL file"
fi	

if test "$have_x" = "yes"
then
  echo ""
  echo "X configuration"
  echo "  X_CFLAGS     = $X_CFLAGS"
  echo "  X_PRE_LIBS   = $X_PRE_LIBS"
  echo "  X_LIBS       = $X_LIBS"
  echo "  X_EXTRA_LIBS = $X_EXTRA_LIBS"
fi

if test "$have_wingdi" = 'yes'
then
  echo ""
  echo "GDI configuration"
  echo "  "
fi

if test "$have_carbon" = 'yes'
then
  echo ""
  echo "MacOS Carbon configuration"
  echo "  "
fi

echo ""
echo "Final Compilation Flags:"
echo "  CC        = $CC"
echo "  CXX       = $CXX"
echo "  CFLAGS    = $CFLAGS"
echo "  CXXFLAGS  = $CXXFLAGS"
echo "  CPPFLAGS  = $CPPFLAGS"
echo "  LDFLAGS   = $LDFLAGS"
echo "  LIBRARIES = $FLTKLIB $FLTKEXTRA $IMLIBS $XLIBS $X_EXTRA_LIBS $THREADLIB $POSIX_IPC_LIB $MATHLIB"
#echo "  LIBS      = $LIBS" 

if test "$ac_cv_cxx_needs_permissive" = 'yes' ; then
	echo ""
	echo "**** Warning ***"
	echo "** Your X11 headers are not compatible with ANSI C++"
	echo "** Imview should still compile, but you are going to see "
	echo "** a **LOT** of compilation warnings. The best way to"
	echo "** avoid this problem is to upgrade your X11 headers to"
	echo "** a more recent version, or to downgrade your compiler"
	echo "** to a more lenient one. If your X11 headers are under"
	echo "** /usr/include/X11, you can also try to upgrade your gcc"
	echo "** to version 2.95.3 or later"
	echo "****************"
fi

echo ""


dnl The End