Modify it to adjust Tizen IVI enviroment
[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)$(OBJCOPY) --rename-section .data=.rodata,alloc,load,readonly,data,contents "src/$*.bin.o"
135         $(AM_V_at)echo "# $@ - a libtool object file" >"$@"
136         $(AM_V_at)echo "# Generated by $(shell $(LIBTOOL) --version | head -n 1)" >>"$@"
137         $(AM_V_at)echo "#" >>"$@"
138         $(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
139         $(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
140         $(AM_V_at)echo >>"$@"
141         $(AM_V_at)echo "# Name of the PIC object." >>"$@"
142         $(AM_V_at)echo "pic_object='$*.bin.o'" >>"$@"
143         $(AM_V_at)echo >>"$@"
144         $(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
145         $(AM_V_at)echo "non_pic_object='$*.bin.o'" >>"$@"
146         $(AM_V_at)echo >>"$@"
147
148 #
149 # Shader Converter
150 # We use a few built-in shader files. To reduce memory-consumption, this helper
151 # removes useless lines from the shaders before they are compiled into an object
152 # file.
153 #
154 # Following regexp are used to remove characters/lines:
155 #  ^/*.*$     Start of multi-line comment
156 #  ^ *.*$     Multi-line comment body
157 #  ^[ \t]*    Indentation whitespace
158 #  [\r\n]     Newlines
159 #
160
161 CLEANFILES += src/*.vert.bin src/*.frag.bin
162 SHADER_SED = -e 's/^\/\*.*$$//' -e 's/^ \*.*$$//' -e 's/^[ \t]*//'
163 SHADER_TR = -d "\r\n"
164
165 src/%.vert.bin: $(top_srcdir)/src/%.vert
166         $(AM_V_at)$(SED) $(SHADER_SED) "$<" | tr $(SHADER_TR) >"$@"
167
168 src/%.frag.bin: $(top_srcdir)/src/%.frag
169         $(AM_V_at)$(SED) $(SHADER_SED) "$<" | tr $(SHADER_TR) >"$@"
170
171 #
172 # XKB Fallback Converter
173 # We use a static built-in XKB fallback keymap. To avoid huge memory consumption
174 # we remove useless lines/characters first.
175 # We also append an ASCII 0 character so it can be used as regular C-string.
176 #
177 # Following regexp are used to remove characters/lines:
178 #   *= *           Whitespace around assignments
179 #   *, *           Whitespace around commatas
180 #   *[][{}()] *    Whitespace around braces
181 #  ^[ \t]*         Indentation whitespace
182 #  [\r\n]          Newlines
183 #
184
185 CLEANFILES += src/*.xkb.bin
186 XKB_SED = -e 's/^[ \t]*//' -e 's/ *\([,=]\) */\1/g' -e 's/ *\([][{}()]\) */\1/g'
187 XKB_TR = -d "\r\n"
188
189 src/%.xkb.bin: $(top_srcdir)/src/%.xkb
190         $(AM_V_at)$(SED) $(XKB_SED) "$<" | tr $(XKB_TR) >"$@"
191         $(AM_V_at)echo -ne "\x00" >>"$@"
192
193 #
194 # SHL - Static Helper Library
195 # The SHL subsystem contains several small code pieces used all over kmscon and
196 # other applications.
197 #
198
199 noinst_LTLIBRARIES += libshl.la
200
201 libshl_la_SOURCES = \
202         src/shl_githead.h \
203         src/shl_githead.c \
204         src/shl_dlist.h \
205         src/shl_array.h \
206         src/shl_hashtable.h \
207         external/htable.h \
208         external/htable.c \
209         src/shl_ring.h \
210         src/shl_timer.h \
211         src/shl_llog.h \
212         src/shl_log.h \
213         src/shl_log.c \
214         src/shl_hook.h \
215         src/shl_misc.h \
216         src/shl_register.h \
217         src/shl_flagset.h
218 libshl_la_CPPFLAGS = \
219         $(AM_CPPFLAGS) \
220         $(XKBCOMMON_CFLAGS) \
221         -pthread
222 libshl_la_LDFLAGS = \
223         $(AM_LDFLAGS) \
224         -pthread
225 libshl_la_LIBADD = \
226         $(AM_LIBADD) \
227         $(XKBCOMMON_LIBS)
228
229 if BUILD_HAVE_GLES2
230 libshl_la_SOURCES += src/shl_gl.h src/shl_gl_shader.c src/shl_gl_math.c
231 libshl_la_CPPFLAGS += $(GLES2_CFLAGS)
232 libshl_la_LIBADD += $(GLES2_LIBS)
233 endif
234
235 #
236 # libeloop
237 # This library contains the whole event-loop implementation of kmscon. It is
238 # compiled into a separate object to allow using it in several other programs.
239 #
240
241 noinst_LTLIBRARIES += libeloop.la
242
243 libeloop_la_SOURCES = \
244         src/eloop.h \
245         src/eloop.c
246
247 libeloop_la_LIBADD = libshl.la
248 libeloop_la_CPPFLAGS = $(AM_CPPFLAGS)
249 libeloop_la_LDFLAGS = $(AM_LDFLAGS)
250
251 #
252 # libuterm
253 # The uterm library provides helpers to create terminals in user-space. They
254 # are not limited to text-based terminals but rather provide graphics contexts
255 # so arbitrary output can be displayed. Additionally, they provide VT
256 # abstractions and an input layer
257 #
258
259 noinst_LTLIBRARIES += libuterm.la
260
261 libuterm_la_SOURCES = \
262         src/uterm_input.h \
263         src/uterm_monitor.h \
264         src/uterm_video.h \
265         src/uterm_vt.h \
266         src/uterm_input_internal.h \
267         src/uterm_video_internal.h \
268         src/uterm_systemd_internal.h \
269         src/uterm_video.c \
270         src/uterm_monitor.c \
271         src/uterm_vt.c \
272         src/uterm_input.c \
273         src/uterm_input_uxkb.c
274
275 nodist_libuterm_la_SOURCES =
276
277 libuterm_la_CPPFLAGS = \
278         $(AM_CPPFLAGS) \
279         $(UDEV_CFLAGS) \
280         $(XKBCOMMON_CFLAGS)
281 libuterm_la_LIBADD = \
282         $(UDEV_LIBS) \
283         $(XKBCOMMON_LIBS) \
284         libeloop.la \
285         libshl.la \
286         src/uterm_input_fallback.xkb.bin.lo
287 libuterm_la_LDFLAGS = \
288         $(AM_LDFLAGS)
289
290 if BUILD_ENABLE_MULTI_SEAT
291 libuterm_la_SOURCES += src/uterm_systemd.c
292 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
293 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
294 endif
295
296 if BUILD_ENABLE_VIDEO_FBDEV
297 libuterm_la_SOURCES += \
298         src/uterm_fbdev_internal.h \
299         src/uterm_fbdev_video.c \
300         src/uterm_fbdev_render.c
301 endif
302
303 if BUILD_ENABLE_VIDEO_DRM2D
304 libuterm_la_SOURCES += \
305         src/uterm_drm2d_internal.h \
306         src/uterm_drm2d_video.c \
307         src/uterm_drm2d_render.c
308 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
309 libuterm_la_LIBADD += $(DRM_LIBS)
310 endif
311
312 if BUILD_ENABLE_VIDEO_DRM3D
313 libuterm_la_SOURCES += \
314         src/uterm_drm3d_internal.h \
315         src/uterm_drm3d_video.c \
316         src/uterm_drm3d_render.c
317 libuterm_la_CPPFLAGS += \
318         $(DRM_CFLAGS) \
319         $(EGL_CFLAGS) \
320         $(GBM_CFLAGS) \
321         $(GLES2_CFLAGS)
322 libuterm_la_LIBADD += \
323         $(DRM_LIBS) \
324         $(EGL_LIBS) \
325         $(GBM_LIBS) \
326         $(GLES2_LIBS) \
327         src/uterm_drm3d_blend.vert.bin.lo \
328         src/uterm_drm3d_blend.frag.bin.lo \
329         src/uterm_drm3d_blit.vert.bin.lo \
330         src/uterm_drm3d_blit.frag.bin.lo \
331         src/uterm_drm3d_fill.vert.bin.lo \
332         src/uterm_drm3d_fill.frag.bin.lo
333 endif
334
335 # add shared sources only once
336 UTERM_DRM_SHARED_SRC = \
337         src/uterm_drm_shared_internal.h \
338         src/uterm_drm_shared.c
339 if BUILD_ENABLE_VIDEO_DRM2D
340 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
341 else
342 if BUILD_ENABLE_VIDEO_DRM3D
343 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
344 endif
345 endif
346
347 #
348 # Unifont Generator
349 # This generates the unifont sources from raw hex-encoded font data.
350 #
351
352 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
353 UNIFONT_BIN = src/font_unifont_data.bin
354 UNIFONT_LT = src/font_unifont_data.bin.lo
355
356 EXTRA_DIST += $(UNIFONT)
357 CLEANFILES += $(UNIFONT_BIN)
358 genunifont_SOURCES = src/genunifont.c
359
360 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CC = $(CC_FOR_BUILD)
361 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
362 genunifont$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
363
364 $(UNIFONT_BIN): $(UNIFONT) genunifont$(BUILD_EXEEXT)
365         $(AM_V_GEN)./genunifont$(BUILD_EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
366
367 #
368 # Kmscon Modules
369 #
370
371 if BUILD_ENABLE_FONT_UNIFONT
372 module_LTLIBRARIES += mod-unifont.la
373 noinst_PROGRAMS += genunifont
374 endif
375
376 mod_unifont_la_SOURCES = \
377         src/kmscon_module_interface.h \
378         src/font_unifont.c \
379         src/kmscon_mod_unifont.c
380 mod_unifont_la_LIBADD = \
381         $(UNIFONT_LT) \
382         libshl.la
383 mod_unifont_la_LDFLAGS = \
384         $(AM_LDFLAGS) \
385         -module \
386         -avoid-version
387
388 if BUILD_ENABLE_FONT_PANGO
389 module_LTLIBRARIES += mod-pango.la
390 endif
391
392 mod_pango_la_SOURCES = \
393         src/kmscon_module_interface.h \
394         src/font_pango.c \
395         src/kmscon_mod_pango.c
396 mod_pango_la_CPPFLAGS = \
397         $(AM_CPPFLAGS) \
398         $(PANGO_CFLAGS) \
399         $(TSM_CFLAGS)
400 mod_pango_la_LIBADD = \
401         $(PANGO_LIBS) \
402         $(TSM_LIBS) \
403         -lpthread \
404         libshl.la
405 mod_pango_la_LDFLAGS = \
406         $(AM_LDFLAGS) \
407         -module \
408         -avoid-version
409
410 if BUILD_ENABLE_RENDERER_BBULK
411 module_LTLIBRARIES += mod-bbulk.la
412 endif
413
414 mod_bbulk_la_SOURCES = \
415         src/kmscon_module_interface.h \
416         src/text_bbulk.c \
417         src/kmscon_mod_bbulk.c
418 mod_bbulk_la_CPPFLAGS = \
419         $(AM_CPPFLAGS) \
420         $(TSM_CFLAGS)
421 mod_bbulk_la_LIBADD = \
422         $(TSM_LIBS) \
423         libshl.la
424 mod_bbulk_la_LDFLAGS = \
425         $(AM_LDFLAGS) \
426         -module \
427         -avoid-version
428
429 if BUILD_ENABLE_RENDERER_GLTEX
430 module_LTLIBRARIES += mod-gltex.la
431 endif
432
433 mod_gltex_la_SOURCES = \
434         src/kmscon_module_interface.h \
435         src/text_gltex.c \
436         src/kmscon_mod_gltex.c
437 mod_gltex_la_CPPFLAGS = \
438         $(AM_CPPFLAGS) \
439         $(TSM_CFLAGS) \
440         $(GLES2_CFLAGS)
441 mod_gltex_la_LIBADD = \
442         $(GLES2_LIBS) \
443         $(TSM_LIBS) \
444         libshl.la \
445         src/text_gltex_atlas.vert.bin.lo \
446         src/text_gltex_atlas.frag.bin.lo
447 mod_gltex_la_LDFLAGS = \
448         $(AM_LDFLAGS) \
449         -module \
450         -avoid-version
451
452 if BUILD_ENABLE_RENDERER_PIXMAN
453 module_LTLIBRARIES += mod-pixman.la
454 endif
455
456 mod_pixman_la_SOURCES = \
457         src/kmscon_module_interface.h \
458         src/text_pixman.c \
459         src/kmscon_mod_pixman.c
460 mod_pixman_la_CPPFLAGS = \
461         $(AM_CPPFLAGS) \
462         $(PIXMAN_CFLAGS)
463 mod_pixman_la_LIBADD = \
464         $(PIXMAN_LIBS) \
465         libshl.la
466 mod_pixman_la_LDFLAGS = \
467         $(AM_LDFLAGS) \
468         -module \
469         -avoid-version
470
471 #
472 # Binaries
473 # These are the sources for the main binaries and test programs. They mostly
474 # consists of a single source file only and include all the libraries that are
475 # built as part of kmscon.
476 #
477
478 bin_PROGRAMS += kmscon
479 check_PROGRAMS += \
480         test_output \
481         test_vt \
482         test_input \
483         test_key
484 MANPAGES += docs/man/kmscon.1
485
486 kmscon_SOURCES = \
487         src/conf.h \
488         src/conf.c \
489         src/pty.h \
490         src/pty.c \
491         src/font.h \
492         src/font.c \
493         src/font_8x16.c \
494         src/text.h \
495         src/text.c \
496         src/text_bblit.c \
497         src/kmscon_module_interface.h \
498         src/kmscon_module.h \
499         src/kmscon_module.c \
500         src/kmscon_terminal.h \
501         src/kmscon_dummy.h \
502         src/kmscon_seat.h \
503         src/kmscon_seat.c \
504         src/kmscon_conf.h \
505         src/kmscon_conf.c \
506         src/kmscon_main.c
507 nodist_kmscon_SOURCES =
508
509 kmscon_CPPFLAGS = \
510         $(AM_CPPFLAGS) \
511         $(XKBCOMMON_CFLAGS) \
512         $(TSM_CFLAGS)
513 kmscon_LDADD = \
514         $(XKBCOMMON_LIBS) \
515         $(TSM_LIBS) \
516         libeloop.la \
517         libuterm.la \
518         libshl.la \
519         -lpthread \
520         -ldl
521 kmscon_LDFLAGS = \
522         $(AM_LDFLAGS) \
523         -rdynamic
524
525 if BUILD_ENABLE_SESSION_DUMMY
526 kmscon_SOURCES += src/kmscon_dummy.c
527 endif
528
529 if BUILD_ENABLE_SESSION_TERMINAL
530 kmscon_SOURCES += src/kmscon_terminal.c
531 endif
532
533 #
534 # Tests
535 #
536
537 test_sources = \
538         src/conf.h \
539         src/conf.c \
540         tests/test_include.h
541 test_cflags = \
542         $(AM_CPPFLAGS) \
543         $(XKBCOMMON_CFLAGS)
544 test_libs = \
545         $(XKBCOMMON_LIBS) \
546         libeloop.la \
547         libshl.la
548
549 test_output_SOURCES = \
550         $(test_sources) \
551         tests/test_output.c
552 test_output_CPPFLAGS = $(test_cflags)
553 test_output_LDADD = \
554         $(test_libs) \
555         libuterm.la
556
557 test_vt_SOURCES = \
558         $(test_sources) \
559         tests/test_vt.c
560 test_vt_CPPFLAGS = $(test_cflags)
561 test_vt_LDADD = \
562         $(test_libs) \
563         libuterm.la
564
565 test_input_SOURCES = \
566         $(test_sources) \
567         tests/test_input.c
568 test_input_CPPFLAGS = $(test_cflags)
569 test_input_LDADD = \
570         $(test_libs) \
571         libuterm.la
572
573 test_key_SOURCES = \
574         $(test_sources) \
575         tests/test_key.c
576 test_key_CPPFLAGS = $(test_cflags)
577 test_key_LDADD = $(test_libs)
578
579 #
580 # Manpages
581 #
582
583 man_MANS =
584 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
585 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
586
587 if BUILD_HAVE_XSLTPROC
588 if BUILD_HAVE_MANPAGES_STYLESHEET
589
590 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
591
592 XSLTPROC_FLAGS = \
593         --stringparam man.authors.section.enabled 0 \
594         --stringparam man.copyright.section.enabled 0 \
595         --stringparam funcsynopsis.style ansi \
596         --stringparam man.output.quietly 1 \
597         --nonet
598
599 XSLTPROC_PROCESS_MAN = \
600         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
601         $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
602         touch .man_fixup
603
604 # Force .man_fixup if $(MANPAGES) are not built
605 .man_fixup: | $(MANPAGES)
606         @touch .man_fixup
607
608 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
609         $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
610
611 docs/man/%.1: docs/man/%.xml
612         $(XSLTPROC_PROCESS_MAN)
613
614 docs/man/%.3: docs/man/%.xml
615         $(XSLTPROC_PROCESS_MAN)
616
617 docs/man/%.5: docs/man/%.xml
618         $(XSLTPROC_PROCESS_MAN)
619
620 docs/man/%.7: docs/man/%.xml
621         $(XSLTPROC_PROCESS_MAN)
622
623 endif # BUILD_HAVE_MANPAGES_STYLESHEET
624 endif # BUILD_HAVE_XSLTPROC
625
626 #
627 # Phony targets
628 #
629
630 .PHONY: $(TPHONY)
631
632 #
633 # Empty .SECONDARY target causes alle intermediate files to be treated as
634 # secondary files. That is, they don't get deleted after make finished.
635 #
636
637 .SECONDARY: