|
| 1 | +diff --git a/configure.ac b/configure.ac |
| 2 | +index cba242df..f442bac8 100644 |
| 3 | +--- a/configure.ac |
| 4 | ++++ b/configure.ac |
| 5 | +@@ -130,6 +130,7 @@ AC_PROG_CC_STDC |
| 6 | + AM_PROG_VALAC([0.20]) |
| 7 | + AC_PROG_INSTALL |
| 8 | + AC_PROG_MAKE_SET |
| 9 | ++AX_PROG_CC_FOR_BUILD |
| 10 | + |
| 11 | + # i18n stuff |
| 12 | + AM_GNU_GETTEXT_VERSION([0.19.8]) |
| 13 | +@@ -151,10 +152,13 @@ AC_CHECK_FUNCS(daemon) |
| 14 | + AC_CHECK_LIB(c, dlclose, LIBDL="", [AC_CHECK_LIB(dl, dlclose, LIBDL="-ldl")]) |
| 15 | + AC_SUBST(LIBDL) |
| 16 | + |
| 17 | ++# Check if cross compiling. |
| 18 | ++AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes) |
| 19 | ++ |
| 20 | + # Check endianness. |
| 21 | + AC_MSG_CHECKING([build system endianness]) |
| 22 | + ENDIAN=unknown |
| 23 | +-AC_RUN_IFELSE( |
| 24 | ++AC_COMPILE_IFELSE( |
| 25 | + [AC_LANG_PROGRAM( |
| 26 | + [[ |
| 27 | + #include <endian.h> |
| 28 | +@@ -165,7 +169,7 @@ AC_RUN_IFELSE( |
| 29 | + )], |
| 30 | + [ENDIAN=little] |
| 31 | + ) |
| 32 | +-AC_RUN_IFELSE( |
| 33 | ++AC_COMPILE_IFELSE( |
| 34 | + [AC_LANG_PROGRAM( |
| 35 | + [[ |
| 36 | + #include <endian.h> |
| 37 | +@@ -207,6 +211,14 @@ AH_BOTTOM([ |
| 38 | + #endif |
| 39 | + ]) |
| 40 | + |
| 41 | ++if test "x$cross_compiling" = "xyes"; then |
| 42 | ++PKG_PROG_PKG_CONFIG_FOR_BUILD |
| 43 | ++GLIB_CFLAGS_FOR_BUILD=`$PKG_CONFIG_FOR_BUILD --cflags glib-2.0 gobject-2.0 gio-2.0 gio-unix-2.0 gthread-2.0` |
| 44 | ++GLIB_LIBS_FOR_BUILD=`$PKG_CONFIG_FOR_BUILD --libs glib-2.0 gobject-2.0 gio-2.0 gio-unix-2.0 gthread-2.0` |
| 45 | ++AC_SUBST(GLIB_CFLAGS_FOR_BUILD) |
| 46 | ++AC_SUBST(GLIB_LIBS_FOR_BUILD) |
| 47 | ++fi |
| 48 | ++ |
| 49 | + # --disable-tests option. |
| 50 | + AC_ARG_ENABLE(tests, |
| 51 | + AS_HELP_STRING([--disable-tests], |
| 52 | +diff --git a/m4/Makefile.am b/m4/Makefile.am |
| 53 | +index dcf84ac3..dcaaa350 100644 |
| 54 | +--- a/m4/Makefile.am |
| 55 | ++++ b/m4/Makefile.am |
| 56 | +@@ -22,7 +22,9 @@ |
| 57 | + |
| 58 | + EXTRA_DIST = \ |
| 59 | + as-version.m4 \ |
| 60 | ++ ax_prog_cc_for_build.m4 \ |
| 61 | + ibuslocale.m4 \ |
| 62 | ++ pkg_config_for_build.m4 \ |
| 63 | + vapigen.m4 \ |
| 64 | + $(NULL) |
| 65 | + |
| 66 | +diff --git a/m4/ax_prog_cc_for_build.m4 b/m4/ax_prog_cc_for_build.m4 |
| 67 | +new file mode 100644 |
| 68 | +index 00000000..1db8d73f |
| 69 | +--- /dev/null |
| 70 | ++++ b/m4/ax_prog_cc_for_build.m4 |
| 71 | +@@ -0,0 +1,155 @@ |
| 72 | ++# =========================================================================== |
| 73 | ++# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html |
| 74 | ++# =========================================================================== |
| 75 | ++# |
| 76 | ++# SYNOPSIS |
| 77 | ++# |
| 78 | ++# AX_PROG_CC_FOR_BUILD |
| 79 | ++# |
| 80 | ++# DESCRIPTION |
| 81 | ++# |
| 82 | ++# This macro searches for a C compiler that generates native executables, |
| 83 | ++# that is a C compiler that surely is not a cross-compiler. This can be |
| 84 | ++# useful if you have to generate source code at compile-time like for |
| 85 | ++# example GCC does. |
| 86 | ++# |
| 87 | ++# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything |
| 88 | ++# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD). |
| 89 | ++# The value of these variables can be overridden by the user by specifying |
| 90 | ++# a compiler with an environment variable (like you do for standard CC). |
| 91 | ++# |
| 92 | ++# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object |
| 93 | ++# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if |
| 94 | ++# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are |
| 95 | ++# substituted in the Makefile. |
| 96 | ++# |
| 97 | ++# LICENSE |
| 98 | ++# |
| 99 | ++# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org> |
| 100 | ++# |
| 101 | ++# Copying and distribution of this file, with or without modification, are |
| 102 | ++# permitted in any medium without royalty provided the copyright notice |
| 103 | ++# and this notice are preserved. This file is offered as-is, without any |
| 104 | ++# warranty. |
| 105 | ++ |
| 106 | ++#serial 21 |
| 107 | ++ |
| 108 | ++AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD]) |
| 109 | ++AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl |
| 110 | ++AC_REQUIRE([AC_PROG_CC])dnl |
| 111 | ++AC_REQUIRE([AC_PROG_CPP])dnl |
| 112 | ++AC_REQUIRE([AC_CANONICAL_BUILD])dnl |
| 113 | ++ |
| 114 | ++dnl Use the standard macros, but make them use other variable names |
| 115 | ++dnl |
| 116 | ++pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl |
| 117 | ++pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl |
| 118 | ++pushdef([ac_cv_prog_cc_c99], ac_cv_build_prog_cc_c99)dnl |
| 119 | ++pushdef([ac_cv_prog_cc_c11], ac_cv_build_prog_cc_c11)dnl |
| 120 | ++pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl |
| 121 | ++pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl |
| 122 | ++pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl |
| 123 | ++pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl |
| 124 | ++pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl |
| 125 | ++pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl |
| 126 | ++pushdef([ac_cv_objext], ac_cv_build_objext)dnl |
| 127 | ++pushdef([ac_exeext], ac_build_exeext)dnl |
| 128 | ++pushdef([ac_objext], ac_build_objext)dnl |
| 129 | ++pushdef([CC], CC_FOR_BUILD)dnl |
| 130 | ++pushdef([CPP], CPP_FOR_BUILD)dnl |
| 131 | ++pushdef([GCC], GCC_FOR_BUILD)dnl |
| 132 | ++pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl |
| 133 | ++pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl |
| 134 | ++pushdef([EXEEXT], BUILD_EXEEXT)dnl |
| 135 | ++pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl |
| 136 | ++pushdef([OBJEXT], BUILD_OBJEXT)dnl |
| 137 | ++pushdef([host], build)dnl |
| 138 | ++pushdef([host_alias], build_alias)dnl |
| 139 | ++pushdef([host_cpu], build_cpu)dnl |
| 140 | ++pushdef([host_vendor], build_vendor)dnl |
| 141 | ++pushdef([host_os], build_os)dnl |
| 142 | ++pushdef([ac_cv_host], ac_cv_build)dnl |
| 143 | ++pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl |
| 144 | ++pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl |
| 145 | ++pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl |
| 146 | ++pushdef([ac_cv_host_os], ac_cv_build_os)dnl |
| 147 | ++pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl |
| 148 | ++pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)dnl |
| 149 | ++pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl |
| 150 | ++pushdef([cross_compiling], cross_compiling_build)dnl |
| 151 | ++ |
| 152 | ++cross_compiling_build=no |
| 153 | ++ |
| 154 | ++ac_build_tool_prefix= |
| 155 | ++AS_IF([test -n "$build"], [ac_build_tool_prefix="$build-"], |
| 156 | ++ [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"]) |
| 157 | ++ |
| 158 | ++AC_LANG_PUSH([C]) |
| 159 | ++ |
| 160 | ++dnl The pushdef([ac_cv_c_compiler_gnu], ...) currently does not cover |
| 161 | ++dnl the use of this variable in _AC_LANG_COMPILER_GNU called by |
| 162 | ++dnl AC_PROG_CC. Unset this cache variable temporarily as a workaround. |
| 163 | ++was_set_c_compiler_gnu=${[ac_cv_c_compiler_gnu]+y} |
| 164 | ++AS_IF([test ${was_set_c_compiler_gnu}], |
| 165 | ++ [saved_c_compiler_gnu=$[ac_cv_c_compiler_gnu] |
| 166 | ++ AS_UNSET([[ac_cv_c_compiler_gnu]])]) |
| 167 | ++ |
| 168 | ++AC_PROG_CC |
| 169 | ++ |
| 170 | ++dnl Restore ac_cv_c_compiler_gnu |
| 171 | ++AS_IF([test ${was_set_c_compiler_gnu}], |
| 172 | ++ [[ac_cv_c_compiler_gnu]=$[saved_c_compiler_gnu]]) |
| 173 | ++ |
| 174 | ++_AC_COMPILER_EXEEXT |
| 175 | ++_AC_COMPILER_OBJEXT |
| 176 | ++AC_PROG_CPP |
| 177 | ++ |
| 178 | ++dnl Restore the old definitions |
| 179 | ++dnl |
| 180 | ++popdef([cross_compiling])dnl |
| 181 | ++popdef([am_cv_prog_cc_c_o])dnl |
| 182 | ++popdef([am_cv_CC_dependencies_compiler_type])dnl |
| 183 | ++popdef([ac_tool_prefix])dnl |
| 184 | ++popdef([ac_cv_host_os])dnl |
| 185 | ++popdef([ac_cv_host_vendor])dnl |
| 186 | ++popdef([ac_cv_host_cpu])dnl |
| 187 | ++popdef([ac_cv_host_alias])dnl |
| 188 | ++popdef([ac_cv_host])dnl |
| 189 | ++popdef([host_os])dnl |
| 190 | ++popdef([host_vendor])dnl |
| 191 | ++popdef([host_cpu])dnl |
| 192 | ++popdef([host_alias])dnl |
| 193 | ++popdef([host])dnl |
| 194 | ++popdef([OBJEXT])dnl |
| 195 | ++popdef([LDFLAGS])dnl |
| 196 | ++popdef([EXEEXT])dnl |
| 197 | ++popdef([CPPFLAGS])dnl |
| 198 | ++popdef([CFLAGS])dnl |
| 199 | ++popdef([GCC])dnl |
| 200 | ++popdef([CPP])dnl |
| 201 | ++popdef([CC])dnl |
| 202 | ++popdef([ac_objext])dnl |
| 203 | ++popdef([ac_exeext])dnl |
| 204 | ++popdef([ac_cv_objext])dnl |
| 205 | ++popdef([ac_cv_exeext])dnl |
| 206 | ++popdef([ac_cv_c_compiler_gnu])dnl |
| 207 | ++popdef([ac_cv_prog_cc_g])dnl |
| 208 | ++popdef([ac_cv_prog_cc_cross])dnl |
| 209 | ++popdef([ac_cv_prog_cc_works])dnl |
| 210 | ++popdef([ac_cv_prog_cc_c89])dnl |
| 211 | ++popdef([ac_cv_prog_gcc])dnl |
| 212 | ++popdef([ac_cv_prog_CPP])dnl |
| 213 | ++ |
| 214 | ++dnl restore global variables ac_ext, ac_cpp, ac_compile, |
| 215 | ++dnl ac_link, ac_compiler_gnu (dependant on the current |
| 216 | ++dnl language after popping): |
| 217 | ++AC_LANG_POP([C]) |
| 218 | ++ |
| 219 | ++dnl Finally, set Makefile variables |
| 220 | ++dnl |
| 221 | ++AC_SUBST(BUILD_EXEEXT)dnl |
| 222 | ++AC_SUBST(BUILD_OBJEXT)dnl |
| 223 | ++AC_SUBST([CFLAGS_FOR_BUILD])dnl |
| 224 | ++AC_SUBST([CPPFLAGS_FOR_BUILD])dnl |
| 225 | ++AC_SUBST([LDFLAGS_FOR_BUILD])dnl |
| 226 | ++]) |
| 227 | +diff --git a/m4/pkg_config_for_build.m4 b/m4/pkg_config_for_build.m4 |
| 228 | +new file mode 100644 |
| 229 | +index 00000000..0422f482 |
| 230 | +--- /dev/null |
| 231 | ++++ b/m4/pkg_config_for_build.m4 |
| 232 | +@@ -0,0 +1,20 @@ |
| 233 | ++# PKG_PROG_PKG_CONFIG_FOR_BUILD([MIN-VERSION]) |
| 234 | ++# ---------------------------------- |
| 235 | ++AC_DEFUN([PKG_PROG_PKG_CONFIG_FOR_BUILD], |
| 236 | ++[m4_pattern_allow([^PKG_CONFIG_FOR_BUILD$]) |
| 237 | ++AC_ARG_VAR([PKG_CONFIG_FOR_BUILD], [path to build system's pkg-config utility]) |
| 238 | ++ |
| 239 | ++if test "x$ac_cv_env_PKG_CONFIG_FOR_BUILD_set" != "xset"; then |
| 240 | ++ AC_PATH_PROG([PKG_CONFIG_FOR_BUILD], [pkg-config]) |
| 241 | ++fi |
| 242 | ++if test -n "$PKG_CONFIG_FOR_BUILD"; then |
| 243 | ++ _pkg_for_build_min_version=m4_default([$1], [0.9.0]) |
| 244 | ++ AC_MSG_CHECKING([build system's pkg-config is at least version $_pkg_min_version]) |
| 245 | ++ if $PKG_CONFIG_FOR_BUILD --atleast-pkgconfig-version $_pkg_min_version; then |
| 246 | ++ AC_MSG_RESULT([yes]) |
| 247 | ++ else |
| 248 | ++ AC_MSG_RESULT([no]) |
| 249 | ++ PKG_CONFIG_FOR_BUILD="" |
| 250 | ++ fi |
| 251 | ++fi[]dnl |
| 252 | ++])# PKG_PROG_PKG_CONFIG_FOR_BUILD |
| 253 | +diff --git a/src/Makefile.am b/src/Makefile.am |
| 254 | +index 426376dd..50cf746f 100644 |
| 255 | +--- a/src/Makefile.am |
| 256 | ++++ b/src/Makefile.am |
| 257 | +@@ -46,9 +46,6 @@ noinst_PROGRAMS = gen-internal-compose-table |
| 258 | + # C preprocessor flags |
| 259 | + AM_CPPFLAGS = \ |
| 260 | + -DG_LOG_DOMAIN=\"IBUS\" \ |
| 261 | +- @GLIB2_CFLAGS@ \ |
| 262 | +- @GOBJECT2_CFLAGS@ \ |
| 263 | +- @GIO2_CFLAGS@ \ |
| 264 | + -DIBUS_CACHE_DIR=\""$(localstatedir)/cache/ibus"\" \ |
| 265 | + -DIBUS_DATA_DIR=\"$(pkgdatadir)\" \ |
| 266 | + -DIBUS_DISABLE_DEPRECATION_WARNINGS \ |
| 267 | +@@ -65,6 +62,11 @@ libibus_1_0_la_LIBADD = \ |
| 268 | + @GOBJECT2_LIBS@ \ |
| 269 | + @GIO2_LIBS@ \ |
| 270 | + $(NULL) |
| 271 | ++libibus_1_0_la_CFLAGS = \ |
| 272 | ++ @GLIB2_CFLAGS@ \ |
| 273 | ++ @GOBJECT2_CFLAGS@ \ |
| 274 | ++ @GIO2_CFLAGS@ \ |
| 275 | ++ $(NULL) |
| 276 | + libibus_1_0_la_LDFLAGS = \ |
| 277 | + -no-undefined \ |
| 278 | + -export-symbols-regex "ibus_.*" \ |
| 279 | +@@ -107,7 +109,7 @@ ibus_sources = \ |
| 280 | + ibusxevent.c \ |
| 281 | + ibusxml.c \ |
| 282 | + $(NULL) |
| 283 | +-libibus_1_0_la_SOURCES = \ |
| 284 | ++libibus_sources = \ |
| 285 | + ibuscomposetable.c \ |
| 286 | + ibusenumtypes.c \ |
| 287 | + ibusmarshalers.c \ |
| 288 | +@@ -166,6 +168,7 @@ ibus_headers = \ |
| 289 | + ibusxevent.h \ |
| 290 | + ibusxml.h \ |
| 291 | + $(NULL) |
| 292 | ++libibus_1_0_la_SOURCES = $(libibus_sources) |
| 293 | + ibusincludedir = $(includedir)/ibus-@IBUS_API_VERSION@ |
| 294 | + ibus_public_headers = \ |
| 295 | + $(ibus_headers) \ |
| 296 | +@@ -188,6 +191,35 @@ noinst_HEADERS = \ |
| 297 | + $(ibus_private_headers) \ |
| 298 | + $(NULL) |
| 299 | + |
| 300 | ++if CROSS_COMPILING |
| 301 | ++# Avoid libtool when building native libraries |
| 302 | ++libnativeibus = |
| 303 | ++parser_extra_sources = $(libibus_sources) |
| 304 | ++ |
| 305 | ++glib_cflags = @GLIB_CFLAGS_FOR_BUILD@ |
| 306 | ++glib_libs = @GLIB_LIBS_FOR_BUILD@ |
| 307 | ++ |
| 308 | ++$(noinst_PROGRAMS): CC=$(CC_FOR_BUILD) |
| 309 | ++$(noinst_PROGRAMS): CCLD=$(CC_FOR_BUILD) |
| 310 | ++$(noinst_PROGRAMS): CFLAGS=$(CFLAGS_FOR_BUILD) |
| 311 | ++$(noinst_PROGRAMS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD) |
| 312 | ++$(noinst_PROGRAMS): LDFLAGS=$(LDFLAGS_FOR_BUILD) |
| 313 | ++else |
| 314 | ++libnativeibus = $(libibus) |
| 315 | ++parser_extra_sources = |
| 316 | ++ |
| 317 | ++glib_libs = \ |
| 318 | ++ @GLIB2_LIBS@ \ |
| 319 | ++ @GOBJECT2_LIBS@ \ |
| 320 | ++ @GIO2_LIBS@ \ |
| 321 | ++ $(NULL) |
| 322 | ++glib_cflags = \ |
| 323 | ++ @GLIB2_CFLAGS@ \ |
| 324 | ++ @GOBJECT2_CFLAGS@ \ |
| 325 | ++ @GIO2_CFLAGS@ \ |
| 326 | ++ $(NULL) |
| 327 | ++endif |
| 328 | ++ |
| 329 | + gen_internal_compose_table_SOURCES = \ |
| 330 | + gencomposetable.c \ |
| 331 | + ibuscomposetable.c \ |
| 332 | +@@ -195,11 +227,12 @@ gen_internal_compose_table_SOURCES = \ |
| 333 | + ibuskeynames.c \ |
| 334 | + ibuskeyuni.c \ |
| 335 | + $(NULL) |
| 336 | +-gen_internal_compose_table_CFLAGS = $(AM_CFLAGS) |
| 337 | ++gen_internal_compose_table_CFLAGS = \ |
| 338 | ++ $(AM_CFLAGS) \ |
| 339 | ++ $(glib_cflags) \ |
| 340 | ++ $(NULL) |
| 341 | + gen_internal_compose_table_LDADD = \ |
| 342 | +- @GLIB2_LIBS@ \ |
| 343 | +- @GOBJECT2_LIBS@ \ |
| 344 | +- @GIO2_LIBS@ \ |
| 345 | ++ $(glib_libs) \ |
| 346 | + $(NULL) |
| 347 | + |
| 348 | + BUILT_SOURCES = \ |
| 349 | +@@ -362,15 +395,15 @@ install-data-hook: |
| 350 | + |
| 351 | + emoji_parser_SOURCES = \ |
| 352 | + emoji-parser.c \ |
| 353 | ++ $(parser_extra_sources) \ |
| 354 | + $(NULL) |
| 355 | + emoji_parser_CFLAGS = \ |
| 356 | +- $(GLIB2_CFLAGS) \ |
| 357 | +- $(GOBJECT2_CFLAGS) \ |
| 358 | ++ $(AM_CFLAGS) \ |
| 359 | ++ $(glib_cflags) \ |
| 360 | + $(NULL) |
| 361 | + emoji_parser_LDADD = \ |
| 362 | +- $(libibus) \ |
| 363 | +- $(GLIB2_LIBS) \ |
| 364 | +- $(GOBJECT2_LIBS) \ |
| 365 | ++ $(libnativeibus) \ |
| 366 | ++ $(glib_libs) \ |
| 367 | + $(NULL) |
| 368 | + endif |
| 369 | + |
| 370 | +@@ -407,13 +440,15 @@ ibusunicodegen.h: |
| 371 | + |
| 372 | + unicode_parser_SOURCES = \ |
| 373 | + unicode-parser.c \ |
| 374 | ++ $(parser_extra_sources) \ |
| 375 | + $(NULL) |
| 376 | + unicode_parser_CFLAGS = \ |
| 377 | +- $(GLIB2_CFLAGS) \ |
| 378 | ++ $(AM_CFLAGS) \ |
| 379 | ++ $(glib_cflags) \ |
| 380 | + $(NULL) |
| 381 | + unicode_parser_LDADD = \ |
| 382 | +- $(GLIB2_LIBS) \ |
| 383 | +- $(libibus) \ |
| 384 | ++ $(glib_libs) \ |
| 385 | ++ $(libnativeibus) \ |
| 386 | + $(NULL) |
| 387 | + endif |
| 388 | + |
0 commit comments