1dnl configure.ac -- autoconf script for the m17n library. 2 3dnl Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 4dnl National Institute of Advanced Industrial Science and Technology (AIST) 5dnl Registration Number H15PRO112 6dnl Copyright (C) 2015, 2016, 2017 K. Handa <handa@gnu.org> 7 8dnl This file is part of the m17n library. 9 10dnl The m17n library is free software; you can redistribute it and/or 11dnl modify it under the terms of the GNU Lesser General Public License 12dnl as published by the Free Software Foundation; either version 2.1 of 13dnl the License, or (at your option) any later version. 14 15dnl The m17n library is distributed in the hope that it will be useful, 16dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 17dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18dnl Lesser General Public License for more details. 19 20dnl You should have received a copy of the GNU Lesser General Public 21dnl License along with the m17n library; if not, write to the Free 22dnl Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 23dnl Boston, MA 02110-1301, USA. 24 25dnl Process this file with autoconf to produce a configure script. 26 27AC_INIT([m17n-lib],[1.8.0],[m17n-lib-bug@m17n.org]) 28AC_CONFIG_MACRO_DIR([m4]) 29AM_INIT_AUTOMAKE 30AC_CONFIG_HEADERS([config.h]) 31AM_MAINTAINER_MODE 32 33API_VERSION=4:2:4 34AC_SUBST(API_VERSION) 35 36# The earliest version that this release has binary compatibility 37# with. This is used for module locations. 38M17N_BINARY_VERSION=1.0 39 40M17N_MODULE_DIR="m17n/$M17N_BINARY_VERSION" 41AC_SUBST(M17N_MODULE_DIR) 42 43 44dnl Checks for programs for compiling. 45AC_PROG_CC 46AC_GNU_SOURCE 47 48AM_GNU_GETTEXT 49AM_GNU_GETTEXT_VERSION([0.17]) 50GETTEXTDIR="$datadir/locale" 51AC_SUBST(GETTEXTDIR) 52 53AC_PROG_LIBTOOL 54dnl LT_PREREQ([2.2.4]) 55dnl LT_INIT 56 57dnl Checks for X libraries. 58AC_PATH_XTRA 59 60dnl Checks for standard header files. 61AC_HEADER_STDC 62AC_HEADER_DIRENT 63AC_HEADER_TIME 64AC_CHECK_HEADERS([fcntl.h langinfo.h limits.h locale.h stdlib.h \ 65 string.h strings.h sys/time.h unistd.h]) 66AC_CHECK_HEADER(X11/Xaw/Command.h, HAVE_XAW=yes) 67 68dnl Checks for typedefs, structures, and compiler characteristics. 69AC_C_CONST 70AC_C_INLINE 71AC_TYPE_SIZE_T 72AC_STRUCT_TM 73 74dnl Checks for endian. This influence the default UTF-16 definition. 75AC_C_BIGENDIAN 76 77dnl Checks for library functions. 78AC_FUNC_ALLOCA 79AC_FUNC_MALLOC 80AC_FUNC_REALLOC 81AC_FUNC_MEMCMP 82AC_FUNC_STAT 83AC_FUNC_STRCOLL 84AC_FUNC_STRFTIME 85AC_FUNC_STRTOD 86AC_CHECK_FUNCS(memmove memset nl_langinfo putenv regcomp setlocale) 87AC_CHECK_FUNCS(strchr strdup gettimeofday) 88 89dnl Checks where the m17n database is installed. 90 91AC_CHECK_PROG(HAVE_M17N_DB, m17n-db, yes) 92if test "x$HAVE_M17N_DB" = "xyes"; then 93 M17NDIR=`m17n-db` 94else 95 M17NDIR="${datadir}/m17n" 96fi 97AC_SUBST(M17NDIR) 98 99dnl Checks which levels of APIs should be compiled. 100 101AC_ARG_ENABLE(gui, 102 AS_HELP_STRING([--enable-gui],[enable GUI level APIs (default is YES)])) 103 104AM_CONDITIONAL(WITH_GUI, test x$with_gui != xno) 105 106if test x$with_gui != xno; then 107 108dnl Checks if dlopen exists, and if it's in libc or libdl. 109 110AC_SEARCH_LIBS(dlopen, , 111 AC_DEFINE(HAVE_DLOPEN, 1, 112 [Define to 1 if you have the function dlopen.])) 113 114dnl Check several libraries without adding -lxxx to LIBS, without 115dnl defining HAVE_LIBXXX nor HAVE_XXX_H because they are used only by 116dnl some libraries (e.g. libm17n-X.so). Instead, define XXX_LD_FLAGS 117dnl and HAVE_XXX if library XXX is available. CPPFLAGS will be 118dnl augmented. 119 120M17N_EXT_LIBS= 121 122AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes) 123AM_CONDITIONAL([HAVE_PKG_CONFIG], [test x$HAVE_PKG_CONFIG = xyes]) 124 125if test "x$no_x" != "xyes"; then 126 AC_DEFINE(HAVE_X11, 1, [Define to 1 if you have X11.]) 127 X11_LD_FLAGS="-lXt -lX11" 128 M17N_EXT_LIBS="$M17N_EXT_LIBS X11" 129 130 if test "x$HAVE_XAW" = "xyes"; then 131 AC_DEFINE(HAVE_X11_XAW_COMMAND_H, 1, 132 [Define to 1 if you have the Xaw header files.]) 133 XAW_LD_FLAGS="-lXaw -lXmu" 134 CONFIG_FLAGS="$CONFIG_FLAGS -DHAVE_X11_XAW_COMMAND_H" 135 M17N_EXT_LIBS="$M17N_EXT_LIBS Xaw" 136 fi 137fi 138AC_SUBST(X11_LD_FLAGS) 139AC_SUBST(XAW_LD_FLAGS) 140 141dnl Check for fribidi library. 142save_CPPFLAGS="$CPPFLAGS" 143save_LIBS="$LIBS" 144AC_CHECK_PROG(HAVE_FRIBIDI_CONFIG, fribidi-config, yes) 145if test "x$HAVE_FRIBIDI_CONFIG" = "xyes"; then 146 CPPFLAGS="$CPPFLAGS `fribidi-config --cflags`" 147 FRIBIDI_LD_FLAGS="`fribidi-config --libs`" 148 LIBS="$LIBS $FRIBIDI_LD_FLAGS" 149else 150 FRIBIDI_LD_FLAGS=-lfribidi 151fi 152AC_CHECK_LIB(fribidi, fribidi_set_mirroring, HAVE_FRIBIDI=yes, HAVE_FRIBIDI=no) 153AC_CHECK_HEADER(fribidi/fribidi.h,, HAVE_FRIBIDI=no) 154if test "x$HAVE_FRIBIDI" = "xyes"; then 155 AC_DEFINE(HAVE_FRIBIDI, 1, 156 [Define to 1 if you have Fribidi library and header file.]) 157 M17N_EXT_LIBS="$M17N_EXT_LIBS fribidi" 158else 159 CPPFLAGS="$save_CPPFLAGS" 160 FRIBIDI_LD_FLAGS= 161fi 162LIBS="$save_LIBS" 163AC_SUBST(FRIBIDI_LD_FLAGS) 164 165dnl Check for otflib usability. 166AC_ARG_WITH(libotf, 167 AS_HELP_STRING([--with-libotf],[with OpenType font suport (default is YES)])) 168 169if test "x$with_libotf" != "xno"; then 170 save_CPPFLAGS="$CPPFLAGS" 171 save_LIBS="$LIBS" 172 AC_CHECK_PROG(HAVE_OTFLIB_CONFIG, libotf-config, yes) 173 OTF_LD_FLAGS=-lotf 174 if test "x$HAVE_OTFLIB_CONFIG" = "xyes"; then 175 CPPFLAGS="$CPPFLAGS `libotf-config --cflags`" 176 OTF_LD_FLAGS="`libotf-config --libs`" 177 LIBS="$LIBS $OTF_LD_FLAGS" 178 elif test "x$HAVE_PKG_CONFIG" = "xyes" ; then 179 if pkg-config libotf ; then 180 CPPFLAGS="$CPPFLAGS `pkg-config --cflags libotf`" 181 OTF_LD_FLAGS="`pkg-config --libs libotf`" 182 fi 183 fi 184 ## We check the availability of OTF_check_features 185 ## because we need libotf-0.9.4 or the later. 186 AC_CHECK_LIB(otf, OTF_check_features, HAVE_OTF=yes, HAVE_OTF=no) 187 AC_CHECK_HEADER(otf.h,, HAVE_OTF=no) 188 if test "x$HAVE_OTF" = "xyes"; then 189 AC_DEFINE(HAVE_OTF, 1, 190 [Define to 1 if you have OTF library and header file.]) 191 M17N_EXT_LIBS="$M17N_EXT_LIBS libotf" 192 AC_CHECK_LIB(otf, OTF_drive_gpos2, HAVE_OTF_DRIVE_GPOS2=yes, 193 HAVE_OTF_DRIVE_GPOS2=no) 194 if test "x$HAVE_OTF_DRIVE_GPOS2" = "xyes"; then 195 AC_DEFINE(HAVE_OTF_DRIVE_GPOS2, 1, 196 [Define to 1 if the OTF library has OTF_drive_gpos2().]) 197 fi 198 else 199 CPPFLAGS="$save_CPPFLAGS" 200 OTF_LD_FLAGS= 201 fi 202 LIBS="$save_LIBS" 203fi 204AC_SUBST(OTF_LD_FLAGS) 205 206dnl Check for Freetype2 usability. 207AC_CHECK_PROG(HAVE_FREETYPE_CONFIG, pkg-config freetype2, yes) 208if test "x$HAVE_FREETYPE_CONFIG" = "xyes"; then 209 FREETYPE_INC=`pkg-config freetype2 --cflags` 210 save_CPPFLAGS="$CPPFLAGS" 211 CPPFLAGS="$CPPFLAGS $FREETYPE_INC" 212 AC_CHECK_HEADER(ft2build.h, HAVE_FREETYPE=yes, 213 HAVE_FREETYPE=no CPPFLAGS="$save_CPPFLAGS") 214 if test "x$HAVE_FREETYPE" = "xyes" ; then 215 save_LIBS="$LIBS" 216 LIBS="$LIBS `pkg-config freetype2 --libs`" 217 AC_CHECK_LIB(freetype, FT_Init_FreeType, HAVE_FREETYPE=yes, 218 HAVE_FREETYPE=no) 219 LIBS="$save_LIBS" 220 if test "x$HAVE_FREETYPE" = "xyes"; then 221 FREETYPE_LD_FLAGS=`pkg-config freetype2 --libs` 222 AC_DEFINE(HAVE_FREETYPE, 1, 223 [Define to 1 if you have FreeType library and header file.]) 224 M17N_EXT_LIBS="$M17N_EXT_LIBS freetype" 225 AC_CHECK_HEADER(freetype/ftbdf.h, HAVE_FTBDF_H=yes, HAVE_FTBDF_H=no, 226 [#include <ft2build.h> 227#include FT_FREETYPE_H]) 228 if test "x$HAVE_FTBDF_H" = "xyes"; then 229 AC_DEFINE(HAVE_FTBDF_H, 1, 230 [Define to 1 if you have freetype/ftbdf.h.]) 231 fi 232 CONFIG_FLAGS="$CONFIG_FLAGS -DHAVE_FREETYPE" 233 fi 234 fi 235fi 236AC_SUBST(FREETYPE_LD_FLAGS) 237 238dnl Check for Xft2 usability. 239save_CPPFLAGS="$CPPFLAGS" 240save_LIBS="$LIBS" 241XFT2_LD_FLAGS="-lXft -lfreetype -lfontconfig -lXrender -lX11" 242AC_CHECK_PROG(HAVE_XFT_CONFIG, xft-config, yes) 243if test "x$HAVE_XFT_CONFIG" = "xyes"; then 244 CPPFLAGS="$CPPFLAGS `xft-config --cflags`" 245 XFT2_LD_FLAGS="`xft-config --libs`" 246elif test "x$HAVE_PKG_CONFIG" = "xyes" ; then 247 if pkg-config xft ; then 248 CPPFLAGS="$CPPFLAGS `pkg-config --cflags xft`" 249 XFT2_LD_FLAGS="`pkg-config --libs xft`" 250 fi 251fi 252LIBS="$LIBS $XFT2_LD_FLAGS" 253AC_CHECK_LIB(Xft, XftDrawCreate, HAVE_XFT2=yes, HAVE_XFT2=no) 254AC_CHECK_HEADER(X11/Xft/Xft.h,, HAVE_XFT2=no, 255 [#include <X11/Xft/Xft.h> 256#if XftVersion >= 20000 257#else 258Version too old. Compiling this line should fail. 259#endif]) 260if test "x$HAVE_XFT2" = "xyes"; then 261 AC_DEFINE(HAVE_XFT2, 1, 262 [Define to 1 if you have Xft2 library and header file.]) 263 M17N_EXT_LIBS="$M17N_EXT_LIBS xft2" 264else 265 XFT2_LD_FLAGS= 266 CPPFLAGS="$save_CPPFLAGS" 267fi 268LIBS="$save_LIBS" 269AC_SUBST(XFT2_LD_FLAGS) 270 271dnl Check for fontconfig usability. 272AC_ARG_WITH(fontconfig, 273 AS_HELP_STRING([--with-fontconfig],[with FontConfig library (default is YES)])) 274if test "x$with_fontconfig" != "xno"; then 275 save_CPPFLAGS="$CPPFLAGS" 276 save_LIBS="$LIBS" 277 FONTCONFIG_LD_FLAGS=-lfontconfig 278 if test "x$HAVE_PKG_CONFIG" = "xyes"; then 279 if pkg-config --exists fontconfig; then 280 CPPFLAGS="$CPPFLAGS `pkg-config --cflags fontconfig`" 281 FONTCONFIG_LD_FLAGS="`pkg-config --libs fontconfig`" 282 LIBS="$LIBS $FONTCONFIG_LD_FLAGS" 283 fi 284 fi 285 AC_CHECK_LIB(fontconfig, FcInit, HAVE_FONTCONFIG=yes, HAVE_FONTCONFIG=no) 286 AC_CHECK_HEADER(fontconfig/fontconfig.h, , HAVE_FONTCONFIG=no) 287 if test "x$HAVE_FONTCONFIG" = "xyes"; then 288 AC_DEFINE(HAVE_FONTCONFIG, 1, 289 [Define to 1 if you have fontconfig library and header file.]) 290 M17N_EXT_LIBS="$M17N_EXT_LIBS fontconfig" 291 else 292 FONTCONFIG_LD_FLAGS= 293 CPPFLAGS="$save_CPPFLAGS" 294 fi 295 LIBS="$save_LIBS" 296fi 297AC_SUBST(FONTCONFIG_LD_FLAGS) 298 299dnl Check for gdlib usability. 300AC_ARG_WITH(gd, 301 AS_HELP_STRING([--with-gd],[suport graphic device by GD library (default is YES)])) 302 303if test "x$with_gd" != "xno"; then 304 save_LIBS="$LIBS" 305 AC_CHECK_LIB(gd, gdImageCreate, HAVE_GD=yes, HAVE_GD=no) 306 AC_CHECK_HEADER(gd.h, , HAVE_GD=no) 307 if test "x$HAVE_GD" = "xyes"; then 308 AC_CHECK_LIB(gd, gdImageCreateTrueColor, HAVE_GD=2, HAVE_GD=1) 309 AC_DEFINE_UNQUOTED(HAVE_GD, $HAVE_GD, 310 [Define to 1 or 2 if you have gd library and header file.]) 311 M17N_EXT_LIBS="$M17N_EXT_LIBS gdlib" 312 GD_LD_FLAGS=-lgd 313 CONFIG_FLAGS="$CONFIG_FLAGS -DHAVE_GD=$HAVE_GD" 314 fi 315 LIBS="$save_LIBS" 316fi 317AC_SUBST(GD_LD_FLAGS) 318 319fi 320 321dnl Check for libxml2 usability. 322save_CPPFLAGS="$CPPFLAGS" 323save_LIBS="$LIBS" 324AC_CHECK_PROG(HAVE_XML2_CONFIG, xml2-config, yes) 325if test "x$HAVE_XML2_CONFIG" = "xyes"; then 326 CPPFLAGS="$CPPFLAGS `xml2-config --cflags`" 327 XML2_LD_FLAGS="`xml2-config --libs`" 328 LIBS="$LIBS $XML2_LD_FLAGS" 329else 330 CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2" 331 XML2_LD_FLAGS="-lxml2 -lz -lpthread -lm" 332fi 333AC_CHECK_LIB(xml2, xmlParseMemory, HAVE_XML2=yes, HAVE_XML2=no) 334AC_CHECK_HEADER(libxml/tree.h,, HAVE_XML2=no, /**/) 335if test "x$HAVE_XML2" = "xyes"; then 336 AC_DEFINE(HAVE_XML2, 1, 337 [Define to 1 if you have libxml2 library and header file]) 338 M17N_EXT_LIBS="$M17N_EXT_LIBS xml2" 339else 340 XML2_LD_FLAGS= 341 CPPFLAGS="$save_CPPFLAGS" 342fi 343LIBS="$save_LIBS" 344AC_SUBST(XML2_LD_FLAGS) 345 346dnl Check for Anthy usability. 347AC_ARG_WITH(anthy, 348 AC_HELP_STRING([--with-anthy], 349 [with Anthy library (default is YES)])) 350if test "x$with_anthy" != "xno"; then 351 352PKG_CHECK_MODULES(ANTHY, anthy, HAVE_ANTHY=yes, HAVE_ANTHY=no) 353if test "x$HAVE_ANTHY" = "xyes"; then 354 AC_DEFINE(HAVE_ANTHY, 1, 355 [Define to 1 if you have Anthy library and header file]) 356 M17N_EXT_LIBS="$M17N_EXT_LIBS anthy" 357 ANTHY_LD_FLAGS="$ANTHY_LIBS" 358 CONFIG_FLAGS="$CONFIG_FLAGS -DHAVE_ANTHY" 359fi 360 361fi 362AC_SUBST(ANTHY_LD_FLAGS) 363 364dnl Check for Ispell usability. 365AC_CHECK_PROG(HAVE_ISPELL, ispell, yes) 366if test "x$HAVE_ISPELL" = "xyes"; then 367 AC_DEFINE(HAVE_ISPELL, 1, [Define if ispell is available.]) 368 M17N_EXT_LIBS="$M17N_EXT_LIBS ispell" 369 CONFIG_FLAGS="$CONFIG_FLAGS -DHAVE_ISPELL" 370fi 371 372dnl Check for Thai word-segmentation library. 373dnl If we have one, define HAVE_THAI_WORDSEG and one of these: 374dnl HAVE_LIBTHAI, HAVE_WORDCUT, or HAVE_WORDCUT_OLD 375dnl In addition, set THAI_WORDSEG_LD_FLAGS to a proper value. 376AC_ARG_WITH(libthai, 377 AC_HELP_STRING([--with-libthai], 378 [with libThai library (default is YES)])) 379if test "x$with_libthai" != "xno"; then 380 381PKG_CHECK_MODULES(LIBTHAI, libthai, HAVE_LIBTHAI=yes, HAVE_LIBTHAI=no) 382PKG_CHECK_MODULES(WORDCUT, wordcut, HAVE_WORDCUT=yes, HAVE_WORDCUT=no) 383 384if test "x$HAVE_LIBTHAI" = "xyes"; then 385 386 AC_DEFINE(HAVE_LIBTHAI, 1, [Define if you have libthai]) 387 THAI_WORDSEG_LD_FLAGS="$LIBTHAI_LIBS" 388 M17N_EXT_LIBS="$M17N_EXT_LIBS libthai" 389 HAVE_THAI_WORDSEG=yes 390 391elif test "x$HAVE_WORDCUT" = "xyes"; then 392 393 save_CPPFLAGS="$CPPFLAGS" 394 CPPFLAGS="$CPPFLAGS $WORDCUT_CFLAGS" 395 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <wordcut/wcwordcut.h>]])],[],[HAVE_WORDCUT=no]) 396 if test "x$HAVE_WORDCUT" = "xno"; then 397 PKG_CHECK_MODULES(GLIB_2_0, glib-2.0, HAVE_GLIB_2_0=yes, HAVE_GLIB_2_0=no) 398 if test "x$HAVE_GLIB_2_0" = "xyes"; then 399 CPPFLAGS="$CPPFLAGS $GLIB_2_0_CFLAGS" 400 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <wordcut/wcwordcut.h>]])],[HAVE_WORDCUT=yes],[]) 401 fi 402 fi 403 if test "x$HAVE_WORDCUT" = "xyes"; then 404 THAI_WORDSEG_LD_FLAGS="$WORDCUT_LIBS" 405 AC_DEFINE(HAVE_WORDCUT, 1, 406 [Define if you have the wordcut library and header file]) 407 M17N_EXT_LIBS="$M17N_EXT_LIBS wordcut" 408 HAVE_THAI_WORDSEG=yes 409 else 410 CPPFLAGS="$save_CPPFLAGS" 411 fi 412 413else 414 415 AC_CHECK_LIB(wordcut, wordcut_init, HAVE_WORDCUT_OLD=yes) 416 if test "x$HAVE_WORDCUT_OLD" = "xyes"; then 417 if test -f "/usr/share/wordcut/tdict.wcd"; then 418 tdict="/usr/share/wordcut/tdict.wcd" 419 elif test -f "/usr/local/share/wordcut/tdict.wcd"; then 420 tdict="/usr/local/share/wordcut/tdict.wcd" 421 fi 422 echo "TDICT=$tdict" 423 if test "x$tdict" != "x"; then 424 AC_DEFINE(HAVE_WORDCUT_OLD, 1, 425 [Define if you have the old version of wordcut library]) 426 AC_DEFINE_UNQUOTED(WORDCUT_TDICT, "$tdict", [Define tdict file name]) 427 THAI_WORDSEG_LD_FLAGS=-lwordcut 428 M17N_EXT_LIBS="$M17N_EXT_LIBS wordcut-old" 429 HAVE_THAI_WORDSEG=yes 430 else 431 HAVE_WORDCUT=no 432 fi 433 fi 434fi 435 436if test "x$HAVE_THAI_WORDSEG" = "xyes"; then 437 AC_DEFINE(HAVE_THAI_WORDSEG, 1, 438 [Define if you have some Thai word-segmentation library]) 439fi 440 441fi 442AC_SUBST(THAI_WORDSEG_LD_FLAGS) 443 444AC_SUBST(CONFIG_FLAGS) 445 446dnl We can't include X_CFLAGS in AM_CPPFLAGS because the generated 447dnl Makefile put ${AM_CPPFLAGS} before ${CPPFLAGS} and that leads to 448dnl inclusion of an incorrect header file. So, append X_CFLAGS to 449dnl CPPFLAGS here directly. 450 451CPPFLAGS="$CPPFLAGS $X_CFLAGS" 452 453dnl AC_ARG_ENABLE(xom, 454dnl [ --enable-xom build and install XOM library.], 455dnl XOM="$enableval") 456 457SHLIB_EXT=".so" 458case $host_os in 459darwin* | rhapsody*) 460 SHLIB_EXT=".dylib";; 461esac 462AC_DEFINE_UNQUOTED(DLOPEN_SHLIB_EXT, "$SHLIB_EXT", 463 [Define to loadable module extention]) 464 465AC_CONFIG_FILES([Makefile intl/Makefile po/Makefile.in 466 src/Makefile 467 example/Makefile 468 m17n-config 469 m17n-core.pc 470 m17n-shell.pc 471 m17n-flt.pc 472 m17n-gui.pc 473 ]) 474 475dnl if test "x$XOM" = "xyes"; then 476dnl AC_CONFIG_FILES(omM17N/Makefile) 477dnl fi 478 479AC_OUTPUT 480 481echo "The m17n library is configured with these external libraries." 482echo " $M17N_EXT_LIBS" 483 484dnl Local Variables: 485dnl comment-start: "dnl " 486dnl comment-end: "" 487dnl comment-start-skip: "\\bdnl\\b\\s *" 488dnl End: 489