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