File: acinclude.m4

package info (click to toggle)
kvirc 1:2.1.2-11
  • links: PTS
  • area: main
  • in suites: woody
  • size: 12,184 kB
  • ctags: 13,390
  • sloc: cpp: 81,801; sh: 9,982; ansic: 802; makefile: 739
file content (1365 lines) | stat: -rw-r--r-- 47,912 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
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
## This file is part of the KVIrc distribution
## (C) 2000-2001 Szymon Stefanek & Triskelios
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##

AC_DEFUN(AC_SS_CXXFLAGS,
[
	
	AC_MSG_CHECKING([if debugging symbols are requested])
	AC_ARG_ENABLE(debug,[  --enable-debug          enable debugging symbols [default=no]],[SS_ADD_DEBUG_SYMBOLS="$enableval"],[SS_ADD_DEBUG_SYMBOLS="no"])
	ac_save_CXXFLAGS="$CXXFLAGS"
	#CXXFLAGS=""

	if test "x$SS_ADD_DEBUG_SYMBOLS" = "xyes"; then
		AC_MSG_RESULT([yes])
		CXXFLAGS="$CXXFLAGS -g"
	else
		AC_MSG_RESULT([no])
		CXXFLAGS="$ac_save_CXXFLAGS"
	fi

	AC_MSG_CHECKING([if O3 optimisation is requested])
	AC_ARG_WITH(o3-optimisation, [  --with-o3-optimisation  use the O3 flag when compiling [default=no]],SS_O3_OPTIMISATION="true")

	if test -n "$SS_O3_OPTIMISATION"; then
		AC_MSG_RESULT([yes])
		CXXFLAGS="-O3 $CXXFLAGS"
	else
		AC_MSG_RESULT([no])
		CXXFLAGS="-O2 $CXXFLAGS"
	fi

	AC_ARG_WITH(i386-asm, [  --with-i386-asm         build with x86 assembly optimisations [default=no]],SS_COMPILE_i386_ASM="true")

	AC_MSG_CHECKING([whether to add extra include search paths])
	SS_DO_IT="false"
	AC_ARG_WITH(extra-includes,    [  --with-extra-includes=DIR
                          add the specified include paths],SS_DO_IT="$withval")
	if test "$SS_DO_IT" != "false"; then
		AC_MSG_RESULT(yes)
		SS_OTHER_INCDIRS="$SS_OTHER_INCDIRS $SS_DO_IT"
	else
		AC_MSG_RESULT(no)
	fi

	AC_MSG_CHECKING([whether to add extra library search paths])
	SS_DO_IT="false"
	AC_ARG_WITH(extra-libs,    [  --with-extra-libs=DIR   add the specified library paths],SS_DO_IT="$withval")
	if test "$SS_DO_IT" != "false"; then
		AC_MSG_RESULT(yes)
		SS_OTHER_LIBDIRS="$SS_DO_IT"
	else
		AC_MSG_RESULT(no)
	fi

	AC_ARG_WITH(pedantic-gcc, [  --with-pedantic-gcc     compile with all warnings enabled [default=no]],SS_COMPILE_USE_PEDANTIC_GCC="true")
	AC_ARG_WITH(verbose-compilation, [  --with-verbose-compilation
                          compile with verbose output [default=no]],SS_VERBOSE_COMPILATION="true")
	AC_ARG_WITH(pipes, [  --with-pipes            use pipes for compilation [default=no]],SS_FLAGS_INCDIRS="-pipe $SS_FLAGS_INCDIRS")
])

AC_DEFUN(AC_SS_FUNCTION_CHECKS,
[
	AC_CHECK_FUNCS(vsnprintf strerror inet_aton inet_ntoa usleep getenv uname)
])


AC_DEFUN(AC_SS_HEADER_CHECKS,
[
	AC_CHECK_HEADERS(unistd.h)
	AC_CHECK_HEADERS(linux/soundcard.h sys/soundcard.h soundcard.h)
	AC_CHECK_HEADERS(math.h strings.h jpeglib.h setjmp.h limits.h sys/utsname.h)
])

AC_DEFUN(AC_SS_LIBRARY_CHECKS,
[
	AC_CHECK_LIB(compat, main, [LIBCOMPAT="-lcompat"])
	HAVE_LIBCRYPT=
	AC_CHECK_LIB(crypt, crypt, [LIBCRYPT="-lcrypt"; HAVE_LIBCRYPT="yes"],
		AC_CHECK_LIB(c, crypt, [LIBCRYPT=""; HAVE_LIBCRYPT="yes"],
		[AC_MSG_WARN([you have no crypt in either libcrypt or libc.
You should install libcrypt from another source])
	]))
	AC_SUBST(LIBCRYPT)
	if test "x$HAVE_LIBCRYPT" = "xyes"; then
		AC_DEFINE_UNQUOTED(HAVE_CRYPT, 1, [Define if your system has the crypt function])
	fi
	AC_CHECK_LIB(socket, socket, [LIBSOCKET="-lsocket -lnsl"])
	AC_CHECK_LIB(smurf, sendALotOfPingsToThisHost, [LIBSMURF="-lsmurf"])
	AC_CHECK_LIB(LAMER, getLamerLevel, [LIBLAMER="-llamer"])
])

AC_DEFUN(AC_SS_FINAL_CHECK_FOR_PLUGINS,
[
	AC_MSG_CHECKING([if we finally can compile the plugins])
	if test -n "$SS_PLUGIN_REQUESTED"; then
		AC_MSG_RESULT([yes])
		if test "$SS_LINK_TO_LIBDL" = "yes"; then
			SS_FLAGS_LIBLINK="$SS_FLAGS_LIBLINK -export-dynamic -ldl"
		else
			SS_FLAGS_LIBLINK="$SS_FLAGS_LIBLINK -export-dynamic"
		fi
		SS_PLUGINS_DIRECTORY_COMPILE="plugins"
	else
		AC_MSG_RESULT([no])
		SS_PLUGINS_DIRECTORY_COMPILE=""
		if test "$SS_KDE_REQUESTED" = "yes"; then
			# Can't compile with KDE and without libdl
			AC_MSG_RESULT(["Warning: Cannot compile KDE support without dlopen support"])
			AC_MSG_RESULT(["Warning: Disabling KDE support"])
			SS_KDE_REQUESTED="no"
		fi
	fi
	AC_SUBST(SS_PLUGINS_DIRECTORY_COMPILE)
])


AC_DEFUN(AC_SS_FINAL_CHECK_FOR_KDE,
[
	AC_MSG_CHECKING([if we finally have to compile the KDE support])
	if test "$SS_KDE_REQUESTED" = "yes"; then
		AC_MSG_RESULT([yes])
		SS_FLAGS_RPATH=""
		SS_FLAGS_INCDIRS="-I$SS_KDE_INCLUDE_DIR $SS_FLAGS_INCDIRS"
		SS_FLAGS_LIBDIRS="-L$SS_KDE_LIBRARY_DIR $SS_FLAGS_LIBDIRS"
		# SS_FLAGS_LIBLINK="-lkdecore -lkdeui -lkfile -lkimgio $SS_FLAGS_LIBLINK"
		SS_FLAGS_LIBLINK="-lkfile -lksycoca $SS_FLAGS_LIBLINK"
		AC_DEFINE(COMPILE_NEED_KDE)
		AC_PREFIX_DEFAULT(${KDEDIR:-/usr/local})
	else
		AC_MSG_RESULT([no])
	fi
])

#AC_DEFUN(KDE_CHECK_FINAL,
#[
#  AC_ARG_ENABLE(final, [  --enable-final          build size optimized apps (experimental - needs lots of memory)],
#	kde_use_final=yes, kde_use_final=no)
#  if test "$SS_KDE_REQUESTED" = "yes"; then
#  if test "x$kde_use_final" = "xyes"; then
#    KDE_USE_FINAL_TRUE=""
#      KDE_USE_FINAL_FALSE="#"
#   else
#      KDE_USE_FINAL_TRUE="#"
#      KDE_USE_FINAL_FALSE=""
#  fi
#  fi
#  AC_SUBST(KDE_USE_FINAL_TRUE)
#  AC_SUBST(KDE_USE_FINAL_FALSE)
#
#  AC_ARG_ENABLE(closure, [  --disable-closure       don't delay template instantiation],
#  	kde_use_closure=$enableval, kde_use_closure=yes)
#
#  if test "x$kde_use_closure" = "xyes"; then
#       KDE_USE_CLOSURE_TRUE=""
#       KDE_USE_CLOSURE_FALSE="#"
#       CXXFLAGS="$CXXFLAGS $REPO"
#  else
#       KDE_USE_CLOSURE_TRUE="#"
#       KDE_USE_CLOSURE_FALSE=""
#  fi
#  AC_SUBST(KDE_USE_CLOSURE_TRUE)
#  AC_SUBST(KDE_USE_CLOSURE_FALSE)
#])


AC_DEFUN(AC_SS_FINAL_CONFIG,
	[
		AC_ARG_WITH(local-8bit-encoding, [  --with-local-8bit-encoding
                          preserve local 8-bit charset encoding [default=no]],SS_LOCAL_8BIT_ENCODING="true")
		AC_ARG_WITH(ignore-sigalarm, [  --with-ignore-sigalarm  ignore SIGALARM in all threads [default=no]],SS_COMPILE_IGNORE_SIGALARM="true")
		AC_ARG_WITH(solaris-libs, [  --with-solaris-libs     link to lsocket, lresolv, and lnsl [default=no]],SS_FLAGS_LIBLINK="$SS_FLAGS_LIBLINK -lnsl -lsocket -lresolv")
		AC_ARG_WITH(own-inet-aton, [  --with-own-inet-aton    use own inet aton implementation [default=no]],SS_COMPILE_USE_OWN_INET_ATON="true")
		AC_ARG_WITH(own-inet-ntoa, [  --with-own-inet-ntoa    use own inet ntoa implementation [default=no]],SS_COMPILE_USE_OWN_INET_NTOA="true")
		AC_ARG_WITH(ipv6-support, [  --with-ipv6-support     enable IPv6 support (experimental) [default=no]],SS_COMPILE_USE_IPV6="true")
		AC_MSG_CHECKING([whether to enable support for font anti-aliasing])
		AC_ARG_WITH(font-antialiasing,   [  --with-font-antialiasing
                          support Xft anti-aliasing for fonts [default=no]],SS_AA_FONTS="true")
		if test "x$SS_AA_FONTS" = "xtrue"; then
			if test "x$SS_QT_XFT" = "xyes"; then
				AC_DEFINE(COMPILE_USE_AA_FONTS)
			fi
		else
			SS_QT_XFT="no"
		fi
		AC_MSG_RESULT([$SS_QT_XFT])
		AC_ARG_WITH(charset-translation, [  --with-charset-translation
                          enable character set translation support [default=no]],SS_CHARSET_TRANSLATION="true")
		NEW_PICS_DIRECTORY=""
		AC_MSG_CHECKING([whether to use new pics])
		AC_ARG_WITH(new-pics, [  --with-new-pics         use new KDE-style icons [default=no]], WITH_NEW_PICS=$withval, WITH_NEW_PICS="no")
		AC_MSG_RESULT([$WITH_NEW_PICS])
#		AM_CONDITIONAL(WITH_NEW_PICS, test "x$WITH_NEW_PICS" = "xyes")
		if test "x$WITH_NEW_PICS" = "xyes"; then
			NEW_PICS_DIRECTORY="newpics"
		fi
		AC_SUBST(NEW_PICS_DIRECTORY)
		# AC_ARG_WITH(static-qt, [  --with-static-qt           link statically to the Qt library],SS_LINK_STATIC_QT="true")

		AC_MSG_CHECKING([for the validity of Maxwell's laws on this machine])
		AC_MSG_RESULT([ok])
		AC_MSG_CHECKING([if e=mc�])
		AC_MSG_RESULT([yes, enabling quantum mechanics])
		AC_MSG_CHECKING([if this machine passes the Turing Test])
		AC_MSG_RESULT([no, building without AI :(])
		AC_MSG_CHECKING([if we can safely swap on /dev/fd0])
		AC_MSG_RESULT([yes])
		AC_MSG_CHECKING([if we can blame it on Nj�rd])
		AC_MSG_RESULT([yes])

		# Set the useful variables

		# if test "$SS_LINK_STATIC_QT" = "true"; then
		#	SS_FLAGS_RPATH=""
		# 	SS_FLAGS_LIBLINK="libqt.a $SS_X_EXTRA_LIBS -lXext -lX11 -lpthread"
		# else

		SS_FLAGS_RPATH=""

		if test "$SS_FREEBSD_PTHREAD" = "yes"; then
			SS_LIB_PTHREAD_FLAG="-pthread"
		else
			SS_LIB_PTHREAD_FLAG="-lpthread"
		fi

		SS_FLAGS_LIBLINK="-l$SS_QTLIB_NAME $SS_X_EXTRA_LIBS -lXext -lX11 $SS_LIB_PTHREAD_FLAG"
		if test "x$SS_USE_QT_MT" = "xyes"; then
			SS_FLAGS_LIBLINK="$SS_FLAGS_LIBLINK -pthread"
		fi

		# fi

	 	SS_FLAGS_INCDIRS="-I$SS_QT_INCLUDE_DIR -I$SS_X_INCLUDE_DIR -D_REENTRANT"
		SS_FLAGS_LIBDIRS="-L$SS_QT_LIBRARY_DIR -L$SS_X_LIBRARY_DIR"

		if test -n "$SS_OTHER_INCDIRS"; then
			SS_FLAGS_INCDIRS="-I$SS_OTHER_INCDIRS $SS_FLAGS_INCDIRS"
		fi

		if test -n "$SS_OTHER_LIBDIRS"; then
			SS_FLAGS_LIBDIRS="-L$SS_OTHER_LIBDIRS $SS_FLAGS_LIBDIRS"
		fi

		AC_SUBST(SS_QT_LIBRARY_DIR)
		AC_SUBST(SS_X_LIBRARY_DIR)
		AC_SUBST(SS_QT_INCLUDE_DIR)
		AC_SUBST(SS_X_INCLUDE_DIR)

		# More funky options
		if test -n "$SS_X_EXTRA_GCC_FLAGS"; then
			SS_FLAGS_INCDIRS="$SS_X_EXTRA_GCC_FLAGS $SS_FLAGS_INCDIRS"
		fi

		if test -n "$SS_X_EXTRA_LDD_FLAGS"; then
			SS_FLAGS_L="$SS_X_EXTRA_LDD_FLAGS $SS_FLAGS_LIBDIRS"
		fi

		AC_SS_FINAL_CHECK_FOR_PLUGINS
		AC_SS_FINAL_CHECK_FOR_KDE


		# Use Qt 3.x?
		if test "x$SS_QT_VERSION" = "x3"; then
			 AC_DEFINE_UNQUOTED(COMPILE_WITH_QT_3, 1, [Define if you are building with Qt 3.x])
		fi

		# Use libjpeg?
		# JPEGIO_CPP=""
		if test "x$SS_QT_JPEG" = "xno"; then
			if test -n "$SS_HAVE_LIBJPEG"; then
				JPEGIO_CPP="kvi_jpegio.cpp"
				SS_FLAGS_LIBLINK="$SS_FLAGS_LIBLINK -ljpeg"
				AC_DEFINE_UNQUOTED(COMPILE_JPEG_SUPPORT, 1, [Define if you wish to use the internal JPEG support])
			fi
		fi
		# AC_SUBST(JPEGIO_CPP)

		if test -n "$SS_CHARSET_TRANSLATION"; then
			AC_DEFINE(COMPILE_NEED_CHARSET_TRANSLATION)
		fi

		if test -n "$SS_VERBOSE_COMPILATION"; then
			SS_FLAGS_INCDIRS="$SS_FLAGS_INCDIRS -v"
		fi

		if test -n "$SS_COMPILE_USE_PEDANTIC_GCC"; then
			SS_FLAGS_INCDIRS="$SS_FLAGS_INCDIRS -Wall -pedantic"
		fi

		if test -n "$SS_COMPILE_USE_IPV6"; then
			AC_DEFINE(COMPILE_NEED_IPV6)
		fi

		if test -n "$SS_COMPILE_IGNORE_SIGALARM"; then
			AC_DEFINE(COMPILE_NEED_IGNORE_SIGALARM)
		fi

		if test -n "$SS_LOCAL_8BIT_ENCODING"; then
			AC_DEFINE(COMPILE_USE_LOCAL_8BIT_ENCODING)
			SS_FLAGS_INCDIRS="$SS_FLAGS_INCDIRS -DQT_NO_ASCII_CAST -DQT_NO_COMPAT"
		fi

		if test -n "$SS_COMPILE_USE_OWN_INET_ATON"; then
			AC_DEFINE(COMPILE_NEED_OWN_INET_ATON)
		fi

		if test -n "$SS_COMPILE_USE_OWN_INET_NTOA"; then
			AC_DEFINE(COMPILE_NEED_OWN_INET_NTOA)
		fi

		if test -n "$SS_COMPILE_i386_ASM"; then
			AC_MSG_CHECKING(target system CPU)
			if test "$target_cpu" = "i386"; then
				AC_MSG_RESULT([i386, compiling asm code])
				AC_DEFINE(HAVE_i386_BASED_CPU)
			else
				if test "$target_cpu" = "i486"; then
					AC_MSG_RESULT([i486, compiling asm code])
					AC_DEFINE(HAVE_i386_BASED_CPU)
				else
					if test "$target_cpu" = "i586"; then
						AC_MSG_RESULT([i586, compiling asm code])
						AC_DEFINE(HAVE_i386_BASED_CPU)
					else
						if test "$target_cpu" = "i686"; then
							AC_MSG_RESULT([i686, compiling asm code])
							AC_DEFINE(HAVE_i386_BASED_CPU)
						else
							AC_MSG_RESULT([$target_cpu\, not using i386 optimisations])
							unset SS_COMPILE_i386_ASM
						fi
					fi
				fi
			fi
		fi

 		build_date=`date`
		AC_DEFINE_UNQUOTED(BUILD_DATE,"$build_date")

 		# Installation directories
		imagedir="\${exec_prefix}/share/kvirc/pics" 	
		msgcolordir="\${exec_prefix}/share/kvirc/msgcolors" 	
		helpdir="\${exec_prefix}/share/kvirc/help/en" 	
		configdir="\${exec_prefix}/share/kvirc/config" 	
		localedir="\${exec_prefix}/share/kvirc/locale" 	
		mandir="\${exec_prefix}/man/man1"
		globalkvircdir="\${exec_prefix}/share/kvirc"
		pluglibdir="\${exec_prefix}/share/kvirc/plugins"
		charmapsdir="\${exec_prefix}/share/kvirc/charmaps"
		if test -n "$KDEDIR"; then
			sharedir="$KDEDIR/share"
		else
			sharedir="\${exec_prefix}/share"
		fi
		topdir=`pwd`
		includedir="\${exec_prefix}/include/kvirc"

		AC_SUBST(topdir)
		AC_SUBST(SS_FLAGS_RPATH)
		AC_SUBST(SS_FLAGS_LIBDIRS)
		AC_SUBST(SS_FLAGS_LIBLINK)
		AC_SUBST(SS_FLAGS_INCDIRS)
		AC_SUBST(charmapsdir)
		AC_SUBST(msgcolordir)
		AC_SUBST(imagedir)
		AC_SUBST(helpdir)
		AC_SUBST(configdir)
		AC_SUBST(localedir)
		AC_SUBST(globalkvircdir)
		AC_SUBST(pluglibdir)
		AC_SUBST(sharedir)
		AC_SUBST(includedir)
	]
)



## ------------------------------------------------------------------------
##  Old stuff
## ------------------------------------------------------------------------




AC_DEFUN(AC_SS_CHECK_BOOL,
[
	AC_MSG_CHECKING([for bool])
	AC_CACHE_VAL(ac_cv_have_bool,
        [
		AC_LANG_CPLUSPLUS
          	AC_TRY_COMPILE([],
                 [bool aBool = true;],
                 [ac_cv_have_bool="yes"],
                 [ac_cv_have_bool="no"])
        ])
        AC_MSG_RESULT($ac_cv_have_bool)
        if test "$ac_cv_have_bool" = "yes"; then
        	AC_DEFINE(HAVE_BOOL) 
        fi 
])

AC_DEFUN(AC_SS_CHECK_KVI_SOCKLEN_T,
[
 	AC_MSG_CHECKING(if getsockname wants socklen_t as third argument)
	AC_LANG_CPLUSPLUS
	AC_CACHE_VAL(ac_cv_kvi_socklen_t,
		[
			AC_TRY_COMPILE(
				[
					#include <sys/types.h>
					#include <sys/socket.h>
				],[
					socklen_t a=0;
					getsockname(0,(struct sockaddr*)0, &a);
				],
				ac_cv_kvi_socklen_t=socklen_t,
				ac_cv_kvi_socklen_t=)
			if test -z "$ac_cv_kvi_socklen_t"; then
 				ac_safe_cxxflags="$CXXFLAGS"
				if test "$GCC" = "yes"; then
					  CXXFLAGS="-Werror $CXXFLAGS"
				fi
				AC_TRY_COMPILE(
					[
						#include <sys/types.h>
 						#include <sys/socket.h>
					],[
						int a=0;
						getsockname(0,(struct sockaddr*)0, &a);
					],
					ac_cv_kvi_socklen_t=int,
					ac_cv_kvi_socklen_t=size_t)
				CXXFLAGS="$ac_safe_cxxflags"
			fi
		]
	)
	if test -z "$ac_cv_kvi_socklen_t"; then
		ac_cv_kvi_socklen_t=int
	fi
	AC_MSG_RESULT($ac_cv_kvi_socklen_t)
	AC_DEFINE_UNQUOTED(kvi_socklen_t, $ac_cv_kvi_socklen_t)
])

dnl just a wrapper to clean up configure.in
AC_DEFUN(KVIRC_PROG_LIBTOOL,
[
AM_PROG_LIBTOOL

LIBTOOL_SHELL="/bin/sh ./libtool"
#  LIBTOOL="$LIBTOOL --silent"

  AC_ARG_ENABLE(objprelink, [  --enable-objprelink     prelink apps (experimental, needs objprelink in path)],
	kvirc_use_objprelink=$enableval, kvirc_use_objprelink=no)
  if test "x$kvirc_use_objprelink" = "xyes"; then 
      echo Patching libtool to run objprelink.
      mv libtool libtool.orig
      cat > libtool <<\EOF
#! /bin/sh
for n
do
	case $n in
		*.o)  test -r $n && echo objprelink $n && objprelink $n
		      ;;
		*.lo) m=`basename $n .lo`".o" && test -r $m && echo objprelink $m && objprelink $m
		      m=".libs/$m" && test -r $m && echo objprelink $m && objprelink $m
		      ;;
	esac
done

EOF
      cat >> libtool libtool.orig
      rm libtool.orig
      chmod a+x libtool
  fi
])

dnl # ------------------------------------------------------------------------
dnl # chck for the pthreads library.
dnl # ------------------------------------------------------------------------

AC_DEFUN(AC_SS_CHECK_PTHREAD,
	[ 
		AC_ARG_WITH(pthread-check,[  --without-pthread-check ignore the pthread library check],SS_IGNORE_PTHREAD_CHECK="$withval",SS_IGNORE_PTHREAD_CHECK="NOTGIVEN")

		AC_ARG_WITH(freebsd-pthread,[  --with-freebsd-pthread  use FreeBSD libc_r instead of libpthread],SS_FREEBSD_PTHREAD="yes",SS_FREEBSD_PTHREAD="no")

		if test "$SS_IGNORE_PTHREAD_CHECK" = "NOTGIVEN"; then

			if test "$SS_FREEBSD_PTHREAD" = "yes"; then

				AC_MSG_CHECKING([for a working libc_r linkage])
				AC_CACHE_VAL(ac_cv_lib_pthread,[
					ac_save_LIBS="$LIBS"
					ac_save_CFLAGS="$CFLAGS"
					if test -n "$SS_OTHER_LIBDIRS"; then
						LIBS="-L$SS_OTHER_LIBDIRS -pthread"
					else
						LIBS="-pthread"
					fi
					if test -n "$SS_OTHER_INCDIRS"; then
						CFLAGS="-I$SS_OTHER_INCDIRS $CFLAGS"
					fi
					AC_TRY_LINK([
						#include <pthread.h>
						],
						[pthread_exit(0);],
						eval "ac_cv_lib_pthread=-phtread",
						eval "ac_cv_lib_pthread=no"
					)
					LIBS="$ac_save_LIBS"
					CFLAGS="$ac_save_CFLAGS"
				])

				if eval "test ! \"`echo $ac_cv_lib_pthread`\" = no"; then
					AC_MSG_RESULT(Ok: seems to work...)
				else
					echo "################################################################################"
					echo "### CONFIGURE ERROR:"
					echo "### Can not find the pthread library."
					echo "### Make sure that it is correctly installed on your system,"
					echo "### and it is in your usual libs directory (such as /lib or /usr/lib)."
					echo "### This is a widely used library , so it must be visible by the compilers."
					echo "### If you feel yourself lucky, you may try to run configure by passing the"
					echo "### --without-pthread-check option: this will make configure skipt this test."
					echo "### You may also take a look at the config.log file in this directory,"
					echo "### that will tell you which check has failed and maybe more about the reason"
					echo "### of the failure."
					echo "### If you're feeling that this may be a bug in this configure script"
					echo "### and want to report this to me , please include your configure script,"
					echo "### the config.log file as well as the complete configure output."
					echo "################################################################################"
					AC_MSG_ERROR(["This was a fatal one...aborting"])
				fi
			else 
				AC_MSG_CHECKING([for libpthread])
				AC_CACHE_VAL(ac_cv_lib_pthread,[
					ac_save_LIBS="$LIBS"
					ac_save_CFLAGS="$CFLAGS"
					if test -n "$SS_OTHER_LIBDIRS"; then
						LIBS="-L$SS_OTHER_LIBDIRS -lpthread"
					else
						LIBS="-lpthread"
					fi
					if test -n "$SS_OTHER_INCDIRS"; then
						CFLAGS="-I$SS_OTHER_INCDIRS $CFLAGS"
					fi
					AC_TRY_LINK([
						#include <pthread.h>
						],
						[pthread_exit(0);],
						eval "ac_cv_lib_pthread=-lphtread",
						eval "ac_cv_lib_pthread=no"
					)
					LIBS="$ac_save_LIBS"
					CFLAGS="$ac_save_CFLAGS"
				])
				if eval "test ! \"`echo $ac_cv_lib_pthread`\" = no"; then
					AC_MSG_RESULT(Ok: seems to work...)
				else
					echo "################################################################################"
					echo "### CONFIGURE ERROR:"
					echo "### Can not find the pthread library."
					echo "### Make sure that it is correctly installed on your system,"
					echo "### and it is in your usual libs directory (such as /lib or /usr/lib)."
					echo "### This is a widely used library , so it must be visible by the compilers."
					echo "### If you feel yourself lucky, you may try to run configure by passing the"
					echo "### --without-pthread-check option: this will make configure skipt this test."
					echo "### You may also take a look at the config.log file in this directory,"
					echo "### that will tell you which check has failed and maybe more about the reason"
					echo "### of the failure."
					echo "### If you're feeling that this may be a bug in this configure script"
					echo "### and want to report this to me , please include your configure script,"
					echo "### the config.log file as well as the complete configure output."
					echo "################################################################################"
					AC_MSG_ERROR(["This was a fatal one...aborting"])
				fi
			fi
		else
			AC_MSG_RESULT("Trusting you...skipping the pthread library check")
		fi
	]
)
## ------------------------------------------------------------------------
## Find the KDE library path and includes
## ------------------------------------------------------------------------

AC_DEFUN(AC_SS_FIND_KDE,
	[

		SS_KDE_REQUESTED="no"
		SS_KDE_GENERAL_DIR="none"
		SS_KDE_INCLUDE_DIR="none"
		SS_KDE_LIBRARY_DIR="none"

		AC_SS_CHECK_IF_KDE_IS_REQUESTED
		if test "$SS_KDE_REQUESTED" = "yes"; then
			AC_SS_FIND_KDE_GENERAL_DIR
			if test "$SS_KDE_REQUESTED" = "yes"; then
				AC_SS_FIND_KDE_INCLUDE_DIR
				if test "$SS_KDE_REQUESTED" = "yes"; then
					AC_SS_FIND_KDE_LIBRARY_DIR
					if test "$SS_KDE_REQUESTED" = "yes"; then
		                              AC_SS_ENSURE_CAN_COMPILE_X_QT_AND_KDE
					fi
				fi
			fi
		fi

		dnl AC_SUBST(SS_KDE_REQUESTED)
		dnl AC_SUBST(SS_KDE_GENERAL_DIR)
		dnl AC_SUBST(SS_KDE_INCLUDE_DIR)
		dnl AC_SUBST(SS_KDE_LIBRARY_DIR)
	]
)


AC_DEFUN(AC_SS_CHECK_IF_KDE_IS_REQUESTED,
	[
 		AC_MSG_CHECKING(if KDE support is requested)
  		AC_ARG_WITH(kde-support,[  --with-kde-support      build with KDE support],SS_KDE_REQUESTED="yes",SS_KDE_REQUESTED="no")
		if test "$SS_KDE_REQUESTED" = "yes"; then
			AC_MSG_RESULT(yes)
		else
		    SS_KDE_REQUESTED="no"
		    AC_MSG_RESULT(no)
		fi
	]
)

AC_DEFUN(AC_SS_FIND_KDE_GENERAL_DIR,
	[
		AC_MSG_CHECKING(for the KDE base directory)
		ss_kde_general_test_dirs="/usr /usr/local /usr /usr/local /usr/build /usr/X11R6 /opt /usr/opt /usr/lib /usr/lib /usr/src /usr/lib /usr/local/lib /"
		if test -n "$HOME"; then
			ss_kde_general_test_dirs="$ss_kde_general_test_dirs $HOME $HOME/lib"
		fi
		if test -n "$KDEDIR"; then
			ss_kde_general_test_dirs="$KDEDIR $ss_kde_general_test_dirs"
		fi
		ss_kde_general_test_path_suffix=". kde kde2.3 kde2.2 kde2.1 kde2.0 kde2 KDE Kde KDE2"

		AC_SS_FIND_FILE_PATH_EXT(include/kwin.h,$ss_kde_general_test_dirs,$ss_kde_general_test_path_suffix,SS_KDE_GENERAL_DIR)

		if test "$SS_KDE_GENERAL_DIR" = "FAILED"; then
			AC_MSG_RESULT(failed...continuing with normal checks)
			unset SS_KDE_GENERAL_DIR
		else
			AC_MSG_RESULT(seems to be $SS_KDE_GENERAL_DIR)
		fi
	]
)

AC_DEFUN(AC_SS_FIND_KDE_INCLUDE_DIR,
	[
		AC_ARG_WITH(kde-includes,[  --with-kde-includes=DIR directory the KDE headers are in],SS_KDE_INCLUDE_DIR="$withval",SS_KDE_INCLUDE_DIR="NOTGIVEN")
		if test "$SS_KDE_INCLUDE_DIR" = "NOTGIVEN"; then

			AC_MSG_CHECKING(for the KDE header files)

			ss_kde_include_test_dirs="/include /usr/include /usr/local/include /usr/kde/include /usr/local/kde/include /usr/X11R6/include /opt/kde/include /usr/lib/kde/include /usr/lib/kde /usr/include/X11"
			test -n "$KDEDIR" && ss_kde_include_test_dirs="$KDEDIR/include $KDEDIR $ss_kde_include_test_dirs"
			ss_kde_include_test_dirs="$ss_kde_include_test_dirs /usr/include/kde /usr/local/include/kde /include/kde /usr/X11R6/include/kde /usr/build/kde/include"
			ss_kde_include_test_dirs="$ss_kde_include_test_dirs /usr/include/kde2 /usr/local/include/kde2 /include/kde2 /usr/X11R6/include/kde2 /usr/include/X11/kde2"
			test -n "$SS_KDE_GENERAL_DIR" && ss_kde_include_test_dirs="$SS_KDE_GENERAL_DIR/include $ss_kde_include_test_dirs"

			AC_SS_FIND_FILE_PATH(kwin.h,$ss_kde_include_test_dirs,SS_KDE_INCLUDE_DIR)

			if test "$SS_KDE_INCLUDE_DIR" = "FAILED"; then
				AC_MSG_RESULT("FAILED")
				SS_KDE_REQUESTED="no"
			else
				AC_MSG_RESULT(found in $SS_KDE_INCLUDE_DIR)
			fi

		else
			AC_MSG_RESULT(using user supplied path for the KDE include files $SS_KDE_INCLUDE_DIR)
			AC_SUBST(SS_KDE_INCLUDE_DIR)
		fi
	]
)

AC_DEFUN(AC_SS_FIND_KDE_LIBRARY_DIR,
	[
		AC_ARG_WITH(kde-libraries,[  --with-kde-libraries=DIR
                          directory the KDE libraries are in],SS_KDE_LIBRARY_DIR="$withval",SS_KDE_LIBRARY_DIR="NOTGIVEN")
		if test "$SS_KDE_LIBRARY_DIR" = "NOTGIVEN"; then
			AC_MSG_CHECKING(for the KDE libraries)

			ss_kde_library_test_dirs="/lib /usr/lib /usr/local/lib /usr/kde/lib /opt/kde/lib /opt/lib /usr/opt/kde/lib /usr/local/kde/lib /usr/X11R6/lib /usr/lib/kde/lib /usr/lib/kde /usr/local/lib/kde/lib"
			test -n "$KDEDIR" && ss_kde_library_test_dirs="$KDEDIR/lib $KDEDIR $ss_kde_library_test_dirs"
			ss_kde_library_test_dirs="$ss_kde_library_test_dirs /usr/local/lib/kde /usr/X11R6/lib/kde /usr/build/kde/lib"
			if test -n "$SS_KDE_GENERAL_DIR"; then
				ss_kde_library_test_dirs="$SS_KDE_GENERAL_DIR/lib $ss_kde_library_test_dirs"
			fi

			AC_SS_FIND_FILE_PATH(libkdecore.so.3.0.0 libkdecore.so.3.0 libkdecore.a libkdecore.so,$ss_kde_library_test_dirs,SS_KDE_LIBRARY_DIR)

			if test "$SS_KDE_LIBRARY_DIR" = "FAILED"; then
				AC_MSG_RESULT("FAILED")
				SS_KDE_REQUESTED="no"

			else
				AC_MSG_RESULT(found in $SS_KDE_LIBRARY_DIR)
			fi
		else
			AC_MSG_RESULT(using user supplied path for the KDE libraries $SS_KDE_LIBRARY_DIR)
			AC_SUBST(SS_KDE_LIBRARY_DIR)
		fi
	]
)

## ------------------------------------------------------------------------
## Make sure we can compile Qt and X stuff
## ------------------------------------------------------------------------

AC_DEFUN(AC_SS_ENSURE_CAN_COMPILE_X_QT_AND_KDE,
	[
		AC_ARG_WITH(kde-check,[  --without-kde-check     do not check whether KDE compiles],SS_CHECK_KQTX_COMPILE="$withval",SS_CHECK_KQTX_COMPILE="yes")
  		if test "$SS_CHECK_KQTX_COMPILE" = "yes"; then
			AC_MSG_CHECKING(if we can compile an X-Qt-KDE application)
			AC_LANG_CPLUSPLUS
			ss_save_CPPFLAGS="$CPPFLAGS"
			ss_save_CXXFLAGS="$CXXFLAGS"
			ss_save_LDFLAGS="$LDFLAGS"
			ss_save_LIBS="$LIBS"
			CPPFLAGS="-I$SS_X_INCLUDE_DIR -I$SS_QT_INCLUDE_DIR -I$SS_KDE_INCLUDE_DIR $CPPFLAGS $X_CFLAGS"
			if test -n "$SS_OTHER_INCDIRS"; then
				CPPFLAGS="-I$SS_OTHER_INCDIRS $CPPFLAGS"
			fi
			CXXFLAGS="-O2 -Wall -g $CXXFLAGS"
			LIBS="-L$SS_KDE_LIBRARY_DIR -L$SS_X_LIBRARY_DIR -L$SS_QT_LIBRARY_DIR $X_ $X_EXTRA_LIBS $X_LIBS $LIBS -lkfile -lksycoca -l$SS_QTLIB_NAME -lXext -lX11 -ldl -Wl,-rpath $SS_KDE_LIBRARY_DIR"
			if test -n "$SS_OTHER_LIBDIRS"; then
				LIBS="-L$SS_OTHER_LIBDIRS $LIBS"
			fi
			LDFLAGS="-s $LDFLAGS"
			AC_TRY_LINK([
					#include "kapp.h"
					#include "kwin.h"
				],[
					int a = KWin::currentDesktop();
					KApplication app(a,0,"kvirc");
				],
				SS_KQTX_LINKED_OK="TRUE",
				SS_KQTX_LINKED_OK="FALSE"
			)
			if test "$SS_KQTX_LINKED_OK" = "FALSE"; then
				SS_KDE_REQUESTED="no"
				AC_MSG_RESULT(failed)
			else
				AC_MSG_RESULT(success)
			fi
			LIBS="$ss_save_LIBS"
			LDFLAGS="$ss_save_LDFLAGS"
			CXXFLAGS="$ss_save_CXXFLAGS"
			CPPFLAGS="$ss_save_CPPFLAGS"
		fi
	]
)
## ------------------------------------------------------------------------
## Find the dl library
## ------------------------------------------------------------------------



AC_DEFUN(AC_SS_CHECK_IF_PLUGIN_SUPPORT_IS_REQUESTED,
	[
		AC_MSG_CHECKING(if plugin support is requested)
		AC_ARG_WITH(plugin-support,[  --without-plugin-support
                          do not build with plugin support],SS_PLUGIN_REQUESTED="$withval",SS_PLUGIN_REQUESTED="yes")
		if test "$SS_PLUGIN_REQUESTED" = "yes"; then
			AC_MSG_RESULT(yes)
		else
		    SS_PLUGIN_REQUESTED="no"
		    AC_MSG_RESULT(no)
		fi
	]
)

AC_DEFUN(AC_SS_FIND_DL,
[
	AC_SS_CHECK_IF_PLUGIN_SUPPORT_IS_REQUESTED
	if test "$SS_PLUGIN_REQUESTED" = "yes"; then
		AC_MSG_CHECKING(["for dlopen capabilities"])
	
		SS_LINK_TO_LIBDL="no"
	
		SS_SAVE_LIBS="$LIBS"
		LIBS="-rdynamic"
		SS_SAVE_CFLAGS="$CFLAGS";
		if test -n "$SS_OTHER_INCDIRS"; then
			CFLAGS="-I$SS_OTHER_INCDIRS $CFLAGS"
		fi
		AC_TRY_LINK([
				#include <dlfcn.h>
			],[
				dlopen("/lib/libc.so.6",RTLD_NOW);
			],
				eval "SS_DLOPEN_OK=yes"
			,
				eval "SS_DLOPEN_OK=no"
			)
		LIBS="$SS_SAVE_LIBS"
		CFLAGS="$SS_SAVE_CFLAGS"
		if test "$SS_DLOPEN_OK" = "yes"; then
			AC_MSG_RESULT("built into libc")
			AC_DEFINE_UNQUOTED(HAVE_LIBDL)
		else
	
			SS_SAVE_LIBS="$LIBS"
			SS_SAVE_CFLAGS="$CFLAGS";
			if test -n "$SS_OTHER_LIBDIRS"; then
				LIBS="-L$SS_OTHER_LIBDIRS -rdynamic -ldl"
			else
				LIBS="-rdynamic -ldl"
			fi
			if test -n "$SS_OTHER_INCDIRS"; then
				CFLAGS="-I$SS_OTHER_INCDIRS $CFLAGS"
			fi
			AC_TRY_LINK([
					#include <dlfcn.h>
				],
					[dlopen("/usr/lib/libdl.so",RTLD_NOW);]
				,
					eval "SS_DLOPEN_OK=yes",
					eval "SS_DLOPEN_OK=no"
				)
			LIBS="$SS_SAVE_LIBS"
			CFLAGS="$SS_SAVE_CFLAGS"
			if test "$SS_DLOPEN_OK" = "yes"; then
				SS_LINK_TO_LIBDL="yes"
				AC_MSG_RESULT("external in libdl")
				AC_DEFINE_UNQUOTED(HAVE_LIBDL)
			else
				AC_MSG_RESULT(["no dlopen capabilities"])
				SS_PLUGIN_REQUESTED="no";
			fi
		fi
	fi
])

dnl # ------------------------------------------------------------------------
dnl # Find a file path(list of files,list of dirs,variable)
dnl # Searches for one of the files in the directories specified
dnl # Sets the veriable to "FAILED" or to the path where the file was found
dnl # ------------------------------------------------------------------------

AC_DEFUN(AC_SS_FIND_FILE_PATH,
	[
		$3="FAILED"
		for a_dir in $2; do
			for a_file in $1; do
				if test -r "$a_dir/$a_file"; then
					$3=$a_dir
					break 2
				fi
			done
		done	
	]
)

AC_DEFUN(AC_SS_FIND_FILE_PATH_EXT,
	[
		$4="FAILED"

		for a_dir in $2; do
			for a_semidir in $3; do
				for a_file in $1; do
					if test -r "$a_dir/$a_semidir/$a_file"; then
						$4="$a_dir/$a_semidir"
						break 3
					fi
				done
			done
		done
	]
)
## ------------------------------------------------------------------------
## Find the Qt library and includes
## sets SS_QT_INCLUDE_DIR, SS_QT_LIBRARY_DIR, SS_QT_MOC
## ------------------------------------------------------------------------

AC_DEFUN(AC_SS_FIND_QT,
	[
		AC_SS_CHECK_QT_MT
		AC_SS_CHECK_QT_NAME
		AC_SS_FIND_QT_GENERAL_DIR
		AC_SS_FIND_QT_INCLUDE_DIR
		AC_SS_FIND_QT_LIBRARY_DIR
		AC_SS_FIND_QT_MOC
		AC_SS_ENSURE_CAN_COMPILE_X_AND_QT
	]
)

AC_DEFUN(AC_SS_CHECK_QT_MT,
	[
		AC_ARG_ENABLE(mt,
		[  --enable-mt             link to multithreaded Qt],
		SS_USE_QT_MT=$enableval,
		SS_USE_QT_MT=no
		)
		USING_QT_MT=""
		if test "x$SS_USE_QT_MT" = "xyes"; then
			case $host in
			*-*-linux-*)
			;;
			*)
			AC_MSG_WARN([mt may not be supported on $host])
			AC_MSG_WARN([configure with --disable-mt if you have problems])
			;;
			esac
			CPPFLAGS="$CPPFLAGS -pthread"
			USING_QT_MT=", using -mt"
		fi
	]
)

AC_DEFUN(AC_SS_CHECK_QT_NAME,
	[
		SS_QTLIB_NAME="qt"
		AC_MSG_CHECKING([for the Qt library name])
		AC_ARG_WITH(qt-lib-name,[  --with-qt-lib-name=NAME use NAME instead of 'qt' for the Qt library],SS_QTLIB_NAME="$withval",SS_QTLIB_NAME="qt")
		if test "x$SS_USE_QT_MT" = "xyes"; then
			SS_QTLIB_NAME="$SS_QTLIB_NAME-mt"
		fi
		AC_MSG_RESULT("$SS_QTLIB_NAME")
	]
)

AC_DEFUN(AC_SS_FIND_QT_GENERAL_DIR,
	[
		SS_QTDIR="$QTDIR"
		AC_MSG_CHECKING([for the Qt base directory])
		AC_ARG_WITH(qt-dir,[  --with-qt-dir=DIR       base directory of the Qt installation],SS_QTDIR="$withval",SS_QTDIR="$QTDIR")
		ss_qt_general_test_dirs="/usr/local /usr /usr/build /usr/X11R6 /usr/lib /usr/src /usr/local/lib /"
		ss_qt_general_test_dirs="$ss_qt_general_test_dirs /opt/kde /kde /usr/kde /usr/local/kde /usr/opt/kde"
		if test -n "$HOME"; then
			ss_qt_general_test_dirs="$ss_qt_general_test_dirs $HOME $HOME/lib"
		fi
		if test -n "$QTDIR"; then
			ss_qt_general_test_dirs="$QTDIR $ss_qt_general_test_dirs"
		fi
		if test -n "$SS_QTDIR"; then
			ss_qt_general_test_dirs="$SS_QTDIR $ss_qt_general_test_dirs"
		fi
		ss_qt_general_test_path_suffix=". qt3 qt.3 qt-3 qt-3.1 qt-3.0 qt-3.0.1 qt-3.0.0 qt2 qt.2 qt-2 qt-2.3 qt-2.3.2 qt-2.3.1 qt-2.3.0 qt-2.2 qt-2.2.4 qt-2.2.3 qt-2.2.2 qt-2.2.1 qt-2.2.0"

		AC_SS_FIND_FILE_PATH_EXT(include/qinputdialog.h,$ss_qt_general_test_dirs,$ss_qt_general_test_path_suffix,SS_QT_GENERAL_DIR)

		if test "$SS_QT_GENERAL_DIR" = "FAILED"; then
			AC_MSG_RESULT(failed, continuing with normal checks)
			unset SS_QT_GENERAL_DIR
		else
			AC_MSG_RESULT(seems to be $SS_QT_GENERAL_DIR)
		fi
	]
)

AC_DEFUN(AC_SS_FIND_QT_INCLUDE_DIR,
	[
		AC_ARG_WITH(qt-includes,[  --with-qt-includes=DIR  directory the Qt headers are in],SS_QT_INCLUDE_DIR="$withval",SS_QT_INCLUDE_DIR="NOTGIVEN")
		if test "$SS_QT_INCLUDE_DIR" = "NOTGIVEN"; then

			AC_MSG_CHECKING(for the Qt header files)

			ss_qt_include_test_dirs="$SS_QT_GENERAL_DIR/include /include /usr/include /usr/local/include /usr/qt/include /usr/local/qt/include /usr/X11R6/include /usr/lib/qt/include /usr/lib/qt /usr/include/X11"
			test -n "$QTDIR" && ss_qt_include_test_dirs="$QTDIR/include $QTDIR $ss_qt_include_test_dirs"
			ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/qt /usr/local/include/qt /include/qt /usr/X11R6/include/qt /usr/build/qt/include"
			ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/qt2 /usr/local/include/qt2 /include/qt2 /usr/X11R6/include/qt2 /usr/include/X11/qt2"
			test -n "$SS_QT_GENERAL_DIR" && ss_qt_include_test_dirs="$SS_QT_GENERAL_DIR/include $ss_qt_include_test_dirs"

			AC_SS_FIND_FILE_PATH(qiconview.h,$ss_qt_include_test_dirs,SS_QT_INCLUDE_DIR)

			if test "$SS_QT_INCLUDE_DIR" = "FAILED"; then
				AC_MSG_RESULT("FAILED")
				echo "################################################################################"
				echo "### CONFIGURE ERROR:"
				echo "### Cannot find Qt >= 2.2.3 header files."
				echo "### Make sure that Qt is correctly installed on your system,"
				echo "### and that the Qt version is the one requested by this version of KVIrc."
				echo "### Try to run configure again, this time passing the --with-qt-includes=DIR"
				echo "### option (see ./configure --help)."
				echo "### You may also take a look at the config.log file in this directory,"
				echo "### that will tell you which check has failed and maybe more about the reason"
				echo "### of the failure."
				echo "### If you're feeling that this may be a bug in this configure script"
				echo "### and want to report this, please include your configure script,"
				echo "### the config.log file, as well as the complete configure output."
				echo "################################################################################"
				AC_MSG_ERROR(["This was a fatal one...aborting"])
			else
				AC_MSG_RESULT(found in $SS_QT_INCLUDE_DIR)
				dnl AC_SUBST(SS_QT_INCLUDE_DIR)
			fi

		else
			AC_MSG_RESULT(using user-supplied Qt header directory $SS_QT_INCLUDE_DIR)
			dnl AC_SUBST(SS_QT_INCLUDE_DIR)
		fi
		if test "x$SS_USE_QT_MT" = "xyes"; then
			SS_QT_INCLUDE_DIR="$SS_QT_INCLUDE_DIR -DQT_THREAD_SUPPORT"
		fi
	]
)

AC_DEFUN(AC_SS_FIND_QT_LIBRARY_DIR,
	[
		AC_ARG_WITH(qt-libraries,[  --with-qt-libraries=DIR directory the Qt library is in],SS_QT_LIBRARY_DIR="$withval",SS_QT_LIBRARY_DIR="NOTGIVEN")
		if test "$SS_QT_LIBRARY_DIR" = "NOTGIVEN"; then
			AC_MSG_CHECKING(for the Qt library)

			ss_qt_library_test_dirs="$SS_QT_GENERAL_DIR/lib /lib /usr/lib /usr/local/lib /usr/qt/lib /usr/local/qt/lib /usr/X11R6/lib /usr/lib/qt/lib /usr/lib/qt /usr/local/lib/qt/lib"
			test -n "$QTDIR" && ss_qt_library_test_dirs="$QTDIR/lib $QTDIR $ss_qt_library_test_dirs"
			ss_qt_library_test_dirs="$ss_qt_library_test_dirs /usr/local/lib/qt /usr/X11R6/lib/qt /usr/build/qt/lib"
			if test -n "$SS_QT_GENERAL_DIR"; then
				ss_qt_library_test_dirs="$SS_QT_GENERAL_DIR/lib $ss_qt_library_test_dirs"
			fi

			AC_SS_FIND_FILE_PATH(libqt.so.2.3 libqt.so.2.2 libqt.so.2 libqt.a libqt-mt.so libqt.so libqt.so.3 libqt.so.3.0 libqt.so.3.1 lib$SS_QTLIB_NAME.so lib$SS_QTLIB_NAME.a,$ss_qt_library_test_dirs,SS_QT_LIBRARY_DIR)

			if test "$SS_QT_LIBRARY_DIR" = "FAILED"; then
				AC_MSG_RESULT("FAILED")
				echo "################################################################################"
				echo "### CONFIGURE ERROR:"
				echo "### Cannot find a Qt >= 2.2.3 library file."
				echo "### Make sure that Qt is correctly installed on your system,"
				echo "### and that the Qt version is the one requested by this version of KVIrc."
				echo "### Try to run configure again, this time passing the --with-qt-libraries=DIR"
				echo "### option (see ./configure --help)."
				echo "### You may also take a look at the config.log file in this directory,"
				echo "### that will tell you which check has failed and maybe more about the reason"
				echo "### of the failure."
				echo "### If you feel this may be a bug in this configure script"
				echo "### and want to report this, please include your configure script,"
				echo "### and config.log file, as well as the complete configure output."
				echo "################################################################################"
				AC_MSG_ERROR(["This was a fatal one...aborting"])
			else
				AC_MSG_RESULT(found in $SS_QT_LIBRARY_DIR$USING_QT_MT)
				dnl AC_SUBST(SS_QT_LIBRARY_DIR)
			fi
		else
			AC_MSG_RESULT(using user supplied path for the Qt library $SS_QT_LIBRARY_DIR)
			dnl AC_SUBST(SS_QT_LIBRARY_DIR)
		fi
	]
)

## ------------------------------------------------------------------------
## Find the Qt meta object preprocessor
## sets SS_MOC to the path/filename of moc
## ------------------------------------------------------------------------

AC_DEFUN(AC_SS_FIND_QT_MOC,
	[	
		AC_ARG_WITH(qt-moc,[  --with-qt-moc=PATH      filename of the Qt meta object compiler],SS_QT_MOC="$withval",SS_QT_MOC="NOTGIVEN")
	 	if test "$SS_QT_MOC" = "NOTGIVEN"; then
	 		unset SS_QT_MOC
			if test -n "$SS_QT_GENERAL_DIR"; then
		 		AC_PATH_PROG(SS_QT_MOC,moc,"FAILED",$SS_QT_GENERAL_DIR/bin:$QTDIR/bin:$PATH:/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin:/usr/lib/qt/bin:/usr/local/qt/bin:/usr/X11R6/qt/bin:/usr/qt/bin:/usr/build/qt/bin)
			else
		 		AC_PATH_PROG(SS_QT_MOC,moc,"FAILED",$QTDIR/bin:$PATH:/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin:/usr/lib/qt/bin:/usr/local/qt/bin:/usr/X11R6/qt/bin:/usr/qt/bin:/usr/build/qt/bin)
			fi

			if test "$SS_QT_MOC" = "FAILED"; then
				AC_MSG_RESULT(["FAILED"])
				echo "################################################################################"
				echo "### CONFIGURE ERROR:"
				echo "### The Qt meta object compiler can not be found."
				echo "### Make sure that qt is correctly installed on your system,"
				echo "### and the qt version is the one requested by this version of kvirc."
				echo "### Try to run configure again, this time passing the --with-qt-moc"
				echo "### option (see ./configure --help)."
				echo "### You may also take a look at the config.log file in this directory,"
				echo "### that will tell you which check has failed and maybe more about the reason"
				echo "### of the failure."
				echo "### If you feel that this may be a bug in this configure script"
				echo "### and want to report this, please include your configure script,"
				echo "### and config.log file, as well as the complete configure output."
				echo "################################################################################"
				AC_MSG_ERROR(["This was a fatal one...aborting"])
			fi
		else
			AC_MSG_RESULT(using user supplied path for moc $SS_QT_MOC)
			dnl AC_SUBST(SS_QT_MOC)
	 	fi
	]
)

## ------------------------------------------------------------------------
## Make sure we can compile Qt and X stuff
## ------------------------------------------------------------------------

AC_DEFUN(AC_SS_ENSURE_CAN_COMPILE_X_AND_QT,
	[
		AC_ARG_WITH(qt-check,[  --without-qt-check      do not check whether Qt compiles],SS_CHECK_QTX_COMPILE="$withval",SS_CHECK_QTX_COMPILE="yes")
  		if test "$SS_CHECK_QTX_COMPILE" = "yes"; then
			AC_MSG_CHECKING(if we can compile an X-Qt application)
			AC_LANG_CPLUSPLUS
			ss_save_CPPFLAGS="$CPPFLAGS"
			ss_save_CXXFLAGS="$CXXFLAGS"
			ss_save_LDFLAGS="$LDFLAGS"
			ss_save_LIBS="$LIBS"
			CPPFLAGS="-I$SS_QT_INCLUDE_DIR $CPPFLAGS $X_CFLAGS"
			if test -n "$SS_X_INCLUDE_DIR"; then
				CPPFLAGS="-I$SS_X_INCLUDE_DIR $CPPFLAGS"
			fi
			if test -n "$SS_OTHER_INCDIRS"; then
				CPPFLAGS="-I$SS_OTHER_INCDIRS $CPPFLAGS"
			fi
			CXXFLAGS="-O2 -Wall -g $CXXFLAGS"
			LIBS="-L$SS_X_LIBRARY_DIR -L$SS_QT_LIBRARY_DIR $X_EXTRA_LIBS $X_LIBS $LIBS -l$SS_QTLIB_NAME -lXext -lX11"
			if test -n "$SS_OTHER_LIBDIRS"; then
				LIBS="-L$SS_OTHER_LIBDIRS $LIBS"
			fi
			LDFLAGS="-s $LDFLAGS"
			AC_TRY_LINK([#include <qwindowsstyle.h>],
				[QWindowsStyle s; s.polish((QWidget *)0);],
				SS_QTX_LINKED_OK="TRUE",SS_QTX_LINKED_OK="FALSE")
			if test "$SS_QTX_LINKED_OK" = "FALSE"; then
				AC_MSG_RESULT("FAILED");
				echo "################################################################################"
				echo "### CONFIGURE ERROR:"
				echo "### Failed to compile the Qt library test program."
				echo "### This may be a bad sign :)"
				echo "### First of all, make sure that Qt is correctly installed on your system,"
				echo "### and that the Qt version is the one requested by this version of KVIrc."
				echo "### Ensure that you have only one copy of Qt visible at a time."
				echo "### You may also take a look at the config.log file in this directory,"
				echo "### which will tell you which check has failed and maybe more about the reason"
				echo "### of the failure."
				echo "### The CPPFLAGS used were:"
				for a_flag in $CPPFLAGS ; do
					echo "###   $a_flag"
				done
				echo "### The CXXFLAGS used were:"
				for a_flag in $CXXFLAGS ; do
					echo "###   $a_flag"
				done
				echo "### The LIBS used were:"
				for a_flag in $LIBS ; do
					echo "###   $a_flag"
				done
				echo "### The LDFLAGS used were:"
				for a_flag in $LDFLAGS ; do
					echo "###   $a_flag"
				done
				echo "### If you're sure that Qt is correctly installed , you may force configure"
				echo "### to skip this check and try to compile KVIrc anyway."
				echo "### Try using the --without-qt-check option."
				echo "### If you're feeling that this may be a bug in this configure script"
				echo "### and want to report this, please include your configure script,"
				echo "### and config.log file, as well as the complete configure output."
				echo "################################################################################"
				AC_MSG_ERROR(["This was a fatal one...aborting"])
			fi
			AC_MSG_RESULT([success$USING_QT_MT])

			AC_MSG_CHECKING([Qt version])
			AC_TRY_LINK([#include <qmemarray.h>],
				[QMemArray s; s.sort();],
				SS_QT_VERSION="3",SS_QT_VERSION="2")
			if test "x$SS_QT_VERSION" = "x3"; then
				AC_MSG_RESULT([using Qt version 3.x])
			else
				AC_MSG_RESULT([using Qt version 2.x])
			fi

			AC_MSG_CHECKING([for JPEG support in Qt])
			AC_TRY_LINK([#include <qjpegio.h>],
				[qInitJpegIO();],
				SS_QT_JPEG="yes",SS_QT_JPEG="no")
			if test "x$SS_QT_JPEG" = "xyes"; then
				AC_MSG_RESULT([yes, disabling internal JPEG support])
			else
				AC_MSG_RESULT([no, using internal JPEG support instead])
			fi

			CXXFLAGS="$CXXFLAGS -DQT_XFT"
			AC_MSG_CHECKING([for Xft anti-aliasing support in Qt])
			AC_TRY_COMPILE([#include <qt_x11.h>],
				[int x = qt_use_xft();],
				SS_QT_XFT="yes",
				SS_QT_XFT="no")

			AC_MSG_RESULT($SS_QT_XFT)
#			if test "x$SS_QT_XFT" = "xyes"; then
#				ss_save_CXXFLAGS="$ss_save_CXXFLAGS -DQT_XFT"
#			fi

			LIBS="$ss_save_LIBS"
			LDFLAGS="$ss_save_LDFLAGS"
			CXXFLAGS="$ss_save_CXXFLAGS"
			CPPFLAGS="$ss_save_CPPFLAGS"
		fi
	]
)
dnl #-------------------------------------------------------------------------
dnl # Find the X libraries and includes
dnl # sets:SS_X_INCLUDE_DIR, SS_X_LIBRARY_DIR
dnl # sets:SS_X_EXTRA_GCC_FLAGS, SS_X_EXTRA_LDD_FLAGS
dnl #-------------------------------------------------------------------------

AC_DEFUN(AC_SS_FIND_X,
	[
		AC_PATH_XTRA
		if test -n "$no_x"; then
			echo "################################################################################"
			echo "### CONFIGURE ERROR:"
			echo "### Cannot find the X libraries."
			echo "### Make sure that X is installed on your system, and try to run configure again,"
			echo "### this time passing the --x-includes and --x-libraries options."
			echo "### You may also take a look at the config.log file in this directory,"
			echo "### That will tell you which checks have failed and maybe more about the"
			echo "### reason of the failure."
			echo "################################################################################"
			AC_MSG_ERROR(["This was a fatal one...aborting"])
		else
			# Set the X include and lib dir
 			SS_X_INCLUDE_DIR="$x_includes"
			SS_X_LIBRARY_DIR="$x_libraries"

			dnl ac_cpp_safe=$ac_cpp
			dnl ac_cpp='$CPPFLAGS $x_includes'
			dnl AC_CHECK_HEADERS(X11/extensions/XShm.h,have_mitshm=yes)
			dnl ac_cpp=$ac_cpp_safe
			
			dnl AC_MSG_CHECKING(if MIT-SHM support is requested)
			dnl AC_ARG_ENABLE(mitshm,
			dnl [  --enable-mitshm         use MIT-SHM for pixmap loading/saving [default=no]],
			dnl [if test "$enableval" = yes; then
			dnl 	AC_MSG_RESULT(yes)
			dnl 	want_mitshm="yes"
			dnl else
			dnl 	AC_MSG_RESULT(no)
			dnl fi], [AC_MSG_RESULT(yes); want_mitshm="yes"])

			dnl if test "$want_mitshm" = "yes" -a "$have_mitshm" = "yes"; then
			dnl 	AC_SUBST(HAVE_MITSHM)
			dnl 	AC_DEFINE(HAVE_MITSHM,1,[Define if you want MIT-SHM support])
			dnl fi

			# Add any extra libs needed
			SS_X_EXTRA_LDD_FLAGS="$X_EXTRA_LIBS"
			for a_flag in "$X_LIBS"; do
				if test "$a_flag" != "-L$x_libraries"; then
					SS_X_EXTRA_LDD_FLAGS="$SS_X_EXTRA_LDD_FLAGS $a_flag"
				fi
			done

			# Add any extra gcc flags
			SS_X_EXTRA_GCC_FLAGS=""
			for a_flag in "$X_CFLAGS"; do
				if test "$a_flag" != "-I$x_includes"; then
					SS_X_EXTRA_GCC_FLAGS="$SS_X_EXTRA_GCC_FLAGS $a_flag"
				fi
			done	
			
			dnl AC_SUBST(SS_X_INCLUDE_DIR)
			dnl AC_SUBST(SS_X_LIBRARY_DIR)
			dnl AC_SUBST(SS_X_EXTRA_GCC_FLAGS)
			dnl AC_SUBST(SS_X_EXTRA_LDD_FLAGS)
		fi
	]
)
## ------------------------------------------------------------------------
## Find the Jpeg library
## ------------------------------------------------------------------------

AC_DEFUN(AC_SS_CHECK_IF_JPEG_SUPPORT_IS_REQUESTED,
	[

 		AC_MSG_CHECKING(if JPEG support is requested)
  		AC_ARG_WITH(jpeg-support,[  --without-jpeg-support  do not use internal JPEG support],SS_JPEG_REQUESTED="$withval",SS_JPEG_REQUESTED="yes")
		if test "$SS_JPEG_REQUESTED" = "yes"; then
			AC_MSG_RESULT(yes)
		else
		    SS_JPEG_REQUESTED="no"
		    AC_MSG_RESULT(no)
		fi
	]
)

AC_DEFUN(AC_SS_FIND_JPEG,
	[
		AC_SS_CHECK_IF_JPEG_SUPPORT_IS_REQUESTED
		if test "$SS_JPEG_REQUESTED" = "yes"; then
			AC_MSG_CHECKING([for jpeglib])
			AC_CACHE_VAL(ac_cv_lib_jpeg,[
				ac_save_LIBS="$LIBS"
				ac_save_CFLAGS="$CFLAGS"
				if test -n "$SS_OTHER_INCDIRS"; then
					CFLAGS="-I$SS_OTHER_INCDIRS $CFLAGS"
				fi
				if test -n "$SS_OTHER_LIBDIRS"; then
					LIBS="-L$SS_OTHER_LIBDIRS -ljpeg"
				else
					LIBS="-ljpeg"
				fi

				AC_TRY_LINK([ /*Override internal prototypes*/
					struct jpeg_decompress_struct;
					typedef struct jpeg_decompress_struct * j_decompress_ptr;
					typedef int size_t;
					#ifdef __cplusplus
					extern "C" {
					#endif
						void jpeg_CreateDecompress(j_decompress_ptr cinfo,int version,size_t struct_size);
					#ifdef __cplusplus
					}
					#endif
					],
					[jpeg_CreateDecompress(0,0,0);],
					eval "ac_cv_lib_jpeg=-ljpeg",
					eval "ac_cv_lib_jpeg=no"
				)
				LIBS="$ac_save_LIBS"
				CFLAGS="$ac_save_CFLAGS"
			])
			if eval "test ! \"`echo $ac_cv_lib_jpeg`\" = no"; then
				SS_HAVE_LIBJPEG="yes"
				dnl AC_SUBST(SS_HAVE_LIBJPEG)
				AC_MSG_RESULT([OK, seems to work])
			else
				AC_MSG_RESULT([not found])
			fi
		fi
	])
dnl Check if localisation support has to be compiled and installed

AC_DEFUN(AC_SS_CHECK_LOCALIZE,
	[
		AC_MSG_CHECKING(if locale support is requested)
  		AC_ARG_WITH(locale,[  --without-locale        do not enable localisation support],SS_LOCALE_REQUESTED="$withval",SS_LOCALE_REQUESTED="yes")
		if test "$SS_LOCALE_REQUESTED" = "yes"; then
			AC_MSG_RESULT(yes)
		else
		    SS_LOCALE_REQUESTED="no"
		    AC_MSG_RESULT(no)
		fi

		if test "$SS_LOCALE_REQUESTED" = "yes"; then
			AC_PATH_PROG(SS_MSGFMT,msgfmt,":",$PATH:/bin:/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin:/usr/lib/qt/bin:/usr/local/qt/bin:/usr/X11R6/qt/bin:/usr/qt/bin:/usr/build/qt/bin)
			if test "SS_MSGFMT" != ":"; then
				AC_DEFINE(COMPILE_NEED_LOCALE)
			fi
 		else
			SS_MSGFMT=":"
		fi

		AC_SUBST(SS_MSGFMT)
	]
)