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