File: configure.ac

package info (click to toggle)
uim 1%3A1.8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 38,956 kB
  • sloc: lisp: 356,804; ansic: 77,833; cpp: 27,846; sh: 12,460; makefile: 2,546; asm: 333; ruby: 288
file content (2103 lines) | stat: -rw-r--r-- 58,814 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
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
m4_define([UIM_MAJOR_VERSION],      [1])
m4_define([UIM_MINOR_VERSION],      [8])
m4_define([UIM_PATCHLEVEL_VERSION], [1])
m4_define([UIM_VERSION],
    UIM_MAJOR_VERSION.UIM_MINOR_VERSION.UIM_PATCHLEVEL_VERSION)

AC_PREREQ(2.60b)
AC_INIT([uim], [UIM_VERSION], [uim-en@googlegroups.com])
AC_CONFIG_SRCDIR([uim/uim.c])
AC_CONFIG_HEADERS([uim/config.h])
AM_INIT_AUTOMAKE([1.10 dist-bzip2])

AC_SUBST(UIM_VERSION_MAJOR, UIM_MAJOR_VERSION)
AC_SUBST(UIM_VERSION_MINOR, UIM_MINOR_VERSION)
AC_SUBST(UIM_VERSION_PATCHLEVEL, UIM_PATCHLEVEL_VERSION)

# Enable GNU extensions such as asprintf(3), BSD-originated functions,
# POSIX features and more on glibc (and some other
# implementations). See features.h. This macro should be placed here.
AC_GNU_SOURCE

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_OBJC
AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PATH_PROG(SH, sh)
AC_PATH_PROG(RSVG, rsvg-convert)
AC_PATH_PROG(CSI, csi)
AC_PATH_PROGS(MD5, md5 md5sum)
AC_PATH_PROGS(SHA1, sha1 sha1sum)
AC_PATH_PROGS(SED, sed gsed)
AX_PATH_QMAKE4

AM_MAINTAINER_MODE

# Checks for libraries
AC_CHECK_LIB(dl,dlopen)
AC_CHECK_LIB(socket,socket)

AX_LIB_GLIBC

dnl ***********************
dnl *** Tests for iconv ***
dnl ***********************
dnl
dnl We do this before the gettext checks, to avoid distortion

AM_ICONV
if test "$am_cv_func_iconv" != yes; then
  AC_MSG_ERROR([Could not find iconv(3) in libc or libiconv (required for uim)])
fi

AC_SUBST(LIBICONV)

dnl *************************
dnl *** Tests for m17nlib ***
dnl *************************

use_m17nlib="no"
AC_ARG_WITH(m17nlib,
  AS_HELP_STRING([--without-m17nlib],
                 [Don't build against m17nlib]),
  [
  if test "x$with_m17nlib" = "xyes"; then
    PKG_CHECK_MODULES(M17NLIB, m17n-shell >= 1.3.1, use_m17nlib="yes",use_m17nlib="no")
    AC_CHECK_PROG(M17NDB, m17n-db, m17n-db)
    if test -n "$M17NDB"; then
      m17n_db_dir=`$M17NDB`
    fi
  fi
  ],
  [
    PKG_CHECK_MODULES(M17NLIB, m17n-shell >= 1.3.1, use_m17nlib="yes",use_m17nlib="no")
    AC_CHECK_PROG(M17NDB, m17n-db, m17n-db)
    if test -n "$M17NDB"; then
      m17n_db_dir=`$M17NDB`
    fi
])

AC_SUBST(M17NLIB_LIBS)
AC_SUBST(m17n_db_dir)


AC_ARG_WITH(scim,
  AC_HELP_STRING([--with-scim],
                 [build against SCIM (broken)
		  @<:@default=no@:>@]),
  [
    case $with_scim in
      no)
        use_scim="no"
      ;;
      yes|*)
        PKG_CHECK_MODULES(SCIM, scim >= 1.3.0, use_scim="yes",use_scim="no")
      ;;
    esac
  ],
  [use_scim="no"] )

# ***********************
# *** Tests for Anthy ***
# ***********************
AC_ARG_WITH(anthy,
  AC_HELP_STRING([--without-anthy], [Don't build with libanthy]),
  [
    if test "x$with_anthy" = "xyes"; then
      AC_CHECK_HEADERS([anthy/anthy.h],
        [
          saved_LIBS=$LIBS
          LIBS="$LIBS -lanthy -lanthydic"
          AC_CHECK_LIB([anthy], [anthy_init], [use_anthy="yes"], [use_anthy="no"])
          LIBS=$saved_LIBS
        ],
        [use_anthy="no"])
    else
      use_anthy="no"
    fi
  ],
  [
    AC_CHECK_HEADERS([anthy/anthy.h],
     [
       saved_LIBS=$LIBS
       LIBS="$LIBS -lanthy -lanthydic"
       AC_CHECK_LIB([anthy], [anthy_init], [use_anthy="yes"], [use_anthy="no"])
       LIBS=$saved_LIBS
     ],
     [use_anthy="no"])
  ])

if test "x$use_anthy" = "xyes"; then
  ANTHY_LIBS="-lanthy -lanthydic"
  ANTHY_CFLAGS=""
  PKG_CHECK_EXISTS(anthy >= 8622,
		   [AC_DEFINE(LIBANTHY_UTF8_CAPABLE, 1,
		    "libanthy can handle UTF-8")])
fi
AC_SUBST(ANTHY_LIBS)
AC_SUBST(ANTHY_CFLAGS)

# *******************************
# *** Tests for Anthy (UTF-8) ***
# *******************************
AC_ARG_WITH(anthy-utf8,
  AC_HELP_STRING([--with-anthy-utf8],
		 [build with libanthy (UTF-8)
		 @<:@default=no@:>@]),
  [
    case $with_anthy_utf8 in
      no)
        use_anthy_utf8="no"
      ;;
      yes|*)
        PKG_CHECK_MODULES(ANTHY_UTF8, anthy >= 8622,
			  [use_anthy_utf8="yes"
			   AC_DEFINE(LIBANTHY_UTF8_CAPABLE, 1,
				     [libanthy can handle UTF-8])],
			   use_anthy_utf8="no")
      ;;
    esac
  ],
  [use_anthy_utf8="no"])

# ***********************
# *** Tests for Canna ***
# ***********************
AC_ARG_WITH(canna,
	AS_HELP_STRING([--with-canna], [Use Canna
					@<:@default=no@:>@]),
	[
	if test "x$with_canna" = "xyes"; then
    		 use_canna="yes"
	else
		use_canna="no"
	fi
	],[
	use_canna="no"
])

# *********************
# *** Tests for Wnn ***
# *********************
AC_ARG_WITH(wnn,
	AS_HELP_STRING([--with-wnn], [Build with libwnn
					@<:@default=no@:>@]),
	[
	if test "x$with_wnn" = "xyes"; then
	   	AM_PATH_WNN(use_wnn=yes, use_wnn=no)
	fi
	],[
	use_wnn="no"
])

# ***********************
# *** Tests for Mana ***
# ***********************
AC_ARG_WITH(mana,
	AS_HELP_STRING([--with-mana], [Build a plugin for Mana
				       @<:@default=yes@:>@]),
	[
	if test "x$with_mana" = "xyes"; then
	        AC_CHECK_PROG(MANA, mana, mana)
		if test -n "$MANA"; then
			use_mana="yes"
		else
			use_mana="no"
		fi
	else
		use_mana="no"
	fi
	],[
	        AC_CHECK_PROG(MANA, mana, mana)
		if test -n "$MANA"; then
			use_mana="yes"
		else
			use_mana="no"
		fi
])

# ***********************
# *** Tests for PRIME ***
# ***********************
AC_ARG_WITH(prime,
	AS_HELP_STRING([--with-prime], [Build a plugin for PRIME
					@<:@default=yes@:>@]),
	[
	if test "x$with_prime" = "xyes"; then
	        use_prime="yes"
	else
		use_prime="no"
	fi
	],[
	        PKG_CHECK_MODULES(PRIME, prime >= 0.8.5.2, use_prime="yes",use_prime="no")
])

# ***********************
# *** Tests for SJ3 ***
# ***********************
AC_ARG_WITH(sj3,
	AS_HELP_STRING([--with-sj3], [Use SJ3
					@<:@default=no@:>@]),
	[
	if test "x$with_sj3" = "xyes"; then
		use_sj3="yes"
	else
		use_sj3="no"
	fi
	],[
	        use_sj3="no"
])

# ***********************
# *** Tests for SKK ***
# ***********************
AC_ARG_WITH(skk,
	AS_HELP_STRING([--with-skk], [Build a plugin for SKK
					@<:@default=yes@:>@]),
	[
	if test "x$with_skk" = "xyes"; then
		use_skk="yes"
	else
		use_skk="no"
	fi
	],[
	        use_skk="yes"
])


# ***********************
# *** Tests for cURL ***
# ***********************
AC_ARG_WITH(curl,
	AS_HELP_STRING([--with-curl], [Build with libcurl
					@<:@default=no@:>@]),
	[
	if test "x$with_curl" = "xyes"; then
		PKG_CHECK_MODULES(CURL, libcurl >= 7.16.4, use_curl="yes", use_curl="no")
	else
		use_curl="no"
	fi
	],[
	use_curl="no"
])

# ***********************
# *** Tests for expat ***
# ***********************
expat_found=no
AM_WITH_EXPAT

# ***********************
# *** Tests for OpenSSL ***
# ***********************
AC_ARG_ENABLE(openssl,
  AC_HELP_STRING([--enable-openssl],
                 [enable openssl @<:@default=no@:>@]),
  [
    use_openssl="yes"
    AM_WITH_OPENSSL
  ],
  [
    use_openssl="no"
  ])


# *************************
# *** Tests for SQLite3 ***
# *************************
AC_ARG_WITH(sqlite3,
	AS_HELP_STRING([--with-sqlite3], [Build with SQLite3
					@<:@default=no@:>@]),
	[
	if test "x$with_sqlite3" = "xyes"; then
		PKG_CHECK_MODULES(SQLITE3, sqlite3 >= 3.0.0, use_sqlite3="yes", use_sqlite3="no")
	else
		use_sqlite3="no"
	fi
	],[
	use_sqlite3="no"
])

# ************************
# *** Tests for libffi ***
# ************************
AC_ARG_WITH(ffi,
	AS_HELP_STRING([--with-ffi], [Build with libffi
					@<:@default=no@:>@]),
	[
	if test "x$with_ffi" = "xyes"; then
		PKG_CHECK_MODULES(FFI, libffi >= 3.0.0, use_ffi="yes", use_ffi="no")
	else
		use_ffi="no"
	fi
	],[
	use_ffi="no"
])

PKG_CHECK_MODULES(X11, x11, x11_use_new_dir="yes", x11_use_new_dir="no")
AC_PATH_XTRA

use_xim="no"
if test x"$have_x" != "xdisabled" && test x"$have_x" != "xno"; then
   PKG_CHECK_MODULES(XIM, xext, use_xim="yes", use_xim="no")
   if test x"$use_xim" = "xyes"; then
     AC_CXX_NAMESPACES
     AC_CXX_HAVE_STL
     if test $ac_cv_cxx_have_stl = no; then
       use_xim="no"
     fi
   fi
   AC_MSG_CHECKING([whether to have Xft support])
   AM_PATH_XFT(yes, XFT=true, XFT=false)
   if test x"$XFT" = "xtrue" ; then
     saved_CFLAGS=$CFLAGS
     saved_LIBS=$LIBS
     CFLAGS="$CFLAGS $XFT_CFLAGS"
     LIBS="$LIBS $XFT_LIBS"
     AC_TRY_LINK([
#include <X11/Xft/Xft.h>], [ XftFontClose(0, 0); return 1; ], 
       [
         AC_DEFINE(WITH_XFT, 1, [font antialiasing support])
         AC_MSG_CHECKING([Xft UTF-8 support])
         AC_TRY_LINK([
#include <X11/Xft/Xft.h>
           ], [ 
XftDrawStringUtf8(0, 0, 0, 0, 0, 0, 0); return 0; 
           ],
             AC_DEFINE(HAVE_XFT_UTF8_STRING, 1, "Xft UTF8 support")
             AC_MSG_RESULT(yes),
             AC_MSG_RESULT(no)) 
       ],
       [
         AC_MSG_RESULT([***Could not link with Xft. Install Xft if you want support for it***])
         XFT=false
         XFT_CFLAGS=
         XFT_LIBS=
       ])
     CFLAGS=$saved_CFLAGS
     LIBS=$saved_LIBS
   fi
fi
AM_CONDITIONAL(WITH_XFT, test x"$XFT" = "xtrue")

# Checks for header files
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([stdint.h inttypes.h sys/inttypes.h sys/types.h])
AC_CHECK_HEADERS([fcntl.h locale.h stdlib.h unistd.h errno.h])
AC_CHECK_HEADERS([string.h sys/ioctl.h sys/socket.h termios.h sys/termios.h wchar.h])
AC_CHECK_HEADERS([sys/time.h sys/stat.h sys/un.h getopt.h assert.h signal.h term.h ncurses/term.h ctype.h pwd.h stdarg.h])
AC_CHECK_HEADERS([pty.h utmp.h util.h libutil.h])
AC_CHECK_HEADERS([curses.h stropts.h])
AC_CHECK_HEADERS([sys/param.h strings.h netdb.h sysexits.h])
AC_CHECK_HEADERS([poll.h sys/poll.h])

# Check for types
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INTMAX_T
AC_TYPE_INTPTR_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINTMAX_T
AC_TYPE_UINTPTR_T

AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_OFF_T

AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_CHECK_TYPES(sig_atomic_t, , ,
  [ #include <signal.h> ])
AC_CHECK_TYPES(sig_t, , ,
  [ #include <signal.h> ])

# Checks for structures

# Checks for compiler characteristics
AC_C_CONST

# FIXME: depending on the internal variable name
AC_DEFUN([AX_LANG_WNOERROR], [ac_[]_AC_LANG_ABBREV[]_werror_flag=])

AC_LANG_WERROR  # Turn warning-only unknown options into error.

AX_CFLAGS_GCC_OPTION([-pedantic])
AX_CFLAGS_GCC_OPTION([-pipe])
AX_CFLAGS_GCC_OPTION([-Wall])
AX_CFLAGS_GCC_OPTION([-Wchar-subscripts])
AX_CFLAGS_GCC_OPTION([-Wmissing-declarations])
AX_CFLAGS_GCC_OPTION([-Wredundant-decls])
AX_CFLAGS_GCC_OPTION([-Wmissing-prototypes])
AX_CFLAGS_GCC_OPTION([-Wnested-externs])
AX_CFLAGS_GCC_OPTION([-Wpointer-arith])
AX_CFLAGS_GCC_OPTION([-Wcast-align])
AX_CFLAGS_GCC_OPTION([-Wsign-compare])
AX_CFLAGS_GCC_OPTION([-Wno-long-long])

# Suppress warnings about strings longer than ISO C 89 maximum length (509).
AX_CFLAGS_GCC_OPTION([-Wno-overlength-strings])

# Disable the problematic preprocessing on Mac OS X
AX_CFLAGS_GCC_OPTION([-no-cpp-precomp])

# Deprecated autoconf macro used in AX_CXXFLAGS_GCC_OPTION.
AC_DEFUN([AC_LANG_CXX], [AC_LANG([C++])])

AX_CXXFLAGS_GCC_OPTION([-pipe])
AX_CXXFLAGS_GCC_OPTION([-W])
AX_CXXFLAGS_GCC_OPTION([-Wall])
AX_CXXFLAGS_GCC_OPTION([-Wchar-subscripts])
AX_CXXFLAGS_GCC_OPTION([-Wnon-virtual-dtor])
AX_CXXFLAGS_GCC_OPTION([-Wno-long-long])
AX_CXXFLAGS_GCC_OPTION([-Wcast-align])
AX_CXXFLAGS_GCC_OPTION([-Wconversion])
AX_CXXFLAGS_GCC_OPTION([-Wchar-subscripts])
AX_CXXFLAGS_GCC_OPTION([-Wpointer-arith])
AX_CXXFLAGS_GCC_OPTION([-Wwrite-strings])
AX_CXXFLAGS_GCC_OPTION([-Wformat-security])

AX_LANG_WNOERROR  # end AC_LANG_WERROR

AC_CHECK_DECL(LLONG_MAX, have_llong_max=1, , [#include <limits.h>])
# compute LLONG_MIN and LLONG_MAX if we don't know them.
if test -z "$have_llong_max"; then
	AC_MSG_CHECKING([for max value of long long])
	AC_RUN_IFELSE(
		[AC_LANG_SOURCE([[
#include <stdio.h>
/* Why is this so damn hard? */
#ifdef __GNUC__
# undef __GNUC__
#endif
#define __USE_ISOC99
#include <limits.h>
#define DATA "conftest.llminmax"
#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))

/*
 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
 * we do this the hard way.
 */
static int
fprint_ll(FILE *f, long long n)
{
	unsigned int i;
	int l[sizeof(long long) * 8];

	if (n < 0)
		if (fprintf(f, "-") < 0)
			return -1;
	for (i = 0; n != 0; i++) {
		l[i] = my_abs(n % 10);
		n /= 10;
	}
	do {
		if (fprintf(f, "%d", l[--i]) < 0)
			return -1;
	} while (i != 0);
	if (fprintf(f, " ") < 0)
		return -1;
	return 0;
}

int main(void) {
	FILE *f;
	long long i, llmin, llmax = 0, llmin1, llmax1;

	if((f = fopen(DATA,"w")) == NULL)
		exit(1);

#if defined(LLONG_MIN) && defined(LLONG_MAX)
	fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
	llmin = LLONG_MIN;
	llmax = LLONG_MAX;
#else
	fprintf(stderr, "Calculating  LLONG_MIN and LLONG_MAX\n");
	/* This will work on one's complement and two's complement */
	for (i = 1; i > llmax; i <<= 1, i++)
		llmax = i;
	llmin = llmax + 1LL;    /* wrap */
#endif

	/* Sanity check */
	llmin1 = llmin - 1;
	llmax1 = llmax + 1;
	if (llmin + 1 < llmin || llmin1 < llmin || llmax1 > llmax
	    || llmax - 1 > llmax || llmin == llmax || llmin == 0
	    || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
		fprintf(f, "unknown unknown\n");
		exit(2);
	}

	if (fprint_ll(f, llmin) < 0)
		exit(3);
	if (fprint_ll(f, llmax) < 0)
		exit(4);
	if (fclose(f) < 0)
		exit(5);
	exit(0);
}
		]])],
		[
			llong_min=`$AWK '{print $1}' conftest.llminmax`
			llong_max=`$AWK '{print $2}' conftest.llminmax`

			AC_MSG_RESULT($llong_max)
			AC_DEFINE_UNQUOTED(LLONG_MAX, [${llong_max}LL],
			    [max value of long long calculated by configure])
			AC_MSG_CHECKING([for min value of long long])
			AC_MSG_RESULT($llong_min)
			AC_DEFINE_UNQUOTED(LLONG_MIN, [${llong_min}LL],
			    [min value of long long calculated by configure])
		],
		[
			AC_MSG_RESULT(not found)
		],
		[
			AC_MSG_WARN([cross compiling: not checking])
		]
	)
fi

# Checks for library functions
AC_FUNC_REALLOC
AC_FUNC_ALLOCA
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AX_FUNC_SIGSETJMP
AC_FUNC_FORK
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_SELECT_ARGTYPES
AC_CHECK_FUNCS([cfmakeraw])
AC_CHECK_FUNCS([wcswidth])
# BSD functions
AC_CHECK_FUNCS([strdup])
# GNU functions
AC_CHECK_FUNCS([asprintf vasprintf])
# C99 functions
AC_CHECK_FUNCS([snprintf vsnprintf])
# FIXME: replace non-standard perror(3)
AC_REPLACE_FUNCS([getpeereid strsep setenv unsetenv strlcpy strlcat strtonum strtoll])
AC_CHECK_FUNCS([getpid stat mkdir chmod])
AC_CHECK_FUNCS([execv execvp])
AC_CHECK_FUNCS([isascii])
AC_CHECK_FUNCS([getaddrinfo freeaddrinfo getnameinfo])
AC_CHECK_FUNCS([issetugid])
AC_CHECK_FUNCS([poll])
AC_CHECK_FUNCS([waitpid])
AC_CHECK_FUNCS([daemon])

# IRIX has a const char return value for gai_strerror()
AC_CHECK_FUNCS(gai_strerror,[
        AC_DEFINE(HAVE_GAI_STRERROR)
        AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>

const char *gai_strerror(int);],[
char *str;

str = gai_strerror(0);],[
                AC_DEFINE(HAVE_CONST_GAI_STRERROR_PROTO, 1,
                [Define if gai_strerror() returns const char *])])])

# Check for broken snprintf
if test "x$ac_cv_func_snprintf" = "xyes" ; then
	AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
	AC_RUN_IFELSE(
		[AC_LANG_SOURCE([[
#include <stdio.h>
int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
		]])],
		[AC_MSG_RESULT(yes)],
		[
			AC_MSG_RESULT(no)
			AC_DEFINE(BROKEN_SNPRINTF, 1,
				[Define if your snprintf is busted])
			AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
		],
		[ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
	)
fi

# If we don't have a working asprintf, then we strongly depend on vsnprintf
# returning the right thing on overflow: the number of characters it tried to
# create (as per SUSv3)
if test "x$ac_cv_func_asprintf" != "xyes" && \
   test "x$ac_cv_func_vsnprintf" = "xyes" ; then
	AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
	AC_RUN_IFELSE(
		[AC_LANG_SOURCE([[
#include <sys/types.h>
#include <stdio.h>
#include <stdarg.h>

int x_snprintf(char *str,size_t count,const char *fmt,...)
{
	size_t ret; va_list ap;
	va_start(ap, fmt); ret = vsnprintf(str, count, fmt, ap); va_end(ap);
	return ret;
}
int main(void)
{
	char x[1];
	exit(x_snprintf(x, 1, "%s %d", "hello", 12345) == 11 ? 0 : 1);
} ]])],
		[AC_MSG_RESULT(yes)],
		[
			AC_MSG_RESULT(no)
			AC_DEFINE(BROKEN_SNPRINTF, 1,
				[Define if your snprintf is busted])
			AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
		],
		[ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
	)
fi

# On systems where [v]snprintf is broken, but is declared in stdio,
# check that the fmt argument is const char * or just char *.
# This is only useful for when BROKEN_SNPRINTF
AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
	   int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
	   int main(void) { snprintf(0, 0, 0); } 
    ]])],
   [AC_MSG_RESULT(yes)
    AC_DEFINE(SNPRINTF_CONST, [const],
              [Define as const if snprintf() can declare const char *fmt])],
   [AC_MSG_RESULT(no)
    AC_DEFINE(SNPRINTF_CONST, [/* not const */])])

AC_SEARCH_LIBS(dlfunc,dl,
  [
    AC_DEFINE(HAVE_DLFUNC, 1,
              [Define to 1 if you have the dlfunc function.])

  ])

# for uim-fep
AM_LANGINFO_CODESET

dnl Solaris 9 needs -lresolv for inet_aton
NETLIBS=""
AC_CHECK_FUNC(inet_aton, ,
  [AC_CHECK_LIB(resolv, inet_aton, [NETLIBS="-lresolv"])])
AC_SUBST(NETLIBS)

dnl socket related
AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
		],
		[ struct sockaddr_storage s; ],
		[ ac_cv_have_struct_sockaddr_storage="yes" ],
		[ ac_cv_have_struct_sockaddr_storage="no" ]
	)
])
if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
		[define if you have struct sockaddr_storage data type])
fi

dnl cred related
AC_CACHE_CHECK([for struct cmsgcred], ac_cv_have_struct_cmsgcred, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
		],
		[ struct cmsgcred s; ],
		[ ac_cv_have_struct_cmsgcred="yes" ],
		[ ac_cv_have_struct_cmsgcred="no" ]
	)
])
if test "x$ac_cv_have_struct_cmsgcred" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_CMSGCRED, 1,
		[define if you have struct cmsgcred data type])
fi

AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <netinet/in.h>
		],
		[ struct sockaddr_in6 s; s.sin6_family = 0; ],
		[ ac_cv_have_struct_sockaddr_in6="yes" ],
		[ ac_cv_have_struct_sockaddr_in6="no" ]
	)
])
if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1,
		[define if you have struct sockaddr_in6 data type])
fi

AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <netinet/in.h>
		],
		[ struct in6_addr s; s.s6_addr[0] = 0; ],
		[ ac_cv_have_struct_in6_addr="yes" ],
		[ ac_cv_have_struct_in6_addr="no" ]
	)
])
if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1,
		[define if you have struct in6_addr data type])
fi

AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
	AC_TRY_COMPILE(
		[
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
		],
		[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
		[ ac_cv_have_struct_addrinfo="yes" ],
		[ ac_cv_have_struct_addrinfo="no" ]
	)
])
if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1,
		[define if you have struct addrinfo data type])
fi


GETTEXT_PACKAGE=uim
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[gettext package name])

AM_GNU_GETTEXT([external], [need-ngettext])
AM_GNU_GETTEXT_VERSION([0.17])

# FIXME: Probably voilent way  -- YamaKen 2005-01-07
if test x$prefix = xNONE; then
   prefix=$ac_default_prefix
fi
if test x$exec_prefix = xNONE; then
   exec_prefix=$prefix
fi

# FIXME: complicated directory handlings  -- YamaKen 2006-07-08
# FIXME: double eval workaround for datarootdir
LIBDIR=`eval eval echo ${libdir}`
AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [libraries dir])
DATADIR=`eval eval echo ${datadir}`
AC_DEFINE_UNQUOTED(DATADIR, "$DATADIR", [read-only architecture-independent data dir])
UIM_LIBEXECDIR=`eval echo "${libexecdir}"`
AC_DEFINE_UNQUOTED(UIM_LIBEXECDIR, "$UIM_LIBEXECDIR", [libexec dir])
AC_SUBST(UIM_LIBEXECDIR)
# we should use more safe macro such as AC_EXPAND_DIR
LOCALEDIR=`eval eval echo ${datadir}/locale`
# backward compatibility
localedir=$LOCALEDIR
AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [locale dir])
AC_DEFINE_UNQUOTED(GNOMELOCALEDIR, "$LOCALEDIR", [locale dir for gnome])
AC_DEFINE_UNQUOTED(GNOME3LOCALEDIR, "$LOCALEDIR", [locale dir for gnome3])
# define XLIB directory for Compose file
if test "x$x11_use_new_dir" = "xyes"; then
  AC_DEFINE_UNQUOTED(XLIB_DIR, "`$PKG_CONFIG x11 --variable=prefix`/share", [X11 Library Directory])
else
  AC_DEFINE_UNQUOTED(XLIB_DIR, "$x_libraries", [X11 Library Directory])
fi
uim_pixmapsdir=`eval eval echo ${datadir}/${PACKAGE_TARNAME}/pixmaps`
AC_DEFINE_UNQUOTED(UIM_PIXMAPSDIR, "${uim_pixmapsdir}", [pixmaps directory])
AC_SUBST(uim_pixmapsdir)

dnl *****************************
dnl *** Check for Gtk Library ***
dnl *****************************
AC_ARG_WITH(gtk2,
  AC_HELP_STRING([--without-gtk2],
                 [don't build against Gtk+2]),
  [
    case $with_gtk2 in
      no)
        use_gtk2="no"
      ;;
      yes|*)
        PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.2.0 gdk-x11-2.0, use_gtk2="yes",use_gtk2="no")
        PKG_CHECK_MODULES(GTK2_4, gtk+-2.0 >= 2.4.0 gdk-x11-2.0, use_gtk2_4="yes",use_gtk2_4="no")
      ;;
    esac
  ],
  [ PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.2.0 gdk-x11-2.0, use_gtk2="yes",use_gtk2="no")
    PKG_CHECK_MODULES(GTK2_4, gtk+-2.0 >= 2.4.0 gdk-x11-2.0, use_gtk2_4="yes",use_gtk2_4="no") ])

AC_ARG_ENABLE(gnome-applet,
  AC_HELP_STRING([--disable-gnome-applet],
                 [disable uim applet for Gnome panel]),
  [
    case $enable_gnome_applet in
      no)
        use_applet_gnome="no"
      ;;
      yes|*)
        PKG_CHECK_MODULES(APPLET_GNOME, libpanelapplet-2.0, use_applet_gnome="yes",use_applet_gnome="no")
        PKG_CHECK_MODULES(APPLET_2_14, libpanelapplet-2.0 >= 2.14.0, panelapplet_have_set_background_api="yes",panelapplet_have_set_background_api="no")
      ;;
    esac
  ],
  [
    PKG_CHECK_MODULES(APPLET_GNOME, libpanelapplet-2.0, use_applet_gnome="yes",use_applet_gnome="no")
    PKG_CHECK_MODULES(APPLET_2_14, libpanelapplet-2.0 >= 2.14.0, panelapplet_have_set_background_api="yes",panelapplet_have_set_background_api="no")
  ])

if test x"$panelapplet_have_set_background_api" = xyes; then
  AC_DEFINE(LIBPANEL_APPLET_HAVE_SET_BACKGROUND_WIDGET, 1 , [libpanel-applet have set_background api])
fi


dnl ******************************
dnl *** Check for Gtk3 Library ***
dnl ******************************
AC_ARG_WITH(gtk3,
  AC_HELP_STRING([--with-gtk3],
                 [build GTK+3 immodule and helper applications
                  @<:@default=yes@:>@]),
  [
    case $with_gtk3 in
      no)
        use_gtk3="no"
      ;;
      yes|*)
        PKG_CHECK_MODULES(GTK3, gtk+-3.0, use_gtk3="yes",use_gtk3="no")
      ;;
    esac
  ],
  [ 
    PKG_CHECK_MODULES(GTK3, gtk+-3.0, use_gtk3="yes",use_gtk3="no")
  ])

AC_ARG_ENABLE(gnome3-applet,
  AC_HELP_STRING([--enable-gnome3-applet],
                 [enable uim applet for Gnome3 panel
            @<:@default=yes@:>@]),
  [
    case $enable_gnome3_applet in
      no)
        use_applet_gnome3="no"
      ;;
      yes|*)
        PKG_CHECK_MODULES(APPLET_GNOME3, libpanelapplet-4.0, use_applet_gnome3="yes",use_applet_gnome3="no")
      ;;
    esac
  ],
  [
    PKG_CHECK_MODULES(APPLET_GNOME3, libpanelapplet-4.0, use_applet_gnome3="yes",use_applet_gnome3="no")
  ])

dnl ****************************
dnl *** Check for Qt Library ***
dnl ****************************
AC_ARG_WITH(qt,
  AC_HELP_STRING([--with-qt],
                 [build qt helper applications
		  @<:@default=no@:>@]),
  [
    case $with_qt in
      no)
        use_qt="no"
      ;;
      yes|*)
        use_qt="yes"
      ;;
    esac
  ],
  [
    use_qt="no"
  ])

AC_ARG_WITH(qt-immodule,
  AC_HELP_STRING([--with-qt-immodule],
                 [Build qt-immodule extension
		  @<:@default=no@:>@]),
  [
    case $with_qtimmodule in
      no)
        use_qtimmodule="no"
      ;;
      yes|*)
        use_qtimmodule="yes"
      ;;
    esac

  ],
  [
    use_qtimmodule="no"
  ])

dnl *****************************
dnl *** Check for Qt4 Library ***
dnl *****************************
AC_ARG_WITH(qt4,
  AC_HELP_STRING([--with-qt4],
                 [build qt4 helper applications
		  @<:@default=no@:>@]),
  [
    case $with_qt4 in
      no)
        use_qt4="no"
      ;;
      yes|*)
        use_qt4="yes"
      ;;
    esac
  ],
  [
    use_qt4="no"
  ])


AC_ARG_WITH(qt4-immodule,
  AC_HELP_STRING([--with-qt4-immodule],
                 [Build qt4-immodule extension
		  @<:@default=no@:>@]),
  [
    case $with_qt4_immodule in
      no)
        use_qt4_immodule="no"
      ;;
      yes|*)
        use_qt4_immodule="yes"
      ;;
    esac

  ],
  [
    use_qt4_immodule="no"
  ])
if test x$use_qt4 = xyes || test x$use_qt4_immodule = xyes; then
    if test -z "$QMAKE4"; then
        AC_MSG_ERROR([no qmake for Qt4 found])
    fi
fi

dnl *****************************************
dnl *** test for Qt3Support module in Qt4 ***
dnl *****************************************
AC_ARG_ENABLE(qt4-qt3support,
  AC_HELP_STRING([--enable-qt4-qt3support],
        [enable support for Qt3Support module in Qt4 
            @<:@default=yes@:>@]),
        enable_qt4_qt3support=$enableval,
        enable_qt4_qt3support=yes)
case "$enable_qt4_qt3support" in
  no)
    use_qt4_qt3support="no"
    ;;
  yes|*)
    if test "x$use_qt4_immodule" = "xyes"; then
        if test -f `${QMAKE4} -query QT_INSTALL_LIBS`/libQt3Support.so; then
            use_qt4_qt3support="yes"
        else
            use_qt4_qt3support="no"
            AC_MSG_WARN([No Qt3Support found])
        fi
    else
        use_qt4_qt3support="no"
    fi
    ;;
esac

default_toolkit="gtk"
AC_ARG_ENABLE(default-toolkit,
  AC_HELP_STRING([--enable-default-toolkit],
                 [Determine default toolkit (gtk, gtk3, qt, or qt4)
		  @<:@default=gtk@:>@]),
  [
  if test x"$enable_default_toolkit" = "xgtk" && test x"$use_gtk2" = "xyes"; then
     default_toolkit="gtk"
  fi
  if test x"$enable_default_toolkit" = "xgtk3" && test x"$use_gtk3" = "xyes"; then
     default_toolkit="gtk3"
  fi
  if test x"$enable_default_toolkit" = "xqt" && test x"$use_qt" = "xyes"; then
     default_toolkit="qt"
  fi
  if test x"$enable_default_toolkit" = "xqt4" && test x"$use_qt4" = "xyes"; then
     default_toolkit="qt4"
  fi
  ],
  [])

AC_ARG_ENABLE(debug,
  AC_HELP_STRING([--enable-debug],
                 [enable debugging @<:@default=no@:>@]),
  [],
  [
    enable_debug="no"
  ])

AC_ARG_ENABLE(fep,
  AC_HELP_STRING([--disable-fep],
                 [disable uim-fep]),
  [
    case $enable_fep in
      no)
        use_uim_fep="no"
      ;;
      yes|*)
        use_uim_fep="yes"
	AC_CHECK_LIB(curses, setupterm, FEP_LIBADD="-lcurses $FEP_LIBADD",
	  [AC_CHECK_LIB(ncurses, setupterm, FEP_LIBADD="-lncurses $FEP_LIBADD",
	    AC_MSG_WARN([fep needs setupterm in libcurses or libncurses. disabled...]);use_uim_fep="no")])
	AC_CHECK_FUNCS(forkpty)
	if test $ac_cv_func_forkpty = no; then
	  AC_CHECK_LIB(util, forkpty, [AC_DEFINE(HAVE_FORKPTY) FEP_LIBADD="-lutil $FEP_LIBADD"])
	fi
	AC_SUBST(FEP_LIBADD)
      ;;
    esac
  ],
  [ use_uim_fep="yes"
    AC_CHECK_LIB(curses, setupterm, FEP_LIBADD="-lcurses $FEP_LIBADD",
      [AC_CHECK_LIB(ncurses, setupterm, FEP_LIBADD="-lncurses $FEP_LIBADD",
        AC_MSG_WARN([fep needs setupterm in libcurses or libncurses. disabled...]);use_uim_fep="no")])
    AC_CHECK_FUNCS(forkpty)
    if test $ac_cv_func_forkpty = no; then
      AC_CHECK_LIB(util, forkpty, [AC_DEFINE(HAVE_FORKPTY) FEP_LIBADD="-lutil $FEP_LIBADD"])
    fi
    AC_SUBST(FEP_LIBADD)
  ])

AC_ARG_ENABLE(emacs,
  AC_HELP_STRING([--disable-emacs],
                 [disable uim.el]),
  [
    case $enable_emacs in
      no)
        use_uim_el="no"
      ;;
      yes|*)
        use_uim_el="yes"
        AM_PATH_LISPDIR
        AC_SUBST(UIMEL_LISP_DIR, $lispdir/uim-el)
      ;;
    esac
  ],
  [ use_uim_el="yes"
    AM_PATH_LISPDIR
    AC_SUBST(UIMEL_LISP_DIR, $lispdir/uim-el)
  ])

AC_ARG_ENABLE(dict,
  AC_HELP_STRING([--enable-dict],
                 [build dictionary utility for uim (Anthy and Canna)
		  @<:@default=no@:>@]),
  [
    case $enable_dict in
      no)
        use_dict="no"
      ;;
      yes|*)
        PKG_CHECK_MODULES(DICT, gtk+-2.0 >= 2.4.0,
            use_dict="yes", use_dict="no")
        if test "x$use_dict" = "xno"; then
            PKG_CHECK_MODULES(DICT, gtk+-3.0, use_dict="yes", use_dict="no")
        fi
        if test "x$use_dict" = "xno"; then
           AC_MSG_WARN([dict needs GTK+ 2 (> 2.4) or GTK+ 3. dict disabled...])
        fi

      dnl Tests for -lcanna for dict
      if test "x$use_dict" = "xyes"; then
	      AC_CHECK_HEADERS([canna/RK.h],
			       [AC_CHECK_LIB(canna, RkInitialize, use_dict_canna="yes", use_dict_canna="no")],
			       [use_dict_canna="no"],
			       [ #undef _WCHAR_T ])
      else
	      use_dict_canna="no"
      fi

      if test "x$use_dict_canna" = "xno" && \
	 test "x$use_anthy" = "xno" && \
	 test "x$use_anthy_utf8" = "xno"; then
	 AC_MSG_WARN([no dictionary backend is usable.  disabled...])
	 use_dict="no"
      fi
      ;;
    esac
  ],
  [ use_dict="no" ])
AM_CONDITIONAL(DICT_CANNA, test "x$use_dict_canna" = "xyes")

dnl ****************************
dnl *** Tests for EB Library ***
dnl ****************************

AC_ARG_WITH(eb,
  AS_HELP_STRING([--with-eb],
                 [Build with EB @<:@default=no@:>@]),
  [
  if test "x$with_eb" = "xyes"; then
    eb_LIB_EB4()
    use_eb="$try_eb"
  else
    use_eb="no"
  fi
  ],
  [
  use_eb="no"
])
if test "x$use_eb" = "xyes"; then
  AC_DEFINE(HAVE_EBLIB, 1, [Define to 1 if you have EB library and header file])
fi

dnl test for OS X
AC_ARG_WITH(osx-dcs,
  AS_HELP_STRING([--with-osx-dcs],
		 [Build with OS X Dictionary Services @<:@default=no@:>@]),
  [
  if test "x$with_osx_dcs" = "xyes"; then
    case $host_os in
    darwin*)
      use_osx_dcs="yes"
      ;;
    *)
      use_osx_dcs="no"
      ;;
    esac
  else
    use_osx_dcs="no"
  fi
  ],
   use_osx_dcs="no"
)
AM_CONDITIONAL(OSX_DCS, test x"$use_osx_dcs" = "xyes")

# Check whether user wants libedit support
# This code was based on openssh-4.1p1

AC_ARG_WITH(libedit,
AC_HELP_STRING([--with-libedit[=DIR], Enable libedit support
				      @<:@default=yes@:>@]),
  [
   if test "x$with_libedit" != "xno"; then
        use_libedit="yes"
	if test "x$withval" = "xyes"; then
		libedit_path=/usr
	else
		libedit_path="$withval"
	fi
   else
        use_libedit="no"
   fi
  ],
  [use_libedit="yes"])

if test "x$use_libedit" != "xno"; then
    saved_CPPFLAGS=$CPPFLAGS
    saved_LDFLAGS=$LDFLAGS
    CPPFLAGS="${CPPFLAGS} -I$libedit_path/include"
    LDFLAGS="${LDFLAGS} -L$libedit_path/lib"
    AC_CHECK_LIB(curses, tgetent, LIBEDIT_LIBS="-lcurses",
        [AC_CHECK_LIB(ncurses, tgetent, LIBEDIT_LIBS="-lncurses",
            AC_MSG_WARN("libedit needs libcurses or libncurses. disabled...")
            use_libedit="no")])
    if test "x$use_libedit" != "xno"; then
        AC_CHECK_LIB(edit, el_init,
            [LIBEDIT_LIBS="-ledit $LIBEDIT_LIBS -L$libedit_path/lib"
                AC_SUBST(LIBEDIT_LIBS)],
            [AC_MSG_WARN("libedit not found. Disabled...")
                use_libedit="no"])
    fi
    CPPFLAGS=$saved_CPPFLAGS
    LDFLAGS=$saved_LDFLAGS
fi

dnl for uim-dict.xml.in
if test "x$use_anthy" = "xyes" || test "x$use_anthy_utf8" = "xyes"; then
  UI_XML_ANTHY_START=""
  UI_XML_ANTHY_END=""
else
  UI_XML_ANTHY_START="<!--"
  UI_XML_ANTHY_END="-->"
fi
if test "x$use_dict_canna" = "xyes"; then
  UI_XML_CANNA_START=""
  UI_XML_CANNA_END=""
else
  UI_XML_CANNA_START="<!--"
  UI_XML_CANNA_END="-->"
fi
AC_SUBST(UI_XML_ANTHY_START)
AC_SUBST(UI_XML_ANTHY_END)
AC_SUBST(UI_XML_CANNA_START)
AC_SUBST(UI_XML_CANNA_END)


AM_CONDITIONAL(M17NLIB, test x$use_m17nlib = xyes)
AM_CONDITIONAL(SCIM, test x$use_scim = xyes)
AM_CONDITIONAL(ANTHY, test x$use_anthy = xyes)
AM_CONDITIONAL(ANTHY_UTF8, test x$use_anthy_utf8 = xyes)
AM_CONDITIONAL(CANNA, test x$use_canna = xyes)
AM_CONDITIONAL(WNN, test x$use_wnn = xyes)
AM_CONDITIONAL(MANA, test x$use_mana = xyes)
AM_CONDITIONAL(PRIME, test x$use_prime = xyes)
AM_CONDITIONAL(SJ3, test x$use_sj3 = xyes)
AM_CONDITIONAL(SKK, test x$use_skk = xyes)
AM_CONDITIONAL(CURL, test x$use_curl = xyes)
AM_CONDITIONAL(EXPAT, test x$expat_found = xyes)
AM_CONDITIONAL(OPENSSL, test x$use_openssl = xyes)
AM_CONDITIONAL(SQLITE3, test x$use_sqlite3 = xyes)
AM_CONDITIONAL(FFI, test x$use_ffi = xyes)
AM_CONDITIONAL(GTK2, test x$use_gtk2 = xyes)
AM_CONDITIONAL(GTK2_4, test x$use_gtk2_4 = xyes)
AM_CONDITIONAL(GTK3, test x$use_gtk3 = xyes)
AM_CONDITIONAL(DEFAULT_TOOLKIT_GTK, test x$default_toolkit = xgtk)
AM_CONDITIONAL(DEFAULT_TOOLKIT_GTK3, test x$default_toolkit = xgtk3)
AM_CONDITIONAL(DEFAULT_TOOLKIT_QT,  test x$default_toolkit = xqt)
AM_CONDITIONAL(DEFAULT_TOOLKIT_QT4, test x$default_toolkit = xqt4)
AM_CONDITIONAL(APPLET_GNOME, test x$use_applet_gnome = xyes)
AM_CONDITIONAL(APPLET_GNOME3, test x$use_applet_gnome3 = xyes)
AM_CONDITIONAL(UIM_FEP, test x$use_uim_fep = xyes)
AM_CONDITIONAL(UIM_EL, test x$use_uim_el = xyes)
AM_CONDITIONAL(XIM, test x$use_xim = xyes)
AM_CONDITIONAL(DICT, test x$use_dict = xyes)
AM_CONDITIONAL(EB, test x$use_eb = xyes)
AM_CONDITIONAL(LIBEDIT, test x$use_libedit = xyes)
AM_CONDITIONAL(DEBUG, test x$enable_debug = xyes)
AM_CONDITIONAL(LIBUIM_X_UTIL, test x$have_x = xyes)
AM_CONDITIONAL(NEED_SETENV_C, test $ac_cv_func_setenv = no -o $ac_cv_func_unsetenv = no)
AM_CONDITIONAL(NEED_STRSEP_C, test $ac_cv_func_strsep = no)
AM_CONDITIONAL(GCC, test x$ac_cv_c_compiler_gnu = xyes)
AM_CONDITIONAL(GXX, test x$ac_cv_cxx_compiler_gnu = xyes)

IT_PROG_INTLTOOL([0.36.3], [no-xml])

GTK_BINARY_VERSION=`$PKG_CONFIG gtk+-2.0 --variable=gtk_binary_version`
GTK_LIBDIR=`$PKG_CONFIG gtk+-2.0 --variable=libdir`
AC_SUBST(GTK_BINARY_VERSION)
AC_SUBST(GTK_LIBDIR)

GTK3_BINARY_VERSION=`$PKG_CONFIG gtk+-3.0 --variable=gtk_binary_version`
GTK3_LIBDIR=`$PKG_CONFIG gtk+-3.0 --variable=libdir`
AC_SUBST(GTK3_BINARY_VERSION)
AC_SUBST(GTK3_LIBDIR)

if test x$use_gtk2 = xyes ; then
AC_DEFINE(USE_GTK2, 1, [use gtk2])
fi

if test x$use_gtk3 = xyes ; then
    AC_DEFINE(USE_GTK3, 1, [use gtk3])
fi

if test x$use_qt = xyes ; then
    # minimum version
    QT_VERSION=3.2.0
    QT_VERSION_NUM=0x030200

    # GUESS $QTDIR
    if test ! -d "$QTDIR"; then
      QTDIR="/usr/lib/qt3"
    fi
    if test ! -d "$QTDIR"; then
      QTDIR="/usr/lib/qt"
    fi
    if test ! -d "$QTDIR"; then
      QTDIR="/usr"
    fi
    AC_MSG_CHECKING(for Qt3 library dir)
    if test ! -d "$QTDIR"; then
      AC_MSG_RESULT(no)
    else
      AC_MSG_RESULT($QTDIR)
    fi

    # GUESS $QTINCDIR from $QTDIR
    QTINCDIR="$QTDIR/include/qt"
    if test ! -d "$QTINCDIR"; then
       QTINCDIR="$QTDIR/include/X11/qt"
    fi
    if test ! -d "$QTINCDIR"; then
       QTINCDIR="$QTDIR/include/qt3"
    fi
    if test ! -d "$QTINCDIR"; then
       QTINCDIR="$QTDIR/include"
    fi
    # GUESS $QTINCDIR independently
    if test ! -d "$QTINCDIR"; then
       QTINCDIR="/usr/include/X11/qt"
    fi
    if test ! -d "$QTINCDIR"; then
       QTINCDIR="/usr/include/qt3"
    fi
    if test ! -d "$QTINCDIR"; then
       QTINCDIR="/usr/include/qt"
    fi
    if test ! -d "$QTINCDIR"; then
       QTINCDIR="/usr/include"
    fi

    # GUESS $QTLIBDIR
    QTLIBDIR="$QTDIR/lib64"
    if test ! -d "$QTLIBDIR"; then
       QTLIBDIR="$QTDIR/lib"
    fi
    if test ! -d "$QTLIBDIR"; then
       QTLIBDIR="/usr/lib/qt3"
    fi
    if test ! -d "$QTLIBDIR"; then
       QTLIBDIR="/usr/lib/qt"
    fi
    if test ! -d "$QTLIBDIR"; then
       QTLIBDIR="/usr/lib"
    fi

    # Check For MOC
    if test -x "$QTDIR/bin/moc"; then
      HOST_MOC="$QTDIR/bin/moc"
    else
      AC_CHECK_PROGS(HOST_MOC, moc-qt3 moc, "")
    fi
    if test -z "$HOST_MOC"; then
      AC_MSG_ERROR([no acceptable moc( meta object compiler ) found])
    fi
    MOC=$HOST_MOC

    # Check For UIC
    if test -x "$QTDIR/bin/uic"; then
      HOST_UIC="$QTDIR/bin/uic"
    else
      AC_CHECK_PROGS(HOST_UIC, uic-qt3 uic, "")
    fi
    if test -z "$HOST_UIC"; then
      AC_MSG_ERROR([no acceptable uic( user interface compiler ) found])
    fi
    UIC=$HOST_UIC

    # GUESS plugins dir for immodule installation
    AC_MSG_CHECKING(for qt-immodule plugins dir)
    if test ! -d "$QTDIR/plugins"; then
      AC_MSG_RESULT(no)
    else
      QT_PLUGINSDIR=$QTDIR/plugins
      AC_MSG_RESULT($QT_PLUGINSDIR)
      AC_SUBST(QT_PLUGINSDIR)
    fi

    # Process for compiler & linker flags
    QT_CXXFLAGS="-I${QTINCDIR} -DQT_GENUINE_STR -DQT_NO_STL"
    if test -z "$enable_debug"; then
      QT_CXXFLAGS="$QT_CXXFLAGS -DQT_NO_DEBUG -DNO_DEBUG"
    fi
    _SAVE_LDFLAGS=$LDFLAGS
    QT_LDFLAGS=-L${QTLIBDIR}
    LDFLAGS="$LDFLAGS $QT_LDFLAGS"
    AC_LANG_SAVE
    AC_LANG_CPLUSPLUS
    AC_CHECK_LIB(qt, main, QT_LIB=-lqt,
        AC_CHECK_LIB(qt-mt, main, QT_LIB=-lqt-mt,
            AC_MSG_ERROR([Cannot find QT libraries.])))

    if test "$QT_LIB" = "-lqt-mt"; then
      QT_CXXFLAGS="$QT_CXXFLAGS -DQT_THREAD_SUPPORT"
    fi

    LDFLAGS=$_SAVE_LDFLAGS
    QT_LIBS="$X_LIBS $QT_LDFLAGS $QT_LIB -lXext -lX11"

    _SAVE_CXXFLAGS=$CXXFLAGS
    _SAVE_LIBS=$LIBS

    CXXFLAGS="$CXXFLAGS $QT_CXXFLAGS"
    LIBS="$LIBS $QT_LIBS"

    AC_MSG_CHECKING(Qt - version >= $QT_VERSION)
    AC_TRY_COMPILE([#include <qglobal.h>],
    [
        #if (QT_VERSION < $QT_VERSION_NUM)
            #error  "QT_VERSION too old"
        #endif
    ],result="yes",result="no")

    AC_MSG_RESULT("$result")
    if test "$result" = "no"; then
       use_qt="no"
       AC_MSG_WARN([Qt Helper requires at least version $QT_VERSION of Qt])
    fi
    CXXFLAGS=$_SAVE_CXXFLAGS
    LIBS=$_SAVE_LIBS

    AC_LANG_RESTORE

    UIM_QT_LDFLAGS=$QT_LIBS
    UIM_QT_CXXFLAGS=$QT_CXXFLAGS

    AC_SUBST(MOC)
    AC_SUBST(UIC)
    AC_SUBST(UIM_QT_CXXFLAGS)
    AC_SUBST(UIM_QT_LDFLAGS)
fi

AC_PATH_PROG(KDE_CONFIG, [kde-config], [no])
if test "x$use_qt" = "xyes"; then
    if test "x$KDE_CONFIG" != "xno"; then
	KDE_ICONDIR=`$KDE_CONFIG --expandvars --install icon`
    fi
    if test -z "$KDE_ICONDIR"; then
      KDE_ICONDIR="$prefix/share/icons"
    fi
    AC_DEFINE_UNQUOTED(KDE_ICONDIR, "$KDE_ICONDIR", [kde icon directory])
fi

dnl **********************************
dnl *** test for KDE3 applet.. XXX ***
dnl **********************************
AC_ARG_ENABLE(kde-applet,
  AC_HELP_STRING([--enable-kde-applet],
  		 [build uim applet for KDE panel
		  @<:@default=yes@:>@]),
		 enable_kde_applet=$enableval,
		 enable_kde_applet=yes)
case "$enable_kde_applet" in
  no)
    use_applet_kde="no"
    ;;
  yes|*)
    if test "x$use_qt" = "xyes"; then
      if test "x$KDE_CONFIG" != "xno"; then
	KDE_PREFIX=`kde-config --prefix`
	KDE_LIB_DIR=`kde-config --expandvars --install lib`
	KDE_DATA_DIR=`kde-config --expandvars --install data`
	saved_cppflags="${CPPFLAGS}"
	CPPFLAGS="-I${KDE_PREFIX}/include/kde ${CPPFLAGS} ${QT_CXXFLAGS}"
	AC_LANG_PUSH(C++)
	AC_CHECK_HEADER([${KDE_PREFIX}/include/kde/kpanelapplet.h],
			[use_applet_kde="yes" KDE_INCLUDE_DIR="${KDE_PREFIX}/include/kde"], [use_applet_kde="no"])
	if test "x$use_applet_kde" = "xno"; then
	  CPPFLAGS="-I${KDE_PREFIX}/include ${saved_cppflags} ${QT_CXXFLAGS}"
	  AC_CHECK_HEADER([${KDE_PREFIX}/include/kglobal.h],
	  		  [use_applet_kde="yes" KDE_INCLUDE_DIR="${KDE_PREFIX}/include"], [use_applet_kde="no"])
	fi
	CPPFLAGS="${saved_cppflags}"
	AC_LANG_POP(C++)
      else
	use_applet_kde="no"
      fi
    else
      use_applet_kde="no"
    fi
    ;;
esac
AC_SUBST(KDE_PREFIX)
AC_SUBST(KDE_LIB_DIR)
AC_SUBST(KDE_DATA_DIR)
AC_SUBST(KDE_INCLUDE_DIR)

dnl ****************************
dnl *** test for KDE4 applet ***
dnl ****************************
AC_ARG_ENABLE(kde4-applet,
  AC_HELP_STRING([--enable-kde4-applet],
        [build uim applet for KDE4 panel (experimental)
            @<:@default=no@:>@]),
        enable_kde4_applet=$enableval,
        enable_kde4_applet=no)
case "$enable_kde4_applet" in
  no)
    use_applet_kde4="no"
    ;;
  yes|*)
    if test "x$use_qt4" = "xyes"; then
        use_applet_kde4="yes"
    else
        use_applet_kde4="no"
    fi
    ;;
esac
AC_PATH_PROG(CMAKE, [cmake], [no])
if test "x$use_applet_kde4" = "xyes" && test "x$CMAKE" = "xno"; then
    AC_MSG_WARN([no CMake found])
    use_applet_kde4="no"
fi
AC_PATH_PROG(KDE4_CONFIG, [kde4-config], [no])
if test "x$use_qt4" = "xyes"; then
    if test "x$KDE4_CONFIG" != "xno"; then
        KDE4_ICONDIR=`$KDE4_CONFIG --expandvars --install icon`
    fi
    if test -z "$KDE4_ICONDIR"; then
        KDE4_ICONDIR="$prefix/share/icons"
    fi
    AC_DEFINE_UNQUOTED(KDE4_ICONDIR, "$KDE4_ICONDIR", [kde4 icon directory])
fi
if test "x$use_applet_kde4" = "xyes" && test "x$KDE4_CONFIG" = "xno"; then
    AC_MSG_WARN([no kde4-config found])
    use_applet_kde4="no"
fi

if test x$use_qtimmodule = xyes ; then
    AC_MSG_CHECKING(for qt-immodule patch)
    # Check for immodule for Qt patch
    if test ! -f $QTINCDIR/qinputcontext.h  || test ! -f $QTINCDIR/qinputcontextplugin.h; then
      AC_MSG_RESULT(no)
      use_qtimmodule="cannot"
    else
      AC_MSG_RESULT(yes)
    fi
fi


AM_CONDITIONAL(QT, test x$use_qt = xyes)
AM_CONDITIONAL(QT_IMMODULE, test x$use_qtimmodule = xyes)
AM_CONDITIONAL(APPLET_KDE, test x$use_applet_kde = xyes)
AM_CONDITIONAL(QT4, test x$use_qt4 = xyes)
AM_CONDITIONAL(QT4_IMMODULE, test x$use_qt4_immodule = xyes)
AM_CONDITIONAL(APPLET_KDE4, test x$use_applet_kde4 = xyes)

AC_ARG_ENABLE(pref,
  AC_HELP_STRING([--enable-pref],
		 [build graphical utility to edit user settings
		  @<:@default=yes@:>@]),
[
    case $enable_pref in
      no)
        use_pref="no"
	;;
      yes|*)
	if test x"$default_toolkit" = "xgtk" && \
	   test x"$use_gtk2_4" = "xyes"; then
	  use_pref="yes"
	elif test x"$default_toolkit" = "xgtk3" && \
	     test x"$use_gtk3" = "xyes"; then
	  use_pref="yes"
	elif test x"$default_toolkit" = "xqt" && \
	     test x"$use_qt" = "xyes"; then
	  use_pref="yes"
	elif test x"$default_toolkit" = "xqt4" && \
	     test x"$use_qt4" = "xyes"; then
	  use_pref="yes"
	else
	  use_pref="no"
	  AC_MSG_WARN([uim-pref needs Gtk+ or Qt toolkit, disabled...])
	fi
	;;
    esac ],
  [
    if test x"$default_toolkit" = "xgtk" && \
       test x"$use_gtk2_4" = "xyes"; then
      use_pref="yes"
    elif test x"$default_toolkit" = "xgtk3" && \
         test x"$use_gtk3" = "xyes"; then
      use_pref="yes"
    elif test x"$default_toolkit" = "xqt" && \
         test x"$use_qt" = "xyes"; then
      use_pref="yes"
    elif test x"$default_toolkit" = "xqt4" && \
         test x"$use_qt4" = "xyes"; then
      use_pref="yes"
    else
      use_pref="no"
      AC_MSG_WARN([uim pref needs Gtk+ or Qt toolkit, disabled...])
    fi
  ])
AM_CONDITIONAL(PREF, test x"$use_pref" = "xyes")

AC_ARG_ENABLE(anthy-static,
    AC_HELP_STRING([--enable-anthy-static],
		   [@<:@default=no@:>@]),
    [
        case $enable_anthy_static in
	yes)
	    build_anthy_static="yes"
	    ;;
	no|*)
	    build_anthy_static="no"
	    ;;
	esac
    ], [
	    build_anthy_static="no"
    ])

AM_CONDITIONAL(ENABLE_ANTHY_STATIC, test x$build_anthy_static = xyes)

AC_ARG_ENABLE(anthy-utf8-static,
    AC_HELP_STRING([--enable-anthy-utf8-static],
		   [@<:@default=no@:>@]),
    [
        case $enable_anthy_utf8_static in
	yes)
	    build_anthy_utf8_static="yes"
	    ;;
	no|*)
	    build_anthy_utf8_static="no"
	    ;;
	esac
    ], [
	    build_anthy_utf8_static="no"
    ])

AM_CONDITIONAL(ENABLE_ANTHY_UTF8_STATIC, test x$build_anthy_utf8_static = xyes)

# ****************************
# *** Tests for uim-notify ***
# ****************************
notify_targets='stderr libnotify knotify3 knotify4 growl'

AC_ARG_ENABLE(notify,
  AS_HELP_STRING([--enable-notify@<:@=agent-list@:>@ (HIGHLY EXPERIMENTAL)],
                 [enable system message notification for users
		  (specify comma separated notification agent list
		  from stderr, libnotify, knotify3, knotify4 and growl)]),
  [ enable_notify=$enableval
    have_notify_opt=yes ],
  [ enable_notify=yes
    have_notify_opt=no ])

if test "x$enable_notify" != xno; then
  AC_DEFINE(UIM_USE_NOTIFY_PLUGINS, 1, [Define to 1 if you want to use uim-notify plugins])
  use_notify="${use_notify}stderr "

  for i in `echo $enable_notify | ${SED} 's/,/ /g'`; do
    eval "au_enable_$i=yes"
  done
fi

AC_MSG_CHECKING([whether libnotify is requested])
if test "x$au_enable_libnotify" = xyes; then
  AC_MSG_RESULT([yes])
  PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= 0.4, use_libnotify="yes",
					       use_libnotify="no")
  if test "x$use_libnotify" = "xyes"; then
    AC_DEFINE(ENABLE_LIBNOTIFY, 1, [set notify interface with libnotify])
    AC_SUBST(LIBNOTIFY_LIBS)
    AC_SUBST(LIBNOTIFY_CFLAGS)
    use_notify="${use_notify}libnotify "
  fi
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING([whether knotify3 is requested])
if test "x$au_enable_knotify3" = xyes; then
  AC_MSG_RESULT([yes])
  if test "x$use_qt4_immodule" = "xyes"; then
    AC_MSG_WARN([knotify3 couldn't be used with qt4-immodule enabled])
    use_knotify3="no"
  elif test "x$use_qt" = "xyes"; then
    if test "x$KDE_CONFIG" != "xno"; then
      KNOTIFY3_PREFIX=`kde-config --prefix`
      KNOTIFY3_LIB_DIR=`kde-config --expandvars --install lib`
      KNOTIFY3_DATA_DIR=`kde-config --expandvars --install data`
      saved_cppflags="${CPPFLAGS}"
      CPPFLAGS="-I${KNOTIFY3_PREFIX}/include/kde ${CPPFLAGS} ${QT_CXXFLAGS}"
      AC_LANG_PUSH(C++)
      AC_CHECK_HEADER([${KNOTIFY3_PREFIX}/include/kde/knotifyclient.h],
                      [use_knotify3="yes" KNOTIFY3_INCLUDE_DIR="${KNOTIFY3_PREFIX}/include/kde"], [use_knotify3="no"])
      if test "x$use_knotify3" = "xno"; then
        CPPFLAGS="-I${KNOTIFY3_PREFIX}/include ${saved_cppflags} ${QT_CXXFLAGS}"
        AC_CHECK_HEADER([${KNOTIFY3_PREFIX}/include/knotifyclient.h],
                        [use_knotify3="yes" KNOTIFY3_INCLUDE_DIR="${KNOTIFY3_PREFIX}/include"], [use_knotify3="no"])
      fi
      CPPFLAGS="${saved_cppflags}"
      AC_LANG_POP(C++)
    else
      use_knotify3="no"
    fi
  else
    use_knotify3="no"
  fi
else
  AC_MSG_RESULT(no)
fi
if test "x$use_knotify3" = "xyes"; then
  AC_DEFINE(ENABLE_KNOTIFY3, 1, [set notify interface with knotify3])
  AC_SUBST(KNOTIFY3_PREFIX)
  AC_SUBST(KNOTIFY3_LIB_DIR)
  AC_SUBST(KNOTIFY3_DATA_DIR)
  AC_SUBST(KNOTIFY3_INCLUDE_DIR)
  use_notify="${use_notify}knotify3 "
fi

AC_MSG_CHECKING([whether knotify4 is requested])
if test "x$au_enable_knotify4" = xyes; then
  if test "x$CMAKE" != "xno"; then
    AC_MSG_RESULT([yes])
    use_knotify4="yes"
    use_notify="${use_notify}knotify4 "
  else
    AC_MSG_WARN([no CMake found])
    use_knotify4="no"
  fi
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING([whether growl is requested])
if test "x$au_enable_growl" = xyes; then
  AC_MSG_RESULT([yes])
  use_growl="yes"
  use_notify="${use_notify}growl "
else
  AC_MSG_RESULT(no)
fi

if test "x$use_notify" = "x"; then
  use_notify=none
fi

AM_CONDITIONAL(NOTIFY, test "x$enable_notify" != xno)
AM_CONDITIONAL(LIBNOTIFY, test x$use_libnotify = xyes)
AM_CONDITIONAL(KNOTIFY3, test x$use_knotify3 = xyes)
AM_CONDITIONAL(KNOTIFY4, test x$use_knotify4 = xyes)
AM_CONDITIONAL(GROWL, test x$use_growl = xyes)


AC_DEFINE(UIM_USE_ERROR_GUARD, 1, [Define to 1 if you want to use longjmp-based error handlings])

#
# Compiler options
#

# Debugging-related flags
if test "x$enable_debug" = xyes; then
  # add -g flag to CFLAGS regardless of GCC=yes or not
  if test "x$ac_cv_prog_cc_g" = xyes; then
    CFLAGS="$CFLAGS -g"
    CXXFLAGS="$CXXFLAGS -g"
  fi

  # Restricting the C dialect tends to cause system library disfunction such as
  # on glibc and Darwin libc. So this option is only specified at debugging
  # mode.
  #
  # -std=gnu89 is required only for (old?) glibc. -std=c89 is sufficient for
  # other environments.
  AC_LANG_WERROR  # Turn warning-only unknown options into error.
  if test "x$ax_cv_lib_glibc" = xyes; then
    AX_CFLAGS_GCC_OPTION([-std=gnu89])
  else
    AX_CFLAGS_GCC_OPTION([-std=c89])
  fi
  AX_LANG_WNOERROR  # end AC_LANG_WERROR

  QT_CONFIG_OPTS="debug"
else
  CFLAGS="$CFLAGS -DNDEBUG"
  CXXFLAGS="$CXXFLAGS -DNDEBUG"

  # Suppress the warnings of combined-mode SigScheme
  AC_LANG_WERROR  # Turn warning-only unknown options into error.
  AX_CFLAGS_GCC_OPTION([-Wno-redundant-decls], [UIM_SCM_CFLAGS])
  AX_CFLAGS_GCC_OPTION([-Wno-unused-function], [UIM_SCM_CFLAGS])
  AX_LANG_WNOERROR  # end AC_LANG_WERROR

  # Suppress the warnings of libuim-scim
  AC_LANG_WERROR  # Turn warning-only unknown options into error.
  AX_CFLAGS_GCC_OPTION([-Wno-unused-function],  [SCIM_CFLAGS])
  AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter], [SCIM_CFLAGS])
  AX_CFLAGS_GCC_OPTION([-Wno-unused-variable],  [SCIM_CFLAGS])
  AX_LANG_WNOERROR  # end AC_LANG_WERROR

  QT_CONFIG_OPTS="release"
fi

AC_ARG_ENABLE(warnings-into-error,
    AC_HELP_STRING([--enable-warnings-into-error],
		   [Treat compiler warnings as error @<:@default=no if !debug@:>@]),
    [
        case $enable_warnings_into_error in
	no)
	    ;;
	yes|*)
	    AX_CFLAGS_GCC_OPTION([-Werror])
	    AX_CXXFLAGS_GCC_OPTION([-Werror])
	    ;;
	esac
    ], [
	    # Enable -Werror by default if --enable-debug. But since
	    # the C89 string length limit always cause the warnings, I
	    # disable it for uim-scm.c.  -- YamaKen 2007-07-19
	    if test x$enable_debug = xyes; then
	      AX_CFLAGS_GCC_OPTION([-Werror])
	      AX_CXXFLAGS_GCC_OPTION([-Werror])
  	      AX_CFLAGS_GCC_OPTION([-Wno-error], [UIM_SCM_CFLAGS])
  	      AX_CFLAGS_GCC_OPTION([-Wno-error], [SCIM_CFLAGS])
	    fi
    ])
AC_SUBST(UIM_SCM_CFLAGS)
AC_SUBST(SCIM_CFLAGS)
AC_SUBST(QT_CONFIG_OPTS)

dnl *************************
dnl *** Tests for gosh and GaUnit ***
dnl *************************
AC_PATH_PROG([GOSH], gosh)
AC_PATH_PROG([GAUCHE_CONFIG], gauche-config)
AC_MSG_CHECKING([whether to have gosh and GaUnit])
if test -n "$GOSH" && test -n "$GAUCHE_CONFIG"; then
  gauche_version=`$GAUCHE_CONFIG -V`
  gauche_major_version=`echo $gauche_version | \
          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  gauche_minor_version=`echo $gauche_version | \
          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  gauche_micro_version=`echo $gauche_version | \
          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  dnl require 0.8.13
  if test "$gauche_major_version" -gt 0 || \
     test "$gauche_major_version" -eq 0 -a "$gauche_minor_version" -gt 8 || \
     test "$gauche_major_version" -eq 0 -a "$gauche_minor_version" -eq 8 -a \
          "$gauche_micro_version" -gt 13; then
    echo '(use test.unit)' | $GOSH -b
    gosh_result=$?
    if test "$gosh_result" = 0; then
      gaunit_version=`echo '(use test.unit) (print *gaunit-version*)' | $GOSH -b`
      gosh_result=$?
      if test "$gosh_result" = 0; then
        gaunit_major_version=`echo $gaunit_version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
        gaunit_minor_version=`echo $gaunit_version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
        gaunit_micro_version=`echo $gaunit_version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
        dnl require 0.1.6
        if test "$gaunit_major_version" -gt 0 || \
           test "$gaunit_major_version" -eq 0 -a \
                "$gaunit_minor_version" -gt 6 || \
           test "$gaunit_major_version" -eq 0 -a \
                "$gaunit_minor_version" -eq 1 -a \
                "$gaunit_micro_version" -ge 6; then
          have_gosh_and_gaunit="yes"
        fi
      fi
    fi
  fi
fi
if test x$have_gosh_and_gaunit = xyes; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi
AM_CONDITIONAL(DO_CHECK_IN_TEST,
	       test x$have_gosh_and_gaunit = xyes -a x$enable_debug = xyes)


# Checks for system services


AH_BOTTOM([/* Include os specific header. */
#include "os_dep.h"])

# Add include path
INCLUDES='-I$(top_srcdir)/replace -I$(top_srcdir)/uim'
AC_SUBST(INCLUDES)

SRCDIR=$srcdir
AC_SUBST(SRCDIR)
AC_SUBST(DESTDIR)

AC_SUBST(abs_srcdir)
AC_SUBST(abs_builddir)
AC_SUBST(abs_top_srcdir)
AC_SUBST(abs_top_builddir)

# configure sigscheme/ subdir
#
# --with-master-pkg=uim instructs that pkgdatadir for Scheme libraries.
# See also sigscheme/lib/Makefile.am
ac_configure_args="$ac_configure_args --with-master-pkg=uim --enable-conf=uim --disable-libsscm --disable-shell"
AC_CONFIG_SUBDIRS([sigscheme])

AC_CONFIG_FILES([Makefile
		 po/Makefile.in
		 m4/Makefile
		 doc/Makefile
		 uim/Makefile
		 uim/version.h
		 scm/Makefile
		 gtk2/Makefile
		 gtk2/candwin/Makefile
		 gtk2/dict/Makefile
		 gtk2/dict/uim-dict-ui.xml
		 gtk2/immodule/Makefile
		 gtk2/pad/Makefile
		 gtk2/pref/Makefile
		 gtk2/switcher/Makefile
		 gtk2/test/Makefile
		 gtk2/test/test.sh
		 gtk2/toolbar/Makefile
		 gtk3/Makefile
		 gtk3/candwin/Makefile
		 gtk3/dict/Makefile
		 gtk3/immodule/Makefile
		 gtk3/pad/Makefile
		 gtk3/pref/Makefile
		 gtk3/switcher/Makefile
		 gtk3/test/Makefile
		 gtk3/toolbar/Makefile
		 qt3/Makefile
		 qt3/candwin/Makefile
		 qt3/chardict/Makefile
		 qt3/immodule/Makefile
		 qt3/pref/Makefile
		 qt3/switcher/Makefile
		 qt3/test/Makefile
		 qt3/toolbar/Makefile
		 qt3/toolbar/uimapplet.desktop
		 qt4/Makefile
		 qt4/common.pro
		 qt4/candwin/Makefile
		 qt4/candwin/uim-candwin-qt4.pro
		 qt4/chardict/Makefile
		 qt4/chardict/uim-chardict-qt4.pro
		 qt4/edittest/Makefile
		 qt4/immodule/quiminputcontextplugin.pro
		 qt4/immodule/Makefile
		 qt4/pref/uim-pref-qt4.pro
		 qt4/pref/Makefile
		 qt4/switcher/uim-im-switcher-qt4.pro
		 qt4/switcher/Makefile
		 qt4/toolbar/plasma-applet-uim.desktop
		 qt4/toolbar/uim-toolbar-qt4.pro
		 qt4/toolbar/Makefile
		 xim/Makefile
		 fep/Makefile
		 emacs/Makefile
		 emacs/uim-version.el
		 tables/Makefile
		 byeoru-data/Makefile
		 test/Makefile
		 test2/Makefile
		 test2/run-singletest.sh
		 examples/Makefile
		 examples/uim-custom/Makefile
		 pixmaps/Makefile
		 pixmaps/uim-m17nlib-relink-icons
		 replace/Makefile
		 notify/Makefile
		 uim.pc
		 uim.desktop.in
		 uim.spec
		 ])

AC_OUTPUT

if test "x$CMAKE" != "xno"; then
    if test "x$enable_debug" = xyes; then
        cmake_build_type=Debug
    else
        cmake_build_type=Release
    fi
    # FIXME: move CMAKE_CXX_FLAGS into cmake_option
    cmake_option="-DCMAKE_BUILD_TYPE=${cmake_build_type}"
    cmake_option="${cmake_option} -DCMAKE_INSTALL_PREFIX=${prefix}"
    cmake_option="${cmake_option} -DCMAKE_SKIP_RPATH=true"
    cmake_option="${cmake_option} -DKDE4_USE_ALWAYS_FULL_RPATH=false"
fi
# Generate Makefiles for Qt4 by qmake
if test x$use_qt4 = xyes; then
    if test x$use_qt4_immodule = xyes; then
        qt4_immodule_option="DEFINES+=QT4_IMMODULE"
    fi
    ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/candwin/Makefile.qmake \
        ${ac_abs_top_builddir}/qt4/candwin/uim-candwin-qt4.pro
    ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/chardict/Makefile.qmake \
        ${ac_abs_top_builddir}/qt4/chardict/uim-chardict-qt4.pro
    ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/pref/Makefile.qmake \
        ${qt4_immodule_option} \
        ${ac_abs_top_builddir}/qt4/pref/uim-pref-qt4.pro
    ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/switcher/Makefile.qmake \
        ${ac_abs_top_builddir}/qt4/switcher/uim-im-switcher-qt4.pro
    ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/toolbar/Makefile.qmake \
        ${ac_abs_top_builddir}/qt4/toolbar/uim-toolbar-qt4.pro

    # Generate a Makefile for KDE4 applet by cmake
    if test x$use_applet_kde4 = xyes; then
        mkdir -p ${ac_abs_top_builddir}/qt4/toolbar/build
        cd ${ac_abs_top_builddir}/qt4/toolbar/build
        # FIXME: move CMAKE_CXX_FLAGS into cmake_option
        ${CMAKE} -DCMAKE_CXX_FLAGS="${CXXFLAGS} ${X_CFLAGS}" \
            ${cmake_option} ${ac_abs_top_srcdir}/qt4/toolbar
        cd -
    fi
fi
if test x$use_qt4_immodule = xyes; then
    if test x$use_qt4_qt3support = xyes; then
        qt4_qt3support_option="QT+=qt3support DEFINES+=ENABLE_QT4_QT3SUPPORT"
    fi
    ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/immodule/Makefile.qmake \
                ${qt4_qt3support_option} \
                ${ac_abs_top_builddir}/qt4/immodule/quiminputcontextplugin.pro
    ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/edittest/Makefile.qmake \
                 ${ac_abs_top_srcdir}/qt4/edittest/edittest.pro
fi
if test "x$use_knotify4" = xyes; then
    # Generate a Makefile for KNotify plugin by cmake
    mkdir -p ${ac_abs_top_builddir}/notify/build
    cd ${ac_abs_top_builddir}/notify/build
    # FIXME: move CMAKE_CXX_FLAGS into cmake_option
    ${CMAKE} -DCMAKE_CXX_FLAGS="${CXXFLAGS} ${X_CFLAGS}" \
        -DUIMNOTIFY_PLUGINDIR="${LIBDIR}/${PACKAGE}"/notify \
        ${cmake_option} ${ac_abs_top_srcdir}/notify
    cd -
fi

AC_MSG_RESULT([
Configure Result :

   Anthy           : ${use_anthy}
   Anthy (UTF-8)   : ${use_anthy_utf8}
   Canna           : ${use_canna}
   Mana            : ${use_mana}
   PRIME           : ${use_prime}
   SJ3             : ${use_sj3}
   SKK             : ${use_skk}
   Wnn             : ${use_wnn}
   m17n-lib        : ${use_m17nlib}
   SCIM            : ${use_scim}
   cURL            : ${use_curl}
   expat           : ${expat_found}
   OpenSSL         : ${use_openssl}
   SQLite3         : ${use_sqlite3}
   ffi             : ${use_ffi}
   Gtk+            : ${use_gtk2}
   Gnome Applet    : ${use_applet_gnome}
   Gtk+3           : ${use_gtk3}
   Gnome3 Applet   : ${use_applet_gnome3}
   Qt3             : ${use_qt}
   Qt3 immodule    : ${use_qtimmodule}
   Qt4             : ${use_qt4}
   Qt4 immodule    : ${use_qt4_immodule}
   Qt4 Qt3Support  : ${use_qt4_qt3support}
   KDE3 Applet     : ${use_applet_kde}
   KDE4 Applet     : ${use_applet_kde4}
   FEP             : ${use_uim_fep}
   Emacs           : ${use_uim_el}
   XIM             : ${use_xim}
   Pref            : ${use_pref}
   DICT            : ${use_dict}
   EB              : ${use_eb}
   OSX dictionary  : ${use_osx_dcs}
   libedit         : ${use_libedit}
   notify          : ${use_notify}
   Default toolkit : ${default_toolkit}
])

if test x$enable_debug = xyes; then
AC_MSG_RESULT([
Configure Result for developers:

   DEBUG           : ${enable_debug}
])
fi