1dnl Process this file with autoconf to produce a configure script. 2AC_PREREQ(2.62) 3AC_INIT([liblangtag], 0.6.3, [http://github.com/tagoh/liblangtag/issues]) 4 5. `dirname $0`/requires 6 7AM_INIT_AUTOMAKE([1.11 -Wno-portability]) 8dnl Support silent build rules, requires at least automake-1.11. 9dnl Enable by either passing --enable-silent-rules to configure or 10dnl passing V=0 to make. 11m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 12 13m4_pattern_allow(^LT_.*_DECLS$) 14m4_pattern_allow(^LT_POINTER_.*$) 15m4_pattern_allow(^LT_HAVE_.*$) 16 17AM_MAINTAINER_MODE 18AC_CONFIG_HEADERS([config.h]) 19AC_CONFIG_MACRO_DIR([m4macros]) 20 21AX_CHECK_ENABLE_DEBUG([no], [ENABLE_DEBUG]) 22AM_CONDITIONAL(ENABLE_DEBUG, test $ax_enable_debug = yes) 23 24AC_USE_SYSTEM_EXTENSIONS 25AC_PROG_CC 26AM_PROG_AR 27 28GNOME_COMPILE_WARNINGS 29GNOME_MAINTAINER_MODE_DEFINES 30 31LT_PREREQ([2.2]) 32LT_INIT([disable-static win32-dll]) 33 34dnl ====================================================================== 35dnl Libraries versioning 36dnl ====================================================================== 37dnl Quote from Updating library version information at libtool.info 38dnl and renumbering 39dnl 40dnl 1. Update the version information only immediately before a public 41dnl release of your software. More frequent updates are unnecessary, 42dnl and only guarantee that the current interface number gets larger 43dnl faster. 44dnl 2. If the library source code has changed at all since the last 45dnl update, then increment REVISION (`C:R:A' becomes `C:r+1:A') 46dnl 3. If any interfaces have been added, removed, or changed since the 47dnl last update, increment CURRENT, and set REVISION to 0. 48dnl 4. If any interfaces have been added since the last public release, 49dnl then increment AGE. 50dnl 5. If any interfaces have been removed since the last public release, 51dnl then set CURRENT to the so number +1 and set AGE to 0. 52dnl 53 54dnl for liblangtag.la 55LT_CURRENT=5 56LT_REVISION=1 57LT_AGE=4 58 59AC_SUBST(LT_CURRENT) 60AC_SUBST(LT_REVISION) 61AC_SUBST(LT_AGE) 62 63dnl for liblangtag-gobject.la 64LT_G_CURRENT=3 65LT_G_REVISION=0 66LT_G_AGE=3 67 68AC_SUBST(LT_G_CURRENT) 69AC_SUBST(LT_G_REVISION) 70AC_SUBST(LT_G_AGE) 71 72dnl ====================================================================== 73dnl define variables 74dnl ====================================================================== 75AM_MISSING_PROG([GIT], [git]) 76 77LANGTAG_MODULEDIR="${libdir}/liblangtag" 78AC_SUBST(LANGTAG_MODULEDIR) 79 80AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes) 81 82dnl check for flavours of varargs macros 83AC_MSG_CHECKING(for ISO C99 varargs macros in C) 84_save_cflags=$CFLAGS 85CFLAGS=$(sed -e 's/\-Werror//g') 86AC_TRY_COMPILE([],[ 87int a(int p1, int p2, int p3); 88#define call_a(...) a(1,__VA_ARGS__) 89call_a(2,3); 90],[have_iso_c_varargs=yes;AC_DEFINE(LT_HAVE_ISO_VARARGS, 1, [Use ISO C99 varargs])],[have_iso_c_varargs=no]) 91CFLAGS=$_save_cflags 92AC_MSG_RESULT($have_iso_c_varargs) 93 94AC_MSG_CHECKING(for GNUC varargs macros) 95_save_cflags=$CFLAGS 96CFLAGS=$(sed -e 's/\-Werror//g') 97AC_TRY_COMPILE([],[ 98int a(int p1, int p2, int p3); 99#define call_a(params...) a(1,params) 100call_a(2,3); 101],[have_gnuc_varargs=yes;AC_DEFINE(LT_HAVE_GNUC_VARARGS, 1, [Use GNUC varargs macro])],[have_gnuc_varargs=no]) 102CFLAGS=$_save_cflags 103AC_MSG_RESULT($have_gnuc_varargs) 104 105dnl inline 106AC_CACHE_CHECK([for __inline], [lt_cv_has__inline], 107 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 108 __inline int foo(void); 109 __inline int foo() {return 0;} 110 int main() {return foo();} 111 ]])], 112 [lt_cv_has__inline=yes], 113 [lt_cv_has__inline=no], []) 114]) 115case x$lt_cv_has__inline in 116xyes) 117 AC_DEFINE(LT_HAVE___INLINE,1,[Have __inline keyword]) 118esac 119AC_CACHE_CHECK([for __inline__], [lt_cv_has__inline__], 120 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 121 __inline__ int foo(void); 122 __inline__ int foo() {return 0;} 123 int main() {return foo();} 124 ]])], 125 [lt_cv_has__inline__=yes], 126 [lt_cv_has__inline__=no], []) 127]) 128case x$lt_cv_has__inline__ in 129xyes) 130 AC_DEFINE(LT_HAVE___INLINE__,1,[Have __inline__ keyword]) 131esac 132AC_CACHE_CHECK([for inline], [lt_cv_hasinline], 133 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 134 #undef inline 135 inline int foo(void); 136 inline int foo() {return 0;} 137 int main() {return foo();} 138 ]])], 139 [lt_cv_hasinline=yes], 140 [lt_cv_hasinline=no], []) 141]) 142case x$lt_cv_hasinline in 143xyes) 144 AC_DEFINE(LT_HAVE_INLINE,1,[Have inline keyword]) 145esac 146AC_MSG_CHECKING(if inline functions in headers work) 147AC_LINK_IFELSE([AC_LANG_SOURCE([[ 148#if defined (LT_HAVE_INLINE) && defined (__GNUC__) && defined (__STRICT_ANSI__) 149#undef inline 150#define inline __inline__ 151#elif !defined (LT_HAVE_INLINE) 152#undef inline 153#if defined (LT_HAVE___INLINE__) 154#define inline __inline__ 155#elif defined (LT_HAVE___INLINE) 156#define inline __inline 157#endif 158#endif 159 160int lt_test_func2(int); 161 162static inline int 163lt_test_func1(void) { 164 return lt_test_func2(1); 165} 166int main(void) {int i = 1; return --i;}]])],[lt_can_inline=yes;AC_DEFINE(LT_CAN_INLINE, 1, [Wheter inline statement can be used])],[lt_can_inline=no]) 167AC_MSG_RESULT($lt_can_inline) 168 169dnl ---build-in atomic functions--- 170AC_CACHE_CHECK([for gcc atomic builtins], [lt_cv_has_atomic], 171 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 172int i, j = 0; 173i = __sync_fetch_and_add(&j, 1); 174__sync_synchronize(); 175j = __sync_fetch_and_sub(&i, 1); 176return j; 177 ]])], [lt_cv_has_atomic=yes], 178 [_save_cflags="$CFLAGS" 179 CFLAGS="$CFLAGS -march=i486" 180 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ 181int i, j = 0; 182i = __sync_fetch_and_add(&j, 1); 183__sync_synchronize(); 184j = __sync_fetch_and_sub(&i, 1); 185return j; 186 ]])], [AC_MSG_ERROR([liblangtag has to be built with -march=i486 or later.])]) 187 # the above code is just to inform the flag is required to be built. 188 # so regardless of that, we deal with no-atomic-function here. 189 CFLAGS="$_save_cflags" 190 lt_cv_has_atomic=no]) 191]) 192if test "x$lt_cv_has_atomic" = "xyes"; then 193 AC_DEFINE(LT_HAVE_ATOMIC_BUILTINS, 1, [Have buit-in atomic functions]) 194fi 195 196dnl ---size--- 197AC_CHECK_SIZEOF(int) 198AC_CHECK_SIZEOF(void *) 199AC_CHECK_SIZEOF(long) 200AC_CHECK_SIZEOF(long long) 201AC_TYPE_SIZE_T 202AC_TYPE_SSIZE_T 203 204dnl ---alignment--- 205AC_CHECK_ALIGNOF(void *) 206 207dnl ---check build env--- 208if test -f $srcdir/data/common/bcp47/variant.xml; then 209 TEST_DATADIR="\\\"\$(abs_top_srcdir)/data/\\\"" 210else 211 TEST_DATADIR="\\\"\$(abs_top_builddir)/data/\\\"" 212fi 213AC_SUBST(TEST_DATADIR) 214 215dnl ====================================================================== 216dnl functions testing 217dnl ====================================================================== 218AX_CREATE_STDINT_H([liblangtag/lt-stdint.h]) 219AC_CHECK_HEADERS([dirent.h execinfo.h libgen.h sys/param.h]) 220AC_CHECK_FUNCS([backtrace getegid geteuid getgid getuid __secure_getenv secure_getenv strndup vasprintf vsnprintf]) 221AC_CHECK_VA_COPY 222 223AC_CACHE_CHECK([Whether vsnprintf is C99-compliant], [lt_cv_c99_vsnprintf], 224 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 225#include <sys/types.h> 226#include <stdio.h> 227#include <stdarg.h> 228#include <stdlib.h> 229int 230foo(char *format, ...) 231{ 232 va_list ap; 233 char c; 234 int retval = 0; 235 236 va_start(ap, format); 237 if (vsnprintf(&c, 1, format, ap) < 0) { 238 retval = -1; 239 } 240 va_end(ap); 241 242 return retval; 243} 244int 245main(void) 246{ 247 char c; 248 249 return foo("foo: %s", "bar"); 250}]])], 251 [lt_cv_c99_vsnprintf=yes],[lt_cv_c99_vsnprintf=no],[lt_cv_c99_vsnprintf=no])]) 252if test "x$lt_cv_c99_vsnprintf" = xyes; then 253 AC_DEFINE(LT_HAVE_C99_VSNPRINTF, 1, [Have C99-compliant vsnprintf]) 254fi 255 256dnl ====================================================================== 257dnl gettext stuff 258dnl ====================================================================== 259dnl GETTEXT_PACKAGE=$PACKAGE 260dnl AC_SUBST(GETTEXT_PACKAGE) 261dnl AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package]) 262dnl 263dnl AM_GLIB_GNU_GETTEXT 264 265dnl ====================================================================== 266dnl options 267dnl ====================================================================== 268AC_ARG_WITH([locale-alias], 269 [AC_HELP_STRING([--with-locale-alias], [set the path to licale.alias])], 270 [with_locale_alias="$withval"], 271 [with_locale_alias="${localedir}/locale.alias"]) 272AC_ARG_ENABLE([rebuild-locale-alias], 273 [AC_HELP_STRING([--disable-rebuild-locale-alias], 274 [disable rebuilding the locale.alias mapping table])], 275 [enable_rebuild_locale_alias="$enableval"], 276 [enable_rebuild_locale_alias=yes]) 277AC_ARG_ENABLE([test], 278 [AC_HELP_STRING([--disable-test], [Disable tests])], 279 [enable_test="$enableval"], 280 [enable_test=yes]) 281AC_ARG_ENABLE([modules], 282 [AC_HELP_STRING([--disable-modules], [Disable modules])], 283 [enable_modules="$enableval"], 284 [enable_modules=yes]) 285AC_ARG_ENABLE([rebuild-data], 286 [AC_HELP_STRING([--disable-rebuild-data], 287 [disable rebuilding the xml data])], 288 [enable_rebuild_data="$enableval"], 289 [enable_rebuild_data=yes]) 290 291dnl ====================================================================== 292dnl options - locale-alias 293dnl ====================================================================== 294AC_MSG_CHECKING(existence of locale.alias) 295if test "x$with_locale_alias" = xyes; then 296 with_locale_alias="${localedir}/locale.alias" 297fi 298ac_lt_file="$with_locale_alias" 299ac_lt_file_old="" 300 301while test "$ac_lt_file_old" != "$ac_lt_file"; do 302 ac_lt_file_old="$ac_lt_file" 303 eval ac_lt_file="\"$ac_lt_file\"" 304done 305if [[ -f "$ac_lt_file" ]]; then 306 AC_MSG_RESULT($with_locale_alias) 307 LOCALE_ALIAS=$with_locale_alias 308 AC_SUBST(LOCALE_ALIAS) 309else 310 AC_MSG_RESULT([Using the prebuilt table]) 311fi 312 313dnl ====================================================================== 314dnl options - rebuild-locale-alias 315dnl ====================================================================== 316BUILD_LOCALEALIAS=\# 317if test "x$enable_rebuild_locale_alias" = "xyes" -a "x$LOCALE_ALIAS" != "x"; then 318 BUILD_LOCALEALIAS= 319fi 320AC_SUBST(BUILD_LOCALEALIAS) 321 322dnl ====================================================================== 323dnl options - modules 324dnl ====================================================================== 325MODULE_LIBS= 326if test "x$enable_modules" != "xno"; then 327 AC_MSG_CHECKING(for the suffix of module shared libraries) 328 export SED 329 shrext_cmds=`libtool --config | grep '^shrext_cmds='` 330 eval $shrext_cmds 331 module=yes eval std_shrext=$shrext_cmds 332 lt_module_suffix=`echo $std_shrext | sed 's/^\.//'` 333 AC_MSG_RESULT(.$lt_module_suffix) 334 if test "x$lt_module_suffix" = x; then 335 AC_MSG_ERROR(Unable to determine shared libreary suffix from libtool) 336 fi 337 use_modules=0 338 339 AC_CHECK_FUNC([dlopen], [use_modules=1], 340 [AC_CHECK_LIB([dl], [dlopen], 341 [AC_CHECK_LIB([dl], [dlsym], [MODULE_LIBS=-ldl; use_modules=1])])]) 342 343 AC_SUBST(MODULE_LIBS) 344 AC_DEFINE_UNQUOTED(ENABLE_MODULE, $use_modules, [Use modules]) 345 AC_DEFINE_UNQUOTED(LT_MODULE_SUFFIX, "$lt_module_suffix", [Shared library suffix]) 346fi 347AM_CONDITIONAL(ENABLE_MODULE, test x$use_modules = x1) 348 349dnl ====================================================================== 350dnl options - rebuild-data 351dnl ====================================================================== 352AM_CONDITIONAL(REBUILD_DATA, test x$enable_rebuild_data = xyes) 353 354dnl ====================================================================== 355dnl check pkg-config stuff 356dnl ====================================================================== 357PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED) 358PKG_CHECK_MODULES(GOBJECT, gobject-2.0 >= $GOBJECT_REQUIRED, has_gobject=yes, has_gobject=no) 359 360if test x$enable_test != xno; then 361 PKG_CHECK_MODULES(CHECK, check >= $CHECK_REQUIRED, 362 [use_check="yes"], 363 [use_check="no"]) 364else 365 use_check=no 366fi 367 368AM_CONDITIONAL(ENABLE_UNIT_TEST, test x$use_check != xno) 369 370dnl ====================================================================== 371dnl check another libraries 372dnl ====================================================================== 373AX_PTHREAD([], 374 [case $host_os in 375 cygwin* | mingw*) 376 ;; 377 *) 378 AC_MSG_ERROR([*** pthread library are required]) 379 esac]) 380 381GOBJECT_INTROSPECTION_CHECK([1.30.0]) 382if test "x$enable_introspection" != "xyes"; then 383 has_gobject=no 384fi 385AM_CONDITIONAL(ENABLE_GOBJECT, test x$has_gobject != xno) 386m4_ifdef([GTK_DOC_CHECK], [ 387GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) 388],[ 389AM_CONDITIONAL([ENABLE_GTK_DOC], false) 390]) 391 392dnl ====================================================================== 393dnl output 394dnl ====================================================================== 395CFLAGS="$CFLAGS $WARN_CFLAGS" 396 397AC_CONFIG_COMMANDS([liblangtag/lt-config.h],[ 398 outfile=liblangtag/lt-config.h-tmp 399 cat > $outfile <<____EOS 400#ifndef __LT_CONFIG_H__ 401#define __LT_CONFIG_H__ 402 403#ifdef __cplusplus 404#define LT_HAVE_INLINE 1 405#else /* !__cplusplus */ 406$lt_inline 407#endif /* !__cplusplus */ 408 409#ifdef __cplusplus 410#define LT_CAN_INLINE 1 411____EOS 412 413 if test x$lt_can_inline = xyes; then 414 cat >>$outfile <<____EOS 415#else /* !__cplusplus */ 416#define LT_CAN_INLINE 1 417____EOS 418 fi 419 420 cat >>$outfile <<____EOS 421#endif 422 423#include <liblangtag/lt-macros.h> 424____EOS 425 426 cat >> $outfile<<____EOS 427 428#endif /* __LT_CONFIG_H__ */ 429____EOS 430 431 if cmp -s $outfile liblangtag/lt-config.h; then 432 AC_MSG_NOTICE([liblangtag/lt-config.h is unchanged]) 433 rm -f $outfile 434 else 435 mv $outfile liblangtag/lt-config.h 436 fi 437],[ 438 if test x$lt_cv_hasinline = xyes; then 439 lt_inline="#define LT_HAVE_INLINE 1" 440 fi 441 if test x$lt_cv_has__inline = xyes; then 442 lt_inline="\$lt_inline 443#define LT_HAVE__INLINE 1" 444 fi 445 if test x$lt_cv_has__inline__ = xyes; then 446 lt_inline="\$lt_inline 447#define LT_HAVE__INLINE__ 1" 448 fi 449]) 450 451AC_CONFIG_FILES([ 452 Makefile 453 data/Makefile 454 docs/Makefile 455 docs/version.xml 456 extensions/Makefile 457 liblangtag/Makefile 458 liblangtag-gobject/Makefile 459 liblangtag.pc 460 liblangtag-uninstalled.pc 461 liblangtag-gobject.pc 462 liblangtag-gobject-uninstalled.pc 463 tests/Makefile 464]) 465AC_OUTPUT 466 467dnl ====================================================================== 468dnl result 469dnl ====================================================================== 470echo "" 471echo "========== Build Information ==========" 472echo " CFLAGS: $CFLAGS" 473echo " LDFLAGS: $LDFLAGS" 474