5a324dd9389d536dc98824a0860a431cd55e609d
[platform/upstream/kmscon.git] / Makefile.am
1 #
2 # Kmscon - Global Makefile
3 # Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
4 #
5
6 #
7 # Library Version Numbers
8 #
9
10 LIBELOOP_CURRENT = 1
11 LIBELOOP_REVISION = 0
12 LIBELOOP_AGE = 0
13
14 #
15 # Global Configurations and Initializations
16 #
17
18 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
19 AM_MAKEFLAGS = --no-print-directory
20 AUTOMAKE_OPTIONS = color-tests
21 AM_DISTCHECK_CONFIGURE_FLAGS = --enable-all
22
23 SUBDIRS = .
24
25 .DELETE_ON_ERROR:
26
27 include_HEADERS =
28 EXTRA_DIST = \
29         README \
30         COPYING \
31         NEWS \
32         docs/kmscon.service \
33         docs/kmsconvt@.service \
34         docs/pc/libeloop.pc.in \
35         docs/sym/libeloop.sym
36 CLEANFILES =
37 pkgconfigdir = $(libdir)/pkgconfig
38 pkgconfig_DATA =
39 MANPAGES =
40 MANPAGES_ALIASES =
41 TPHONY =
42
43 bin_PROGRAMS =
44 check_PROGRAMS =
45 noinst_PROGRAMS =
46 lib_LTLIBRARIES =
47 noinst_LTLIBRARIES =
48
49 moduledir = $(libdir)/kmscon
50 module_LTLIBRARIES =
51
52 #
53 # Default CFlags
54 # Make all files include "config.h" by default. This shouldn't cause any
55 # problems and we cannot forget to include it anymore.
56 #
57 # Also make the linker discard all unused symbols.
58 #
59 # When compiling in debug mode, we enable debug symbols so debugging with gdb
60 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
61 # Otherwise, we use standard optimizations -O2.
62 #
63
64 AM_CFLAGS = \
65         -Wall \
66         -pipe \
67         -fno-common \
68         -ffast-math \
69         -fdiagnostics-show-option \
70         -fno-strict-aliasing \
71         -fvisibility=hidden \
72         -ffunction-sections \
73         -fdata-sections \
74         -fstack-protector
75 AM_CPPFLAGS = \
76         -DBUILD_MODULE_DIR='"$(moduledir)"' \
77         -include $(top_builddir)/config.h \
78         -I $(srcdir)/src
79 AM_LDFLAGS = \
80         -Wl,--as-needed \
81         -Wl,--gc-sections \
82         -Wl,-z,relro \
83         -Wl,-z,now
84
85 if BUILD_ENABLE_DEBUG
86 AM_CFLAGS += -g
87 endif
88
89 if BUILD_ENABLE_OPTIMIZATIONS
90 AM_CFLAGS += -O2
91 else
92 AM_CFLAGS += -O0
93 endif
94
95 #
96 # GIT-HEAD helper
97 # The file ./src/shl_githead.c contains a constant "shl_git_head" which is
98 # defined to the string returned by "git describe". We need to adjust this
99 # string for every build and correctly rebuild any sources that depend on it.
100 # Therefore, you should use this file rarely as it causes rebuilds on every
101 # git-commit.
102 #
103 # We have a helper-script ./src/genversion.sh that takes as argument the source
104 # file and creates it if necessary. It updates it only if the new git-describe
105 # string is different to the old one. So the file is only modified on changes.
106 # Hence, we can use it as normal dependency in this Makefile.
107 # However, we need to run this script on _every_ "make" invocation before any
108 # recipy is executed. To achieve this, we use $(shell ...) and assign it to a
109 # "simply expanded" variable (:=) so the shell command is executed on
110 # variable-declaration and not during expansion.
111 #
112 # Note that we must not clean ./src/shl_githead.c ever! If we would, a
113 # distribution tarball might delete that file and have no way to recreate it.
114 # We could delete it on something like "make maintainerclean", but then again,
115 # it seems unnecessary so lets simply not clean it at all.
116 #
117 # If the helper-script is executed in a directory that is not a git-repository
118 # (like a distribution tarball) and shl_githead.c exists, then it does nothing
119 # as it expects shl_githead.c to be correctly written by "make dist".
120 # However, if shl_githead.c does not exist, it will print a warning and write
121 # an unknown random git-revision.
122 # This guarantees, that shl_githead.c is always present and has the most correct
123 # value that we can get under any conditions.
124 #
125 # The $(emptyvariable) expansion below is used for broken $(shell ...)
126 # syntax-highlighting algorithms in many existing editors.
127 #
128
129 EXTRA_DIST += src/genversion.sh
130 GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/shl_githead.c")
131
132 #
133 # Binary File Compiler
134 # This target gets as input a binary file *.bin and produces an ELF/etc. output
135 # object file *.bin.o and the corresponding libtool file *.bin.lo.
136 # Note that we fake the libtool object files as there is no way to make libtool
137 # create it. The comments in the .lo file are mandatory so don't remove them!
138 #
139
140 CLEANFILES += src/*.bin.lo src/*.bin.o
141
142 src/%.bin.lo: src/%.bin
143         $(AM_V_GEN)$(LD) -r -o "src/$*.bin.o" -z noexecstack --format=binary "$<"
144         $(AM_V_at)echo "# $@ - a libtool object file" >"$@"
145         $(AM_V_at)echo "# Generated by $(shell $(LIBTOOL) --version | head -n 1)" >>"$@"
146         $(AM_V_at)echo "#" >>"$@"
147         $(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
148         $(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
149         $(AM_V_at)echo >>"$@"
150         $(AM_V_at)echo "# Name of the PIC object." >>"$@"
151         $(AM_V_at)echo "pic_object='$*.bin.o'" >>"$@"
152         $(AM_V_at)echo >>"$@"
153         $(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
154         $(AM_V_at)echo "non_pic_object='$*.bin.o'" >>"$@"
155         $(AM_V_at)echo >>"$@"
156
157 #
158 # SHL - Static Helper Library
159 # The SHL subsystem contains several small code pieces used all over kmscon and
160 # other applications.
161 #
162
163 noinst_LTLIBRARIES += libshl.la
164
165 libshl_la_SOURCES = \
166         src/shl_githead.h \
167         src/shl_githead.c \
168         src/shl_dlist.h \
169         src/shl_array.h \
170         src/shl_hashtable.h \
171         external/htable.h \
172         external/htable.c \
173         src/shl_ring.h \
174         src/shl_timer.h \
175         src/shl_llog.h \
176         src/shl_log.h \
177         src/shl_log.c \
178         src/shl_hook.h \
179         src/shl_misc.h \
180         src/shl_register.h \
181         src/shl_flagset.h
182 libshl_la_CPPFLAGS = \
183         $(AM_CPPFLAGS) \
184         $(XKBCOMMON_CFLAGS) \
185         -pthread
186 libshl_la_LDFLAGS = \
187         $(AM_LDFLAGS) \
188         -pthread
189 libshl_la_LIBADD = \
190         $(AM_LIBADD) \
191         $(XKBCOMMON_LIBS)
192
193 #
194 # libeloop
195 # This library contains the whole event-loop implementation of kmscon. It is
196 # compiled into a separate object to allow using it in several other programs.
197 #
198
199 if BUILD_ENABLE_ELOOP
200 lib_LTLIBRARIES += libeloop.la
201 include_HEADERS += src/eloop.h
202 pkgconfig_DATA += docs/pc/libeloop.pc
203 endif
204
205 libeloop_la_SOURCES = \
206         src/eloop.h \
207         src/eloop.c
208
209 libeloop_la_LIBADD = libshl.la
210 libeloop_la_CPPFLAGS = $(AM_CPPFLAGS)
211 EXTRA_libeloop_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libeloop.sym
212 libeloop_la_LDFLAGS = \
213         $(AM_LDFLAGS) \
214         -version-info $(LIBELOOP_CURRENT):$(LIBELOOP_REVISION):$(LIBELOOP_AGE) \
215         -Wl,--version-script=$(top_srcdir)/docs/sym/libeloop.sym
216
217
218 if BUILD_ENABLE_ELOOP_DBUS
219 libeloop_la_SOURCES += \
220         external/dbus-common.h \
221         external/dbus-loop.h \
222         external/dbus-loop.c
223 libeloop_la_CPPFLAGS += $(DBUS_CFLAGS)
224 libeloop_la_LIBADD += $(DBUS_LIBS)
225 endif
226
227 #
228 # libuterm
229 # The uterm library provides helpers to create terminals in user-space. They
230 # are not limited to text-based terminals but rather provide graphics contexts
231 # so arbitrary output can be displayed. Additionally, they provide VT
232 # abstractions and an input layer
233 #
234
235 noinst_LTLIBRARIES += libuterm.la
236
237 libuterm_la_SOURCES = \
238         src/uterm_input.h \
239         src/uterm_monitor.h \
240         src/uterm_video.h \
241         src/uterm_vt.h \
242         src/uterm_input_internal.h \
243         src/uterm_video_internal.h \
244         src/uterm_systemd_internal.h \
245         src/uterm_video.c \
246         src/uterm_monitor.c \
247         src/uterm_vt.c \
248         src/uterm_input.c \
249         src/uterm_input_uxkb.c
250
251 nodist_libuterm_la_SOURCES =
252
253 libuterm_la_CPPFLAGS = \
254         $(AM_CPPFLAGS) \
255         $(XKBCOMMON_CFLAGS)
256 libuterm_la_LIBADD = \
257         $(XKBCOMMON_LIBS) \
258         libeloop.la \
259         libshl.la
260 libuterm_la_LDFLAGS = \
261         $(AM_LDFLAGS)
262
263 if BUILD_ENABLE_MULTI_SEAT
264 libuterm_la_SOURCES += src/uterm_systemd.c
265 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
266 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
267 endif
268
269 if BUILD_ENABLE_HOTPLUG
270 libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
271 libuterm_la_LIBADD += $(UDEV_LIBS)
272 endif
273
274 if BUILD_ENABLE_VIDEO_FBDEV
275 libuterm_la_SOURCES += \
276         src/uterm_fbdev_internal.h \
277         src/uterm_fbdev_video.c \
278         src/uterm_fbdev_render.c
279 endif
280
281 if BUILD_ENABLE_VIDEO_DRM2D
282 libuterm_la_SOURCES += \
283         src/uterm_drm2d_internal.h \
284         src/uterm_drm2d_video.c \
285         src/uterm_drm2d_render.c
286 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
287 libuterm_la_LIBADD += $(DRM_LIBS)
288 endif
289
290 if BUILD_ENABLE_VIDEO_DRM3D
291 noinst_PROGRAMS += genshader
292 libuterm_la_SOURCES += \
293         src/uterm_drm3d_internal.h \
294         src/uterm_drm3d_video.c \
295         src/uterm_drm3d_render.c \
296         src/static_gl.h \
297         src/static_gl_math.c \
298         src/static_gl_shader.c
299 nodist_libuterm_la_SOURCES += src/static_shaders.c
300 libuterm_la_CPPFLAGS += \
301         $(DRM_CFLAGS) \
302         $(EGL_CFLAGS) \
303         $(GBM_CFLAGS) \
304         $(GLES2_CFLAGS)
305 libuterm_la_LIBADD += \
306         $(DRM_LIBS) \
307         $(EGL_LIBS) \
308         $(GBM_LIBS) \
309         $(GLES2_LIBS)
310 endif
311
312 # add shared sources only once
313 UTERM_DRM_SHARED_SRC = \
314         src/uterm_drm_shared_internal.h \
315         src/uterm_drm_shared.c
316 if BUILD_ENABLE_VIDEO_DRM2D
317 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
318 else
319 if BUILD_ENABLE_VIDEO_DRM3D
320 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
321 endif
322 endif
323
324 #
325 # Shaders
326 # As there is no need to modify shaders at run-time, we statically compile them
327 # into object files. As autotools would ignore them, we need to add them to
328 # EXTRA_DIST.
329 # The program that converts the shaders into C-source files is "genshader". It's
330 # pretty simple and just creates a string with the shader source as content.
331 #
332
333 SHADERS = \
334         $(srcdir)/src/static_fill.vert \
335         $(srcdir)/src/static_fill.frag \
336         $(srcdir)/src/static_blend.vert \
337         $(srcdir)/src/static_blend.frag \
338         $(srcdir)/src/static_blit.vert \
339         $(srcdir)/src/static_blit.frag \
340         $(srcdir)/src/static_gltex.vert \
341         $(srcdir)/src/static_gltex.frag
342
343 EXTRA_DIST += $(SHADERS)
344 CLEANFILES += src/static_shaders.c
345 genshader_SOURCES = src/genshader.c
346
347 # TODO: Using $(BUILD_EXEEXT) breaks if it doesn't equal $(EXEEXT). But stupid
348 # automake doesn't allow $(EXEEXT) so lets just rely on both being the same.
349
350 src/static_shaders.c: $(SHADERS) genshader$(BUILD_EXEEXT)
351         $(AM_V_GEN)./genshader$(BUILD_EXEEXT) src/static_shaders.c $(SHADERS)
352
353 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CC = $(CC_FOR_BUILD)
354 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
355 genshader$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
356
357 #
358 # Unifont Generator
359 # This generates the unifont sources from raw hex-encoded font data.
360 #
361
362 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
363 UNIFONT_BIN = src/font_unifont_data.bin
364 UNIFONT_LT = src/font_unifont_data.bin.lo
365
366 EXTRA_DIST += $(UNIFONT)
367 CLEANFILES += $(UNIFONT_BIN)
368 genunifont_SOURCES = src/genunifont.c
369
370 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CC = $(CC_FOR_BUILD)
371 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
372 genunifont$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
373
374 $(UNIFONT_BIN): $(UNIFONT) genunifont$(BUILD_EXEEXT)
375         $(AM_V_GEN)./genunifont$(BUILD_EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
376
377 #
378 # Kmscon Modules
379 #
380
381 if BUILD_ENABLE_FONT_UNIFONT
382 module_LTLIBRARIES += mod-unifont.la
383 noinst_PROGRAMS += genunifont
384 endif
385
386 mod_unifont_la_SOURCES = \
387         src/kmscon_module_interface.h \
388         src/font_unifont.c \
389         src/kmscon_mod_unifont.c
390 mod_unifont_la_LIBADD = \
391         $(UNIFONT_LT) \
392         libshl.la
393 mod_unifont_la_LDFLAGS = \
394         $(AM_LDFLAGS) \
395         -module \
396         -avoid-version
397
398 if BUILD_ENABLE_FONT_PANGO
399 module_LTLIBRARIES += mod-pango.la
400 endif
401
402 mod_pango_la_SOURCES = \
403         src/kmscon_module_interface.h \
404         src/font_pango.c \
405         src/kmscon_mod_pango.c
406 mod_pango_la_CPPFLAGS = \
407         $(AM_CPPFLAGS) \
408         $(PANGO_CFLAGS) \
409         $(TSM_CFLAGS)
410 mod_pango_la_LIBADD = \
411         $(PANGO_LIBS) \
412         $(TSM_LIBS) \
413         -lpthread \
414         libshl.la
415 mod_pango_la_LDFLAGS = \
416         $(AM_LDFLAGS) \
417         -module \
418         -avoid-version
419
420 if BUILD_ENABLE_RENDERER_BBULK
421 module_LTLIBRARIES += mod-bbulk.la
422 endif
423
424 mod_bbulk_la_SOURCES = \
425         src/kmscon_module_interface.h \
426         src/text_bbulk.c \
427         src/kmscon_mod_bbulk.c
428 mod_bbulk_la_LIBADD = libshl.la
429 mod_bbulk_la_LDFLAGS = \
430         $(AM_LDFLAGS) \
431         -module \
432         -avoid-version
433
434 if BUILD_ENABLE_RENDERER_GLTEX
435 module_LTLIBRARIES += mod-gltex.la
436 noinst_PROGRAMS += genshader
437 endif
438
439 mod_gltex_la_SOURCES = \
440         src/kmscon_module_interface.h \
441         src/text_gltex.c \
442         src/static_gl.h \
443         src/static_gl_math.c \
444         src/static_gl_shader.c \
445         src/kmscon_mod_gltex.c
446 nodist_mod_gltex_la_SOURCES = \
447         src/static_shaders.c
448 mod_gltex_la_CPPFLAGS = \
449         $(AM_CPPFLAGS) \
450         $(GLES2_CFLAGS)
451 mod_gltex_la_LIBADD = \
452         $(GLES2_LIBS) \
453         libshl.la
454 mod_gltex_la_LDFLAGS = \
455         $(AM_LDFLAGS) \
456         -module \
457         -avoid-version
458
459 if BUILD_ENABLE_RENDERER_PIXMAN
460 module_LTLIBRARIES += mod-pixman.la
461 endif
462
463 mod_pixman_la_SOURCES = \
464         src/kmscon_module_interface.h \
465         src/text_pixman.c \
466         src/kmscon_mod_pixman.c
467 mod_pixman_la_CPPFLAGS = \
468         $(AM_CPPFLAGS) \
469         $(PIXMAN_CFLAGS)
470 mod_pixman_la_LIBADD = \
471         $(PIXMAN_LIBS) \
472         libshl.la
473 mod_pixman_la_LDFLAGS = \
474         $(AM_LDFLAGS) \
475         -module \
476         -avoid-version
477
478 #
479 # Binaries
480 # These are the sources for the main binaries and test programs. They mostly
481 # consists of a single source file only and include all the libraries that are
482 # built as part of kmscon.
483 #
484
485 if BUILD_ENABLE_KMSCON
486 bin_PROGRAMS += kmscon
487 check_PROGRAMS += \
488         test_output \
489         test_vt \
490         test_input \
491         test_key
492 MANPAGES += docs/man/kmscon.1
493 endif
494
495 kmscon_SOURCES = \
496         src/conf.h \
497         src/conf.c \
498         src/pty.h \
499         src/pty.c \
500         src/font.h \
501         src/font.c \
502         src/font_8x16.c \
503         src/text.h \
504         src/text.c \
505         src/text_bblit.c \
506         src/kmscon_module_interface.h \
507         src/kmscon_module.h \
508         src/kmscon_module.c \
509         src/kmscon_terminal.h \
510         src/kmscon_dummy.h \
511         src/kmscon_seat.h \
512         src/kmscon_seat.c \
513         src/kmscon_conf.h \
514         src/kmscon_conf.c \
515         src/kmscon_main.c
516 nodist_kmscon_SOURCES =
517
518 kmscon_CPPFLAGS = \
519         $(AM_CPPFLAGS) \
520         $(XKBCOMMON_CFLAGS) \
521         $(TSM_CFLAGS)
522 kmscon_LDADD = \
523         $(XKBCOMMON_LIBS) \
524         $(TSM_LIBS) \
525         libeloop.la \
526         libuterm.la \
527         libshl.la \
528         -lpthread \
529         -ldl
530 kmscon_LDFLAGS = \
531         $(AM_LDFLAGS) \
532         -rdynamic
533
534 if BUILD_ENABLE_SESSION_DUMMY
535 kmscon_SOURCES += src/kmscon_dummy.c
536 endif
537
538 if BUILD_ENABLE_SESSION_TERMINAL
539 kmscon_SOURCES += src/kmscon_terminal.c
540 endif
541
542 #
543 # Tests
544 #
545
546 test_sources = \
547         src/conf.h \
548         src/conf.c \
549         tests/test_include.h
550 test_cflags = \
551         $(AM_CPPFLAGS) \
552         $(XKBCOMMON_CFLAGS)
553 test_libs = \
554         $(XKBCOMMON_LIBS) \
555         libeloop.la \
556         libshl.la
557
558 test_output_SOURCES = \
559         $(test_sources) \
560         tests/test_output.c
561 test_output_CPPFLAGS = $(test_cflags)
562 test_output_LDADD = \
563         $(test_libs) \
564         libuterm.la
565
566 test_vt_SOURCES = \
567         $(test_sources) \
568         tests/test_vt.c
569 test_vt_CPPFLAGS = $(test_cflags)
570 test_vt_LDADD = \
571         $(test_libs) \
572         libuterm.la
573
574 test_input_SOURCES = \
575         $(test_sources) \
576         tests/test_input.c
577 test_input_CPPFLAGS = $(test_cflags)
578 test_input_LDADD = \
579         $(test_libs) \
580         libuterm.la
581
582 test_key_SOURCES = \
583         $(test_sources) \
584         tests/test_key.c
585 test_key_CPPFLAGS = $(test_cflags)
586 test_key_LDADD = $(test_libs)
587
588 #
589 # Manpages
590 #
591
592 man_MANS =
593 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
594 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
595
596 if BUILD_HAVE_XSLTPROC
597 if BUILD_HAVE_MANPAGES_STYLESHEET
598
599 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
600
601 XSLTPROC_FLAGS = \
602         --stringparam man.authors.section.enabled 0 \
603         --stringparam man.copyright.section.enabled 0 \
604         --stringparam funcsynopsis.style ansi \
605         --stringparam man.output.quietly 1 \
606         --nonet
607
608 XSLTPROC_PROCESS_MAN = \
609         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
610         $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
611         touch .man_fixup
612
613 # Force .man_fixup if $(MANPAGES) are not built
614 .man_fixup: | $(MANPAGES)
615         @touch .man_fixup
616
617 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
618         $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
619
620 docs/man/%.1: docs/man/%.xml
621         $(XSLTPROC_PROCESS_MAN)
622
623 docs/man/%.3: docs/man/%.xml
624         $(XSLTPROC_PROCESS_MAN)
625
626 docs/man/%.5: docs/man/%.xml
627         $(XSLTPROC_PROCESS_MAN)
628
629 docs/man/%.7: docs/man/%.xml
630         $(XSLTPROC_PROCESS_MAN)
631
632 endif # BUILD_HAVE_MANPAGES_STYLESHEET
633 endif # BUILD_HAVE_XSLTPROC
634
635 #
636 # Phony targets
637 #
638
639 .PHONY: $(TPHONY)