shl: hook: link elements in reverse order
[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_DLIST)
92 SHL_MISC = \
93         src/shl_misc.h
94
95 #
96 # libeloop
97 # This library contains the whole event-loop implementation of kmscon. It is
98 # compiled into a separate object to allow using it in several other programs.
99 #
100
101 if BUILD_ENABLE_ELOOP
102 lib_LTLIBRARIES += libeloop.la
103 include_HEADERS += src/eloop.h
104 pkgconfig_DATA += libeloop.pc
105 endif
106
107 libeloop_la_SOURCES = \
108         $(SHL_DLIST) \
109         $(SHL_LLOG) \
110         $(SHL_HOOK) \
111         src/eloop.h \
112         src/eloop.c
113
114 if BUILD_ENABLE_DBUS
115 libeloop_la_SOURCES += \
116         external/dbus-common.h \
117         external/dbus-loop.h \
118         external/dbus-loop.c
119 endif
120
121 libeloop_la_CPPFLAGS = \
122         $(AM_CPPFLAGS) \
123         $(DBUS_CFLAGS)
124 libeloop_la_LIBADD = \
125         $(DBUS_LIBS)
126 libeloop_la_LDFLAGS = \
127         -version-info 1:0:0
128
129 #
130 # libtsm
131 # The Terminal-emulator State Machine is a library that implements the whole VTE
132 # layer and everything related to it. It has no external dependencies so it can
133 # be used to implement any kind of terminal emulator or debugger.
134 #
135
136 if BUILD_ENABLE_TSM
137 lib_LTLIBRARIES += libtsm.la
138 include_HEADERS += \
139         src/tsm_screen.h \
140         src/tsm_unicode.h \
141         src/tsm_vte.h
142 pkgconfig_DATA += 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
158 libtsm_la_CPPFLAGS = \
159         $(AM_CPPFLAGS) \
160         $(XKBCOMMON_CFLAGS)
161 libtsm_la_LDFLAGS = \
162         $(XKBCOMMON_LIBS) \
163         -version-info 1:0:0
164
165 #
166 # libuterm
167 # The uterm library provides helpers to create terminals in user-space. They
168 # are not limited to text-based terminals but rather provide graphics contexts
169 # so arbitrary output can be displayed. Additionally, they provide VT
170 # abstractions and an input layer
171 #
172
173 if BUILD_ENABLE_UTERM
174 lib_LTLIBRARIES += libuterm.la
175 include_HEADERS += src/uterm.h
176 pkgconfig_DATA += libuterm.pc
177 endif
178
179 libuterm_la_SOURCES = \
180         $(SHL_DLIST) \
181         $(SHL_HOOK) \
182         $(SHL_MISC) \
183         src/uterm.h \
184         src/uterm_input.h \
185         src/uterm_video.h \
186         src/uterm_video.c \
187         src/uterm_monitor.c \
188         src/uterm_vt.c \
189         src/uterm_input.c \
190         src/uterm_input_uxkb.c \
191         src/uterm_input_plain.c \
192         external/imKStoUCS.h \
193         external/imKStoUCS.c
194 nodist_libuterm_la_SOURCES =
195
196 libuterm_la_CPPFLAGS = \
197         $(AM_CPPFLAGS) \
198         $(SYSTEMD_CFLAGS) \
199         $(DRM_CFLAGS) \
200         $(EGL_CFLAGS) \
201         $(GBM_CFLAGS) \
202         $(GLES2_CFLAGS) \
203         $(UDEV_CFLAGS) \
204         $(XKBCOMMON_CFLAGS)
205 libuterm_la_LIBADD = \
206         $(SYSTEMD_LIBS) \
207         $(DRM_LIBS) \
208         $(EGL_LIBS) \
209         $(GBM_LIBS) \
210         $(GLES2_LIBS) \
211         $(UDEV_LIBS) \
212         $(XKBCOMMON_LIBS) \
213         libeloop.la
214 libuterm_la_LDFLAGS = \
215         -version-info 1:0:0
216
217 if BUILD_ENABLE_FBDEV
218 libuterm_la_SOURCES += \
219         src/uterm_video_fbdev.c
220 endif
221
222 if BUILD_ENABLE_DRM
223 libuterm_la_SOURCES += \
224         src/uterm_video_drm.c
225 libuterm_la_SOURCES += \
226         src/static_gl.h \
227         src/static_gl_math.c \
228         src/static_gl_shader.c
229 nodist_libuterm_la_SOURCES += \
230         src/static_shaders.c
231 endif
232
233 if BUILD_ENABLE_DUMB
234 libuterm_la_SOURCES += \
235         src/uterm_video_dumb.c
236 endif
237
238 #
239 # Shaders
240 # As there is no need to modify shaders at run-time, we statically compile them
241 # into object files. As autotools would ignore them, we need to add them to
242 # EXTRA_DIST.
243 # The program that converts the shaders into C-source files is "genshader". It's
244 # pretty simple and just creates a string with the shader source as content.
245 #
246
247 SHADERS = \
248         $(srcdir)/src/static_fill.vert \
249         $(srcdir)/src/static_fill.frag \
250         $(srcdir)/src/static_blend.vert \
251         $(srcdir)/src/static_blend.frag \
252         $(srcdir)/src/static_blit.vert \
253         $(srcdir)/src/static_blit.frag \
254         $(srcdir)/src/static_gltex.vert \
255         $(srcdir)/src/static_gltex.frag
256
257 EXTRA_DIST += \
258         $(SHADERS)
259 CLEANFILES += \
260         src/static_shaders.c
261
262 genshader_SOURCES = \
263         src/genshader.c
264
265 src/static_shaders.c: $(SHADERS) genshader$(EXEEXT)
266         $(AM_V_GEN)./genshader$(EXEEXT) src/static_shaders.c $(SHADERS)
267
268 #
269 # Unifont Generator
270 # This generates the unifont sources from raw hex-encoded font data.
271 #
272
273 UNIFONT = \
274         src/text_font_unifont_data.hex
275
276 EXTRA_DIST += \
277         $(UNIFONT)
278 CLEANFILES += \
279         src/text_font_unifont_data.c
280
281 genunifont_SOURCES = \
282         src/genunifont.c
283
284 src/text_font_unifont_data.c: $(UNIFONT) genunifont$(EXEEXT)
285         $(AM_V_GEN)./genunifont$(EXEEXT) src/text_font_unifont_data.c $(UNIFONT)
286
287 #
288 # Text-font library
289 # The text-font library is used by kmscon _and_ wlterm but is currently linked
290 # statically as it hasn't been cleaned up entirely.
291 # It has a build-time dependency to UTERM and runtime dependencies to TSM.
292 #
293
294 if BUILD_ENABLE_KMSCON
295 noinst_LTLIBRARIES += libtext-font.la
296 else
297 if BUILD_ENABLE_WLTERM
298 noinst_LTLIBRARIES += libtext-font.la
299 endif
300 endif
301
302 libtext_font_la_SOURCES = \
303         $(SHL_DLIST) \
304         $(SHL_HASHTABLE) \
305         $(SHL_HOOK) \
306         src/text.h \
307         src/text_font.c
308 nodist_libtext_font_la_SOURCES =
309
310 if BUILD_ENABLE_UNIFONT
311 libtext_font_la_SOURCES += \
312         src/text_font_unifont.c
313 nodist_libtext_font_la_SOURCES += \
314         src/text_font_unifont_data.c
315 endif
316
317 if BUILD_ENABLE_8X16
318 libtext_font_la_SOURCES += \
319         src/text_font_8x16.c
320 endif
321
322 if BUILD_ENABLE_FREETYPE2
323 libtext_font_la_SOURCES += \
324         src/text_font_freetype2.c
325 endif
326
327 if BUILD_ENABLE_PANGO
328 libtext_font_la_SOURCES += \
329         src/text_font_pango.c
330 endif
331
332 libtext_font_la_CPPFLAGS = \
333         $(AM_CPPFLAGS) \
334         $(PANGO_CFLAGS) \
335         $(FREETYPE2_CFLAGS)
336 libtext_font_la_LIBADD = \
337         $(PANGO_LIBS) \
338         $(FREETYPE2_LIBS) \
339         -lpthread \
340         libtsm.la
341
342 #
343 # libkmscon-core
344 # This static library contains all the source files used in kmscon. We build
345 # them as separate library to allow linking them to the test programs.
346 # Only "main.c" is not included here as it contains the main() function.
347 #
348
349 if BUILD_ENABLE_KMSCON
350 noinst_LTLIBRARIES += libkmscon-core.la
351 endif
352
353 libkmscon_core_la_SOURCES = \
354         $(SHL_DLIST) \
355         $(SHL_ARRAY) \
356         $(SHL_HASHTABLE) \
357         $(SHL_RING) \
358         $(SHL_TIMER) \
359         $(SHL_HOOK) \
360         $(SHL_MISC) \
361         src/main.h \
362         src/conf.c src/conf.h \
363         src/ui.c src/ui.h \
364         src/log.c src/log.h \
365         src/terminal.c src/terminal.h \
366         src/pty.c src/pty.h \
367         src/text.h \
368         src/text.c
369 nodist_libkmscon_core_la_SOURCES =
370
371 if BUILD_ENABLE_BBLIT
372 libkmscon_core_la_SOURCES += \
373         src/text_bblit.c
374 endif
375
376 if BUILD_ENABLE_BBULK
377 libkmscon_core_la_SOURCES += \
378         src/text_bbulk.c
379 endif
380
381 if BUILD_ENABLE_GLES2
382 libkmscon_core_la_SOURCES += \
383         src/text_gltex.c \
384         src/static_gl.h \
385         src/static_gl_math.c \
386         src/static_gl_shader.c
387 nodist_libkmscon_core_la_SOURCES += \
388         src/static_shaders.c
389 endif
390
391 libkmscon_core_la_CPPFLAGS = \
392         $(AM_CPPFLAGS) \
393         $(GLES2_CFLAGS) \
394         $(XKBCOMMON_CFLAGS)
395 libkmscon_core_la_LIBADD = \
396         $(GLES2_LIBS) \
397         $(XKBCOMMON_LIBS) \
398         -lpthread \
399         libeloop.la \
400         libtsm.la \
401         libuterm.la \
402         libtext-font.la
403
404 #
405 # Binaries
406 # These are the sources for the main binaries and test programs. They mostly
407 # consists of a single source file only and include all the libraries that are
408 # built as part of kmscon.
409 #
410
411 if BUILD_ENABLE_KMSCON
412 bin_PROGRAMS += kmscon
413 check_PROGRAMS += \
414         test_output \
415         test_vt \
416         test_input \
417         test_key
418 endif
419
420 kmscon_SOURCES = \
421         $(SHL_DLIST) \
422         $(SHL_MISC) \
423         src/main.c
424 kmscon_CPPFLAGS = \
425         $(AM_CPPFLAGS) \
426         $(XKBCOMMON_CFLAGS)
427 kmscon_LDADD = \
428         $(XKBCOMMON_LIBS) \
429         libuterm.la \
430         libeloop.la \
431         libtext-font.la \
432         libkmscon-core.la
433
434 test_output_SOURCES = tests/test_output.c tests/test_include.h
435 test_output_LDADD = libkmscon-core.la
436
437 test_vt_SOURCES = tests/test_vt.c
438 test_vt_LDADD = libkmscon-core.la
439
440 test_input_SOURCES = tests/test_input.c
441 test_input_LDADD = libkmscon-core.la
442
443 test_key_SOURCES = tests/test_key.c
444
445 #
446 # Wayland Terminal
447 #
448
449 if BUILD_ENABLE_WLTERM
450 bin_PROGRAMS += wlterm
451 endif
452
453 wlterm_SOURCES = \
454         $(SHL_MISC) \
455         $(SHL_ARRAY) \
456         $(SHL_DLIST) \
457         $(SHL_HOOK) \
458         src/wlt_main.h \
459         src/wlt_main.c \
460         src/wlt_toolkit.h \
461         src/wlt_toolkit.c \
462         src/wlt_theme.h \
463         src/wlt_theme.c \
464         src/wlt_terminal.h \
465         src/wlt_terminal.c \
466         src/log.h \
467         src/log.c \
468         src/conf.h \
469         src/conf.c \
470         src/pty.h \
471         src/pty.c
472 wlterm_CPPFLAGS = \
473         $(AM_CPPFLAGS) \
474         $(WAYLAND_CFLAGS) \
475         $(XKBCOMMON_CFLAGS)
476 wlterm_LDADD = \
477         libeloop.la \
478         libtsm.la \
479         libtext-font.la \
480         -lpthread \
481         $(WAYLAND_LIBS) \
482         $(XKBCOMMON_LIBS)