File: configure.in

package info (click to toggle)
uae 0.8.29-7
  • links: PTS, VCS
  • area: contrib
  • in suites: squeeze, wheezy
  • size: 5,396 kB
  • ctags: 10,637
  • sloc: ansic: 74,950; sh: 3,302; asm: 1,064; cpp: 710; objc: 549; makefile: 265; perl: 216
file content (1105 lines) | stat: -rw-r--r-- 32,852 bytes parent folder | download
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
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
dnl Process this file with autoconf to produce a configure script.
dnl Written 1996, 1997, 1998 Bernd Schmidt

dnl If you can use anything from this file, feel free to steal it. I put
dnl this into the public domain.

dnl There are still many uncaught errors (e.g. --enable-dga on an Amiga)
dnl I didn't have the nerve to track them all down.

AC_INIT(UAE, 0.8.29, , uae)
AC_CONFIG_SRCDIR([amiga/source/transdisk.c])
AC_PREREQ(2.59)

dnl Checks for programs.
AC_PROG_CC

AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PATH_PROG(MAKEDEPPRG, makedepend, not-found)
AC_PATH_PROG(FILEPRG, file, not-found)
AC_PATH_PROG(WRCPRG, wrc, not-found)
AC_PATH_PROG(RCLPRG, rcl, not-found)
AC_PATH_PROG(SDL_CONFIG, sdl-config, not-found)

AC_AIX
AC_ISC_POSIX

AC_MSG_CHECKING(for Watcom C)
AC_EGREP_CPP(yes,
[#ifdef __WATCOMC__
  yes
#endif
], [uae_cv_prog_cc_watcom=yes], [uae_cv_prog_cc_watcom=no])
AC_MSG_RESULT($uae_cv_prog_cc_watcom)

AC_CANONICAL_HOST()
AC_DIAGNOSE([obsolete],[AC_CYGWIN is obsolete: use AC_CANONICAL_HOST and $host_os])case $host_os in
  *cygwin* ) CYGWIN=yes;;
	 * ) CYGWIN=no;;
esac

AC_DIAGNOSE([obsolete],[AC_MINGW32 is obsolete: use AC_CANONICAL_HOST and $host_os])case $host_os in
  *mingw32* ) MINGW32=yes;;
	  * ) MINGW32=no;;
esac

AC_EXEEXT()

NR_WARNINGS=0
NR_ERRORS=0

tmp_save_dir=`pwd`
cd $srcdir
abssrcdir=`pwd`
cd $tmp_save_dir

NEED_THREAD_SUPPORT=no

ADDITIONAL_CFLAGS=
OPTIMIZE_CFLAGS=
WARNING_CFLAGS=
DEBUG_CFLAGS=
NO_SCHED_CFLAGS=
NO_REORDER_CFLAGS=
LDFLAGS="$LDFLAGS -L."

dnl Checks for libraries.
HAVE_BEOS=no
dnl Replace `main' with a function in -lMedia_s: (Ian!)
AC_CHECK_LIB(Media_s, main, HAVE_MEDIA_LIB=yes, HAVE_MEDIA_LIB=no)
dnl Replace `main' with a function in -lNeXT_s:
AC_CHECK_LIB(NeXT_s, main, HAVE_NEXT_LIB=yes, HAVE_NEXT_LIB=no)
AC_CHECK_LIB(moto, cos, HAVE_MOTO_LIB=yes, HAVE_MOTO_LIB=no)
AC_CHECK_LIB(amiga, OpenLibrary, HAVE_AMIGA_LIB=yes, HAVE_AMIGA_LIB=n)
AC_CHECK_LIB(vga, vga_setmode, HAVE_SVGA_LIB=yes, HAVE_SVGA_LIB=no)
AC_CHECK_LIB(mme, waveOutGetNumDevs, HAVE_MME_LIB=yes, HAVE_MME_LIB=no)
AC_CHECK_LIB(ncurses, waddch, HAVE_NCURSES_LIB=yes, HAVE_NCURSES_LIB=no)
AC_CHECK_LIB(posix4, sem_init, HAVE_POSIX4_LIB=yes, HAVE_POSIX4_LIB=no)
AC_CHECK_LIB(rt, sem_init, HAVE_RT_LIB=yes, HAVE_RT_LIB=no)
AC_CHECK_LIB(audio, alOpenPort, HAVE_SGIAUDIO_LIB=yes, HAVE_SGIAUDIO_LIB=no)
AC_CHECK_LIB(asound, snd_pcm_open, HAVE_ALSA=yes, HAVE_ALSA=no)

AC_PATH_XTRA
AC_CONFIG_HEADER(src/sysconfig.h)

AC_HEADER_DIRENT
AC_HEADER_STDC

dnl @@@ Is <sys/termios.h> the right way or is it <termios.h>?
AC_CHECK_HEADERS(unistd.h fcntl.h sys/time.h sys/types.h utime.h string.h strings.h values.h ncurses.h curses.h)
AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h sun/audioio.h sys/audioio.h getopt.h features.h sys/termios.h)
AC_CHECK_HEADERS(posix_opt.h sys/ioctl.h sys/ipc.h sys/shm.h sys/stat.h sys/utime.h)
AC_CHECK_HEADERS(windows.h ddraw.h)
AC_CHECK_HEADER(be_math.h, HAVE_BEOS=yes, HAVE_BEOS=no)
AC_CHECK_HEADERS(machine/joystick.h)
AC_CHECK_HEADERS(devices/ahi.h)
AC_CHECK_HEADERS(libraries/cybergraphics.h cybergraphx/cybergraphics.h)

AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(void *, 4)
AC_CHECK_SIZEOF(long long, 8)
AC_CHECK_SIZEOF(__int64, 8)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
if [[ "x$ac_cv_c_inline" = "xno" ]]; then
  ac_cv_c_inline=
fi
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_STRUCT_ST_BLOCKS
AC_HEADER_TIME
AC_STRUCT_TM

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_FUNC_UTIME_NULL
AC_CHECK_FUNCS(getcwd getopt strdup gettimeofday sigaction mkdir rmdir)
AC_CHECK_FUNCS(select strerror strstr isnan isinf setitimer)
AC_CHECK_FUNCS(tcgetattr cfmakeraw readdir_r vprintf vsprintf vfprintf)

dnl GNOME_FILEUTILS_CHECKS will fail for native Win32 compilers like Watcom C
dnl So don't use that macro if we know it will fail
DO_FILEUTILS_CHECK=yes
if test $uae_cv_prog_cc_watcom = yes -o $MINGW32 = yes; then
  DO_FILEUTILS_CHECK=no
fi
if test $DO_FILEUTILS_CHECK = yes; then
  GNOME_FILEUTILS_CHECKS
fi

if test "$SDL_CONFIG" = "not-found" ; then
  HAVE_SDL_LIB=no
else
  HAVE_SDL_LIB=yes
  SDL_CFLAGS=`$SDL_CONFIG --cflags`
  SDL_LIBS=`$SDL_CONFIG --libs`
fi


dnl Verify that the ncurses installation makes some sense.

if [[ "x$HAVE_NCURSES_LIB" = "xyes" ]]; then
  if [[ "x$ac_cv_header_ncurses_h" = "xno" -a "x$ac_cv_header_curses_h" = "xno" ]]; then
    echo "Installation problem, found libncurses but neither curses.h nor ncurses.h!"
    HAVE_NCURSES_LIB=no
    NR_ERRORS=`expr $NR_ERRORS + 1`
  else
    if [[ "x$ac_cv_header_ncurses_h" = "xno" ]]; then
      AC_MSG_CHECKING(for attr_t in curses.h)
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[{ attr_t a; a = A_NORMAL; }]])],[AC_MSG_RESULT(yes)],[
        ADDITIONAL_CFLAGS="$ADDITIONAL_CFLAGS -DDONT_HAVE_ATTR_T"
        AC_MSG_RESULT(no)
	NR_WARNINGS=`expr $NR_WARNINGS + 1`
	echo "Please install a newer version of libncurses if you can."
      ])
    else
      AC_MSG_CHECKING(for attr_t in ncurses.h)
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ncurses.h>]], [[{ attr_t a; a = A_NORMAL; }]])],[AC_MSG_RESULT(yes)],[
        ADDITIONAL_CFLAGS="$ADDITIONAL_CFLAGS -DDONT_HAVE_ATTR_T"
        AC_MSG_RESULT(no)
	NR_WARNINGS=`expr $NR_WARNINGS + 1`
	echo "Please install a newer version of libncurses if you can."
      ])
    fi
  fi
fi

AC_MSG_CHECKING(for pthread library)
TMP_SAVE_CFLAGS=$CFLAGS
TMP_SAVE_LIBS=$LIBS
LIBS="$LIBS -lpthread"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include "confdefs.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <pthread.h>]], [[
pthread_exit (0);
]])],[HAVE_PTHREAD_LIB=yes
AC_MSG_RESULT(yes)],[HAVE_PTHREAD_LIB=no
AC_MSG_RESULT(no)])
CFLAGS=$TMP_SAVE_CFLAGS
LIBS=$TMP_SAVE_LIBS

AC_MSG_CHECKING(for DirectX)
TMP_SAVE_CFLAGS=$CFLAGS
TMP_SAVE_LIBS=$LIBS
CFLAGS="$CFLAGS $X_CFLAGS"
LIBS="$LIBS -lddraw"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include "confdefs.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <windows.h>
#include <ddraw.h>]], [[
LPDIRECTDRAW lpDD;
IDirectDraw_CreateSurface(lpDD, 0, 0, 0);
]])],[HAVE_DIRECTX=yes
AC_MSG_RESULT(yes)],[HAVE_DIRECTX=no
AC_MSG_RESULT(no)])
CFLAGS=$TMP_SAVE_CFLAGS
LIBS=$TMP_SAVE_LIBS

HAVE_OSS_SOUND=no
if [[ "x$ac_cv_header_sys_soundcard_h" = "xyes" -o "x$ac_cv_header_machine_soundcard_h" = "xyes" ]]; then
  dnl Avoid surprises
  AC_MSG_CHECKING(whether sys/soundcard.h or machine/soundcard.h works)
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include "confdefs.h"
#ifdef HAVE_SYS_SOUNDCARD_H
#include <sys/soundcard.h>
#else
#include <machine/soundcard.h>
#endif
#include <sys/ioctl.h>
]], [[int soundfd; ioctl (soundfd, SNDCTL_DSP_GETFMTS, 0);]])],[AC_MSG_RESULT(yes)
HAVE_OSS_SOUND=yes],[AC_MSG_RESULT(no)])
fi

DO_PROFILING=no
WANT_SVGALIB=dunno
WANT_ASCIIART=dunno
WANT_UI=dunno
WANT_NCURSES_UI=no
WANT_DGA=no
WANT_VIDMODE=no

AC_ARG_ENABLE(profiling,[  --enable-profiling      Build a profiling (SLOW!) version],[DO_PROFILING=$enableval],[])
AC_ARG_WITH(svgalib,[  --with-svgalib          Use SVGAlib for graphics output],[WANT_SVGALIB=$withval],[])
AC_ARG_WITH(sdl,[  --with-sdl              Use SDL library for low-level functions],[WANT_SDL=$withval],[])
AC_ARG_WITH(sdl-sound,[  --with-sdl-sound        Use SDL library for sound],[WANT_SDLSND=$withval],[])
AC_ARG_WITH(sdl-gfx,[  --with-sdl-gfx          Use SDL library for graphics],[WANT_SDLGFX=$withval],[])
AC_ARG_WITH(oss-sound,[  --with-oss-sound        Use OSS interface sound (default)],[WANT_OSS=$withval],[])
AC_ARG_WITH(alsa,[  --with-alsa             Use ALSA library for sound],[WANT_ALSA=$withval],[])
AC_ARG_WITH(asciiart,[  --with-asciiart         Use ncurses ascii art for graphics output],[WANT_ASCIIART=$withval],[])
AC_ARG_ENABLE(dga,[  --enable-dga            X11 version: Use the DGA extension],[WANT_DGA=$enableval],[])
AC_ARG_ENABLE(vidmode,[  --enable-vidmode        X11 version: Use the XF86VidMode extension],[WANT_VIDMODE=$enableval],[])
AC_ARG_ENABLE(ui,[  --enable-ui             Use a user interface if possible (default on)],[WANT_UI=$enableval],[])
AC_ARG_WITH(hostcc,[  --with-hostcc=x         Use a x as compiler for the host system],[HOSTCC=$withval],[HOSTCC=$CC])

dnl Configure tools directory first, so that warning messages appear near the
dnl end of the output.

mkdir -p src/tools
progname=$0
changequote(,)dnl
srcd=`echo ${progname} | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
changequote([,])dnl
topsrcdir=`cd $srcd; pwd`
tcc=$CC
CC=$HOSTCC
(cd src/tools && $topsrcdir/src/tools/configure)
CC=$tcc

dnl Some simple plausibility tests...

if [[ "x$WANT_ALSA" = "xyes" ]]; then
  if [[ "x$HAVE_ALSA" = "xno" ]]; then
    echo "Could not find libasound, disabling ALSA support."
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_ALSA=no
  else
    LIBS="$LIBS -lasound"
  fi
fi

if [[ "x$WANT_OSS" = "xyes" ]]; then
  if [[ "x$HAVE_OSS_SOUND" = "xno" ]]; then
    echo "Could not find OSS interface, disabling OSS support."
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_ALSA=no
  else
    LIBS="$LIBS -lasound"
  fi
fi

if [[ "x$WANT_SDLSND" = "xyes" ]]; then
  if [[ "x$WANT_ALSA" = "xyes" -o "x$WANT_OSS" = "xyes" ]]; then
    echo "Multiple sound backends selected; disabling SDL sound."
    WANT_SDLSND=no
  fi
fi

if [[ "x$WANT_ALSA" = "xyes" ]]; then
  if [[ "x$WANT_OSS" = "xyes" ]]; then
    echo "Multiple sound backends selected; disabling ALSA."
    WANT_ALSA=no
  fi
fi

if [[ "x$WANT_SDLSND" = "xyes" -o "x$WANT_SDLGFX" = "xyes" ]]; then
  WANT_SDL=yes    
fi

if [[ "x$WANT_SDL" = "xyes" ]]; then
  if [[ "x$HAVE_SDL_LIB" = "xno" ]]; then
    echo "Could not find libSDL, disabling SDL support."
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_SDL=no
    WANT_SDLSND=no
    WANT_SDLGFX=no
  else
    LIBS="$LIBS $SDL_LIBS"
    ADDITIONAL_CFLAGS="$ADDITIONAL_CFLAGS $SDL_CFLAGS -DUSE_SDL"
  fi
fi

if [[ "x$WANT_DGA" = "xyes" ]]; then
  if [[ "x$WANT_SVGALIB" = "xyes" -o "x$WANT_ASCIIART" = "xyes" -o "x$WANT_SDLGFX" = "xyes" ]]; then
    echo "You can't enable DGA for SVGAlib, SDL and ncurses targets!"
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_DGA=no
  fi
fi

if [[ "x$WANT_SVGALIB" = "xyes" ]]; then
  if [[ "x$WANT_ASCIIART" = "xyes" -o "x$WANT_SDLGFX" = "xyes" ]]; then
    echo "You can't enable both SVGAlib and other targets!"
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_DGA=no
  fi
fi

if [[ "x$WANT_DGA" = "xyes" -a "x$no_x" = "xyes" ]]; then
  echo "Ignoring --enable-dga, since X was disabled or not found."
  NR_ERRORS=`expr $NR_ERRORS + 1`
  WANT_DGA=no
fi

if [[ "x$WANT_DGA" = "xno" -a "x$WANT_VIDMODE" = "xyes" ]]; then
  echo "The XF86VidMode extension can only be used in DGA mode. Disabling it."
  NR_ERRORS=`expr $NR_ERRORS + 1`
  WANT_VIDMODE=no
fi

dnl Check if we have the libraries needed for the user's selection.

if [[ "x$WANT_SVGALIB" = "xyes" ]]; then
  if [[ "x$HAVE_SVGA_LIB" = "xno" ]]; then
    echo "Could not find libsvga, disabling svgalib support."
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_SVGALIB=no
  else
    no_x=yes
  fi
fi

if [[ "x$WANT_ASCIIART" = "xyes" ]]; then
  if [[ "x$HAVE_NCURSES_LIB" = "xno" ]]; then
    echo "Could not find libncurses, disabling ascii art support."
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_ASCIIART=no
  else if [[ "x$WANT_SVGALIB" = "xyes" -o "x$WANT_SDLGFX" = "xyes" ]]; then
    echo "You can't configure for both ncurses and another target. Disabling ncurses."
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_ASCIIART=no
  else
    no_x=yes
  fi
  fi
fi

dnl If the user wants DGA, see if we have it.
dnl This must come after we checked for X11.

if [[ "x$WANT_DGA" = "xyes" ]]; then
  TMP_SAVE_LIBS=$LIBS
  LIBS="$X_LIBS $LIBS"
  AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, HAVE_DGA=yes, HAVE_DGA=no, [ $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS ])
  LIBS=$TMP_SAVE_LIBS
  if [[ "x$HAVE_DGA" = "xno" ]]; then
    echo "Could not find DGA extension, ignoring --enable-dga."
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_DGA=no
  fi
fi

if [[ "x$WANT_VIDMODE" = "xyes" ]]; then
  TMP_SAVE_LIBS=$LIBS
  LIBS="$X_LIBS $LIBS"
  AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, HAVE_VIDMODE=yes, HAVE_VIDMODE=no, [ $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS ])
  LIBS=$TMP_SAVE_LIBS
  if [[ "x$HAVE_VIDMODE" = "xno" ]]; then
    echo "Could not find VidMode extension, ignoring --enable-vidmode."
    NR_ERRORS=`expr $NR_ERRORS + 1`
    WANT_VIDMODE=no
  fi
fi

#GTK_PACKAGES="gtk+-2.0"
#GTK_REQUIRED_VERSION=2.4.0
#PKG_CHECK_MODULES(DEPS, $GTK_PACKAGES >= $GTK_REQUIRED_VERSION)
#GTK_CFLAGS=`$PKG_CONFIG --cflags $ATK_PACKAGES $GTK_PACKAGES $LIBGNOMECANVAS_PACKAGES`
#GTK_LIBS=`$PKG_CONFIG --libs $ATK_PACKAGES $GTK_PACKAGES $LIBGNOMECANVAS_PACKAGES`

AM_PATH_GTK_2_0(2.4.0)

dnl See if we can at least compile SHM support

SHM_SUPPORT_LINKS=0
if [[ "x$no_x" != "xyes" -a "x$ac_cv_header_sys_ipc_h" = "xyes" -a "x$ac_cv_header_sys_shm_h" = "xyes" ]]; then
  AC_MSG_CHECKING(whether the X11 MIT-SHM extension can be compiled in)
  TMP_SAVE_CFLAGS=$CFLAGS
  TMP_SAVE_LIBS=$LIBS
  CFLAGS="$CFLAGS $X_CFLAGS"
  LIBS="$X_LIBS $LIBS $X_PRE_LIBS -lX11 -lXext $X_EXTRA_LIBS"
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include "confdefs.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>]], [[
static XShmSegmentInfo shminfo;
static Display *display;
XShmAttach(display, &shminfo);
XSync(display,0);
shmctl(shminfo.shmid, IPC_RMID, 0);
]])],[SHM_SUPPORT_LINKS=1
AC_MSG_RESULT(yes)],[SHM_SUPPORT_LINKS=0
AC_MSG_RESULT(no)])
  CFLAGS=$TMP_SAVE_CFLAGS
  LIBS=$TMP_SAVE_LIBS
fi

MATHLIB=-lm
DEBUGOBJS="debug.o"

GUIDEP=gui-none
GUIOBJS_IN=nogui.o

AC_MSG_CHECKING(which target to use)

if [[ "x$WANT_SDLGFX" = "xyes" ]]; then
  AC_MSG_RESULT(SDL)
  MATHLIB=
  TARGET=x11
  GFXOBJS="sdlgfx.o sdlkeys.o rawkeys.o"
  # @@@ Kludge.  This may get changed later.
  TARGETDEP=t-x11.h
else if [[ "x$HAVE_DIRECTX" = "xyes" ]]; then
  AC_MSG_RESULT(Win32/DirectX)
  MATHLIB=
  TARGET=win32
  TARGETDEP=t-win32.h
  GFXOBJS="osdep/win32.o osdep/parser.o osdep/keyboard.o osdep/posixemu.o"
  RESOBJS="osdep/winuae.res"
else if [[ "x$HAVE_BEOS" = "xyes" ]]; then
  AC_MSG_RESULT(BeOS)
  MATHLIB=
  TARGET=beos
  TARGETDEP=t-beos.h
  GFXOBJS=osdep/beos.o
  OPTIMIZE_CFLAGS=-O7
else if [[ "x$HAVE_AMIGA_LIB" = "xyes" ]]; then
  AC_MSG_RESULT(AmigaOS)
  TARGET=amigaos
  TARGETDEP=t-amiga.h
  GFXOBJS="osdep/ami-win.o osdep/ami-disk.o osdep/ami-rexx.o osdep/ami-appw.o"
else if [[ "x$HAVE_NEXT_LIB" = "xyes" ]]; then
  AC_MSG_RESULT(NeXTStep)
  MATHLIB=
  TARGET=next
  GFXOBJS="NeXTwin.o"
  TARGETDEP=t-next.h
  LIBRARIES="-sectcreate __ICON __header ../Uae.app/Uae.iconheader -segprot __ICON r r -sectcreate __ICON app ../Uae.app/Uae.tiff -lMedia_s -lNeXT_s"
else
  dnl Unix system
  dnl If we don't have X, see what else we have and/or want.

  if [[ "x$no_x" = "xyes" ]]; then
    if [[ "x$WANT_SVGALIB" != "xyes" -a "x$WANT_ASCIIART" != "xyes" ]]; then
      if [[ "x$WANT_SVGALIB" != "xno" -a "x$HAVE_SVGA_LIB" = "xyes" ]]; then
        WANT_SVGALIB=yes
      else if [[ "x$WANT_ASCIIART" != "xno" -a "x$HAVE_NCURSES_LIB" = "xyes" ]]; then
        WANT_ASCIIART=yes
      fi
      fi
    fi
  fi

  if [[ "x$WANT_SVGALIB" = "xyes" ]]; then
    AC_MSG_RESULT(SVGAlib)
    TARGET=svgalib
    TARGETDEP=t-svgalib.h
    GFXOBJS=svga.o
    LIBRARIES="-lvga"
    WANT_NCURSES_UI=yes
  else if [[ "x$WANT_ASCIIART" = "xyes" ]]; then
    AC_MSG_RESULT(ncurses ASCII art)
    TARGET=asciiart
    TARGETDEP=t-ascii.h
    GFXOBJS="ncurses.o"
    WANT_NCURSES_UI=yes
    LIBRARIES="-lncurses"
  else if [[ "x$no_x" = "xyes" ]]; then
    AC_MSG_RESULT(Ummm....)
    echo "Fatal error: No graphics system found, don't know what target to use."
    exit 1
  else
    AC_MSG_RESULT(X11)
    TARGET=x11
    TARGETDEP=t-x11.h
    GFXOBJS="xwin.o x11keys.o"

    LIBRARIES="$X_LIBS $X_PRE_LIBS"
    dnl If we still think we want DGA, set it up.
    if [[ "x$WANT_DGA" = "xyes" ]]; then
      LIBRARIES="$LIBRARIES -lXxf86dga"
      X_CFLAGS="$X_CFLAGS -DUSE_DGA_EXTENSION"
      if [[ "x$WANT_VIDMODE" = "xyes" ]]; then
        LIBRARIES="$LIBRARIES -lXxf86vm"
	X_CFLAGS="$X_CFLAGS -DUSE_VIDMODE_EXTENSION"
      fi
    fi
    LIBRARIES="$LIBRARIES -lXext -lX11 $X_EXTRA_LIBS"
  fi
  fi
  fi
fi
fi
fi
fi
fi

if [[ "x$HAVE_DIRECTX" = "xyes" ]]; then
  TARGETDEP=t-win32.h
  TARGET=win32
fi

if [[ "x$WANT_UI" != "xno" ]]; then
  if [[ "x$HAVE_DIRECTX" = "xyes" ]]; then
    GUIOBJS=osdep/win32gui.o
  else if [[ "x$HAVE_AMIGA_LIB" = "xyes" ]]; then
    GUIOBJS="osdep/ami-gui.o"
  else if [[ "x$WANT_NCURSES_UI" = "xyes" ]]; then
    if [[ "x$HAVE_NCURSES_LIB" = "xno" ]]; then
      echo "ncurses is unavailable, can't provide a user interface"
      if [[ "x$WANT_UI" = "xyes" ]]; then
        NR_ERRORS=`expr $NR_ERRORS + 1`
      fi
      WANT_UI=no
    else
      GUIOBJS="tui.o svgancui.o"
      LIBRARIES="$LIBRARIES -lncurses"
      ADDITIONAL_CFLAGS="$ADDITIONAL_CFLAGS -DUSING_CURSES_UI"
      if [[ "x$ac_cv_header_ncurses_h" = "xno" ]]; then
        echo "Found libncurses, but no ncurses.h. This is normal with recent versions"
        echo "of ncurses, but it might indicate a problem with older versions."
        NR_WARNINGS=`expr $NR_WARNINGS + 1`
      fi
    fi
  else if [[ "x$no_x" != "xno" ]]; then
    if [[ "x$no_gtk" = "xyes" ]]; then
      echo "Did not find gtk+, disabling user interface"
      GTK_CFLAGS=
      if [[ "x$WANT_UI" = "xyes" ]]; then
        NR_ERRORS=`expr $NR_ERRORS + 1`
      fi
    else
      echo "Using gtk+ GUI."
      NEED_THREAD_SUPPORT=yes
      ADDITIONAL_CFLAGS="$ADDITIONAL_CFLAGS -DUSING_GTK_GUI -I$abssrcdir/src/gui-gtk"
dnl      GUIOBJS="gtkui.o chipsetspeedpanel.o chipsettypepanel.o chooserwidget.o"
dnl      GUIOBJS="$GUIOBJS cpuspeedpanel.o cputypepanel.o floppyfileentry.o led.o util.o"
      GUIDEP=gui-gtk
      GUIOBJS_IN="gtkui.o util.o"
    fi
  else 
    if [[ "x$WANT_UI" = "xyes" ]]; then
      echo "GUI requested, but no suitable libraries found."
      NR_ERRORS=`expr $NR_ERRORS + 1`
    fi
  fi
  fi
  fi
  fi
fi

dnl
dnl  MULTIPLICATION_PROFITABLE?
dnl
dnl  We always set this for now. It's only used in the audio emulation,
dnl  where the option is to do multiplication or table look-up. On just
dnl  about any CPU it's worthwhile running E-UAE on, multiplication will be
dnl  better.

AC_DEFINE(MULTIPLICATION_PROFITABLE, 1, [Define to 1 if your CPU has a fast multiply instruction.])

dnl Find out some things about the system 
dnl  - whether we have GCC 2.7 or better.
dnl  - what CPU we have (to use some assembly hacks on the x86)
dnl  - whether we are on a Linux system

MACHDEP=md-generic
OSDEP=od-generic
THREADDEP=td-none
SOUNDDEP=od-generic

FPP_H=fpp-unknown.h
USE_THREADS=no
USE_FILE_SOUND=no
USE_SCSI_DEVICE=no

USE_UNDERSCORE=dunno

HAVELINUX=no
HAVEBSD=no
HAVEGCC27=no
HAVEI386=no
HAVE68K=no
HAVEPPC=no

ASMOBJS=
CPUOBJS=cpuemu.o

dnl
dnl  Find out what CPU arch to build for
dnl
AC_MSG_CHECKING([host cpu support])

dnl default is to use no CPU-specific features
HOST_CPU=generic
MDFPP_H=fpp-unknown.h

case $host_cpu in
     i[[3-6]]86)
       HOST_CPU=i386
       MDFPP_H=fpp-ieee.h       
       ;;
     amd64 | x86_64)
       HOST_CPU=amd64
       MDFPP_H=fpp-ieee.h       
       ;;
     powerpc)
       HOST_CPU=ppc
       MDFPP_H=fpp-ieee.h
       ;;
     m68k)
       HOST_CPU=68k
       MDFPP_H=fpp-ieee.h
       ;;
esac

AC_MSG_RESULT([$HOST_CPU])
MACHDEP="md-$HOST_CPU"

AC_MSG_CHECKING(for GCC 2.7 or higher)
AC_EGREP_CPP(yes,
[#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
  yes
#endif
], [AC_MSG_RESULT(yes); HAVEGCC27=yes], AC_MSG_RESULT(no))

if test $ac_cv_c_compiler_gnu = yes; then
  WARNING_CFLAGS="-Wall -Wno-unused -Wno-format -W -Wmissing-prototypes -Wstrict-prototypes"
  OPTIMIZE_CFLAGS="-O2 -fomit-frame-pointer"
  dnl Not nice, but needed to turn off -g
  CFLAGS=
fi

if [[ "x$DO_PROFILING" = "xyes" ]]; then
  if test $ac_cv_prog_gcc = yes; then
    OPTIMIZE_CFLAGS="-O"
    DEBUG_CFLAGS="-g -fno-inline -fno-omit-frame-pointer -pg -DUSE_PROFILING"
    LDFLAGS="-pg"
  else
    DO_PROFILING=no
    echo "Don't know how to set up profiling for your compiler."
    NR_ERRORS=`expr $NR_ERRORS + 1`
  fi
fi

CFLAGS="$OPTIMIZE_CFLAGS $DEBUG_CFLAGS $WARNING_CFLAGS $CFLAGS $ADDITIONAL_CFLAGS"

if test $ac_cv_prog_gcc = yes; then
  if test $HAVEGCC27 != yes; then
    AC_MSG_WARN([Version 2.7 or better of GCC is recommended])
    NR_WARNINGS=`expr $NR_WARNINGS + 1`
  fi
else
  if test $uae_cv_prog_cc_watcom != yes; then
    AC_MSG_WARN([UAE may not compile and run correctly with your compiler])
    NR_WARNINGS=`expr $NR_WARNINGS + 1`
  fi
fi

if test $ac_cv_prog_gcc = yes; then
  if [[ "$HOST_CPU" = i386 -o "$HOST_CPU" = ppc -o "$HOST_CPU" = amd64 ]]; then
    MACHDEP="$MACHDEP-gcc"
  fi
fi

dnl X86.S needs to know whether it needs to add underscores to symbols.
dnl This might break some obscure systems which don't have ELF but don't
dnl add underscores either.

AC_MSG_CHECKING(whether assembler symbols need an underscore)
cat >conftest1.S << EOF
	.text
	.globl _symbol
_symbol:
EOF
cat >conftest2.c << EOF
extern void symbol ();
int main ()
{
symbol ();
}
EOF
$CC conftest1.S -c -o conftest1.o >/dev/null 2>&1
$CC conftest2.c -c -o conftest2.o >/dev/null 2>&1
if $CC conftest1.o conftest2.o -o conftest >/dev/null 2>&1; then
  USE_UNDERSCORE=yes
  CFLAGS="$CFLAGS -DUSE_UNDERSCORE"
else
  USE_UNDERSCORE=no
fi
AC_MSG_RESULT($USE_UNDERSCORE)

rm -f conftest*

AC_ARG_ENABLE(threads,[  --enable-threads        Enable some generally useful thread support],[USE_THREADS=$enableval],[])

dnl See if we have something better than GCC 2.7.

if [[ "x$HAVEGCC27" = "xyes" -a "x$HAVEI386" = "xyes" ]]; then
  SAVECFLAGS=$CFLAGS
  CFLAGS="$CFLAGS -mno-schedule-prologue"
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int main(){return 0;}]])],[NO_SCHED_CFLAGS="-mno-schedule-prologue"],[])
  CFLAGS=$SAVECFLAGS
fi

if [[ "x$HAVEGCC27" = "xyes" -a "x$HAVEI386" = "xyes" ]]; then
  SAVECFLAGS=$CFLAGS
  CFLAGS="$CFLAGS -mpreferred-stack-boundary=2"
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int main(){return 0;}]])],[SAVECFLAGS=$CFLAGS],[])
  CFLAGS=$SAVECFLAGS
fi

if [[ "x$HAVEGCC27" = "xyes" -a "x$HAVEI386" = "xyes" ]]; then
  SAVECFLAGS=$CFLAGS
  CFLAGS="$CFLAGS -fno-reorder-blocks"
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int main(){return 0;}]])],[NO_REORDER_CFLAGS="-fno-reorder-blocks"],[])
  CFLAGS=$SAVECFLAGS
fi

dnl If GCC supports exceptions, we don't want them.

if [[ "x$HAVEGCC27" = "xyes" -a "x$HAVEI386" = "xyes" ]]; then
  SAVECFLAGS=$CFLAGS
  CFLAGS="$CFLAGS -fno-exceptions"
  NOEXCEPTIONS=no
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int main(){return 0;}]])],[NOEXCEPTIONS=yes],[])
  if [[ "x$NOEXCEPTIONS" = "xno" ]]; then
    CFLAGS=$SAVECFLAGS
  fi
fi


dnl Set up the link to the appropriate machdep directory and select something
dnl for the REGPARAM define.

if [[ "x$HAVEGCC27" = "xyes" -a "x$HAVEI386" = "xyes" -a "x$DO_PROFILING" = "xno" ]]; then
  MACHDEP=md-i386-gcc
  dnl strength-reduce is turned off not because of paranoia, but because it
  dnl actually makes the code worse in some cases on the i386 (generates too
  dnl many registers, which all end up on the stack).
  CFLAGS="$CFLAGS -DUNALIGNED_PROFITABLE -fno-strength-reduce -DREGPARAM=\"__attribute__((regparm(3)))\""

  CFLAGS="$CFLAGS -DX86_ASSEMBLY -DOPTIMIZED_FLAGS"
  ASMOBJS=md-X86.o
else if test $uae_cv_prog_cc_watcom = yes; then
  MACHDEP=md-i386-watcom
  echo CFLAGS before: $CFLAGS
  CFLAGS=`echo $CFLAGS | sed 's, -g , ,' |sed 's,^-g ,,'`
  CFLAGS="$CFLAGS --/--bm --/--mf --/--w4 --/--s --/--ei --/--zp4 --/--5r"
  CFLAGS="$CFLAGS --/--oe=50 --/--oi --/--ok --/--ol --/--ot --/--oh --/--or --/--zq"
  CFLAGS="$CFLAGS -DREGPARAM= -DUNALIGNED_PROFITABLE"
  echo CFLAGS after:  $CFLAGS
else if [[ "x$HAVEGCC27" = "xyes" -a "x$HAVEPPC" = "xyes" ]]; then
  MACHDEP=md-ppc-gcc
  CFLAGS="$CFLAGS -DREGPARAM="
  if [[ "x$HAVE_MOTO_LIB" = "xyes" ]]; then
    MATHLIB="-lmoto $MATHLIB"
  fi
else if [[ "x$TARGET" = "xamigaos" ]]; then
  OSDEP=od-amiga
  CPU=`uname -m`
  if [[ "x$HAVEGCC27" = "xyes" -a "x$HAVE68K" = "xyes" ]]; then
    MACHDEP=md-68k
    CFLAGS="$CFLAGS -DUNALIGNED_PROFITABLE -DREGPARAM=\"__attribute__((regparm(4)))\" -DM68K_FLAG_OPT=1"
  else if [[ "x$HAVEGCC27" = "xyes" -a "x$CPU" = "xppc" ]]; then
    MACHDEP=md-ppc-gcc
  else
    dnl sam: amigaos without gcc
    CFLAGS="$CFLAGS -O -DREGPARAM="
  fi
  CPUOBJS="cpuemu1.o cpuemu2.o cpuemu3.o cpuemu4.o cpuemu5.o cpuemu6.o cpuemu7.o cpuemu8.o"
  fi
else if [[ "x$HAVEGCC27" = "xyes" -a "x$HAVE68K" = "xyes" -a "x$DO_PROFILING" = "xno" ]]; then
  dnl sam: This is for linux 68k (REGPARAM is not used under linux)
  MACHDEP=md-68k
  CFLAGS="$CFLAGS -DM68K_FLAG_OPT=1 -DREGPARAM="
else if [[ "x$TARGET" = "xbeos" ]]; then
  MACHDEP=md-ppc
  CFLAGS="$CFLAGS -DREGPARAM="
  OSDEP=od-beos
else
  CFLAGS="$CFLAGS -DREGPARAM="
fi
fi
fi
fi
fi
fi

FSDBOBJS=fsdb_unix.o
if [[ "x$TARGET" = "xwin32" ]]; then
  OSDEP=od-win32
  FSDBOBJS=osdep/fsdb_win32.o
  if test $ac_cv_c_compiler_gnu = yes; then
    LIBS="$LIBS -lddraw -lwinmm -lcomctl32 -lcomdlg32 -luser32 -lgdi32 -lkernel32 -ladvapi32 -lshell32"
  else if test $uae_cv_prog_cc_watcom = yes; then
    LIBS="$LIBS -lddraw -lwinmm -lcomctl32"
  fi
  fi
else if [[ "x$HAVELINUX" = "xyes" ]]; then
  OSDEP=od-linux
fi
fi

if [[ "x$TARGET" = "xx11" -o "x$TARGET" = "xsvgalib" -o "x$TARGET" = "xamigaos" \
     -o "x$TARGET" = "xbeos" -o "x$TARGET" = "xasciiart" ]]; then
  dnl On Unix, BeOS and AmigaOS system, zfile is supposed to work. Dunno about others.
  CFLAGS="$CFLAGS -DUSE_ZFILE"
fi

AC_MSG_CHECKING(which sound system to use)
AC_ARG_ENABLE(file-sound,[  --enable-file-sound     Enable sound output to file],[USE_FILE_SOUND=$enableval],[])

if [[ "x$USE_FILE_SOUND" = "xyes" ]]; then
  AC_MSG_RESULT(file output)
  SOUNDDEP=sd-file
  USE_SOUND=yes  
else if [[ "x$WANT_SDLSND" = "xyes" ]]; then
  AC_MSG_RESULT(SDL)
  SOUNDDEP=sd-sdl
  USE_SOUND=yes
  NEED_THREAD_SUPPORT=yes
  if [[ "x$HAVE_ALSA" = "xyes" -o "x$HAVE_OSS_SOUND" = "xyes" ]]; then
    NR_WARNINGS=`expr $NR_WARNINGS + 1`
    echo "SDL sound support was selected, but OSS or ALSA are more reliable."
  fi
else if [[ "x$WANT_ALSA" = "xyes" ]]; then
  AC_MSG_RESULT(ALSA)
  SOUNDDEP=sd-alsa
  USE_SOUND=yes
else if [[ "x$HAVE_OSS_SOUND" = "xyes" ]]; then
  AC_MSG_RESULT(OSS)
  SOUNDDEP=sd-uss
  USE_SOUND=yes
else if [[ "x$ac_cv_header_sys_audioio_h" = "xyes" -o "x$ac_cv_header_sun_audioio_h" = "xyes" ]]; then
  AC_MSG_RESULT(Solaris/NetBSD)
  SOUNDDEP=sd-solaris
  USE_SOUND=yes
else if [[ "x$HAVE_MME_LIB" = "xyes" ]]; then
  AC_MSG_RESULT(MME sound)
  SOUNDDEP=sd-mme
  LIBS="$LIBS -lmme"
  USE_SOUND=yes
else if [[ "x$TARGET" = "xamigaos" ]]; then
  if [[ "x$ac_cv_header_devices_ahi_h" = "xyes" ]]; then
    AC_MSG_RESULT(Amiga AHI.device)
  else
    AC_MSG_RESULT(Amiga audio.device)
  fi
  SOUNDDEP=od-amiga
  USE_SOUND=yes
else if [[ "x$TARGET" = "xbeos" ]]; then
  AC_MSG_RESULT(BeOS sound)
  SOUNDDEP=od-beos
  USE_SOUND=yes
else if [[ "x$TARGET" = "xwin32" ]]; then
  AC_MSG_RESULT(Win32 sound)
  SOUNDDEP=od-win32
  USE_SOUND=yes
else
  echo "no known sound system found"
  NR_ERRORS=`expr $NR_ERRORS + 1`
fi
fi
fi
fi
fi
fi
fi
fi
fi

if [[ "x$NEED_THREAD_SUPPORT" = "xyes" ]]; then
  if [[ "x$USE_THREADS" != "xyes" ]]; then
    echo "Threads are needed for this configuration; enabling thread support."
  fi
fi

if [[ "x$USE_THREADS" = "xyes" -o "x$NEED_THREAD_SUPPORT" = "xyes" ]]; then
  if [[ "x$WANT_SDL" = "xyes" ]]; then
    THREADDEP=td-sdl
    CFLAGS="$CFLAGS -DSUPPORT_THREADS -D_REENTRANT"
  else if [[ "x$HAVE_PTHREAD_LIB" = "xyes" ]]; then
    THREADDEP=td-posix
    CFLAGS="$CFLAGS -DSUPPORT_THREADS -D_REENTRANT"
    LIBS="$LIBS -lpthread"
    if [[ "x$HAVE_POSIX4_LIB" = "xyes" ]]; then
      LIBS="$LIBS -lposix4"
    fi

    if [[ "x$USE_THREADS" = "xyes" ]]; then    
      CFLAGS="$CFLAGS -DUAE_FILESYS_THREADS"
    fi

    if [[ "x$TARGET" = "xsvgalib" ]]; then
      echo "If you didn't compile a fixed version of SVGAlib then thread support"
      echo "in UAE will lock your machine real hard."
      NR_WARNINGS=`expr $NR_WARNINGS + 1`
    fi
  else
    echo "You tried to enable threads, but I couldn't find a thread library!"
    NR_ERRORS=`expr $NR_ERRORS + 1`
  fi
  fi
fi

SCSIOBJS=scsi-none.o
AC_ARG_ENABLE(scsi-device,[  --enable-scsi-device    Enable the uaescsi.device],[USE_SCSI_DEVICE=$enableval],[])
if [[ "x$USE_SCSI_DEVICE" = "xyes" ]]; then
  AC_MSG_CHECKING("availability of libscg headers and lib")
  OLDLIBS="$LIBS"
  OLDCFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -Isrc/include"
  LIBS="-Lsrc $LIBS -lscg -lschily"
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int BOOL;
#include "scg/scgcmd.h"
#include "scg/scsitransp.h"
#include "scg/scsireg.h"]], [[{SCSI *scgp = open_scsi ((void *)0, (void *)0, 0, 1, 1);}]])],[
    AC_MSG_RESULT(available)
    SCSIOBJS=scsidev.o
  ],[
     AC_MSG_RESULT(not available)
     NR_WARNINGS=`expr $NR_WARNINGS + 1`
     echo "Please refer to the UAE SCSI device section in docs/README for installation instructions."
     LIBS="$OLDLIBS"
  ])
  CFLAGS="$OLDCFLAGS"
fi

dnl Special case hack for BSD: try to use the Linux joystick.c.

if [[ "x$WANT_SDL" = "xyes" ]]; then
    OD_JOYSTICK=sdl-joystick.c
else if [[ "x$ac_cv_header_machine_joystick_h" = "xyes" ]]; then
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <machine/joystick.h>]], [[{ struct joystick a; }]])],[OD_JOYSTICK=od-linux/joystick.c],[])
else
    OD_JOYSTICK=$OSDEP/joystick.c
fi
fi

rm -f src/machdep
rm -f src/osdep
rm -rf src/guidep
rm -f src/threaddep
rm -f src/sounddep
rm -f src/scsidep
rm -f src/target.h
rm -f src/sd-sound.c
rm -f src/od-joy.c
rm -f src/md-support.c
rm -f src/md-X86.S
rm -f src/scsi-support.c

if [[ "x$TARGET" = "xamigaos" ]]; then
  dnl Determine the cpu-type
  AC_MSG_CHECKING(which CPU to use)
  cpu=`cpu | cut -d' ' -f2`
  AC_MSG_RESULT($cpu)
  CFLAGS="$CFLAGS -m$cpu"

  dnl Is that correct for the fpu ?
  AC_MSG_CHECKING(which FPU to use)
  fpu=`cpu | cut -d' ' -f3 | grep '^6888[12]$'`
  if [[ "x$fpu" != "x" ]]; then
    dnl gcc only knows about 68881
    AC_MSG_RESULT(68881)
    CFLAGS="$CFLAGS -m68881"
  else
    AC_MSG_RESULT(none)
  fi
fi

if [[ "x$DO_PROFILING" = "xyes" ]]; then
  echo "Building a profiling version of UAE (select this option only if you know"
  echo "what you are doing)"
fi

dnl Create some more links and files.

dnl We removed those from the build directory above, so if the source
dnl directory still has them, something is fairly wrong.

dnl This doesn't work with Solaris /bin/sh, neither do all the alternatives I
dnl tried. It doesn't seem to cause a failure either, though.

if test -f $abssrcdir/src/target.h
then
  echo
  echo "Fatal error: Can't configure in the current directory, because"
  echo "configure was run in the source directory. Go to the source"
  echo "directory, type"
  echo "  make streifenfrei"
  echo "and try again."
  exit 1
fi

AC_CONFIG_LINKS(src/osdep:src/$OSDEP)
AC_CONFIG_LINKS(src/sounddep:src/$SOUNDDEP)
AC_CONFIG_LINKS(src/threaddep:src/$THREADDEP)
AC_CONFIG_LINKS(src/machdep:src/$MACHDEP)
dnl AC_CONFIG_LINKS(src/gfxdep:src/$GFX_DEP)

mkdir src/guidep
for x in $GUIOBJS_IN; do
  src=`echo $x |sed s,'\.o$,.c,'`
  AC_CONFIG_LINKS(src/guidep/$src:src/$GUIDEP/$src)
  GUIOBJS="$GUIOBJS guidep/$x"
done


echo "#include \"$abssrcdir/src/targets/$TARGETDEP\"" > src/target.h

echo "#include \"$abssrcdir/src/$SOUNDDEP/sound.c\"" >src/sd-sound.c
echo "#include \"$abssrcdir/src/$OD_JOYSTICK\"" >src/od-joy.c
echo "#include \"$abssrcdir/src/$MACHDEP/support.c\"" >src/md-support.c

if [[ "x$MACHDEP" = "xmd-i386-gcc" ]]; then
  echo "#include \"machdep/X86.S\"" >src/md-X86.S
fi
echo "#include \"$abssrcdir/src/include/$FPP_H\"" >src/md-fpp.h

mkdir -p src/keymap

AC_SUBST(ac_cv_c_inline)
AC_SUBST(WRCPRG)
AC_SUBST(NO_SCHED_CFLAGS)
AC_SUBST(NO_REORDER_CFLAGS)
AC_SUBST(LIBRARIES)
AC_SUBST(TARGET)
AC_SUBST(GFXOBJS)
AC_SUBST(GUIOBJS)
AC_SUBST(RESOBJS)
AC_SUBST(ASMOBJS)
AC_SUBST(SCSIOBJS)
AC_SUBST(CPUOBJS)
AC_SUBST(DEBUGOBJS)
AC_SUBST(FSDBOBJS)
AC_SUBST(SET_MAKE)
AC_SUBST(MATHLIB)
AC_SUBST(SHM_SUPPORT_LINKS)

AC_SUBST(top_srcdir)

AC_CONFIG_FILES([src/Makefile Makefile])

AC_OUTPUT

echo
echo
if [[ "x$NR_ERRORS" = "x0" ]]; then
  if [[ "x$NR_WARNINGS" = "x0" ]]; then
    echo "Configuration was successful!"
  else
    echo "There were $NR_WARNINGS warnings. That is usually harmless, but read the output"
    echo "from configure carefully if you run into problems."
  fi
else
  echo "There were $NR_ERRORS errors. UAE may still build and run cleanly, but you may"
  echo "not get all the features you asked for."
fi
echo