1m4_define([UIM_MAJOR_VERSION],      [1])
2m4_define([UIM_MINOR_VERSION],      [8])
3m4_define([UIM_PATCHLEVEL_VERSION], [9])
4m4_define([UIM_VERSION],
5    UIM_MAJOR_VERSION.UIM_MINOR_VERSION.UIM_PATCHLEVEL_VERSION)
6
7AC_PREREQ(2.60b)
8AC_INIT([uim], [UIM_VERSION], [uim-en@googlegroups.com])
9AC_CONFIG_MACRO_DIR([m4.generated])
10AC_CONFIG_SRCDIR([uim/uim.c])
11AC_CONFIG_HEADERS([uim/config.h])
12AM_INIT_AUTOMAKE([1.10 foreign dist-bzip2])
13
14AC_SUBST(UIM_VERSION_MAJOR, UIM_MAJOR_VERSION)
15AC_SUBST(UIM_VERSION_MINOR, UIM_MINOR_VERSION)
16AC_SUBST(UIM_VERSION_PATCHLEVEL, UIM_PATCHLEVEL_VERSION)
17
18# Enable GNU extensions such as asprintf(3), BSD-originated functions,
19# POSIX features and more on glibc (and some other
20# implementations). See features.h. This macro should be placed here.
21AC_GNU_SOURCE
22
23# Checks for programs.
24AC_PROG_CXX
25AC_PROG_CC
26AC_PROG_CPP
27AC_PROG_OBJC
28
29if test "${GCC}" = "yes"; then
30  AC_MSG_CHECKING([for gcc is 4 or earlier])
31  AC_TRY_COMPILE([
32#if __GNUC__ >= 5
33#  error GCC 5 or later
34#endif
35                 ],
36                 [],
37                 [gcc_4_or_earlier=yes],
38                 [gcc_4_or_earlier=no])
39  AC_MSG_RESULT($gcc_4_or_earlier)
40else
41  gcc_4_or_earlier=no
42fi
43AM_CONDITIONAL(GCC_4_OR_EARLIER, test "$gcc_4_or_earlier" = "yes")
44
45AC_PROG_LN_S
46AC_PROG_INSTALL
47AC_PROG_MAKE_SET
48AC_DISABLE_STATIC
49AC_PROG_LIBTOOL
50AC_PATH_PROG(SH, sh)
51AC_PATH_PROG(RSVG, rsvg-convert)
52AC_PATH_PROG(CSI, csi)
53AC_PATH_PROGS(MD5, md5 md5sum)
54AC_PATH_PROGS(SHA1, sha1 sha1sum)
55AC_PATH_PROGS(SHA256, sha256 sha256sum)
56AC_PATH_PROGS(SED, sed gsed)
57AX_PATH_QMAKE4
58AX_PATH_QMAKE5
59
60AM_MAINTAINER_MODE
61
62# Checks for libraries
63AC_CHECK_LIB(dl,dlopen)
64AC_CHECK_LIB(socket,socket)
65
66AX_LIB_GLIBC
67
68dnl ***********************
69dnl *** Tests for iconv ***
70dnl ***********************
71dnl
72dnl We do this before the gettext checks, to avoid distortion
73
74AM_ICONV
75if test "$am_cv_func_iconv" != yes; then
76  AC_MSG_ERROR([Could not find iconv(3) in libc or libiconv (required for uim)])
77fi
78
79AC_SUBST(LIBICONV)
80
81dnl *************************
82dnl *** Tests for m17nlib ***
83dnl *************************
84
85AC_ARG_WITH(m17nlib,
86  AS_HELP_STRING([--without-m17nlib],
87    [do not build against m17nlib]),
88  [],
89  [with_m17nlib=yes])
90
91if test "x$with_m17nlib" != xno; then
92  PKG_CHECK_MODULES(M17NLIB, m17n-shell >= 1.3.1,
93                    with_m17nlib=yes, with_m17nlib=no)
94  AC_CHECK_PROG(M17NDB, m17n-db, m17n-db)
95  if test -n "$M17NDB"; then
96    m17n_db_dir=`$M17NDB`
97  fi
98fi
99
100AC_SUBST(M17NLIB_LIBS)
101AC_SUBST(m17n_db_dir)
102AM_CONDITIONAL(M17NLIB, test "x$with_m17nlib" = xyes)
103
104# ***********************
105# *** Tests for Anthy ***
106# ***********************
107AC_ARG_WITH(anthy,
108  AC_HELP_STRING([--without-anthy],
109    [do not build with libanthy]),
110  [],
111  [with_anthy=yes])
112
113if test "x$with_anthy" != xno; then
114  AC_CHECK_HEADERS([anthy/anthy.h],
115    [
116      saved_LIBS=$LIBS
117      LIBS="$LIBS -lanthy -lanthydic"
118      AC_CHECK_LIB([anthy], [anthy_init], [with_anthy=yes], [with_anthy=no])
119      LIBS=$saved_LIBS
120    ],
121    [with_anthy=no])
122fi
123
124if test "x$with_anthy" = xyes; then
125  ANTHY_LIBS="-lanthy -lanthydic"
126  ANTHY_CFLAGS=""
127  PKG_CHECK_EXISTS(anthy >= 0.4,
128                   [AC_DEFINE(LIBANTHY_UTF8_CAPABLE, 1,
129                    "libanthy can handle UTF-8")])
130fi
131AC_SUBST(ANTHY_LIBS)
132AC_SUBST(ANTHY_CFLAGS)
133AM_CONDITIONAL(ANTHY, test "x$with_anthy" = xyes)
134
135# *******************************
136# *** Tests for Anthy (UTF-8) ***
137# *******************************
138AC_ARG_WITH(anthy-utf8,
139  AC_HELP_STRING([--with-anthy-utf8],
140    [build with libanthy (UTF-8)]),
141  [],
142  [with_anthy_utf8=no])
143
144if test "x$with_anthy_utf8" != xno; then
145  PKG_CHECK_MODULES(ANTHY_UTF8, anthy >= 0.4,
146                    [with_anthy_utf8=yes
147                     AC_DEFINE(LIBANTHY_UTF8_CAPABLE, 1,
148                     [libanthy can handle UTF-8])],
149                     with_anthy_utf8=no)
150fi
151
152AM_CONDITIONAL(ANTHY_UTF8, test "x$with_anthy_utf8" = xyes)
153
154dnl for uim-dict.xml.in
155if test "x$with_anthy" = xyes || test "x$with_anthy_utf8" = xyes; then
156  UI_XML_ANTHY_START=""
157  UI_XML_ANTHY_END=""
158else
159  UI_XML_ANTHY_START="<!--"
160  UI_XML_ANTHY_END="-->"
161fi
162AC_SUBST(UI_XML_ANTHY_START)
163AC_SUBST(UI_XML_ANTHY_END)
164
165# ***********************
166# *** Tests for Canna ***
167# ***********************
168AC_ARG_WITH(canna,
169  AS_HELP_STRING([--with-canna],
170    [use Canna]),
171    [],
172    [with_canna=no])
173
174AM_CONDITIONAL(CANNA, test "x$with_canna" = xyes)
175
176# *********************
177# *** Tests for Wnn ***
178# *********************
179AC_ARG_WITH(wnn,
180  AS_HELP_STRING([--with-wnn],
181    [build with libwnn]),
182  [],
183  [with_wnn=no])
184
185if test "x$with_wnn" != xno; then
186  AM_PATH_WNN(with_wnn=yes, with_wnn=no)
187fi
188
189AM_CONDITIONAL(WNN, test "x$with_wnn" = xyes)
190
191# ***********************
192# *** Tests for Mana ***
193# ***********************
194AC_ARG_WITH(mana,
195  AS_HELP_STRING([--without-mana],
196    [do not build a plugin for Mana]),
197  [],
198  [with_mana=yes])
199
200if test "x$with_mana" != xno; then
201  AC_CHECK_PROG(MANA, mana, mana)
202  if test -z "$MANA"; then
203    with_mana=no
204  fi
205fi
206
207AM_CONDITIONAL(MANA, test "x$with_mana" = xyes)
208
209# ***********************
210# *** Tests for PRIME ***
211# ***********************
212AC_ARG_WITH(prime,
213  AS_HELP_STRING([--without-prime],
214    [do not build a plugin for PRIME]),
215  [],
216  [with_prime=yes])
217
218if test "x$with_prime" != xno; then
219  PKG_CHECK_MODULES(PRIME, prime >= 0.8.5.2, with_prime=yes, with_prime=no)
220fi
221
222AM_CONDITIONAL(PRIME, test "x$with_prime" = xyes)
223
224# *********************
225# *** Tests for SJ3 ***
226# *********************
227AC_ARG_WITH(sj3,
228  AS_HELP_STRING([--with-sj3],
229    [use SJ3]),
230  [],
231  [with_sj3=no])
232
233AM_CONDITIONAL(SJ3, test "x$with_sj3" = xyes)
234
235# *********************
236# *** Tests for SKK ***
237# *********************
238AC_ARG_WITH(skk,
239  AS_HELP_STRING([--without-skk],
240    [do not build a plugin for SKK]),
241  [],
242  [with_skk=yes])
243
244AM_CONDITIONAL(SKK, test "x$with_skk" = xyes)
245
246# **********************
247# *** Tests for cURL ***
248# **********************
249AC_ARG_WITH(curl,
250  AS_HELP_STRING([--with-curl],
251    [build with libcurl]),
252  [],
253  [with_curl=no])
254
255if test "x$with_curl" != xno; then
256  PKG_CHECK_MODULES(CURL, libcurl >= 7.16.4, with_curl=yes, with_curl=no)
257fi
258
259AM_CONDITIONAL(CURL, test "x$with_curl" = xyes)
260
261# ***********************
262# *** Tests for expat ***
263# ***********************
264expat_found=no
265AM_WITH_EXPAT
266AM_CONDITIONAL(EXPAT, test "x$expat_found" = xyes)
267
268# *************************
269# *** Tests for OpenSSL ***
270# *************************
271AC_ARG_ENABLE(openssl,
272  AC_HELP_STRING([--enable-openssl],
273    [enable OpenSSL]),
274  [],
275  [enable_openssl=no])
276
277if test "x$enable_openssl" != xno; then
278  AM_WITH_OPENSSL
279fi
280
281AM_CONDITIONAL(OPENSSL, test "x$enable_openssl" = xyes)
282
283# *************************
284# *** Tests for SQLite3 ***
285# *************************
286AC_ARG_WITH(sqlite3,
287  AS_HELP_STRING([--with-sqlite3],
288    [build with SQLite3]),
289  [],
290  [with_sqlite3=yes])
291
292if test "x$with_sqlite3" = xyes; then
293  PKG_CHECK_MODULES(SQLITE3, sqlite3 >= 3.0.0,
294                    with_sqlite3=yes, with_sqlite3=no)
295fi
296
297AM_CONDITIONAL(SQLITE3, test "x$with_sqlite3" = xyes)
298
299# ************************
300# *** Tests for libffi ***
301# ************************
302AC_ARG_WITH(ffi,
303  AS_HELP_STRING([--with-ffi],
304    [build with libffi]),
305  [],
306  [with_ffi=no])
307
308if test "x$with_ffi" = xyes; then
309  PKG_CHECK_MODULES(FFI, libffi >= 3.0.0, with_ffi=yes, with_ffi=no)
310fi
311
312AM_CONDITIONAL(FFI, test "x$with_ffi" = xyes)
313
314PKG_CHECK_MODULES(X11, x11, x11_use_new_dir=yes, x11_use_new_dir=no)
315AC_PATH_XTRA
316
317use_xim=no
318if test x"$have_x" != xdisabled && test x"$have_x" != xno; then
319  PKG_CHECK_MODULES(XIM, xext, use_xim=yes, use_xim=no)
320  if test "x$use_xim" = xyes; then
321    AC_CXX_NAMESPACES
322    AC_CXX_HAVE_STL
323    if test $ac_cv_cxx_have_stl = no; then
324      use_xim=no
325    fi
326  fi
327  AC_MSG_CHECKING([whether to have Xft support])
328  AM_PATH_XFT(yes, XFT=true, XFT=false)
329  if test x"$XFT" = xtrue; then
330    saved_CFLAGS=$CFLAGS
331    saved_LIBS=$LIBS
332    CFLAGS="$CFLAGS $XFT_CFLAGS"
333    LIBS="$LIBS $XFT_LIBS"
334    AC_TRY_LINK([
335#include <X11/Xft/Xft.h>], [ XftFontClose(0, 0); return 1; ],
336      [
337        AC_DEFINE(WITH_XFT, 1, [font antialiasing support])
338        AC_MSG_CHECKING([Xft UTF-8 support])
339        AC_TRY_LINK([
340#include <X11/Xft/Xft.h>
341          ], [
342XftDrawStringUtf8(0, 0, 0, 0, 0, 0, 0); return 0;
343          ],
344            AC_DEFINE(HAVE_XFT_UTF8_STRING, 1, "Xft UTF8 support")
345            AC_MSG_RESULT(yes),
346            AC_MSG_RESULT(no))
347      ],
348      [
349        AC_MSG_RESULT([***Could not link with Xft. Install Xft if you want support for it***])
350        XFT=false
351        XFT_CFLAGS=
352        XFT_LIBS=
353      ])
354    CFLAGS=$saved_CFLAGS
355    LIBS=$saved_LIBS
356  fi
357fi
358
359AC_XKB
360
361AM_CONDITIONAL(XIM, test x"$use_xim" = xyes)
362AM_CONDITIONAL(WITH_XFT, test x"$XFT" = xtrue)
363
364# Checks for header files
365AC_HEADER_STDC
366AC_HEADER_STDBOOL
367AC_CHECK_HEADERS([stdint.h inttypes.h sys/inttypes.h sys/types.h])
368AC_CHECK_HEADERS([fcntl.h locale.h stdlib.h unistd.h errno.h])
369AC_CHECK_HEADERS([string.h sys/ioctl.h sys/socket.h termios.h sys/termios.h wchar.h])
370AC_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])
371AC_CHECK_HEADERS([pty.h utmp.h util.h libutil.h])
372AC_CHECK_HEADERS([curses.h stropts.h])
373AC_CHECK_HEADERS([sys/param.h strings.h netdb.h sysexits.h])
374AC_CHECK_HEADERS([poll.h sys/poll.h])
375
376# Check for types
377AC_TYPE_INT8_T
378AC_TYPE_INT16_T
379AC_TYPE_INT32_T
380AC_TYPE_INT64_T
381AC_TYPE_INTMAX_T
382AC_TYPE_INTPTR_T
383AC_TYPE_UINT8_T
384AC_TYPE_UINT16_T
385AC_TYPE_UINT32_T
386AC_TYPE_UINT64_T
387AC_TYPE_UINTMAX_T
388AC_TYPE_UINTPTR_T
389
390AC_TYPE_SIZE_T
391AC_TYPE_SSIZE_T
392AC_TYPE_OFF_T
393
394AC_TYPE_PID_T
395AC_TYPE_SIGNAL
396AC_CHECK_TYPES(sig_atomic_t, , ,
397  [ #include <signal.h> ])
398AC_CHECK_TYPES(sig_t, , ,
399  [ #include <signal.h> ])
400
401# Checks for structures
402
403# Checks for compiler characteristics
404AC_C_CONST
405
406# FIXME: depending on the internal variable name
407AC_DEFUN([AX_LANG_WNOERROR], [ac_[]_AC_LANG_ABBREV[]_werror_flag=])
408
409AC_LANG_WERROR  # Turn warning-only unknown options into error.
410
411AX_CFLAGS_GCC_OPTION([-pedantic])
412AX_CFLAGS_GCC_OPTION([-pipe])
413AX_CFLAGS_GCC_OPTION([-Wall])
414AX_CFLAGS_GCC_OPTION([-Wchar-subscripts])
415AX_CFLAGS_GCC_OPTION([-Wmissing-declarations])
416AX_CFLAGS_GCC_OPTION([-Wredundant-decls])
417AX_CFLAGS_GCC_OPTION([-Wmissing-prototypes])
418AX_CFLAGS_GCC_OPTION([-Wnested-externs])
419AX_CFLAGS_GCC_OPTION([-Wpointer-arith])
420AX_CFLAGS_GCC_OPTION([-Wcast-align])
421AX_CFLAGS_GCC_OPTION([-Wsign-compare])
422AX_CFLAGS_GCC_OPTION([-Wno-long-long])
423
424# Suppress warnings about strings longer than ISO C 89 maximum length (509).
425AX_CFLAGS_GCC_OPTION([-Wno-overlength-strings])
426
427# Disable the problematic preprocessing on Mac OS X
428AX_CFLAGS_GCC_OPTION([-no-cpp-precomp])
429
430# Deprecated autoconf macro used in AX_CXXFLAGS_GCC_OPTION.
431AC_DEFUN([AC_LANG_CXX], [AC_LANG([C++])])
432
433AX_CXXFLAGS_GCC_OPTION([-pipe])
434AX_CXXFLAGS_GCC_OPTION([-W])
435AX_CXXFLAGS_GCC_OPTION([-Wall])
436AX_CXXFLAGS_GCC_OPTION([-Wchar-subscripts])
437AX_CXXFLAGS_GCC_OPTION([-Wnon-virtual-dtor])
438AX_CXXFLAGS_GCC_OPTION([-Wno-long-long])
439AX_CXXFLAGS_GCC_OPTION([-Wcast-align])
440AX_CXXFLAGS_GCC_OPTION([-Wconversion])
441AX_CXXFLAGS_GCC_OPTION([-Wchar-subscripts])
442AX_CXXFLAGS_GCC_OPTION([-Wpointer-arith])
443AX_CXXFLAGS_GCC_OPTION([-Wwrite-strings])
444AX_CXXFLAGS_GCC_OPTION([-Wformat-security])
445
446AX_LANG_WNOERROR  # end AC_LANG_WERROR
447
448AC_CHECK_DECL(LLONG_MAX, have_llong_max=1, , [#include <limits.h>])
449# compute LLONG_MIN and LLONG_MAX if we don't know them.
450if test -z "$have_llong_max"; then
451	AC_MSG_CHECKING([for max value of long long])
452	AC_RUN_IFELSE(
453		[AC_LANG_SOURCE([[
454#include <stdio.h>
455/* Why is this so damn hard? */
456#ifdef __GNUC__
457# undef __GNUC__
458#endif
459#define __USE_ISOC99
460#include <limits.h>
461#define DATA "conftest.llminmax"
462#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
463
464/*
465 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
466 * we do this the hard way.
467 */
468static int
469fprint_ll(FILE *f, long long n)
470{
471	unsigned int i;
472	int l[sizeof(long long) * 8];
473
474	if (n < 0)
475		if (fprintf(f, "-") < 0)
476			return -1;
477	for (i = 0; n != 0; i++) {
478		l[i] = my_abs(n % 10);
479		n /= 10;
480	}
481	do {
482		if (fprintf(f, "%d", l[--i]) < 0)
483			return -1;
484	} while (i != 0);
485	if (fprintf(f, " ") < 0)
486		return -1;
487	return 0;
488}
489
490int main(void) {
491	FILE *f;
492	long long i, llmin, llmax = 0, llmin1, llmax1;
493
494	if((f = fopen(DATA,"w")) == NULL)
495		exit(1);
496
497#if defined(LLONG_MIN) && defined(LLONG_MAX)
498	fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
499	llmin = LLONG_MIN;
500	llmax = LLONG_MAX;
501#else
502	fprintf(stderr, "Calculating  LLONG_MIN and LLONG_MAX\n");
503	/* This will work on one's complement and two's complement */
504	for (i = 1; i > llmax; i <<= 1, i++)
505		llmax = i;
506	llmin = llmax + 1LL;    /* wrap */
507#endif
508
509	/* Sanity check */
510	llmin1 = llmin - 1;
511	llmax1 = llmax + 1;
512	if (llmin + 1 < llmin || llmin1 < llmin || llmax1 > llmax
513	    || llmax - 1 > llmax || llmin == llmax || llmin == 0
514	    || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
515		fprintf(f, "unknown unknown\n");
516		exit(2);
517	}
518
519	if (fprint_ll(f, llmin) < 0)
520		exit(3);
521	if (fprint_ll(f, llmax) < 0)
522		exit(4);
523	if (fclose(f) < 0)
524		exit(5);
525	exit(0);
526}
527		]])],
528		[
529			llong_min=`$AWK '{print $1}' conftest.llminmax`
530			llong_max=`$AWK '{print $2}' conftest.llminmax`
531
532			AC_MSG_RESULT($llong_max)
533			AC_DEFINE_UNQUOTED(LLONG_MAX, [${llong_max}LL],
534			    [max value of long long calculated by configure])
535			AC_MSG_CHECKING([for min value of long long])
536			AC_MSG_RESULT($llong_min)
537			AC_DEFINE_UNQUOTED(LLONG_MIN, [${llong_min}LL],
538			    [min value of long long calculated by configure])
539		],
540		[
541			AC_MSG_RESULT(not found)
542		],
543		[
544			AC_MSG_WARN([cross compiling: not checking])
545		]
546	)
547fi
548
549# Checks for library functions
550AC_FUNC_REALLOC
551AC_FUNC_ALLOCA
552AC_FUNC_MEMCMP
553AC_FUNC_MMAP
554AX_FUNC_SIGSETJMP
555AC_FUNC_FORK
556AC_FUNC_LSTAT
557AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
558AC_FUNC_SELECT_ARGTYPES
559AC_CHECK_FUNCS([cfmakeraw])
560AC_CHECK_FUNCS([wcswidth])
561# BSD functions
562AC_CHECK_FUNCS([strdup])
563# GNU functions
564AC_CHECK_FUNCS([asprintf vasprintf])
565# C99 functions
566AC_CHECK_FUNCS([snprintf vsnprintf])
567# FIXME: replace non-standard perror(3)
568AC_REPLACE_FUNCS([getpeereid strsep setenv unsetenv strlcpy strlcat strtonum strtoll])
569AC_CHECK_FUNCS([getpid stat mkdir chmod])
570AC_CHECK_FUNCS([execv execvp])
571AC_CHECK_FUNCS([isascii])
572AC_CHECK_FUNCS([getaddrinfo freeaddrinfo getnameinfo])
573AC_CHECK_FUNCS([issetugid])
574AC_CHECK_FUNCS([poll])
575AC_CHECK_FUNCS([waitpid])
576AC_CHECK_FUNCS([daemon])
577
578# IRIX has a const char return value for gai_strerror()
579AC_CHECK_FUNCS(gai_strerror,[
580        AC_DEFINE(HAVE_GAI_STRERROR)
581        AC_TRY_COMPILE([
582#include <sys/types.h>
583#include <sys/socket.h>
584#include <netdb.h>
585
586const char *gai_strerror(int);],[
587char *str;
588
589str = gai_strerror(0);],[
590                AC_DEFINE(HAVE_CONST_GAI_STRERROR_PROTO, 1,
591                [Define if gai_strerror() returns const char *])])])
592
593# Check for broken snprintf
594if test "x$ac_cv_func_snprintf" = xyes; then
595	AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
596	AC_RUN_IFELSE(
597		[AC_LANG_SOURCE([[
598#include <stdio.h>
599int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
600		]])],
601		[AC_MSG_RESULT(yes)],
602		[
603			AC_MSG_RESULT(no)
604			AC_DEFINE(BROKEN_SNPRINTF, 1,
605				[Define if your snprintf is busted])
606			AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
607		],
608		[ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
609	)
610fi
611
612# If we don't have a working asprintf, then we strongly depend on vsnprintf
613# returning the right thing on overflow: the number of characters it tried to
614# create (as per SUSv3)
615if test "x$ac_cv_func_asprintf" != xyes && \
616   test "x$ac_cv_func_vsnprintf" = xyes; then
617	AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
618	AC_RUN_IFELSE(
619		[AC_LANG_SOURCE([[
620#include <sys/types.h>
621#include <stdio.h>
622#include <stdarg.h>
623
624int x_snprintf(char *str,size_t count,const char *fmt,...)
625{
626	size_t ret; va_list ap;
627	va_start(ap, fmt); ret = vsnprintf(str, count, fmt, ap); va_end(ap);
628	return ret;
629}
630int main(void)
631{
632	char x[1];
633	exit(x_snprintf(x, 1, "%s %d", "hello", 12345) == 11 ? 0 : 1);
634} ]])],
635		[AC_MSG_RESULT(yes)],
636		[
637			AC_MSG_RESULT(no)
638			AC_DEFINE(BROKEN_SNPRINTF, 1,
639				[Define if your snprintf is busted])
640			AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
641		],
642		[ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
643	)
644fi
645
646# On systems where [v]snprintf is broken, but is declared in stdio,
647# check that the fmt argument is const char * or just char *.
648# This is only useful for when BROKEN_SNPRINTF
649AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
650AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
651	   int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
652	   int main(void) { snprintf(0, 0, 0); }
653    ]])],
654   [AC_MSG_RESULT(yes)
655    AC_DEFINE(SNPRINTF_CONST, [const],
656              [Define as const if snprintf() can declare const char *fmt])],
657   [AC_MSG_RESULT(no)
658    AC_DEFINE(SNPRINTF_CONST, [/* not const */])])
659
660AC_SEARCH_LIBS(dlfunc,dl,
661  [
662    AC_DEFINE(HAVE_DLFUNC, 1,
663              [Define to 1 if you have the dlfunc function.])
664
665  ])
666
667# for uim-fep
668AM_LANGINFO_CODESET
669
670dnl Solaris 9 needs -lresolv for inet_aton
671NETLIBS=""
672AC_CHECK_FUNC(inet_aton, ,
673  [AC_CHECK_LIB(resolv, inet_aton, [NETLIBS="-lresolv"])])
674AC_SUBST(NETLIBS)
675
676dnl socket related
677AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
678	AC_TRY_COMPILE(
679		[
680#include <sys/types.h>
681#include <sys/socket.h>
682		],
683		[ struct sockaddr_storage s; ],
684		[ ac_cv_have_struct_sockaddr_storage=yes ],
685		[ ac_cv_have_struct_sockaddr_storage=no ]
686	)
687])
688if test "x$ac_cv_have_struct_sockaddr_storage" = xyes; then
689	AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
690		[define if you have struct sockaddr_storage data type])
691fi
692
693dnl cred related
694AC_CACHE_CHECK([for struct cmsgcred], ac_cv_have_struct_cmsgcred, [
695	AC_TRY_COMPILE(
696		[
697#include <sys/types.h>
698#include <sys/socket.h>
699		],
700		[ struct cmsgcred s; ],
701		[ ac_cv_have_struct_cmsgcred=yes ],
702		[ ac_cv_have_struct_cmsgcred=no ]
703	)
704])
705if test "x$ac_cv_have_struct_cmsgcred" = xyes; then
706	AC_DEFINE(HAVE_STRUCT_CMSGCRED, 1,
707		[define if you have struct cmsgcred data type])
708fi
709
710AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
711	AC_TRY_COMPILE(
712		[
713#include <sys/types.h>
714#include <netinet/in.h>
715		],
716		[ struct sockaddr_in6 s; s.sin6_family = 0; ],
717		[ ac_cv_have_struct_sockaddr_in6=yes ],
718		[ ac_cv_have_struct_sockaddr_in6=no ]
719	)
720])
721if test "x$ac_cv_have_struct_sockaddr_in6" = xyes; then
722	AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1,
723		[define if you have struct sockaddr_in6 data type])
724fi
725
726AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
727	AC_TRY_COMPILE(
728		[
729#include <sys/types.h>
730#include <netinet/in.h>
731		],
732		[ struct in6_addr s; s.s6_addr[0] = 0; ],
733		[ ac_cv_have_struct_in6_addr=yes ],
734		[ ac_cv_have_struct_in6_addr=no ]
735	)
736])
737if test "x$ac_cv_have_struct_in6_addr" = xyes; then
738	AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1,
739		[define if you have struct in6_addr data type])
740fi
741
742AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
743	AC_TRY_COMPILE(
744		[
745#include <sys/types.h>
746#include <sys/socket.h>
747#include <netdb.h>
748		],
749		[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
750		[ ac_cv_have_struct_addrinfo=yes ],
751		[ ac_cv_have_struct_addrinfo=no ]
752	)
753])
754if test "x$ac_cv_have_struct_addrinfo" = xyes; then
755	AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1,
756		[define if you have struct addrinfo data type])
757fi
758
759GETTEXT_PACKAGE=uim
760AC_SUBST(GETTEXT_PACKAGE)
761AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[gettext package name])
762
763AM_GNU_GETTEXT([external], [need-ngettext])
764AM_GNU_GETTEXT_VERSION([0.17])
765
766# FIXME: Probably voilent way  -- YamaKen 2005-01-07
767if test "x$prefix" = xNONE; then
768  prefix=$ac_default_prefix
769fi
770if test "x$exec_prefix" = xNONE; then
771  exec_prefix=$prefix
772fi
773
774# FIXME: complicated directory handlings  -- YamaKen 2006-07-08
775# FIXME: double eval workaround for datarootdir
776LIBDIR=`eval eval echo ${libdir}`
777AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [libraries dir])
778DATADIR=`eval eval echo ${datadir}`
779AC_DEFINE_UNQUOTED(DATADIR, "$DATADIR", [read-only architecture-independent data dir])
780UIM_LIBEXECDIR=`eval echo "${libexecdir}"`
781AC_DEFINE_UNQUOTED(UIM_LIBEXECDIR, "$UIM_LIBEXECDIR", [libexec dir])
782AC_SUBST(UIM_LIBEXECDIR)
783# we should use more safe macro such as AC_EXPAND_DIR
784LOCALEDIR=`eval eval echo ${datadir}/locale`
785# backward compatibility
786localedir=$LOCALEDIR
787AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [locale dir])
788AC_DEFINE_UNQUOTED(GNOMELOCALEDIR, "$LOCALEDIR", [locale dir for GNOME])
789AC_DEFINE_UNQUOTED(GNOME3LOCALEDIR, "$LOCALEDIR", [locale dir for GNOME3])
790# define XLIB directory for Compose file
791if test "x$x11_use_new_dir" = xyes; then
792  AC_DEFINE_UNQUOTED(XLIB_DIR, "`$PKG_CONFIG x11 --variable=prefix`/share", [X11 Library Directory])
793else
794  AC_DEFINE_UNQUOTED(XLIB_DIR, "$x_libraries", [X11 Library Directory])
795fi
796uim_pixmapsdir=`eval eval echo ${datadir}/${PACKAGE_TARNAME}/pixmaps`
797AC_DEFINE_UNQUOTED(UIM_PIXMAPSDIR, "${uim_pixmapsdir}", [pixmaps directory])
798AC_SUBST(uim_pixmapsdir)
799
800dnl ******************************
801dnl *** Check for GTK+ Library ***
802dnl ******************************
803AC_ARG_WITH(gtk2,
804  AC_HELP_STRING([--without-gtk2],
805    [do not build against GTK+2]),
806  [],
807  [with_gtk2=yes])
808
809if test "x$with_gtk2" != xno; then
810  PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.2.0 gdk-x11-2.0,
811                    with_gtk2=yes, with_gtk2=no)
812  PKG_CHECK_MODULES(GTK2_4, gtk+-2.0 >= 2.4.0 gdk-x11-2.0,
813                    with_gtk2_4=yes, with_gtk2_4=no)
814fi
815
816AM_CONDITIONAL(GTK2, test "x$with_gtk2" = xyes)
817AM_CONDITIONAL(GTK2_4, test "x$with_gtk2_4" = xyes)
818
819if test "x$with_gtk2" = xyes; then
820  GTK_BINARY_VERSION=`$PKG_CONFIG gtk+-2.0 --variable=gtk_binary_version`
821  GTK_LIBDIR=`$PKG_CONFIG gtk+-2.0 --variable=libdir`
822  AC_SUBST(GTK_BINARY_VERSION)
823  AC_SUBST(GTK_LIBDIR)
824  AC_DEFINE(USE_GTK2, 1, [use GTK+2])
825fi
826
827AC_ARG_ENABLE(gnome-applet,
828  AC_HELP_STRING([--disable-gnome-applet],
829    [disable uim applet for GNOME2 panel]),
830  [],
831  [enable_gnome_applet=yes])
832
833if test "x$enable_gnome_applet" != xno; then
834  PKG_CHECK_MODULES(GNOME_APPLET, libpanelapplet-2.0,
835                    enable_gnome_applet=yes, enable_gnome_applet=no)
836  PKG_CHECK_MODULES(APPLET_2_14, libpanelapplet-2.0 >= 2.14.0,
837                    panelapplet_have_set_background_api=yes,
838                    panelapplet_have_set_background_api=no)
839fi
840
841if test x"$panelapplet_have_set_background_api" = xyes; then
842  AC_DEFINE(LIBPANEL_APPLET_HAVE_SET_BACKGROUND_WIDGET, 1 , [libpanel-applet have set_background api])
843fi
844
845AM_CONDITIONAL(GNOME_APPLET, test "x$enable_gnome_applet" = xyes)
846
847dnl *******************************
848dnl *** Check for GTK+3 Library ***
849dnl *******************************
850AC_ARG_WITH(gtk3,
851  AC_HELP_STRING([--without-gtk3],
852    [do not build GTK+3 immodule and helper applications]),
853  [],
854  [with_gtk3=yes])
855
856if test "x$with_gtk3" != xno; then
857  PKG_CHECK_MODULES(GTK3, gtk+-3.0, with_gtk3=yes, with_gtk3=no)
858fi
859
860AM_CONDITIONAL(GTK3, test "x$with_gtk3" = xyes)
861
862if test "x$with_gtk3" = xyes; then
863  AC_DEFINE(USE_GTK3, 1, [use GTK+3])
864  GTK3_BINARY_VERSION=`$PKG_CONFIG gtk+-3.0 --variable=gtk_binary_version`
865  GTK3_LIBDIR=`$PKG_CONFIG gtk+-3.0 --variable=libdir`
866  AC_SUBST(GTK3_BINARY_VERSION)
867  AC_SUBST(GTK3_LIBDIR)
868fi
869
870AC_ARG_ENABLE(gnome3-applet,
871  AC_HELP_STRING([--disable-gnome3-applet],
872    [disable uim applet for GNOME3 panel]),
873  [],
874  [enable_gnome3_applet=yes])
875
876if test "x$enable_gnome3_applet" != xno; then
877  PKG_CHECK_MODULES(GNOME3_APPLET, libpanel-applet,
878                    enable_gnome3_applet=yes, enable_gnome3_applet=no)
879fi
880
881AM_CONDITIONAL(GNOME3_APPLET, test "x$enable_gnome3_applet" = xyes)
882
883if test "x$enable_gnome3_applet" = xyes; then
884  AC_ARG_WITH([libpanel-applet-dir], [], [LIBPANEL_APPLET_DIR=$withval], [LIBPANEL_APPLET_DIR=""])
885  if test "$LIBPANEL_APPLET_DIR" = ""; then
886    LIBPANEL_APPLET_DIR=`$PKG_CONFIG --variable=libpanel_applet_dir libpanel-applet`
887  fi
888  AC_SUBST(LIBPANEL_APPLET_DIR)
889fi
890
891AC_ARG_ENABLE(debug,
892  AC_HELP_STRING([--enable-debug],
893    [enable debugging]),
894  [],
895  [enable_debug=no])
896
897AM_CONDITIONAL(DEBUG, test "x$enable_debug" = xyes)
898
899dnl ****************************
900dnl *** Check for Qt Library ***
901dnl ****************************
902AC_ARG_WITH(qt,
903  AC_HELP_STRING([--with-qt],
904    [build Qt3 helper applications]),
905  [],
906  [with_qt=no])
907
908if test "x$with_qt" = xyes; then
909  # minimum version
910  QT_VERSION=3.2.0
911  QT_VERSION_NUM=0x030200
912
913  # GUESS $QTDIR
914  if test ! -d "$QTDIR"; then
915    QTDIR="/usr/lib/qt3"
916  fi
917  if test ! -d "$QTDIR"; then
918    QTDIR="/usr/lib/qt"
919  fi
920  if test ! -d "$QTDIR"; then
921    QTDIR="/usr"
922  fi
923  AC_MSG_CHECKING(for Qt3 library dir)
924  if test ! -d "$QTDIR"; then
925    AC_MSG_RESULT(no)
926  else
927    AC_MSG_RESULT($QTDIR)
928  fi
929
930  # GUESS $QTINCDIR from $QTDIR
931  QTINCDIR="$QTDIR/include/qt"
932  if test ! -d "$QTINCDIR"; then
933    QTINCDIR="$QTDIR/include/X11/qt"
934  fi
935  if test ! -d "$QTINCDIR"; then
936    QTINCDIR="$QTDIR/include/qt3"
937  fi
938  if test ! -d "$QTINCDIR"; then
939    QTINCDIR="$QTDIR/include"
940  fi
941  # GUESS $QTINCDIR independently
942  if test ! -d "$QTINCDIR"; then
943    QTINCDIR="/usr/include/X11/qt"
944  fi
945  if test ! -d "$QTINCDIR"; then
946    QTINCDIR="/usr/include/qt3"
947  fi
948  if test ! -d "$QTINCDIR"; then
949    QTINCDIR="/usr/include/qt"
950  fi
951  if test ! -d "$QTINCDIR"; then
952    QTINCDIR="/usr/include"
953  fi
954
955  # GUESS $QTLIBDIR
956  QTLIBDIR="$QTDIR/lib64"
957  if test ! -d "$QTLIBDIR"; then
958    QTLIBDIR="$QTDIR/lib"
959  fi
960  if test ! -d "$QTLIBDIR"; then
961    QTLIBDIR="/usr/lib/qt3"
962  fi
963  if test ! -d "$QTLIBDIR"; then
964    QTLIBDIR="/usr/lib/qt"
965  fi
966  if test ! -d "$QTLIBDIR"; then
967    QTLIBDIR="/usr/lib"
968  fi
969
970  # Check For MOC
971  if test -x "$QTDIR/bin/moc"; then
972    HOST_MOC="$QTDIR/bin/moc"
973  else
974    AC_CHECK_PROGS(HOST_MOC, moc-qt3 moc, "")
975  fi
976  if test -z "$HOST_MOC"; then
977    AC_MSG_ERROR([no acceptable moc( meta object compiler ) found])
978  fi
979  MOC=$HOST_MOC
980
981  # Check For UIC
982  if test -x "$QTDIR/bin/uic"; then
983    HOST_UIC="$QTDIR/bin/uic"
984  else
985    AC_CHECK_PROGS(HOST_UIC, uic-qt3 uic, "")
986  fi
987  if test -z "$HOST_UIC"; then
988    AC_MSG_ERROR([no acceptable uic( user interface compiler ) found])
989  fi
990  UIC=$HOST_UIC
991
992  # GUESS plugins dir for immodule installation
993  AC_MSG_CHECKING(for qt-immodule plugins dir)
994  if test ! -d "$QTDIR/plugins"; then
995    AC_MSG_RESULT(no)
996  else
997    QT_PLUGINSDIR=$QTDIR/plugins
998    AC_MSG_RESULT($QT_PLUGINSDIR)
999    AC_SUBST(QT_PLUGINSDIR)
1000  fi
1001
1002  # Process for compiler & linker flags
1003  QT_CXXFLAGS="-I${QTINCDIR} -DQT_GENUINE_STR -DQT_NO_STL"
1004  if test "x$enable_debug" = xno; then
1005    QT_CXXFLAGS="$QT_CXXFLAGS -DQT_NO_DEBUG -DNO_DEBUG"
1006  fi
1007  _SAVE_LDFLAGS=$LDFLAGS
1008  QT_LDFLAGS=-L${QTLIBDIR}
1009  LDFLAGS="$LDFLAGS $QT_LDFLAGS"
1010  AC_LANG_SAVE
1011  AC_LANG_CPLUSPLUS
1012  AC_CHECK_LIB(qt, main, QT_LIB=-lqt,
1013      AC_CHECK_LIB(qt-mt, main, QT_LIB=-lqt-mt,
1014          AC_MSG_ERROR([Cannot find QT libraries.])))
1015
1016  if test "$QT_LIB" = "-lqt-mt"; then
1017    QT_CXXFLAGS="$QT_CXXFLAGS -DQT_THREAD_SUPPORT"
1018  fi
1019
1020  LDFLAGS=$_SAVE_LDFLAGS
1021  QT_LIBS="$X_LIBS $QT_LDFLAGS $QT_LIB -lXext -lX11"
1022
1023  _SAVE_CXXFLAGS=$CXXFLAGS
1024  _SAVE_LIBS=$LIBS
1025
1026  CXXFLAGS="$CXXFLAGS $QT_CXXFLAGS"
1027  LIBS="$LIBS $QT_LIBS"
1028
1029  AC_MSG_CHECKING(Qt - version >= $QT_VERSION)
1030  AC_TRY_COMPILE([#include <qglobal.h>],
1031  [
1032      #if (QT_VERSION < $QT_VERSION_NUM)
1033          #error  "QT_VERSION too old"
1034      #endif
1035  ],result=yes,result=no)
1036
1037  AC_MSG_RESULT("$result")
1038  if test "x$result" = xno; then
1039    with_qt=no
1040    AC_MSG_WARN([Qt Helper requires at least version $QT_VERSION of Qt])
1041  fi
1042  CXXFLAGS=$_SAVE_CXXFLAGS
1043  LIBS=$_SAVE_LIBS
1044
1045  AC_LANG_RESTORE
1046
1047  UIM_QT_LDFLAGS=$QT_LIBS
1048  UIM_QT_CXXFLAGS=$QT_CXXFLAGS
1049
1050  AC_SUBST(MOC)
1051  AC_SUBST(UIC)
1052  AC_SUBST(UIM_QT_CXXFLAGS)
1053  AC_SUBST(UIM_QT_LDFLAGS)
1054fi
1055
1056AC_PATH_PROG(KDE_CONFIG, [kde-config], [no])
1057if test "x$with_qt" = xyes; then
1058  if test "x$KDE_CONFIG" != xno; then
1059    KDE_ICONDIR=`$KDE_CONFIG --expandvars --install icon`
1060  fi
1061  if test -z "$KDE_ICONDIR"; then
1062    KDE_ICONDIR="$prefix/share/icons"
1063  fi
1064  AC_DEFINE_UNQUOTED(KDE_ICONDIR, "$KDE_ICONDIR", [kde icon directory])
1065fi
1066
1067AM_CONDITIONAL(QT, test "x$with_qt" = xyes)
1068
1069AC_ARG_WITH(qt-immodule,
1070  AC_HELP_STRING([--with-qt-immodule],
1071    [build Qt3-immodule extension]),
1072  [],
1073  [with_qt_immodule=no])
1074
1075if test "x$with_qt_immodule" = xyes; then
1076  AC_MSG_CHECKING(for qt-immodule patch)
1077  # Check for immodule for Qt patch
1078  if test ! -f $QTINCDIR/qinputcontext.h \
1079      || test ! -f $QTINCDIR/qinputcontextplugin.h; then
1080    AC_MSG_RESULT(no)
1081    with_qt_immodule=no
1082  else
1083    AC_MSG_RESULT(yes)
1084  fi
1085fi
1086
1087AM_CONDITIONAL(QT_IMMODULE, test "x$with_qt_immodule" = xyes)
1088
1089dnl *****************************
1090dnl *** Check for Qt4 Library ***
1091dnl *****************************
1092AC_ARG_WITH(qt4,
1093  AC_HELP_STRING([--with-qt4],
1094    [build Qt4 helper applications]),
1095  [],
1096  [with_qt4=no])
1097
1098AM_CONDITIONAL(QT4, test "x$with_qt4" = xyes)
1099
1100AC_ARG_WITH(qt4-immodule,
1101  AC_HELP_STRING([--with-qt4-immodule],
1102    [build Qt4-immodule extension]),
1103  [],
1104  [with_qt4_immodule=no])
1105
1106AM_CONDITIONAL(QT4_IMMODULE, test "x$with_qt4_immodule" = xyes)
1107
1108if test "x$with_qt4" = xyes || test "x$with_qt4_immodule" = xyes; then
1109  if test -z "$QMAKE4"; then
1110    AC_MSG_ERROR([no qmake for Qt4 found])
1111  fi
1112fi
1113
1114dnl *****************************************
1115dnl *** test for Qt3Support module in Qt4 ***
1116dnl *****************************************
1117AC_ARG_ENABLE(qt4-qt3support,
1118  AC_HELP_STRING([--disable-qt4-qt3support],
1119    [disable support for Qt3Support module in Qt4]),
1120  [],
1121  [enable_qt4_qt3support=yes])
1122
1123if test "x$enable_qt4_qt3support" != xno; then
1124  if test "x$with_qt4_immodule" = xyes; then
1125    if test -f `${QMAKE4} -query QT_INSTALL_LIBS`/libQt3Support.so; then
1126      enable_qt4_qt3support=yes
1127    else
1128      enable_qt4_qt3support=no
1129      AC_MSG_WARN([No Qt3Support found])
1130    fi
1131  else
1132    enable_qt4_qt3support=no
1133  fi
1134fi
1135
1136dnl *****************************
1137dnl *** Check for Qt5 Library ***
1138dnl *****************************
1139AC_ARG_WITH(qt5,
1140  AC_HELP_STRING([--with-qt5],
1141    [build Qt5 helper applications]),
1142  [],
1143  [with_qt5=no])
1144
1145AM_CONDITIONAL(QT5, test "x$with_qt5" = xyes)
1146
1147AC_ARG_WITH(qt5-immodule,
1148  AC_HELP_STRING([--with-qt5-immodule],
1149    [build Qt5-immodule extension]),
1150  [],
1151  [with_qt5_immodule=no])
1152
1153if test "x$with_qt5" = xyes || test "x$with_qt5_immodule" = xyes; then
1154  if test -z "$QMAKE5"; then
1155    AC_MSG_ERROR([no qmake for Qt5 found])
1156  fi
1157fi
1158
1159AM_CONDITIONAL(QT5_IMMODULE, test "x$with_qt5_immodule" = xyes)
1160
1161AC_ARG_ENABLE(default-toolkit,
1162  AC_HELP_STRING([--enable-default-toolkit],
1163    [determine default toolkit (gtk, gtk3, qt, qt4 or qt5) @<:@default=gtk@:>@]),
1164  [],
1165  [enable_default_toolkit=no])
1166
1167default_toolkit=gtk
1168if test "x$enable_default_toolkit" != xno; then
1169  if test "x$enable_default_toolkit" = xgtk && \
1170     test "x$with_gtk2" = xyes; then
1171    default_toolkit=gtk
1172  elif test "x$enable_default_toolkit" = xgtk3 && \
1173       test "x$with_gtk3" = xyes; then
1174    default_toolkit=gtk3
1175  elif test "x$enable_default_toolkit" = xqt && \
1176       test "x$with_qt" = xyes; then
1177    default_toolkit=qt
1178  elif test "x$enable_default_toolkit" = xqt4 && \
1179       test "x$with_qt4" = xyes; then
1180    default_toolkit=qt4
1181  elif test "x$enable_default_toolkit" = xqt5 && \
1182       test "x$with_qt5" = xyes; then
1183    default_toolkit=qt5
1184  fi
1185fi
1186
1187AM_CONDITIONAL(DEFAULT_TOOLKIT_GTK, test "x$default_toolkit" = xgtk)
1188AM_CONDITIONAL(DEFAULT_TOOLKIT_GTK3, test "x$default_toolkit" = xgtk3)
1189AM_CONDITIONAL(DEFAULT_TOOLKIT_QT,  test "x$default_toolkit" = xqt)
1190AM_CONDITIONAL(DEFAULT_TOOLKIT_QT4, test "x$default_toolkit" = xqt4)
1191AM_CONDITIONAL(DEFAULT_TOOLKIT_QT5, test "x$default_toolkit" = xqt5)
1192AC_SUBST(default_toolkit)
1193
1194AC_ARG_ENABLE(fep,
1195  AC_HELP_STRING([--disable-fep],
1196    [disable uim-fep]),
1197  [],
1198  [enable_fep=yes])
1199
1200if test "x$enable_fep" != xno; then
1201  enable_fep=yes
1202  AC_CHECK_LIB(curses, setupterm, FEP_LIBADD="-lcurses $FEP_LIBADD",
1203    [AC_CHECK_LIB(ncurses, setupterm, FEP_LIBADD="-lncurses $FEP_LIBADD",
1204      AC_MSG_WARN([fep needs setupterm in libcurses or libncurses. disabled...]);enable_fep=no)])
1205  AC_CHECK_FUNCS(forkpty)
1206  if test "x$ac_cv_func_forkpty" = xno; then
1207    AC_CHECK_LIB(util, forkpty,
1208      [AC_DEFINE(HAVE_FORKPTY) FEP_LIBADD="-lutil $FEP_LIBADD"])
1209  fi
1210  AC_SUBST(FEP_LIBADD)
1211fi
1212
1213AM_CONDITIONAL(UIM_FEP, test "x$enable_fep" = xyes)
1214
1215AC_ARG_ENABLE(emacs,
1216  AC_HELP_STRING([--disable-emacs],
1217    [disable uim.el]),
1218  [],
1219  [enable_emacs=yes])
1220
1221if test "x$enable_emacs" != xno; then
1222  AM_PATH_LISPDIR
1223  AC_SUBST(UIMEL_LISP_DIR, $lispdir/uim-el)
1224fi
1225
1226AM_CONDITIONAL(UIM_EL, test "x$enable_emacs" = xyes)
1227
1228AC_ARG_ENABLE(dict,
1229  AC_HELP_STRING([--enable-dict],
1230    [build dictionary utility for uim (Anthy and Canna)]),
1231  [],
1232  [enable_dict=no])
1233
1234if test "x$enable_dict" != xno; then
1235  PKG_CHECK_MODULES(DICT, gtk+-2.0 >= 2.4.0,
1236    enable_dict=yes, enable_dict=no)
1237
1238  if test "x$enable_dict" = xno; then
1239    PKG_CHECK_MODULES(DICT, gtk+-3.0, enable_dict=yes, enable_dict=no)
1240  fi
1241
1242  if test "x$enable_dict" = xno; then
1243    AC_MSG_WARN([dict needs GTK+ 2 (> 2.4) or GTK+ 3. dict disabled...])
1244  fi
1245
1246  dnl Tests for -lcanna for dict
1247  if test "x$enable_dict" = xyes; then
1248    AC_CHECK_HEADERS([canna/RK.h],
1249      [AC_CHECK_LIB(canna, RkInitialize,
1250        enable_dict_canna=yes, enable_dict_canna=no)],
1251      [enable_dict_canna=no],
1252      [ #undef _WCHAR_T ])
1253  else
1254    enable_dict_canna=no
1255  fi
1256
1257  if test "x$enable_dict_canna" = xno && \
1258     test "x$with_anthy" = xno && \
1259     test "x$with_anthy_utf8" = xno; then
1260    AC_MSG_WARN([no dictionary backend is usable.  disabled...])
1261    enable_dict=no
1262  fi
1263fi
1264
1265AM_CONDITIONAL(DICT, test "x$enable_dict" = xyes)
1266AM_CONDITIONAL(DICT_CANNA, test "x$enable_dict_canna" = xyes)
1267
1268if test "x$enable_dict_canna" = xyes; then
1269  UI_XML_CANNA_START=""
1270  UI_XML_CANNA_END=""
1271else
1272  UI_XML_CANNA_START="<!--"
1273  UI_XML_CANNA_END="-->"
1274fi
1275AC_SUBST(UI_XML_CANNA_START)
1276AC_SUBST(UI_XML_CANNA_END)
1277
1278dnl ****************************
1279dnl *** Tests for EB Library ***
1280dnl ****************************
1281
1282AC_ARG_WITH(eb,
1283  AS_HELP_STRING([--with-eb],
1284    [build with EB]),
1285  [],
1286  [with_eb=no])
1287
1288if test "x$with_eb" = xyes; then
1289  eb_LIB_EB4()
1290  with_eb=$try_eb
1291fi
1292
1293if test "x$with_eb" = xyes; then
1294  AC_DEFINE(HAVE_EBLIB, 1,
1295    [Define to 1 if you have EB library and header file])
1296fi
1297
1298AM_CONDITIONAL(EB, test "x$with_eb" = xyes)
1299
1300dnl test for OS X
1301AC_ARG_WITH(osx-dcs,
1302  AS_HELP_STRING([--with-osx-dcs],
1303    [build with OS X Dictionary Services]),
1304  [],
1305  [with_osx_dcs=no])
1306
1307if test "x$with_osx_dcs" = xyes; then
1308  case $host_os in
1309  darwin*)
1310    with_osx_dcs=yes
1311    ;;
1312  *)
1313    with_osx_dcs=no
1314    ;;
1315  esac
1316fi
1317
1318AM_CONDITIONAL(OSX_DCS, test "x$with_osx_dcs" = xyes)
1319
1320# Check whether user wants libedit support
1321# This code was based on openssh-4.1p1
1322
1323AC_ARG_WITH(libedit,
1324  AC_HELP_STRING([--with-libedit[=DIR]],
1325    [enable libedit support @<:@default=yes@:>@]),
1326  [],
1327  [with_libedit=yes])
1328
1329if test "x$with_libedit" != xno; then
1330  if test "x$with_libedit" = xyes; then
1331    libedit_path=/usr
1332  else
1333    libedit_path="$with_libedit"
1334    with_libedit=yes
1335  fi
1336
1337  saved_CPPFLAGS=$CPPFLAGS
1338  saved_LDFLAGS=$LDFLAGS
1339  CPPFLAGS="${CPPFLAGS} -I$libedit_path/include"
1340  LDFLAGS="${LDFLAGS} -L$libedit_path/lib"
1341  AC_CHECK_LIB(curses, tgetent, LIBEDIT_LIBS="-lcurses",
1342    [AC_CHECK_LIB(ncurses, tgetent, LIBEDIT_LIBS="-lncurses",
1343      AC_MSG_WARN("libedit needs libcurses or libncurses. disabled...")
1344        with_libedit=no)])
1345
1346  if test "x$with_libedit" != xno; then
1347      AC_CHECK_LIB(edit, el_init,
1348        [LIBEDIT_LIBS="-ledit $LIBEDIT_LIBS -L$libedit_path/lib"
1349          AC_SUBST(LIBEDIT_LIBS)],
1350        [AC_MSG_WARN("libedit not found. Disabled...")
1351          with_libedit=no])
1352  fi
1353  CPPFLAGS=$saved_CPPFLAGS
1354  LDFLAGS=$saved_LDFLAGS
1355fi
1356
1357AM_CONDITIONAL(LIBEDIT, test "x$with_libedit" != xno)
1358
1359AM_CONDITIONAL(LIBUIM_X_UTIL, test "x$have_x" = xyes)
1360AM_CONDITIONAL(NEED_SETENV_C,
1361              test "x$ac_cv_func_setenv" = xno -o "x$ac_cv_func_unsetenv" = xno)
1362AM_CONDITIONAL(NEED_STRSEP_C, test $ac_cv_func_strsep = no)
1363AM_CONDITIONAL(GCC, test "x$ac_cv_c_compiler_gnu" = xyes)
1364AM_CONDITIONAL(GXX, test "x$ac_cv_cxx_compiler_gnu" = xyes)
1365
1366IT_PROG_INTLTOOL([0.36.3], [no-xml])
1367
1368dnl **********************************
1369dnl *** test for KDE3 applet.. XXX ***
1370dnl **********************************
1371AC_ARG_ENABLE(kde-applet,
1372  AC_HELP_STRING([--disable-kde-applet],
1373    [do not build uim applet for KDE3 panel]),
1374  [],
1375  [enable_kde_applet=yes])
1376
1377if test "x$enable_kde_applet" != xno; then
1378  if test "x$with_qt" = xyes; then
1379    if test "x$KDE_CONFIG" != xno; then
1380      KDE_PREFIX=`kde-config --prefix`
1381      KDE_LIB_DIR=`kde-config --expandvars --install lib`
1382      KDE_DATA_DIR=`kde-config --expandvars --install data`
1383
1384      saved_cppflags="${CPPFLAGS}"
1385      CPPFLAGS="-I${KDE_PREFIX}/include/kde ${CPPFLAGS} ${QT_CXXFLAGS}"
1386      AC_LANG_PUSH(C++)
1387      AC_CHECK_HEADER([${KDE_PREFIX}/include/kde/kpanelapplet.h],
1388        [enable_kde_applet=yes KDE_INCLUDE_DIR="${KDE_PREFIX}/include/kde"],
1389        [enable_kde_applet=no])
1390      if test "x$enable_kde_applet" = xno; then
1391        CPPFLAGS="-I${KDE_PREFIX}/include ${saved_cppflags} ${QT_CXXFLAGS}"
1392        AC_CHECK_HEADER([${KDE_PREFIX}/include/kglobal.h],
1393          [enable_kde_applet=yes KDE_INCLUDE_DIR="${KDE_PREFIX}/include"],
1394          [enable_kde_applet=no])
1395      fi
1396      CPPFLAGS="${saved_cppflags}"
1397      AC_LANG_POP(C++)
1398    else
1399      enable_kde_applet=no
1400    fi
1401  else
1402    enable_kde_applet=no
1403  fi
1404fi
1405
1406AC_SUBST(KDE_PREFIX)
1407AC_SUBST(KDE_LIB_DIR)
1408AC_SUBST(KDE_DATA_DIR)
1409AC_SUBST(KDE_INCLUDE_DIR)
1410
1411AM_CONDITIONAL(KDE_APPLET, test "x$enable_kde_applet" = xyes)
1412
1413dnl ****************************
1414dnl *** test for KDE4 applet ***
1415dnl ****************************
1416AC_ARG_ENABLE(kde4-applet,
1417  AC_HELP_STRING([--disable-kde4-applet],
1418    [do not build uim KDE4 Plasma widget]),
1419  [],
1420  [enable_kde4_applet=yes])
1421
1422if test "x$enable_kde4_applet" != xno; then
1423  if test "x$with_qt4" != xyes; then
1424    enable_kde4_applet=no
1425  fi
1426fi
1427
1428AC_PATH_PROG(CMAKE, [cmake], [no])
1429if test "x$enable_kde4_applet" = xyes && test "x$CMAKE" = xno; then
1430  AC_MSG_WARN([no CMake found])
1431  enable_kde4_applet=no
1432fi
1433
1434AC_PATH_PROG(KDE4_CONFIG, [kde4-config], [no])
1435if test "x$with_qt4" = xyes || test "x$with_qt5" = xyes; then
1436  if test "x$KDE4_CONFIG" != xno; then
1437    KDE4_ICONDIR=`$KDE4_CONFIG --expandvars --install icon`
1438  fi
1439  if test -z "$KDE4_ICONDIR"; then
1440    KDE4_ICONDIR="$prefix/share/icons"
1441  fi
1442  AC_DEFINE_UNQUOTED(KDE4_ICONDIR, "$KDE4_ICONDIR", [kde4 icon directory])
1443fi
1444
1445if test "x$enable_kde4_applet" = xyes && test "x$KDE4_CONFIG" = xno; then
1446  AC_MSG_WARN([no kde4-config found])
1447  enable_kde4_applet=no
1448fi
1449
1450AM_CONDITIONAL(KDE4_APPLET, test "x$enable_kde4_applet" = xyes)
1451
1452AC_ARG_ENABLE(pref,
1453  AC_HELP_STRING([--disable-pref],
1454    [do not build graphical utility to edit user settings]),
1455  [],
1456  [enable_pref=yes])
1457
1458if test "x$enable_pref" != xno; then
1459  if test x"$default_toolkit" = xgtk && \
1460     test x"$with_gtk2_4" = xyes; then
1461    enable_pref=yes
1462  elif test x"$default_toolkit" = xgtk3 && \
1463       test x"$with_gtk3" = xyes; then
1464    enable_pref=yes
1465  elif test x"$default_toolkit" = xqt && \
1466       test x"$with_qt" = xyes; then
1467    enable_pref=yes
1468  elif test x"$default_toolkit" = xqt4 && \
1469       test x"$with_qt4" = xyes; then
1470    enable_pref=yes
1471  elif test x"$default_toolkit" = xqt5 && \
1472       test x"$with_qt5" = xyes; then
1473    enable_pref=yes
1474  else
1475    enable_pref=no
1476    AC_MSG_WARN([uim-pref needs GTK+ or Qt toolkit, disabled...])
1477  fi
1478fi
1479
1480AM_CONDITIONAL(PREF, test x"$enable_pref" = xyes)
1481
1482AC_ARG_ENABLE(anthy-static,
1483  AC_HELP_STRING([--enable-anthy-static],
1484    [enable static Anthy]),
1485  [],
1486  [enable_anthy_static=no])
1487
1488AM_CONDITIONAL(ENABLE_ANTHY_STATIC, test "x$enable_anthy_static" = xyes)
1489
1490AC_ARG_ENABLE(anthy-utf8-static,
1491  AC_HELP_STRING([--enable-anthy-utf8-static],
1492    [enable static Anthy-UTF8]),
1493  [],
1494  [enable_anthy_utf8_static=no])
1495
1496AM_CONDITIONAL(ENABLE_ANTHY_UTF8_STATIC,
1497               test "x$enable_anthy_utf8_static" = xyes)
1498
1499# ****************************
1500# *** Tests for uim-notify ***
1501# ****************************
1502notify_targets='stderr libnotify knotify3 knotify4 growl'
1503
1504AC_ARG_ENABLE(notify,
1505  AS_HELP_STRING([--enable-notify@<:@=agent-list@:>@ (HIGHLY EXPERIMENTAL)],
1506    [enable system message notification for users
1507     (specify comma separated notification agent list from
1508      stderr, libnotify, knotify3, knotify4 and growl)]),
1509  [],
1510  [enable_notify=yes])
1511
1512if test "x$enable_notify" != xno; then
1513  AC_DEFINE(UIM_USE_NOTIFY_PLUGINS, 1,
1514            [Define to 1 if you want to use uim-notify plugins])
1515  use_notify="stderr "
1516
1517  for i in `echo $enable_notify | ${SED} 's/,/ /g'`; do
1518    eval "au_enable_$i=yes"
1519  done
1520fi
1521
1522AC_MSG_CHECKING([whether libnotify is requested])
1523if test "x$au_enable_libnotify" = xyes; then
1524  AC_MSG_RESULT([yes])
1525  PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= 0.4,
1526                    use_libnotify=yes, use_libnotify=no)
1527  if test "x$use_libnotify" = xyes; then
1528    AC_DEFINE(ENABLE_LIBNOTIFY, 1, [set notify interface with libnotify])
1529    AC_SUBST(LIBNOTIFY_LIBS)
1530    AC_SUBST(LIBNOTIFY_CFLAGS)
1531    use_notify="${use_notify}libnotify "
1532  fi
1533else
1534  AC_MSG_RESULT(no)
1535fi
1536
1537AC_MSG_CHECKING([whether knotify3 is requested])
1538if test "x$au_enable_knotify3" = xyes; then
1539  AC_MSG_RESULT([yes])
1540  if test "x$with_qt4_immodule" = xyes; then
1541    AC_MSG_WARN([knotify3 could not be used with qt4-immodule enabled])
1542    use_knotify3=no
1543  elif test "x$with_qt" = xyes; then
1544    if test "x$KDE_CONFIG" != xno; then
1545      KNOTIFY3_PREFIX=`kde-config --prefix`
1546      KNOTIFY3_LIB_DIR=`kde-config --expandvars --install lib`
1547      KNOTIFY3_DATA_DIR=`kde-config --expandvars --install data`
1548      saved_cppflags="${CPPFLAGS}"
1549      CPPFLAGS="-I${KNOTIFY3_PREFIX}/include/kde ${CPPFLAGS} ${QT_CXXFLAGS}"
1550      AC_LANG_PUSH(C++)
1551      AC_CHECK_HEADER([${KNOTIFY3_PREFIX}/include/kde/knotifyclient.h],
1552                      [use_knotify3=yes KNOTIFY3_INCLUDE_DIR="${KNOTIFY3_PREFIX}/include/kde"], [use_knotify3=no])
1553      if test "x$use_knotify3" = xno; then
1554        CPPFLAGS="-I${KNOTIFY3_PREFIX}/include ${saved_cppflags} ${QT_CXXFLAGS}"
1555        AC_CHECK_HEADER([${KNOTIFY3_PREFIX}/include/knotifyclient.h],
1556                        [use_knotify3=yes KNOTIFY3_INCLUDE_DIR="${KNOTIFY3_PREFIX}/include"], [use_knotify3=no])
1557      fi
1558      CPPFLAGS="${saved_cppflags}"
1559      AC_LANG_POP(C++)
1560    else
1561      use_knotify3=no
1562    fi
1563  else
1564    use_knotify3=no
1565  fi
1566else
1567  AC_MSG_RESULT(no)
1568fi
1569
1570if test "x$use_knotify3" = xyes; then
1571  AC_DEFINE(ENABLE_KNOTIFY3, 1, [set notify interface with knotify3])
1572  AC_SUBST(KNOTIFY3_PREFIX)
1573  AC_SUBST(KNOTIFY3_LIB_DIR)
1574  AC_SUBST(KNOTIFY3_DATA_DIR)
1575  AC_SUBST(KNOTIFY3_INCLUDE_DIR)
1576  use_notify="${use_notify}knotify3 "
1577fi
1578
1579AC_MSG_CHECKING([whether knotify4 is requested])
1580if test "x$au_enable_knotify4" = xyes; then
1581  if test "x$CMAKE" != xno; then
1582    AC_MSG_RESULT([yes])
1583    use_knotify4=yes
1584    use_notify="${use_notify}knotify4 "
1585  else
1586    AC_MSG_WARN([no CMake found])
1587    use_knotify4=no
1588  fi
1589else
1590  AC_MSG_RESULT(no)
1591fi
1592
1593AC_MSG_CHECKING([whether growl is requested])
1594if test "x$au_enable_growl" = xyes; then
1595  AC_MSG_RESULT([yes])
1596  use_growl=yes
1597  use_notify="${use_notify}growl "
1598else
1599  AC_MSG_RESULT(no)
1600fi
1601
1602if test "x$use_notify" = x; then
1603  use_notify=none
1604fi
1605
1606AM_CONDITIONAL(NOTIFY, test "x$enable_notify" != xno)
1607AM_CONDITIONAL(LIBNOTIFY, test "x$use_libnotify" = xyes)
1608AM_CONDITIONAL(KNOTIFY3, test "x$use_knotify3" = xyes)
1609AM_CONDITIONAL(KNOTIFY4, test "x$use_knotify4" = xyes)
1610AM_CONDITIONAL(GROWL, test "x$use_growl" = xyes)
1611
1612AC_DEFINE(UIM_USE_ERROR_GUARD, 1, [Define to 1 if you want to use longjmp-based error handlings])
1613
1614#
1615# Compiler options
1616#
1617
1618# Debugging-related flags
1619if test "x$enable_debug" = xyes; then
1620  # add -g flag to CFLAGS regardless of GCC=yes or not
1621  if test "x$ac_cv_prog_cc_g" = xyes; then
1622    CFLAGS="$CFLAGS -g"
1623    CXXFLAGS="$CXXFLAGS -g"
1624  fi
1625
1626  # Restricting the C dialect tends to cause system library disfunction such as
1627  # on glibc and Darwin libc. So this option is only specified at debugging
1628  # mode.
1629  #
1630  # -std=gnu89 is required only for (old?) glibc. -std=c89 is sufficient for
1631  # other environments.
1632  AC_LANG_WERROR  # Turn warning-only unknown options into error.
1633  if test "x$ax_cv_lib_glibc" = xyes; then
1634    AX_CFLAGS_GCC_OPTION([-std=gnu89])
1635  else
1636    AX_CFLAGS_GCC_OPTION([-std=c89])
1637  fi
1638  AX_LANG_WNOERROR  # end AC_LANG_WERROR
1639
1640  QT_CONFIG_OPTS="debug"
1641else
1642  CFLAGS="$CFLAGS -DNDEBUG"
1643  CXXFLAGS="$CXXFLAGS -DNDEBUG"
1644
1645  # Suppress the warnings of combined-mode SigScheme
1646  AC_LANG_WERROR  # Turn warning-only unknown options into error.
1647  AX_CFLAGS_GCC_OPTION([-Wno-redundant-decls], [UIM_SCM_CFLAGS])
1648  AX_CFLAGS_GCC_OPTION([-Wno-unused-function], [UIM_SCM_CFLAGS])
1649  AX_LANG_WNOERROR  # end AC_LANG_WERROR
1650
1651  QT_CONFIG_OPTS="release"
1652fi
1653
1654AC_ARG_ENABLE(warnings-into-error,
1655  AC_HELP_STRING([--enable-warnings-into-error],
1656    [treat compiler warnings as error @<:@default=no if !debug@:>@]),
1657    [
1658        case $enable_warnings_into_error in
1659	no)
1660	    ;;
1661	yes|*)
1662	    AX_CFLAGS_GCC_OPTION([-Werror])
1663	    AX_CXXFLAGS_GCC_OPTION([-Werror])
1664	    ;;
1665	esac
1666    ], [
1667	    # Enable -Werror by default if --enable-debug. But since
1668	    # the C89 string length limit always cause the warnings, I
1669	    # disable it for uim-scm.c.  -- YamaKen 2007-07-19
1670	    if test "x$enable_debug" = xyes; then
1671	      AX_CFLAGS_GCC_OPTION([-Werror])
1672	      AX_CXXFLAGS_GCC_OPTION([-Werror])
1673  	      AX_CFLAGS_GCC_OPTION([-Wno-error], [UIM_SCM_CFLAGS])
1674	    fi
1675    ])
1676AC_SUBST(UIM_SCM_CFLAGS)
1677AC_SUBST(QT_CONFIG_OPTS)
1678
1679dnl *************************
1680dnl *** Tests for gosh and GaUnit ***
1681dnl *************************
1682AC_PATH_PROG([GOSH], gosh)
1683AC_PATH_PROG([GAUCHE_CONFIG], gauche-config)
1684AC_MSG_CHECKING([whether to have gosh and GaUnit])
1685if test -n "$GOSH" && test -n "$GAUCHE_CONFIG"; then
1686  gauche_version=`$GAUCHE_CONFIG -V`
1687  gauche_major_version=`echo $gauche_version | \
1688          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1689  gauche_minor_version=`echo $gauche_version | \
1690          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1691  gauche_micro_version=`echo $gauche_version | \
1692          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1693  dnl require 0.8.13
1694  if test "$gauche_major_version" -gt 0 || \
1695     test "$gauche_major_version" -eq 0 -a "$gauche_minor_version" -gt 8 || \
1696     test "$gauche_major_version" -eq 0 -a "$gauche_minor_version" -eq 8 -a \
1697          "$gauche_micro_version" -gt 13; then
1698    echo '(use test.unit)' | $GOSH -b
1699    gosh_result=$?
1700    if test "$gosh_result" = 0; then
1701      gaunit_version=`echo '(use test.unit) (print *gaunit-version*)' | $GOSH -b`
1702      gosh_result=$?
1703      if test "$gosh_result" = 0; then
1704        gaunit_major_version=`echo $gaunit_version | \
1705            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1706        gaunit_minor_version=`echo $gaunit_version | \
1707            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1708        gaunit_micro_version=`echo $gaunit_version | \
1709            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1710        dnl require 0.1.6
1711        if test "$gaunit_major_version" -gt 0 || \
1712           test "$gaunit_major_version" -eq 0 -a \
1713                "$gaunit_minor_version" -gt 6 || \
1714           test "$gaunit_major_version" -eq 0 -a \
1715                "$gaunit_minor_version" -eq 1 -a \
1716                "$gaunit_micro_version" -ge 6; then
1717          have_gosh_and_gaunit=yes
1718        fi
1719      fi
1720    fi
1721  fi
1722fi
1723if test "x$have_gosh_and_gaunit" = xyes; then
1724  AC_MSG_RESULT(yes)
1725else
1726  AC_MSG_RESULT(no)
1727fi
1728AM_CONDITIONAL(DO_CHECK_IN_TEST,
1729               test "x$have_gosh_and_gaunit" = xyes -a "x$enable_debug" = xyes)
1730
1731# Checks for system services
1732
1733AH_BOTTOM([/* Include os specific header. */
1734#include "os_dep.h"])
1735
1736# Add include path
1737INCLUDES='-I$(top_srcdir)/replace -I$(top_srcdir)/uim'
1738AC_SUBST(INCLUDES)
1739
1740SRCDIR=$srcdir
1741AC_SUBST(SRCDIR)
1742AC_SUBST(DESTDIR)
1743
1744AC_SUBST(abs_srcdir)
1745AC_SUBST(abs_builddir)
1746AC_SUBST(abs_top_srcdir)
1747AC_SUBST(abs_top_builddir)
1748
1749# configure sigscheme/ subdir
1750#
1751# --with-master-pkg=uim instructs that pkgdatadir for Scheme libraries.
1752# See also sigscheme/lib/Makefile.am
1753ac_configure_args="$ac_configure_args --with-master-pkg=uim --enable-conf=uim --disable-libsscm --disable-shell"
1754AC_CONFIG_SUBDIRS([sigscheme])
1755
1756AC_ARG_WITH(libgcroots,
1757            AS_HELP_STRING([--with-libgcroots@<:@=WHICH@:>@],
1758                           [use alternative libgcroots instead of
1759                            package-bundled one.
1760                            WHICH=(installed|tiny-subst)
1761                            @<:@default=installed@:>@]))
1762
1763case "${with_libgcroots:=no}" in
1764  no)
1765    # bundled libgcroots package
1766    GCROOTS_LIBS='$(abs_top_builddir)/sigscheme/libgcroots/libgcroots.la'
1767    GCROOTS_CFLAGS='-I$(abs_top_srcdir)/sigscheme/libgcroots/include'
1768  ;;
1769  yes|installed)
1770    PKG_CHECK_MODULES(GCROOTS, [gcroots],
1771                      [],
1772                      [AC_MSG_ERROR([installed libgcroots is not found.])])
1773  ;;
1774  tiny-subst)
1775    # use src/gcroots/gcroots.[hc]
1776    GCROOTS_LIBS=
1777    GCROOTS_CFLAGS='-I$(abs_top_srcdir)/sigscheme/src/gcroots'
1778  ;;
1779  *)
1780    AC_MSG_ERROR([invalid argument for --with-libgcroots.])
1781  ;;
1782esac
1783
1784AC_SUBST(GCROOTS_LIBS)
1785AC_SUBST(GCROOTS_CFLAGS)
1786
1787AC_CONFIG_FILES([Makefile
1788                 po/Makefile.in
1789                 m4/Makefile
1790                 doc/Makefile
1791                 uim/Makefile
1792                 uim/version.h
1793                 scm/Makefile
1794                 gtk2/Makefile
1795                 gtk2/candwin/Makefile
1796                 gtk2/dict/Makefile
1797                 gtk2/dict/uim-dict-ui.xml
1798                 gtk2/immodule/Makefile
1799                 gtk2/pad/Makefile
1800                 gtk2/pref/Makefile
1801                 gtk2/switcher/Makefile
1802                 gtk2/test/Makefile
1803                 gtk2/test/test.sh
1804                 gtk2/toolbar/Makefile
1805                 gtk3/Makefile
1806                 gtk3/candwin/Makefile
1807                 gtk3/dict/Makefile
1808                 gtk3/immodule/Makefile
1809                 gtk3/pad/Makefile
1810                 gtk3/pref/Makefile
1811                 gtk3/switcher/Makefile
1812                 gtk3/test/Makefile
1813                 gtk3/toolbar/Makefile
1814                 qt3/Makefile
1815                 qt3/candwin/Makefile
1816                 qt3/chardict/Makefile
1817                 qt3/immodule/Makefile
1818                 qt3/pref/Makefile
1819                 qt3/switcher/Makefile
1820                 qt3/test/Makefile
1821                 qt3/toolbar/Makefile
1822                 qt3/toolbar/uimapplet.desktop
1823                 qt4/Makefile
1824                 qt4/common.pro
1825                 qt4/candwin/Makefile
1826                 qt4/candwin/uim-candwin-qt4.pro
1827                 qt4/chardict/Makefile
1828                 qt4/chardict/uim-chardict-qt4.pro
1829                 qt4/edittest/Makefile
1830                 qt4/immodule/quiminputcontextplugin.pro
1831                 qt4/immodule/Makefile
1832                 qt4/pref/uim-pref-qt4.pro
1833                 qt4/pref/Makefile
1834                 qt4/switcher/uim-im-switcher-qt4.pro
1835                 qt4/switcher/Makefile
1836                 qt4/toolbar/plasma-applet-uim.desktop
1837                 qt4/toolbar/uim-toolbar-qt4.pro
1838                 qt4/toolbar/Makefile
1839                 qt5/Makefile
1840                 qt5/applet/Makefile
1841                 qt5/applet/qtquick-plugin/Makefile
1842                 qt5/candwin/Makefile
1843                 qt5/candwin/uim-candwin-qt5.pro
1844                 qt5/chardict/Makefile
1845                 qt5/chardict/uim-chardict-qt5.pro
1846                 qt5/edittest/Makefile
1847                 qt5/immodule/quimplatforminputcontextplugin.pro
1848                 qt5/immodule/Makefile
1849                 qt5/pref/uim-pref-qt5.pro
1850                 qt5/pref/Makefile
1851                 qt5/switcher/uim-im-switcher-qt5.pro
1852                 qt5/switcher/Makefile
1853                 qt5/toolbar/uim-toolbar-qt5.pro
1854                 qt5/toolbar/Makefile
1855                 xim/Makefile
1856                 fep/Makefile
1857                 emacs/Makefile
1858                 emacs/uim-version.el
1859                 tables/Makefile
1860                 byeoru-data/Makefile
1861                 test/Makefile
1862                 test2/Makefile
1863                 test2/run-singletest.sh
1864                 examples/Makefile
1865                 examples/uim-custom/Makefile
1866                 pixmaps/Makefile
1867                 pixmaps/uim-m17nlib-relink-icons
1868                 replace/Makefile
1869                 notify/Makefile
1870                 uim.pc
1871                 uim.desktop.in
1872])
1873
1874AC_OUTPUT
1875
1876if test "x$CMAKE" != xno; then
1877  if test "x$enable_debug" = xyes; then
1878    cmake_build_type=Debug
1879  else
1880    cmake_build_type=Release
1881  fi
1882  # FIXME: move CMAKE_CXX_FLAGS into cmake_option
1883  cmake_option="-DCMAKE_BUILD_TYPE=${cmake_build_type}"
1884  cmake_option="${cmake_option} -DCMAKE_INSTALL_PREFIX=${prefix}"
1885  cmake_option="${cmake_option} -DCMAKE_SKIP_RPATH=true"
1886  cmake_option="${cmake_option} -DKDE4_USE_ALWAYS_FULL_RPATH=false"
1887fi
1888
1889if test "x$with_qt4" = xyes; then
1890  if test "x$with_qt4_immodule" = xyes; then
1891    qt4_immodule_option="DEFINES+=QT4_IMMODULE"
1892  fi
1893  set -e
1894  # Generate Makefiles for Qt4 by qmake
1895  ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/candwin/Makefile.qmake \
1896    ${ac_abs_top_builddir}/qt4/candwin/uim-candwin-qt4.pro
1897  ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/chardict/Makefile.qmake \
1898    ${ac_abs_top_builddir}/qt4/chardict/uim-chardict-qt4.pro
1899  ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/pref/Makefile.qmake \
1900    ${qt4_immodule_option} \
1901    ${ac_abs_top_builddir}/qt4/pref/uim-pref-qt4.pro
1902  ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/switcher/Makefile.qmake \
1903    ${ac_abs_top_builddir}/qt4/switcher/uim-im-switcher-qt4.pro
1904  ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/toolbar/Makefile.qmake \
1905    ${ac_abs_top_builddir}/qt4/toolbar/uim-toolbar-qt4.pro
1906
1907  # Generate a Makefile for KDE4 applet by cmake
1908  if test "x$enable_kde4_applet" = xyes; then
1909    mkdir -p ${ac_abs_top_builddir}/qt4/toolbar/build
1910    cd ${ac_abs_top_builddir}/qt4/toolbar/build
1911    # FIXME: move CMAKE_CXX_FLAGS into cmake_option
1912    ${CMAKE} -DCMAKE_CXX_FLAGS="${CXXFLAGS} ${X_CFLAGS}" \
1913      ${cmake_option} ${ac_abs_top_srcdir}/qt4/toolbar
1914    cd -
1915  fi
1916  set +e
1917fi
1918
1919if test "x$with_qt4_immodule" = xyes; then
1920  if test "x$enable_qt4_qt3support" = xyes; then
1921    qt4_qt3support_option="QT+=qt3support DEFINES+=ENABLE_QT4_QT3SUPPORT"
1922  fi
1923  set -e
1924  ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/immodule/Makefile.qmake \
1925    ${qt4_qt3support_option} \
1926    ${ac_abs_top_builddir}/qt4/immodule/quiminputcontextplugin.pro
1927  ${QMAKE4} -o ${ac_abs_top_builddir}/qt4/edittest/Makefile.qmake \
1928    ${ac_abs_top_srcdir}/qt4/edittest/edittest.pro
1929  set +e
1930fi
1931
1932if test "x$use_knotify4" = xyes; then
1933  set -e
1934  # Generate a Makefile for KNotify plugin by cmake
1935  mkdir -p ${ac_abs_top_builddir}/notify/build
1936  cd ${ac_abs_top_builddir}/notify/build
1937  # FIXME: move CMAKE_CXX_FLAGS into cmake_option
1938  ${CMAKE} -DCMAKE_CXX_FLAGS="${CXXFLAGS} ${X_CFLAGS}" \
1939    -DUIMNOTIFY_PLUGINDIR="${LIBDIR}/${PACKAGE}"/notify \
1940    ${cmake_option} ${ac_abs_top_srcdir}/notify
1941  cd -
1942  set +e
1943fi
1944
1945# Generate Makefiles for Qt5 by CMake and qmake
1946if test "x$with_qt5" = xyes; then
1947  if test "x$with_qt5_immodule" = xyes; then
1948    qt5_immodule_option="DEFINES+=QT5_IMMODULE"
1949  fi
1950  set -e
1951  # FIXME: move CMAKE_CXX_FLAGS into cmake_option
1952  ${CMAKE} \
1953    -B ${ac_abs_top_builddir}/qt5/applet.cmake \
1954    -S ${ac_abs_top_srcdir}/qt5/applet \
1955    -DCMAKE_CXX_FLAGS="${CXXFLAGS} ${X_CFLAGS}" \
1956    ${cmake_option}
1957  ${QMAKE5} -o ${ac_abs_top_builddir}/qt5/candwin/Makefile.qmake \
1958    ${ac_abs_top_builddir}/qt5/candwin/uim-candwin-qt5.pro
1959  ${QMAKE5} -o ${ac_abs_top_builddir}/qt5/chardict/Makefile.qmake \
1960    ${ac_abs_top_builddir}/qt5/chardict/uim-chardict-qt5.pro
1961  ${QMAKE5} -o ${ac_abs_top_builddir}/qt5/pref/Makefile.qmake \
1962    ${qt5_immodule_option} \
1963    ${ac_abs_top_builddir}/qt5/pref/uim-pref-qt5.pro
1964  ${QMAKE5} -o ${ac_abs_top_builddir}/qt5/switcher/Makefile.qmake \
1965    ${ac_abs_top_builddir}/qt5/switcher/uim-im-switcher-qt5.pro
1966  ${QMAKE5} -o ${ac_abs_top_builddir}/qt5/toolbar/Makefile.qmake \
1967    ${ac_abs_top_builddir}/qt5/toolbar/uim-toolbar-qt5.pro
1968  set +e
1969fi
1970
1971if test "x$with_qt5_immodule" = xyes; then
1972  set -e
1973  ${QMAKE5} -o ${ac_abs_top_builddir}/qt5/immodule/Makefile.qmake \
1974    ${ac_abs_top_builddir}/qt5/immodule/quimplatforminputcontextplugin.pro
1975  ${QMAKE5} -o ${ac_abs_top_builddir}/qt5/edittest/Makefile.qmake \
1976    ${ac_abs_top_srcdir}/qt4/edittest/edittest.pro
1977  set +e
1978fi
1979
1980AC_MSG_RESULT([
1981Configure Result :
1982
1983   Anthy           : ${with_anthy}
1984   Anthy (UTF-8)   : ${with_anthy_utf8}
1985   Canna           : ${with_canna}
1986   Mana            : ${with_mana}
1987   PRIME           : ${with_prime}
1988   SJ3             : ${with_sj3}
1989   SKK             : ${with_skk}
1990   Wnn             : ${with_wnn}
1991   m17n-lib        : ${with_m17nlib}
1992   cURL            : ${with_curl}
1993   expat           : ${expat_found}
1994   OpenSSL         : ${enable_openssl}
1995   SQLite3         : ${with_sqlite3}
1996   ffi             : ${with_ffi}
1997   GTK+2           : ${with_gtk2}
1998   GNOME2 Applet   : ${enable_gnome_applet}
1999   GTK+3           : ${with_gtk3}
2000   GNOME3 Applet   : ${enable_gnome3_applet}
2001   Qt3             : ${with_qt}
2002   Qt3 immodule    : ${with_qt_immodule}
2003   Qt4             : ${with_qt4}
2004   Qt4 immodule    : ${with_qt4_immodule}
2005   Qt4 Qt3Support  : ${enable_qt4_qt3support}
2006   Qt5             : ${with_qt5}
2007   Qt5 immodule    : ${with_qt5_immodule}
2008   KDE3 Applet     : ${enable_kde_applet}
2009   KDE4 Applet     : ${enable_kde4_applet}
2010   FEP             : ${enable_fep}
2011   Emacs           : ${enable_emacs}
2012   XIM             : ${use_xim}
2013   Pref            : ${enable_pref}
2014   DICT            : ${enable_dict}
2015   EB              : ${with_eb}
2016   OSX dictionary  : ${with_osx_dcs}
2017   libedit         : ${with_libedit}
2018   notify          : ${use_notify}
2019   Default toolkit : ${default_toolkit}
2020])
2021
2022if test "x$enable_debug" = xyes; then
2023AC_MSG_RESULT([
2024Configure Result for developers:
2025
2026   DEBUG           : ${enable_debug}
2027])
2028fi
2029