build: actually make use of pkg-config info about xbkcommon
[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 CLEANFILES =
15 pkgconfigdir = $(libdir)/pkgconfig
16 pkgconfig_DATA =
17
18 #
19 # Build targets
20 #
21 # kmscon: Main kmscon program
22 # test_output: Test program for the display graphics subsystem
23 # test_vt: Test program for the VT subsystem
24 # test_input: Test program for the input subsystem
25 # libkmscon-core: Static core library for kmscon and test programs
26 # genshader: Program used to convert shaders into C-source files
27 #
28
29 bin_PROGRAMS =
30 check_PROGRAMS =
31 noinst_PROGRAMS = \
32         genshader \
33         genunifont
34 noinst_LTLIBRARIES =
35 lib_LTLIBRARIES =
36
37 #
38 # Default CFlags
39 # Make all files include "config.h" by default. This shouldn't cause any
40 # problems and we cannot forget to include it anymore.
41 #
42 # Also make the linker discard all unused symbols as we are not building a
43 # shared library.
44 #
45 # When compiling in debug mode, we enable debug symbols so debugging with gdb
46 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
47 # Otherwise, we use standard optimizations -O2.
48 #
49
50 AM_CFLAGS = \
51         -Wall
52 AM_CPPFLAGS = \
53         -include $(top_builddir)/config.h \
54         -I $(srcdir)/src \
55         -I $(srcdir)/external
56 AM_LDFLAGS = \
57         -Wl,--as-needed
58
59 if BUILD_ENABLE_DEBUG
60 AM_CFLAGS += -g
61 endif
62
63 if BUILD_ENABLE_OPTIMIZATIONS
64 AM_CFLAGS += -O2
65 else
66 AM_CFLAGS += -O0
67 endif
68
69 #
70 # SHL - Static Helper Library
71 # The SHL subsystem contains several small code pieces used all over kmscon and
72 # other applications.
73 #
74
75 SHL_DLIST = \
76         src/shl_dlist.h
77 SHL_ARRAY = \
78         src/shl_array.h
79 SHL_HASHTABLE = \
80         src/shl_hashtable.h \
81         external/htable.h \
82         external/htable.c
83 SHL_RING = \
84         src/shl_ring.h
85 SHL_TIMER = \
86         src/shl_timer.h
87 SHL_LLOG = \
88         src/shl_llog.h
89 SHL_HOOK = \
90         src/shl_hook.h
91 SHL_MISC = \
92         src/shl_misc.h
93
94 #
95 # libeloop
96 # This library contains the whole event-loop implementation of kmscon. It is
97 # compiled into a separate object to allow using it in several other programs.
98 #
99
100 if BUILD_ENABLE_ELOOP
101 lib_LTLIBRARIES += libeloop.la
102 include_HEADERS += src/eloop.h
103 pkgconfig_DATA += libeloop.pc
104 endif
105
106 libeloop_la_SOURCES = \
107         $(SHL_DLIST) \
108         $(SHL_LLOG) \
109         $(SHL_HOOK) \
110         src/eloop.h \
111         src/eloop.c
112
113 if BUILD_ENABLE_DBUS
114 libeloop_la_SOURCES += \
115         external/dbus-common.h \
116         external/dbus-loop.h \
117         external/dbus-loop.c
118 endif
119
120 libeloop_la_CPPFLAGS = \
121         $(AM_CPPFLAGS) \
122         $(DBUS_CFLAGS)
123 libeloop_la_LIBADD = \
124         $(DBUS_LIBS)
125 libeloop_la_LDFLAGS = \
126         -version-info 1:0:0
127
128 #
129 # libtsm
130 # The Terminal-emulator State Machine is a library that implements the whole VTE
131 # layer and everything related to it. It has no external dependencies so it can
132 # be used to implement any kind of terminal emulator or debugger.
133 #
134
135 if BUILD_ENABLE_TSM
136 lib_LTLIBRARIES += libtsm.la
137 include_HEADERS += \
138         src/tsm_screen.h \
139         src/tsm_unicode.h \
140         src/tsm_vte.h
141 pkgconfig_DATA += libtsm.pc
142 endif
143
144 libtsm_la_SOURCES = \
145         $(SHL_LLOG) \
146         $(SHL_TIMER) \
147         $(SHL_ARRAY) \
148         $(SHL_HASHTABLE) \
149         src/tsm_screen.h \
150         src/tsm_screen.c \
151         src/tsm_unicode.h \
152         src/tsm_unicode.c \
153         src/tsm_vte.h \
154         src/tsm_vte.c \
155         src/tsm_vte_charsets.c
156
157 libtsm_la_CPPFLAGS = \
158         $(AM_CPPFLAGS) \
159         $(XKBCOMMON_CFLAGS)
160 libtsm_la_LDFLAGS = \
161         $(XKBCOMMON_LIBS) \
162         -version-info 1:0:0
163
164 #
165 # libuterm
166 # The uterm library provides helpers to create terminals in user-space. They
167 # are not limited to text-based terminals but rather provide graphics contexts
168 # so arbitrary output can be displayed. Additionally, they provide VT
169 # abstractions and an input layer
170 #
171
172 if BUILD_ENABLE_UTERM
173 lib_LTLIBRARIES += libuterm.la
174 include_HEADERS += src/uterm.h
175 pkgconfig_DATA += libuterm.pc
176 endif
177
178 libuterm_la_SOURCES = \
179         $(SHL_DLIST) \
180         $(SHL_HOOK) \
181         $(SHL_MISC) \
182         src/uterm.h \
183         src/uterm_input.h \
184         src/uterm_video.h \
185         src/uterm_video.c \
186         src/uterm_monitor.c \
187         src/uterm_vt.c \
188         src/uterm_input.c \
189         src/uterm_input_uxkb.c \
190         src/uterm_input_plain.c \
191         external/imKStoUCS.h \
192         external/imKStoUCS.c
193 nodist_libuterm_la_SOURCES =
194
195 libuterm_la_CPPFLAGS = \
196         $(AM_CPPFLAGS) \
197         $(SYSTEMD_CFLAGS) \
198         $(DRM_CFLAGS) \
199         $(EGL_CFLAGS) \
200         $(GBM_CFLAGS) \
201         $(GLES2_CFLAGS) \
202         $(UDEV_CFLAGS) \
203         $(XKBCOMMON_CFLAGS)
204 libuterm_la_LIBADD = \
205         $(SYSTEMD_LIBS) \
206         $(DRM_LIBS) \
207         $(EGL_LIBS) \
208         $(GBM_LIBS) \
209         $(GLES2_LIBS) \
210         $(UDEV_LIBS) \
211         $(XKBCOMMON_LIBS) \
212         libeloop.la
213 libuterm_la_LDFLAGS = \
214         -version-info 1:0:0
215
216 if BUILD_ENABLE_FBDEV
217 libuterm_la_SOURCES += \
218         src/uterm_video_fbdev.c
219 endif
220
221 if BUILD_ENABLE_DRM
222 libuterm_la_SOURCES += \
223         src/uterm_video_drm.c
224 libuterm_la_SOURCES += \
225         src/static_gl.h \
226         src/static_gl_math.c \
227         src/static_gl_shader.c
228 nodist_libuterm_la_SOURCES += \
229         src/static_shaders.c
230 endif
231
232 if BUILD_ENABLE_DUMB
233 libuterm_la_SOURCES += \
234         src/uterm_video_dumb.c
235 endif
236
237 #
238 # Shaders
239 # As there is no need to modify shaders at run-time, we statically compile them
240 # into object files. As autotools would ignore them, we need to add them to
241 # EXTRA_DIST.
242 # The program that converts the shaders into C-source files is "genshader". It's
243 # pretty simple and just creates a string with the shader source as content.
244 #
245
246 SHADERS = \
247         $(srcdir)/src/static_fill.vert \
248         $(srcdir)/src/static_fill.frag \
249         $(srcdir)/src/static_blend.vert \
250         $(srcdir)/src/static_blend.frag \
251         $(srcdir)/src/static_blit.vert \
252         $(srcdir)/src/static_blit.frag \
253         $(srcdir)/src/static_gltex.vert \
254         $(srcdir)/src/static_gltex.frag
255
256 EXTRA_DIST += \
257         $(SHADERS)
258 CLEANFILES += \
259         src/static_shaders.c
260
261 genshader_SOURCES = \
262         src/genshader.c
263
264 src/static_shaders.c: $(SHADERS) genshader$(EXEEXT)
265         ./genshader$(EXEEXT) src/static_shaders.c $(SHADERS)
266
267 #
268 # Unifont Generator
269 # This generates the unifont sources from raw hex-encoded font data.
270 #
271
272 UNIFONT = \
273         src/text_font_unifont_data.hex
274
275 EXTRA_DIST += \
276         $(UNIFONT)
277 CLEANFILES += \
278         src/text_font_unifont_data.c
279
280 genunifont_SOURCES = \
281         src/genunifont.c
282
283 src/text_font_unifont_data.c: $(UNIFONT) genunifont$(EXEEXT)
284         ./genunifont$(EXEEXT) src/text_font_unifont_data.c $(UNIFONT)
285
286 #
287 # Text-font library
288 # The text-font library is used by kmscon _and_ wlterm but is currently linked
289 # statically as it hasn't been cleaned up entirely.
290 # It has a build-time dependency to UTERM and runtime dependencies to TSM.
291 #
292
293 if BUILD_ENABLE_KMSCON
294 noinst_LTLIBRARIES += libtext-font.la
295 else
296 if BUILD_ENABLE_WLTERM
297 noinst_LTLIBRARIES += libtext-font.la
298 endif
299 endif
300
301 libtext_font_la_SOURCES = \
302         $(SHL_DLIST) \
303         $(SHL_HASHTABLE) \
304         $(SHL_HOOK) \
305         src/text.h \
306         src/text_font.c
307 nodist_libtext_font_la_SOURCES =
308
309 if BUILD_ENABLE_UNIFONT
310 libtext_font_la_SOURCES += \
311         src/text_font_unifont.c
312 nodist_libtext_font_la_SOURCES += \
313         src/text_font_unifont_data.c
314 endif
315
316 if BUILD_ENABLE_8X16
317 libtext_font_la_SOURCES += \
318         src/text_font_8x16.c
319 endif
320
321 if BUILD_ENABLE_FREETYPE2
322 libtext_font_la_SOURCES += \
323         src/text_font_freetype2.c
324 endif
325
326 if BUILD_ENABLE_PANGO
327 libtext_font_la_SOURCES += \
328         src/text_font_pango.c
329 endif
330
331 libtext_font_la_CPPFLAGS = \
332         $(AM_CPPFLAGS) \
333         $(PANGO_CFLAGS) \
334         $(FREETYPE2_CFLAGS)
335 libtext_font_la_LIBADD = \
336         $(PANGO_LIBS) \
337         $(FREETYPE2_LIBS) \
338         -lpthread \
339         libtsm.la
340
341 #
342 # libkmscon-core
343 # This static library contains all the source files used in kmscon. We build
344 # them as separate library to allow linking them to the test programs.
345 # Only "main.c" is not included here as it contains the main() function.
346 #
347
348 if BUILD_ENABLE_KMSCON
349 noinst_LTLIBRARIES += libkmscon-core.la
350 endif
351
352 libkmscon_core_la_SOURCES = \
353         $(SHL_DLIST) \
354         $(SHL_ARRAY) \
355         $(SHL_HASHTABLE) \
356         $(SHL_RING) \
357         $(SHL_TIMER) \
358         $(SHL_HOOK) \
359         $(SHL_MISC) \
360         src/main.h \
361         src/conf.c src/conf.h \
362         src/ui.c src/ui.h \
363         src/log.c src/log.h \
364         src/terminal.c src/terminal.h \
365         src/pty.c src/pty.h \
366         src/text.h \
367         src/text.c
368 nodist_libkmscon_core_la_SOURCES =
369
370 if BUILD_ENABLE_BBLIT
371 libkmscon_core_la_SOURCES += \
372         src/text_bblit.c
373 endif
374
375 if BUILD_ENABLE_BBULK
376 libkmscon_core_la_SOURCES += \
377         src/text_bbulk.c
378 endif
379
380 if BUILD_ENABLE_GLES2
381 libkmscon_core_la_SOURCES += \
382         src/text_gltex.c \
383         src/static_gl.h \
384         src/static_gl_math.c \
385         src/static_gl_shader.c
386 nodist_libkmscon_core_la_SOURCES += \
387         src/static_shaders.c
388 endif
389
390 libkmscon_core_la_CPPFLAGS = \
391         $(AM_CPPFLAGS) \
392         $(GLES2_CFLAGS) \
393         $(XKBCOMMON_CFLAGS)
394 libkmscon_core_la_LIBADD = \
395         $(GLES2_LIBS) \
396         $(XKBCOMMON_LIBS) \
397         -lpthread \
398         libeloop.la \
399         libtsm.la \
400         libuterm.la
401
402 #
403 # Binaries
404 # These are the sources for the main binaries and test programs. They mostly
405 # consists of a single source file only and include all the libraries that are
406 # built as part of kmscon.
407 #
408
409 if BUILD_ENABLE_KMSCON
410 bin_PROGRAMS += kmscon
411 check_PROGRAMS += \
412         test_output \
413         test_vt \
414         test_input \
415         test_key
416 endif
417
418 kmscon_SOURCES = \
419         $(SHL_DLIST) \
420         $(SHL_MISC) \
421         src/main.c
422 kmscon_CPPFLAGS = \
423         $(AM_CPPFLAGS) \
424         $(XKBCOMMON_CFLAGS)
425 kmscon_LDADD = \
426         $(XKBCOMMON_LIBS) \
427         libuterm.la \
428         libeloop.la \
429         libtext-font.la \
430         libkmscon-core.la
431
432 test_output_SOURCES = tests/test_output.c tests/test_include.h
433 test_output_LDADD = libkmscon-core.la
434
435 test_vt_SOURCES = tests/test_vt.c
436 test_vt_LDADD = libkmscon-core.la
437
438 test_input_SOURCES = tests/test_input.c
439 test_input_LDADD = libkmscon-core.la
440
441 test_key_SOURCES = tests/test_key.c
442
443 #
444 # Wayland Terminal
445 #
446
447 if BUILD_ENABLE_WLTERM
448 bin_PROGRAMS += wlterm
449 endif
450
451 wlterm_SOURCES = \
452         $(SHL_MISC) \
453         src/wlt_main.h \
454         src/wlt_main.c \
455         src/wlt_toolkit.h \
456         src/wlt_toolkit.c \
457         src/wlt_theme.h \
458         src/wlt_theme.c \
459         src/wlt_terminal.h \
460         src/wlt_terminal.c \
461         src/log.h \
462         src/log.c \
463         src/conf.h \
464         src/conf.c \
465         src/pty.h \
466         src/pty.c
467 wlterm_CPPFLAGS = \
468         $(AM_CPPFLAGS) \
469         $(WAYLAND_CFLAGS) \
470         $(XKBCOMMON_CFLAGS)
471 wlterm_LDADD = \
472         libeloop.la \
473         libtsm.la \
474         libtext-font.la \
475         -lpthread \
476         $(WAYLAND_LIBS) \
477         $(XKBCOMMON_LIBS)