tsm: unicode: add wcwidth() implementation
[platform/upstream/kmscon.git] / Makefile.am
1 #
2 # Kmscon - Global Makefile
3 # Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
4 #
5
6 ACLOCAL_AMFLAGS = -I m4
7 SUBDIRS = \
8         .
9 include_HEADERS =
10 EXTRA_DIST = \
11         README \
12         COPYING \
13         NEWS \
14         docs/kmscon.service \
15         docs/kmscon@.service \
16         docs/getty@.service
17 CLEANFILES =
18 pkgconfigdir = $(libdir)/pkgconfig
19 pkgconfig_DATA =
20 MANPAGES =
21 MANPAGES_ALIASES =
22
23 bin_PROGRAMS =
24 check_PROGRAMS =
25 noinst_PROGRAMS = \
26         genshader \
27         genunifont
28 noinst_LTLIBRARIES =
29 lib_LTLIBRARIES =
30
31 #
32 # Default CFlags
33 # Make all files include "config.h" by default. This shouldn't cause any
34 # problems and we cannot forget to include it anymore.
35 #
36 # Also make the linker discard all unused symbols.
37 #
38 # When compiling in debug mode, we enable debug symbols so debugging with gdb
39 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
40 # Otherwise, we use standard optimizations -O2.
41 #
42
43 AM_CFLAGS = \
44         -Wall
45 AM_CPPFLAGS = \
46         -include $(top_builddir)/config.h \
47         -I $(srcdir)/src
48 AM_LDFLAGS = \
49         -Wl,--as-needed
50
51 if BUILD_ENABLE_DEBUG
52 AM_CFLAGS += -g
53 endif
54
55 if BUILD_ENABLE_OPTIMIZATIONS
56 AM_CFLAGS += -O2
57 else
58 AM_CFLAGS += -O0
59 endif
60
61 #
62 # SHL - Static Helper Library
63 # The SHL subsystem contains several small code pieces used all over kmscon and
64 # other applications.
65 #
66 # Simply include $(SHL_*) in your source-file list. Except for SHL_MISC none of
67 # these have external dependencies. SHL_MISC needs xkbcommon.
68 #
69
70 SHL_DLIST = \
71         src/shl_dlist.h
72 SHL_ARRAY = \
73         src/shl_array.h
74 SHL_HASHTABLE = \
75         src/shl_hashtable.h \
76         external/htable.h \
77         external/htable.c
78 SHL_RING = \
79         src/shl_ring.h
80 SHL_TIMER = \
81         src/shl_timer.h
82 SHL_LLOG = \
83         src/shl_llog.h
84 SHL_HOOK = \
85         src/shl_hook.h \
86         $(SHL_DLIST)
87 SHL_MISC = \
88         src/shl_misc.h
89
90 #
91 # libeloop
92 # This library contains the whole event-loop implementation of kmscon. It is
93 # compiled into a separate object to allow using it in several other programs.
94 #
95
96 if BUILD_ENABLE_ELOOP
97 lib_LTLIBRARIES += libeloop.la
98 include_HEADERS += src/eloop.h
99 pkgconfig_DATA += docs/pc/libeloop.pc
100 endif
101
102 libeloop_la_SOURCES = \
103         $(SHL_DLIST) \
104         $(SHL_LLOG) \
105         $(SHL_HOOK) \
106         src/eloop.h \
107         src/eloop.c
108
109 libeloop_la_CPPFLAGS = \
110         $(AM_CPPFLAGS)
111 libeloop_la_LIBADD =
112 libeloop_la_LDFLAGS = \
113         -version-info 1:0:0
114
115
116 if BUILD_ENABLE_ELOOP_DBUS
117 libeloop_la_SOURCES += \
118         external/dbus-common.h \
119         external/dbus-loop.h \
120         external/dbus-loop.c
121 libeloop_la_CPPFLAGS += \
122         $(DBUS_CFLAGS)
123 libeloop_la_LIBADD += \
124         $(DBUS_LIBS)
125 endif
126
127 #
128 # libtsm
129 # The Terminal-emulator State Machine is a library that implements the whole VTE
130 # layer and everything related to it. It has no external dependencies so it can
131 # be used to implement any kind of terminal emulator or debugger.
132 #
133
134 if BUILD_ENABLE_TSM
135 lib_LTLIBRARIES += \
136         libtsm.la
137 include_HEADERS += \
138         src/tsm_screen.h \
139         src/tsm_unicode.h \
140         src/tsm_vte.h
141 pkgconfig_DATA += \
142         docs/pc/libtsm.pc
143 endif
144
145 libtsm_la_SOURCES = \
146         $(SHL_LLOG) \
147         $(SHL_TIMER) \
148         $(SHL_ARRAY) \
149         $(SHL_HASHTABLE) \
150         src/tsm_screen.h \
151         src/tsm_screen.c \
152         src/tsm_unicode.h \
153         src/tsm_unicode.c \
154         src/tsm_vte.h \
155         src/tsm_vte.c \
156         src/tsm_vte_charsets.c \
157         external/wcwidth.h \
158         external/wcwidth.c
159
160 libtsm_la_CPPFLAGS = \
161         $(AM_CPPFLAGS) \
162         $(XKBCOMMON_CFLAGS)
163 libtsm_la_LDFLAGS = \
164         $(XKBCOMMON_LIBS) \
165         -version-info 1:0:0
166
167 #
168 # libuterm
169 # The uterm library provides helpers to create terminals in user-space. They
170 # are not limited to text-based terminals but rather provide graphics contexts
171 # so arbitrary output can be displayed. Additionally, they provide VT
172 # abstractions and an input layer
173 #
174
175 if BUILD_ENABLE_UTERM
176 lib_LTLIBRARIES += libuterm.la
177 include_HEADERS += src/uterm.h
178 pkgconfig_DATA += docs/pc/libuterm.pc
179 endif
180
181 libuterm_la_SOURCES = \
182         $(SHL_DLIST) \
183         $(SHL_HOOK) \
184         $(SHL_MISC) \
185         src/uterm.h \
186         src/uterm_input.h \
187         src/uterm_video.h \
188         src/uterm_pci.h \
189         src/uterm_systemd.h \
190         src/uterm_video.c \
191         src/uterm_monitor.c \
192         src/uterm_vt.c \
193         src/uterm_input.c \
194         src/uterm_input_uxkb.c
195
196 nodist_libuterm_la_SOURCES =
197
198 libuterm_la_CPPFLAGS = \
199         $(AM_CPPFLAGS) \
200         $(XKBCOMMON_CFLAGS)
201 libuterm_la_LIBADD =
202         $(XKBCOMMON_LIBS) \
203         libeloop.la
204 libuterm_la_LDFLAGS = \
205         -version-info 1:0:0
206
207 if BUILD_ENABLE_MULTI_SEAT
208 libuterm_la_SOURCES += src/uterm_systemd.c
209 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
210 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
211 endif
212
213 if BUILD_ENABLE_HOTPLUG
214 libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
215 libuterm_la_LIBADD += $(UDEV_LIBS)
216 endif
217
218 if BUILD_ENABLE_PCIACCESS
219 libuterm_la_CPPFLAGS += $(PCIACCESS_CFLAGS)
220 libuterm_la_LIBADD += $(PCIACCESS_LIBS)
221 libuterm_la_SOURCES += src/uterm_pci.c
222 endif
223
224 if BUILD_ENABLE_VIDEO_FBDEV
225 libuterm_la_SOURCES += src/uterm_video_fbdev.c
226 endif
227
228 if BUILD_ENABLE_VIDEO_DUMB
229 libuterm_la_SOURCES += src/uterm_video_dumb.c
230 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
231 libuterm_la_LIBADD += $(DRM_LIBS)
232 endif
233
234 if BUILD_ENABLE_VIDEO_DRM
235 libuterm_la_SOURCES += \
236         src/uterm_video_drm.c \
237         src/static_gl.h \
238         src/static_gl_math.c \
239         src/static_gl_shader.c
240 nodist_libuterm_la_SOURCES += \
241         src/static_shaders.c
242 libuterm_la_CPPFLAGS += \
243         $(DRM_CFLAGS) \
244         $(EGL_CFLAGS) \
245         $(GBM_CFLAGS) \
246         $(GLES2_CFLAGS)
247 libuterm_la_LIBADD += \
248         $(DRM_LIBS) \
249         $(EGL_LIBS) \
250         $(GBM_LIBS) \
251         $(GLES2_LIBS)
252 endif
253
254 #
255 # Shaders
256 # As there is no need to modify shaders at run-time, we statically compile them
257 # into object files. As autotools would ignore them, we need to add them to
258 # EXTRA_DIST.
259 # The program that converts the shaders into C-source files is "genshader". It's
260 # pretty simple and just creates a string with the shader source as content.
261 #
262
263 SHADERS = \
264         $(srcdir)/src/static_fill.vert \
265         $(srcdir)/src/static_fill.frag \
266         $(srcdir)/src/static_blend.vert \
267         $(srcdir)/src/static_blend.frag \
268         $(srcdir)/src/static_blit.vert \
269         $(srcdir)/src/static_blit.frag \
270         $(srcdir)/src/static_gltex.vert \
271         $(srcdir)/src/static_gltex.frag
272
273 EXTRA_DIST += $(SHADERS)
274 CLEANFILES += src/static_shaders.c
275 genshader_SOURCES = src/genshader.c
276
277 src/static_shaders.c: $(SHADERS) genshader$(EXEEXT)
278         $(AM_V_GEN)./genshader$(EXEEXT) src/static_shaders.c $(SHADERS)
279
280 #
281 # Unifont Generator
282 # This generates the unifont sources from raw hex-encoded font data.
283 #
284
285 UNIFONT = src/text_font_unifont_data.hex
286
287 EXTRA_DIST += $(UNIFONT)
288 CLEANFILES += src/text_font_unifont_data.c
289 genunifont_SOURCES = src/genunifont.c
290
291 src/text_font_unifont_data.c: $(UNIFONT) genunifont$(EXEEXT)
292         $(AM_V_GEN)./genunifont$(EXEEXT) src/text_font_unifont_data.c $(UNIFONT)
293
294 #
295 # Text-font library
296 # The text-font library is used by kmscon _and_ wlterm but is currently linked
297 # statically as it hasn't been cleaned up entirely.
298 # It has a build-time dependency to UTERM and runtime dependencies to TSM.
299 #
300
301 if BUILD_ENABLE_KMSCON
302 noinst_LTLIBRARIES += libtext-font.la
303 else
304 if BUILD_ENABLE_WLTERM
305 noinst_LTLIBRARIES += libtext-font.la
306 endif
307 endif
308
309 libtext_font_la_SOURCES = \
310         $(SHL_DLIST) \
311         $(SHL_HASHTABLE) \
312         $(SHL_HOOK) \
313         src/text.h \
314         src/text_font.c
315 nodist_libtext_font_la_SOURCES =
316
317 libtext_font_la_CPPFLAGS = \
318         $(AM_CPPFLAGS)
319 libtext_font_la_LIBADD = \
320         -lpthread \
321         libtsm.la
322
323 if BUILD_ENABLE_FONT_8X16
324 libtext_font_la_SOURCES += src/text_font_8x16.c
325 endif
326
327 if BUILD_ENABLE_FONT_UNIFONT
328 libtext_font_la_SOURCES += src/text_font_unifont.c
329 nodist_libtext_font_la_SOURCES += src/text_font_unifont_data.c
330 endif
331
332 if BUILD_ENABLE_FONT_FREETYPE2
333 libtext_font_la_SOURCES += src/text_font_freetype2.c
334 libtext_font_la_CPPFLAGS += $(FREETYPE2_CFLAGS)
335 libtext_font_la_LIBADD += $(FREETYPE2_LIBS)
336 endif
337
338 if BUILD_ENABLE_FONT_PANGO
339 libtext_font_la_SOURCES += src/text_font_pango.c
340 libtext_font_la_CPPFLAGS += $(PANGO_CFLAGS)
341 libtext_font_la_LIBADD += $(PANGO_LIBS)
342 endif
343
344 #
345 # Binaries
346 # These are the sources for the main binaries and test programs. They mostly
347 # consists of a single source file only and include all the libraries that are
348 # built as part of kmscon.
349 #
350
351 if BUILD_ENABLE_KMSCON
352 bin_PROGRAMS += kmscon
353 check_PROGRAMS += \
354         test_output \
355         test_vt \
356         test_input \
357         test_key
358 endif
359
360 kmscon_SOURCES = \
361         $(SHL_DLIST) \
362         $(SHL_MISC) \
363         $(SHL_ARRAY) \
364         $(SHL_HASHTABLE) \
365         $(SHL_RING) \
366         $(SHL_TIMER) \
367         $(SHL_HOOK) \
368         src/conf.h \
369         src/conf.c \
370         src/log.h \
371         src/log.c \
372         src/pty.h \
373         src/pty.c \
374         src/text.h \
375         src/text.c \
376         src/kmscon_terminal.h \
377         src/kmscon_dummy.h \
378         src/kmscon_cdev.h \
379         src/kmscon_seat.h \
380         src/kmscon_seat.c \
381         src/kmscon_conf.h \
382         src/kmscon_conf.c \
383         src/kmscon_main.c
384 nodist_kmscon_SOURCES =
385
386 kmscon_CPPFLAGS = \
387         $(AM_CPPFLAGS) \
388         $(XKBCOMMON_CFLAGS)
389 kmscon_LDADD = \
390         $(XKBCOMMON_LIBS) \
391         libeloop.la \
392         libuterm.la \
393         libtext-font.la \
394         -lpthread
395
396 if BUILD_ENABLE_SESSION_DUMMY
397 kmscon_SOURCES += src/kmscon_dummy.c
398 endif
399
400 if BUILD_ENABLE_SESSION_TERMINAL
401 kmscon_SOURCES += src/kmscon_terminal.c
402 kmscon_LDADD += libtsm.la
403 endif
404
405 if BUILD_ENABLE_SESSION_CDEV
406 kmscon_SOURCES += src/kmscon_cdev.c
407 kmscon_CPPFLAGS += $(FUSE_CFLAGS)
408 kmscon_LDADD += $(FUSE_LIBS)
409 endif
410
411 if BUILD_ENABLE_RENDERER_BBLIT
412 kmscon_SOURCES += src/text_bblit.c
413 endif
414
415 if BUILD_ENABLE_RENDERER_BBULK
416 kmscon_SOURCES += src/text_bbulk.c
417 endif
418
419 if BUILD_ENABLE_RENDERER_GLTEX
420 kmscon_SOURCES += \
421         src/text_gltex.c \
422         src/static_gl.h \
423         src/static_gl_math.c \
424         src/static_gl_shader.c
425 nodist_kmscon_SOURCES += src/static_shaders.c
426 kmscon_CPPFLAGS += $(GLES2_CFLAGS)
427 kmscon_LDADD += $(GLES2_LIBS)
428 MANPAGES += docs/man/kmscon.1
429 endif
430
431 #
432 # Wayland Terminal
433 #
434
435 if BUILD_ENABLE_WLTERM
436 bin_PROGRAMS += wlterm
437 endif
438
439 wlterm_SOURCES = \
440         $(SHL_MISC) \
441         $(SHL_ARRAY) \
442         $(SHL_DLIST) \
443         $(SHL_HOOK) \
444         src/wlt_main.h \
445         src/wlt_main.c \
446         src/wlt_toolkit.h \
447         src/wlt_toolkit.c \
448         src/wlt_theme.h \
449         src/wlt_theme.c \
450         src/wlt_terminal.h \
451         src/wlt_terminal.c \
452         src/log.h \
453         src/log.c \
454         src/conf.h \
455         src/conf.c \
456         src/pty.h \
457         src/pty.c
458 wlterm_CPPFLAGS = \
459         $(AM_CPPFLAGS) \
460         $(WAYLAND_CFLAGS) \
461         $(XKBCOMMON_CFLAGS)
462 wlterm_LDADD = \
463         $(WAYLAND_LIBS) \
464         $(XKBCOMMON_LIBS) \
465         libeloop.la \
466         libtsm.la \
467         libtext-font.la \
468         -lpthread
469
470 #
471 # Tests
472 #
473
474 test_sources = \
475         src/log.h \
476         src/log.c \
477         src/conf.h \
478         src/conf.c \
479         tests/test_include.h
480 test_cflags = \
481         $(XKBCOMMON_CFLAGS)
482 test_libs = \
483         $(XKBCOMMON_LIBS) \
484         libeloop.la
485
486 test_output_SOURCES = \
487         $(test_sources) \
488         tests/test_output.c
489 test_output_CPPFLAGS = \
490         $(AM_CPPFLAGS) \
491         $(test_cflags)
492 test_output_LDADD = \
493         $(test_libs) \
494         libuterm.la
495
496 test_vt_SOURCES = \
497         $(test_sources) \
498         tests/test_vt.c
499 test_vt_CPPFLAGS = \
500         $(AM_CPPFLAGS) \
501         $(test_cflags)
502 test_vt_LDADD = \
503         $(test_libs) \
504         libuterm.la
505
506 test_input_SOURCES = \
507         $(test_sources) \
508         tests/test_input.c
509 test_input_CPPFLAGS = \
510         $(AM_CPPFLAGS) \
511         $(test_cflags)
512 test_input_LDADD = \
513         $(test_libs) \
514         libuterm.la
515
516 test_key_SOURCES = \
517         $(test_sources) \
518         tests/test_key.c
519 test_key_CPPFLAGS = \
520         $(AM_CPPFLAGS) \
521         $(test_cflags)
522 test_key_LDADD = \
523         $(test_libs)
524
525 #
526 # Manpages
527 #
528
529 MAN_XML_FILES = ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
530 man_MANS =
531 EXTRA_DIST += $(MAN_XML_FILES)
532
533 if BUILD_HAVE_XSLTPROC
534 if BUILD_HAVE_MANPAGES_STYLESHEET
535
536 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES)
537 EXTRA_DIST += $(MANPAGES) $(MANPAGES_ALIASES)
538 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES) man_fixup_aliases
539
540 XSLTPROC_FLAGS = \
541         --stringparam man.authors.section.enabled 0 \
542         --stringparam man.copyright.section.enabled 0 \
543         --stringparam funcsynopsis.style ansi \
544         --stringparam man.output.quietly 1 \
545         --nonet
546
547 XSLTPROC_PROCESS_MAN = \
548         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
549         $(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) $<
550
551 man_fixup_aliases: $(MANPAGES) $(MANPAGES_ALIASES)
552         $(AM_V_GEN)if test -n "$(MANPAGES_ALIASES)" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' $(MANPAGES_ALIASES) ; fi
553
554 docs/man/%.1: docs/man/%.xml
555         $(XSLTPROC_PROCESS_MAN)
556
557 docs/man/%.3: docs/man/%.xml
558         $(XSLTPROC_PROCESS_MAN)
559
560 docs/man/%.5: docs/man/%.xml
561         $(XSLTPROC_PROCESS_MAN)
562
563 docs/man/%.7: docs/man/%.xml
564         $(XSLTPROC_PROCESS_MAN)
565
566 endif # BUILD_HAVE_MANPAGES_STYLESHEET
567 endif # BUILD_HAVE_XSLTPROC