summaryrefslogtreecommitdiff
path: root/src/Makefile.am
blob: adc7f04aa507d4f2d7f38b59caac839cdf9e1d38 (plain)
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
455
456
457
458
# vim:set noet ts=4:
#
# ibus - The Input Bus
#
# Copyright (c) 2007-2015 Peng Huang <shawn.p.huang@gmail.com>
# Copyright (c) 2015-2023 Takao Fujiwara <takao.fujiwara1@gmail.com>
# Copyright (c) 2007-2017 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
# USA

NULL =

if ENABLE_TESTS
TESTS_DIR = tests
endif

SUBDIRS = . compose $(TESTS_DIR)

# libibus = libibus-@IBUS_API_VERSION@.la
libibus = libibus-1.0.la

# gobject introspection
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_SCANNER_ARGS =
INTROSPECTION_COMPILER_ARGS = \
    --includedir=$(srcdir)    \
    --includedir=.            \
    $(NULL)
INTROSPECTION_GIRS =
CLEANFILES =
noinst_PROGRAMS = gen-internal-compose-table

# C preprocessor flags
AM_CPPFLAGS =                                           \
    -DG_LOG_DOMAIN=\"IBUS\"                             \
    @GLIB2_CFLAGS@                                      \
    @GOBJECT2_CFLAGS@                                   \
    @GIO2_CFLAGS@                                       \
    -DIBUS_CACHE_DIR=\""$(localstatedir)/cache/ibus"\"  \
    -DIBUS_DATA_DIR=\"$(pkgdatadir)\"                   \
    -DIBUS_DISABLE_DEPRECATION_WARNINGS                 \
    -DIBUS_COMPILATION                                  \
    -DISOCODES_PREFIX=\"$(ISOCODES_PREFIX)\"            \
    -DX11_LOCALEDATADIR=\"$(X11_LOCALEDATADIR)\"        \
    $(NULL)

# ibus library
lib_LTLIBRARIES = $(libibus)

libibus_1_0_la_LIBADD =     \
    @GLIB2_LIBS@            \
    @GOBJECT2_LIBS@         \
    @GIO2_LIBS@             \
    $(NULL)
libibus_1_0_la_LDFLAGS =            \
    -no-undefined                   \
    -export-symbols-regex "ibus_.*" \
    -version-info @LT_VERSION_INFO@ \
    $(NULL)

ibus_sources =              \
    ibusaccelgroup.c        \
    ibusattribute.c         \
    ibusattrlist.c          \
    ibusbus.c               \
    ibuscomponent.c         \
    ibusconfig.c            \
    ibusconfigservice.c     \
    ibusemoji.c             \
    ibusengine.c            \
    ibusenginedesc.c        \
    ibusenginesimple.c      \
    ibuserror.c             \
    ibusfactory.c           \
    ibushotkey.c            \
    ibusinputcontext.c      \
    ibuskeymap.c            \
    ibuskeynames.c          \
    ibuskeyuni.c            \
    ibuslookuptable.c       \
    ibusobject.c            \
    ibusobservedpath.c      \
    ibuspanelservice.c      \
    ibusproperty.c          \
    ibusproplist.c          \
    ibusproxy.c             \
    ibusregistry.c          \
    ibusserializable.c      \
    ibusservice.c           \
    ibusshare.c             \
    ibustext.c              \
    ibusunicode.c           \
    ibusutil.c              \
    ibusxevent.c            \
    ibusxml.c               \
    $(NULL)
libibus_1_0_la_SOURCES =    \
    ibuscomposetable.c      \
    ibusenumtypes.c         \
    ibusmarshalers.c        \
    ibusresources.c         \
    $(ibus_sources)         \
    $(NULL)
ibus_marshalers_sources =   \
    ibusmarshalers.c        \
    ibusmarshalers.h        \
    $(NULL)
ibus_enumtypes_sources =    \
    ibusenumtypes.c         \
    ibusenumtypes.h         \
    $(NULL)
ibus_resources_sources =    \
    ibusresources.c         \
    ibusresources.h         \
    $(NULL)
ibus_headers =              \
    ibus.h                  \
    ibusaccelgroup.h        \
    ibusattribute.h         \
    ibusattrlist.h          \
    ibusbus.h               \
    ibuscomponent.h         \
    ibusconfig.h            \
    ibusconfigservice.h     \
    ibusdebug.h             \
    ibusemoji.h             \
    ibusengine.h            \
    ibusenginedesc.h        \
    ibusenginesimple.h      \
    ibuserror.h             \
    ibusfactory.h           \
    ibushotkey.h            \
    ibusinputcontext.h      \
    ibuskeymap.h            \
    ibuskeys.h              \
    ibuskeysyms-compat.h    \
    ibuskeysyms.h           \
    ibuslookuptable.h       \
    ibusobject.h            \
    ibusobservedpath.h      \
    ibuspanelservice.h      \
    ibusproperty.h          \
    ibusproplist.h          \
    ibusproxy.h             \
    ibusregistry.h          \
    ibusserializable.h      \
    ibusservice.h           \
    ibusshare.h             \
    ibustext.h              \
    ibustypes.h             \
    ibusunicode.h           \
    ibusutil.h              \
    ibusxevent.h            \
    ibusxml.h               \
    $(NULL)
ibusincludedir = $(includedir)/ibus-@IBUS_API_VERSION@
ibus_public_headers =       \
    $(ibus_headers)         \
    ibusenumtypes.h         \
    ibusversion.h           \
    $(NULL)
ibusinclude_HEADERS =       \
    $(ibus_public_headers)  \
    $(NULL)
ibus_private_headers =          \
    ibuscomposetable.h          \
    ibusemojigen.h              \
    ibusenginesimpleprivate.h   \
    ibusinternal.h              \
    ibusresources.h             \
    ibusunicodegen.h            \
    keyname-table.h             \
    $(NULL)
noinst_HEADERS =            \
    $(ibus_private_headers) \
    $(NULL)

gen_internal_compose_table_SOURCES = \
    gencomposetable.c   \
    ibuscomposetable.c  \
    ibuserror.c         \
    ibuskeynames.c      \
    ibuskeyuni.c        \
    ibusenumtypes.h     \
    $(NULL)
gen_internal_compose_table_CFLAGS = $(AM_CFLAGS)
gen_internal_compose_table_LDADD = \
    @GLIB2_LIBS@        \
    @GOBJECT2_LIBS@     \
    @GIO2_LIBS@         \
    $(NULL)

BUILT_SOURCES =                 \
    $(ibus_marshalers_sources)  \
    $(ibus_enumtypes_sources)   \
    $(ibus_resources_sources)   \
    $(NULL)

if HAVE_INTROSPECTION
introspection_sources =         \
    $(ibus_headers)             \
    $(ibus_sources)             \
    $(NULL)
built_introspection_sources =   \
    $(ibus_enumtypes_sources)   \
    ibusversion.h               \
    $(NULL)
IBus-1.0.gir: $(libibus) Makefile
IBus_1_0_gir_SCANNERFLAGS = --pkg-export=ibus-1.0 $(IBUS_GIR_SCANNERFLAGS)
IBus_1_0_gir_INCLUDES = GLib-2.0 GObject-2.0 Gio-2.0
IBus_1_0_gir_LIBS = $(libibus)
IBus_1_0_gir_FILES =                                            \
    $(addprefix $(srcdir)/,$(introspection_sources))            \
    $(addprefix $(builddir)/,$(built_introspection_sources))    \
    $(NULL)
IBus_1_0_gir_CFLAGS = -DIBUS_COMPILATION -I$(srcdir) -I$(builddir)
INTROSPECTION_GIRS += IBus-1.0.gir

girdir = $(datadir)/gir-1.0
dist_gir_DATA = $(INTROSPECTION_GIRS)

typelibsdir = $(libdir)/girepository-1.0
typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)

CLEANFILES += $(dist_gir_DATA) $(typelibs_DATA)
endif

# gen enum types
ibusenumtypes.h: $(ibus_headers) ibusenumtypes.h.template
	$(AM_V_GEN) ( top_builddir=`cd $(top_builddir) && pwd`; \
	cd $(srcdir) && $(GLIB_MKENUMS) --template ibusenumtypes.h.template $(ibus_headers) | \
		sed 's/i_bus_/ibus_/g' | \
		sed 's/I_TYPE_BUS_/IBUS_TYPE_/g') > \
	ibusenumtypes.h.tmp && mv ibusenumtypes.h.tmp ibusenumtypes.h

ibusenumtypes.c: $(ibus_headers) ibusenumtypes.c.template
	$(AM_V_GEN) ( top_builddir=`cd $(top_builddir) && pwd`; \
	cd $(srcdir) && $(GLIB_MKENUMS) --template ibusenumtypes.c.template $(ibus_headers) | \
		sed 's/i_bus_/ibus_/g' | \
		sed 's/I_TYPE_BUS_/IBUS_TYPE_/g') > \
	ibusenumtypes.c.tmp && mv ibusenumtypes.c.tmp ibusenumtypes.c

# gen marshal
ibusmarshalers.h: ibusmarshalers.list
	$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_ibus_marshal $(srcdir)/ibusmarshalers.list --header --internal > $@.tmp && \
	mv $@.tmp $@

ibusmarshalers.c: ibusmarshalers.h ibusmarshalers.list
	$(AM_V_GEN) (echo "#include \"ibusmarshalers.h\""; \
	$(GLIB_GENMARSHAL) --prefix=_ibus_marshal $(srcdir)/ibusmarshalers.list --body --internal) > $@.tmp && \
	mv $@.tmp $@

# gen GResource
ibus.gresources.xml: ibus.gresources.xml.in
	$(AM_V_GEN) sed -e "s|\@ENDIAN\@|$(ENDIAN)|g" \
	$< > $@.tmp && \
	mv $@.tmp $@

compose/sequences-$(ENDIAN)-endian: gen-internal-compose-table
	$(AM_V_GEN) $(MKDIR_P) $(builddir)/compose && \
	$(builddir)/gen-internal-compose-table && \
	mv $(builddir)/sequences-big-endian $(builddir)/compose && \
	mv $(builddir)/sequences-little-endian $(builddir)/compose

ibusresources.h: ibus.gresources.xml compose/sequences-$(ENDIAN)-endian
	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --generate-header --internal \
	    --target=ibusresources.h --external-data --c-name _ibus \
	    --manual-register ibus.gresources.xml

ibusresources.c: ibus.gresources.xml compose/sequences-$(ENDIAN)-endian
	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --generate-source --internal \
	    --target=ibusresources.c --c-name _ibus --manual-register \
	    ibus.gresources.xml

if ENABLE_EMOJI_DICT
AM_CPPFLAGS += -DENABLE_EMOJI_DICT

dictdir = $(pkgdatadir)/dicts
LANG_FILES = $(basename $(notdir $(wildcard $(EMOJI_ANNOTATION_DIR)/*.xml)))
EMOJI_DICT_FILES = $(patsubst %,dicts/emoji-%.dict,$(LANG_FILES))
# emoji-root.dict, emoji-sr_Cyrl.dict have no contents.
dict_DATA = $(EMOJI_DICT_FILES)

noinst_PROGRAMS += emoji-parser

dicts/emoji-%.dict: emoji-parser
	$(AM_V_at)if test x"$(LANG_FILES)" = x ; then \
	    echo "WARNING: Not found $(EMOJI_ANNOTATION_DIR)/en.xml" 1>&2; \
	fi; \
	if test -f $@; then \
	    echo "Already exists $@"; \
	    exit 0; \
	fi; \
	if test -f \
	    "$(EMOJI_ANNOTATION_DIR)/../annotationsDerived/$*.xml" ; then \
	        xml_derived_option="--xml-derived $(EMOJI_ANNOTATION_DIR)/../annotationsDerived/$*.xml"; \
	        plus_comment="derived"; \
	fi; \
	is_skip=0; \
	if test x"$*" = xen ; then \
	    $(builddir)/emoji-parser \
	        --unicode-emoji-dir $(UNICODE_EMOJI_DIR) \
	        --xml $(EMOJI_ANNOTATION_DIR)/$*.xml \
	        $$xml_derived_option \
	        --xml-ascii $(top_srcdir)/data/annotations/en_ascii.xml \
	        --out-category ibusemojigen.h \
	        --out $@; \
	else \
	    $(builddir)/emoji-parser \
	        --unicode-emoji-dir $(UNICODE_EMOJI_DIR) \
	        --xml $(EMOJI_ANNOTATION_DIR)/$*.xml \
	        $$xml_derived_option \
	        --out $@; \
	    retval=$$?; \
	    if test $$retval -eq 99 ; then \
	        is_skip=1; \
	        touch $@; \
	    elif test $$retval -ne 0 ; then \
	        echo "Fail to generate $@"; \
	        abrt; \
	    fi; \
	fi; \
	if test $$is_skip -eq 0 ; then \
	    echo "Generated $$plus_comment $@"; \
	else \
	    echo "Skip $$plus_comment $@"; \
	fi;

ibusemojigen.h:
	$(MAKE) $(AM_MAKEFLAGS) dicts/emoji-en.dict

# We put dicts/emoji-%.dict as the make target for the parallel build
# and the make target has to be genarated even if the file size is zero.
# But we don't want to install the zero size files and delete them
# in install-data-hook.
install-data-hook:
	$(AM_V_at)list='$(wildcard dicts/*.dict)'; \
        test -n "$(dictdir)" || list=; \
	for p in $$list; do \
	    if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
	    if test -s  "$$d$$p"; then continue; fi;  \
	    basename "$$p"; \
	done | \
	while read file; do \
	    if test -f "$(DESTDIR)$(dictdir)/$$file"; then \
	        echo "Delete $(DESTDIR)$(dictdir)/$$file"; \
	        rm "$(DESTDIR)$(dictdir)/$$file" || exit $$?; \
	    fi; \
	done

emoji_parser_SOURCES =          \
    emoji-parser.c              \
    $(NULL)
emoji_parser_CFLAGS =           \
    $(GLIB2_CFLAGS)             \
    $(GOBJECT2_CFLAGS)          \
    $(NULL)
emoji_parser_LDADD =            \
    $(libibus)                  \
    $(GLIB2_LIBS)               \
    $(GOBJECT2_LIBS)            \
    $(NULL)
endif

if ENABLE_UNICODE_DICT
unicodedir = $(pkgdatadir)/dicts
unicode_DATA = dicts/unicode-names.dict dicts/unicode-blocks.dict
noinst_PROGRAMS += unicode-parser

dicts/unicode-names.dict: unicode-parser
	$(AM_V_at)input_file="$(UCD_DIR)/NamesList.txt"; \
	if test ! -f "$$input_file" ; then \
	    echo "WARNING: Not found $$input_file" 1>&2; \
	else \
	    $(builddir)/unicode-parser \
	        --input-names-list $$input_file \
	        --output-names-list $@; \
	    echo "Generated $@"; \
	fi;

dicts/unicode-blocks.dict: unicode-parser
	$(AM_V_at)input_file="$(UCD_DIR)/Blocks.txt"; \
	if test ! -f "$$input_file" ; then \
	    echo "WARNING: Not found $$input_file" 1>&2; \
	else \
	    $(builddir)/unicode-parser \
	        --input-blocks $$input_file \
	        --output-blocks-trans ibusunicodegen.h \
	        --output-blocks $@; \
	    echo "Generated $@"; \
	fi;

ibusunicodegen.h:
	$(MAKE) $(AM_MAKEFLAGS) dicts/unicode-blocks.dict

unicode_parser_SOURCES =        \
    unicode-parser.c            \
    $(NULL)
unicode_parser_CFLAGS =         \
    $(GLIB2_CFLAGS)             \
    $(NULL)
unicode_parser_LDADD =          \
    $(GLIB2_LIBS)               \
    $(libibus)                  \
    $(NULL)
endif

EXTRA_DIST =                    \
    emoji-parser.c              \
    ibus.gresources.xml.in      \
    ibusversion.h.in            \
    ibusmarshalers.list         \
    ibusenumtypes.h.template    \
    ibusenumtypes.c.template    \
    unicode-parser.c            \
    $(NULL)

CLEANFILES +=                   \
    $(BUILT_SOURCES)            \
    ibus.gresources.xml         \
    stamp-ibusmarshalers.h      \
    stamp-ibusenumtypes.h       \
    $(NULL)

MAINTAINERCLEANFILES =          \
    ibusemojigen.h              \
    ibusunicodegen.h            \
    dicts/emoji-en.dict         \
    dicts/unicode-blocks.dict   \
    $(NULL)

DISTCLEANFILES =                \
    $(MAINTAINERCLEANFILES)     \
    ibusversion.h               \
    $(NULL)

clean-local:
	-rm -rf dicts;                                                      \
	if test x"$(srcdir)" != x"$(builddir)" ; then                       \
	    rm -f  $(builddir)/compose/sequences-big-endian;                \
	    rm -f  $(builddir)/compose/sequences-little-endian;             \
	fi;
	$(NULL)

-include $(top_srcdir)/git.mk