kmscon: move config-handling to kmscon_conf.c
[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         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         $(AM_V_GEN)./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         $(AM_V_GEN)./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/conf.c src/conf.h \
361         src/log.c src/log.h \
362         src/pty.c src/pty.h \
363         src/text.h \
364         src/text.c
365 nodist_libkmscon_core_la_SOURCES =
366
367 if BUILD_ENABLE_BBLIT
368 libkmscon_core_la_SOURCES += \
369         src/text_bblit.c
370 endif
371
372 if BUILD_ENABLE_BBULK
373 libkmscon_core_la_SOURCES += \
374         src/text_bbulk.c
375 endif
376
377 if BUILD_ENABLE_GLES2
378 libkmscon_core_la_SOURCES += \
379         src/text_gltex.c \
380         src/static_gl.h \
381         src/static_gl_math.c \
382         src/static_gl_shader.c
383 nodist_libkmscon_core_la_SOURCES += \
384         src/static_shaders.c
385 endif
386
387 libkmscon_core_la_CPPFLAGS = \
388         $(AM_CPPFLAGS) \
389         $(GLES2_CFLAGS) \
390         $(XKBCOMMON_CFLAGS)
391 libkmscon_core_la_LIBADD = \
392         $(GLES2_LIBS) \
393         $(XKBCOMMON_LIBS) \
394         -lpthread \
395         libeloop.la \
396         libtsm.la \
397         libuterm.la \
398         libtext-font.la
399
400 #
401 # Binaries
402 # These are the sources for the main binaries and test programs. They mostly
403 # consists of a single source file only and include all the libraries that are
404 # built as part of kmscon.
405 #
406
407 if BUILD_ENABLE_KMSCON
408 bin_PROGRAMS += kmscon
409 check_PROGRAMS += \
410         test_output \
411         test_vt \
412         test_input \
413         test_key
414 endif
415
416 kmscon_SOURCES = \
417         $(SHL_DLIST) \
418         $(SHL_MISC) \
419         src/kmscon_terminal.h \
420         src/kmscon_terminal.c \
421         src/kmscon_ui.h \
422         src/kmscon_ui.c \
423         src/kmscon_conf.h \
424         src/kmscon_conf.c \
425         src/kmscon_main.c
426 kmscon_CPPFLAGS = \
427         $(AM_CPPFLAGS) \
428         $(XKBCOMMON_CFLAGS)
429 kmscon_LDADD = \
430         $(XKBCOMMON_LIBS) \
431         libuterm.la \
432         libeloop.la \
433         libtext-font.la \
434         libkmscon-core.la
435
436 test_output_SOURCES = tests/test_output.c tests/test_include.h
437 test_output_LDADD = libkmscon-core.la
438
439 test_vt_SOURCES = tests/test_vt.c
440 test_vt_LDADD = libkmscon-core.la
441
442 test_input_SOURCES = tests/test_input.c
443 test_input_LDADD = libkmscon-core.la
444
445 test_key_SOURCES = tests/test_key.c
446
447 #
448 # Wayland Terminal
449 #
450
451 if BUILD_ENABLE_WLTERM
452 bin_PROGRAMS += wlterm
453 endif
454
455 wlterm_SOURCES = \
456         $(SHL_MISC) \
457         $(SHL_ARRAY) \
458         $(SHL_DLIST) \
459         $(SHL_HOOK) \
460         src/wlt_main.h \
461         src/wlt_main.c \
462         src/wlt_toolkit.h \
463         src/wlt_toolkit.c \
464         src/wlt_theme.h \
465         src/wlt_theme.c \
466         src/wlt_terminal.h \
467         src/wlt_terminal.c \
468         src/log.h \
469         src/log.c \
470         src/conf.h \
471         src/conf.c \
472         src/pty.h \
473         src/pty.c
474 wlterm_CPPFLAGS = \
475         $(AM_CPPFLAGS) \
476         $(WAYLAND_CFLAGS) \
477         $(XKBCOMMON_CFLAGS)
478 wlterm_LDADD = \
479         libeloop.la \
480         libtsm.la \
481         libtext-font.la \
482         -lpthread \
483         $(WAYLAND_LIBS) \
484         $(XKBCOMMON_LIBS)