build: remove getty@.service from makefiles
[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         docs/kmscon.service \
15         docs/kmsconvt@.service
16 CLEANFILES =
17 pkgconfigdir = $(libdir)/pkgconfig
18 pkgconfig_DATA =
19 MANPAGES =
20 MANPAGES_ALIASES =
21 TPHONY =
22
23 bin_PROGRAMS =
24 check_PROGRAMS =
25 noinst_PROGRAMS = \
26         genshader \
27         genunifont
28 noinst_LTLIBRARIES =
29 lib_LTLIBRARIES =
30
31 moduledir = @libdir@/kmscon
32 module_LTLIBRARIES =
33
34 #
35 # Default CFlags
36 # Make all files include "config.h" by default. This shouldn't cause any
37 # problems and we cannot forget to include it anymore.
38 #
39 # Also make the linker discard all unused symbols.
40 #
41 # When compiling in debug mode, we enable debug symbols so debugging with gdb
42 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
43 # Otherwise, we use standard optimizations -O2.
44 #
45
46 AM_CFLAGS = \
47         -Wall
48 AM_CPPFLAGS = \
49         -DBUILD_MODULE_DIR='"$(moduledir)"' \
50         -include $(top_builddir)/config.h \
51         -I $(srcdir)/src
52 AM_LDFLAGS = \
53         -Wl,--as-needed
54
55 if BUILD_ENABLE_DEBUG
56 AM_CFLAGS += -g
57 endif
58
59 if BUILD_ENABLE_OPTIMIZATIONS
60 AM_CFLAGS += -O2
61 else
62 AM_CFLAGS += -O0
63 endif
64
65 #
66 # SHL - Static Helper Library
67 # The SHL subsystem contains several small code pieces used all over kmscon and
68 # other applications.
69 #
70 # Simply include $(SHL_*) in your source-file list.
71 # SHL_MISC needs xkbcommon
72 # SHL_REGISTER needs pthread
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 SHL_REGISTER = \
95         src/shl_register.h \
96         $(SHL_DLIST)
97
98 #
99 # GIT-HEAD helper
100 # The file ./src/githead.h contains a constant BUILD_GIT_HEAD which is defined
101 # to the string returned by "git describe". We need to adjust this string for
102 # every build and correctly rebuild any sources that depend on it. Therefore,
103 # you should use this file rarely as it causes rebuilds on every git-commit.
104 #
105 # We have a helper-script ./src/genversion.sh that takes as argument the header
106 # file and creates it if necessary. It updates it only if the new git-describe
107 # string is different to the old one. So the file is only modified on changes.
108 # Hence, we can use it as normal dependency in this Makefile.
109 # However, we need to run this script on _every_ "make" invocation before any
110 # recipy is executed. To achieve this, we use $(shell ...) and assign it to a
111 # "simply expanded" variable (:=) so the shell command is executed on
112 # variable-declaration and not during expansion.
113 #
114 # Note that we must not clean ./src/githead.h ever! If we would, a distribution
115 # tarball might delete that file and have no way to recreate it.
116 # We could delete it on something like "make maintainerclean", but then again,
117 # it seems unnecessary so lets simply not clean it at all.
118 #
119 # If the helper-script is executed in a directory that is not a git-repository
120 # (like a distribution tarball) and githead.h exists, then it does nothing as it
121 # expects githead.h to be correctly written by "make dist".
122 # However, if githead.h does not exist, it will print a warning and write
123 # "<unknown>" as git-revision.
124 # This guarantees, that githead.h is always present and has the most correct
125 # value that we can get under any conditions.
126 #
127 # The $(emptyvariable) expansion below is used for broken $(shell ...)
128 # syntax-highlighting algorithms in many existing editors.
129 #
130
131 EXTRA_DIST += src/genversion.sh
132 GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/githead.h")
133
134 #
135 # libeloop
136 # This library contains the whole event-loop implementation of kmscon. It is
137 # compiled into a separate object to allow using it in several other programs.
138 #
139
140 if BUILD_ENABLE_ELOOP
141 lib_LTLIBRARIES += libeloop.la
142 include_HEADERS += src/eloop.h
143 pkgconfig_DATA += docs/pc/libeloop.pc
144 endif
145
146 libeloop_la_SOURCES = \
147         $(SHL_DLIST) \
148         $(SHL_LLOG) \
149         $(SHL_HOOK) \
150         src/eloop.h \
151         src/eloop.c
152
153 libeloop_la_CPPFLAGS = \
154         $(AM_CPPFLAGS)
155 libeloop_la_LIBADD =
156 libeloop_la_LDFLAGS = \
157         -version-info 1:0:0
158
159
160 if BUILD_ENABLE_ELOOP_DBUS
161 libeloop_la_SOURCES += \
162         external/dbus-common.h \
163         external/dbus-loop.h \
164         external/dbus-loop.c
165 libeloop_la_CPPFLAGS += \
166         $(DBUS_CFLAGS)
167 libeloop_la_LIBADD += \
168         $(DBUS_LIBS)
169 endif
170
171 #
172 # libtsm
173 # The Terminal-emulator State Machine is a library that implements the whole VTE
174 # layer and everything related to it. It has no external dependencies so it can
175 # be used to implement any kind of terminal emulator or debugger.
176 #
177
178 if BUILD_ENABLE_TSM
179 lib_LTLIBRARIES += \
180         libtsm.la
181 include_HEADERS += \
182         src/tsm_screen.h \
183         src/tsm_unicode.h \
184         src/tsm_vte.h
185 pkgconfig_DATA += \
186         docs/pc/libtsm.pc
187 endif
188
189 libtsm_la_SOURCES = \
190         $(SHL_LLOG) \
191         $(SHL_TIMER) \
192         $(SHL_ARRAY) \
193         $(SHL_HASHTABLE) \
194         src/tsm_screen.h \
195         src/tsm_screen.c \
196         src/tsm_unicode.h \
197         src/tsm_unicode.c \
198         src/tsm_vte.h \
199         src/tsm_vte.c \
200         src/tsm_vte_charsets.c \
201         external/wcwidth.h \
202         external/wcwidth.c
203
204 libtsm_la_CPPFLAGS = \
205         $(AM_CPPFLAGS) \
206         $(XKBCOMMON_CFLAGS)
207 libtsm_la_LDFLAGS = \
208         $(XKBCOMMON_LIBS) \
209         -version-info 1:0:0
210
211 #
212 # libuterm
213 # The uterm library provides helpers to create terminals in user-space. They
214 # are not limited to text-based terminals but rather provide graphics contexts
215 # so arbitrary output can be displayed. Additionally, they provide VT
216 # abstractions and an input layer
217 #
218
219 if BUILD_ENABLE_UTERM
220 lib_LTLIBRARIES += libuterm.la
221 include_HEADERS += src/uterm.h
222 pkgconfig_DATA += docs/pc/libuterm.pc
223 endif
224
225 libuterm_la_SOURCES = \
226         $(SHL_DLIST) \
227         $(SHL_HOOK) \
228         $(SHL_MISC) \
229         src/uterm.h \
230         src/uterm_input.h \
231         src/uterm_video.h \
232         src/uterm_pci.h \
233         src/uterm_systemd.h \
234         src/uterm_video.c \
235         src/uterm_monitor.c \
236         src/uterm_vt.c \
237         src/uterm_input.c \
238         src/uterm_input_uxkb.c
239
240 nodist_libuterm_la_SOURCES =
241
242 libuterm_la_CPPFLAGS = \
243         $(AM_CPPFLAGS) \
244         $(XKBCOMMON_CFLAGS)
245 libuterm_la_LIBADD = \
246         $(XKBCOMMON_LIBS) \
247         libeloop.la
248 libuterm_la_LDFLAGS = \
249         -version-info 1:0:0
250
251 if BUILD_ENABLE_MULTI_SEAT
252 libuterm_la_SOURCES += src/uterm_systemd.c
253 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
254 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
255 endif
256
257 if BUILD_ENABLE_HOTPLUG
258 libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
259 libuterm_la_LIBADD += $(UDEV_LIBS)
260 endif
261
262 if BUILD_ENABLE_PCIACCESS
263 libuterm_la_CPPFLAGS += $(PCIACCESS_CFLAGS)
264 libuterm_la_LIBADD += $(PCIACCESS_LIBS)
265 libuterm_la_SOURCES += src/uterm_pci.c
266 endif
267
268 if BUILD_ENABLE_VIDEO_FBDEV
269 libuterm_la_SOURCES += src/uterm_video_fbdev.c
270 endif
271
272 if BUILD_ENABLE_VIDEO_DUMB
273 libuterm_la_SOURCES += src/uterm_video_dumb.c
274 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
275 libuterm_la_LIBADD += $(DRM_LIBS)
276 endif
277
278 if BUILD_ENABLE_VIDEO_DRM
279 libuterm_la_SOURCES += \
280         src/uterm_video_drm.c \
281         src/static_gl.h \
282         src/static_gl_math.c \
283         src/static_gl_shader.c
284 nodist_libuterm_la_SOURCES += \
285         src/static_shaders.c
286 libuterm_la_CPPFLAGS += \
287         $(DRM_CFLAGS) \
288         $(EGL_CFLAGS) \
289         $(GBM_CFLAGS) \
290         $(GLES2_CFLAGS)
291 libuterm_la_LIBADD += \
292         $(DRM_LIBS) \
293         $(EGL_LIBS) \
294         $(GBM_LIBS) \
295         $(GLES2_LIBS)
296 endif
297
298 #
299 # Shaders
300 # As there is no need to modify shaders at run-time, we statically compile them
301 # into object files. As autotools would ignore them, we need to add them to
302 # EXTRA_DIST.
303 # The program that converts the shaders into C-source files is "genshader". It's
304 # pretty simple and just creates a string with the shader source as content.
305 #
306
307 SHADERS = \
308         $(srcdir)/src/static_fill.vert \
309         $(srcdir)/src/static_fill.frag \
310         $(srcdir)/src/static_blend.vert \
311         $(srcdir)/src/static_blend.frag \
312         $(srcdir)/src/static_blit.vert \
313         $(srcdir)/src/static_blit.frag \
314         $(srcdir)/src/static_gltex.vert \
315         $(srcdir)/src/static_gltex.frag
316
317 EXTRA_DIST += $(SHADERS)
318 CLEANFILES += src/static_shaders.c
319 genshader_SOURCES = src/genshader.c
320
321 src/static_shaders.c: $(SHADERS) genshader$(EXEEXT)
322         $(AM_V_GEN)./genshader$(EXEEXT) src/static_shaders.c $(SHADERS)
323
324 #
325 # Unifont Generator
326 # This generates the unifont sources from raw hex-encoded font data.
327 #
328
329 UNIFONT = src/font_unifont_data.hex
330
331 EXTRA_DIST += $(UNIFONT)
332 CLEANFILES += src/font_unifont_data.c
333 genunifont_SOURCES = src/genunifont.c
334
335 src/font_unifont_data.c: $(UNIFONT) genunifont$(EXEEXT)
336         $(AM_V_GEN)./genunifont$(EXEEXT) src/font_unifont_data.c $(UNIFONT)
337
338 #
339 # Kmscon Modules
340 #
341
342 if BUILD_ENABLE_FONT_UNIFONT
343 module_LTLIBRARIES += mod-unifont.la
344 endif
345
346 mod_unifont_la_SOURCES = \
347         src/kmscon_module_interface.h \
348         src/githead.h \
349         src/font_unifont.c \
350         src/kmscon_mod_unifont.c
351 nodist_mod_unifont_la_SOURCES = \
352         src/font_unifont_data.c
353 mod_unifont_la_LDFLAGS = \
354         -module \
355         -avoid-version
356
357 if BUILD_ENABLE_FONT_FREETYPE2
358 module_LTLIBRARIES += mod-freetype2.la
359 endif
360
361 mod_freetype2_la_SOURCES = \
362         $(SHL_DLIST) \
363         $(SHL_HASHTABLE) \
364         src/kmscon_module_interface.h \
365         src/githead.h \
366         src/font_freetype2.c \
367         src/kmscon_mod_freetype2.c
368 mod_freetype2_la_CPPFLAGS = \
369         $(AM_CPPFLAGS) \
370         $(FREETYPE2_CFLAGS)
371 mod_freetype2_la_LIBADD = \
372         $(FREETYPE2_LIBS) \
373         -lpthread \
374         libtsm.la
375 mod_freetype2_la_LDFLAGS = \
376         -module \
377         -avoid-version
378
379 if BUILD_ENABLE_FONT_PANGO
380 module_LTLIBRARIES += mod-pango.la
381 endif
382
383 mod_pango_la_SOURCES = \
384         $(SHL_DLIST) \
385         $(SHL_HASHTABLE) \
386         src/kmscon_module_interface.h \
387         src/githead.h \
388         src/font_pango.c \
389         src/kmscon_mod_pango.c
390 mod_pango_la_CPPFLAGS = \
391         $(AM_CPPFLAGS) \
392         $(PANGO_CFLAGS)
393 mod_pango_la_LIBADD = \
394         $(PANGO_LIBS) \
395         -lpthread \
396         libtsm.la
397 mod_pango_la_LDFLAGS = \
398         -module \
399         -avoid-version
400
401 if BUILD_ENABLE_RENDERER_BBULK
402 module_LTLIBRARIES += mod-bbulk.la
403 endif
404
405 mod_bbulk_la_SOURCES = \
406         src/kmscon_module_interface.h \
407         src/githead.h \
408         src/text_bbulk.c \
409         src/kmscon_mod_bbulk.c
410 mod_bbulk_la_LDFLAGS = \
411         -module \
412         -avoid-version
413
414 if BUILD_ENABLE_RENDERER_GLTEX
415 module_LTLIBRARIES += mod-gltex.la
416 endif
417
418 mod_gltex_la_SOURCES = \
419         src/kmscon_module_interface.h \
420         src/githead.h \
421         src/text_gltex.c \
422         src/static_gl.h \
423         src/static_gl_math.c \
424         src/static_gl_shader.c \
425         src/kmscon_mod_gltex.c
426 nodist_mod_gltex_la_SOURCES = \
427         src/static_shaders.c
428 mod_gltex_la_CPPFLAGS = \
429         $(AM_CPPFLAGS) \
430         $(GLES2_CFLAGS)
431 mod_gltex_la_LIBADD = \
432         $(GLES2_LIBS)
433 mod_gltex_la_LDFLAGS = \
434         -module \
435         -avoid-version
436
437 #
438 # Binaries
439 # These are the sources for the main binaries and test programs. They mostly
440 # consists of a single source file only and include all the libraries that are
441 # built as part of kmscon.
442 #
443
444 if BUILD_ENABLE_KMSCON
445 bin_PROGRAMS += kmscon
446 check_PROGRAMS += \
447         test_output \
448         test_vt \
449         test_input \
450         test_key
451 MANPAGES += docs/man/kmscon.1
452 endif
453
454 kmscon_SOURCES = \
455         $(SHL_DLIST) \
456         $(SHL_MISC) \
457         $(SHL_ARRAY) \
458         $(SHL_HASHTABLE) \
459         $(SHL_RING) \
460         $(SHL_TIMER) \
461         $(SHL_HOOK) \
462         $(SHL_REGISTER) \
463         src/githead.h \
464         src/conf.h \
465         src/conf.c \
466         src/log.h \
467         src/log.c \
468         src/pty.h \
469         src/pty.c \
470         src/font.h \
471         src/font.c \
472         src/font_8x16.c \
473         src/text.h \
474         src/text.c \
475         src/text_bblit.c \
476         src/kmscon_module_interface.h \
477         src/kmscon_module.h \
478         src/kmscon_module.c \
479         src/kmscon_terminal.h \
480         src/kmscon_dummy.h \
481         src/kmscon_cdev.h \
482         src/kmscon_seat.h \
483         src/kmscon_seat.c \
484         src/kmscon_conf.h \
485         src/kmscon_conf.c \
486         src/kmscon_main.c
487 nodist_kmscon_SOURCES =
488
489 kmscon_CPPFLAGS = \
490         $(AM_CPPFLAGS) \
491         $(XKBCOMMON_CFLAGS)
492 kmscon_LDADD = \
493         $(XKBCOMMON_LIBS) \
494         libeloop.la \
495         libuterm.la \
496         libfont.la \
497         -lpthread
498 kmscon_LDFLAGS = \
499         -rdynamic
500
501 if BUILD_ENABLE_SESSION_DUMMY
502 kmscon_SOURCES += src/kmscon_dummy.c
503 endif
504
505 if BUILD_ENABLE_SESSION_TERMINAL
506 kmscon_SOURCES += src/kmscon_terminal.c
507 kmscon_LDADD += libtsm.la
508 endif
509
510 if BUILD_ENABLE_SESSION_CDEV
511 kmscon_SOURCES += src/kmscon_cdev.c
512 kmscon_CPPFLAGS += $(FUSE_CFLAGS)
513 kmscon_LDADD += $(FUSE_LIBS)
514 endif
515
516 #
517 # Wayland Terminal
518 #
519
520 if BUILD_ENABLE_WLTERM
521 bin_PROGRAMS += wlterm
522 endif
523
524 wlterm_SOURCES = \
525         $(SHL_MISC) \
526         $(SHL_ARRAY) \
527         $(SHL_DLIST) \
528         $(SHL_HOOK) \
529         src/wlt_main.h \
530         src/wlt_main.c \
531         src/wlt_toolkit.h \
532         src/wlt_toolkit.c \
533         src/wlt_theme.h \
534         src/wlt_theme.c \
535         src/wlt_terminal.h \
536         src/wlt_terminal.c \
537         src/log.h \
538         src/log.c \
539         src/conf.h \
540         src/conf.c \
541         src/pty.h \
542         src/pty.c
543 wlterm_CPPFLAGS = \
544         $(AM_CPPFLAGS) \
545         $(WAYLAND_CFLAGS) \
546         $(XKBCOMMON_CFLAGS)
547 wlterm_LDADD = \
548         $(WAYLAND_LIBS) \
549         $(XKBCOMMON_LIBS) \
550         libeloop.la \
551         libtsm.la \
552         -lpthread
553
554 #
555 # Tests
556 #
557
558 test_sources = \
559         src/log.h \
560         src/log.c \
561         src/conf.h \
562         src/conf.c \
563         tests/test_include.h
564 test_cflags = \
565         $(XKBCOMMON_CFLAGS)
566 test_libs = \
567         $(XKBCOMMON_LIBS) \
568         libeloop.la
569
570 test_output_SOURCES = \
571         $(test_sources) \
572         tests/test_output.c
573 test_output_CPPFLAGS = \
574         $(AM_CPPFLAGS) \
575         $(test_cflags)
576 test_output_LDADD = \
577         $(test_libs) \
578         libuterm.la
579
580 test_vt_SOURCES = \
581         $(test_sources) \
582         tests/test_vt.c
583 test_vt_CPPFLAGS = \
584         $(AM_CPPFLAGS) \
585         $(test_cflags)
586 test_vt_LDADD = \
587         $(test_libs) \
588         libuterm.la
589
590 test_input_SOURCES = \
591         $(test_sources) \
592         tests/test_input.c
593 test_input_CPPFLAGS = \
594         $(AM_CPPFLAGS) \
595         $(test_cflags)
596 test_input_LDADD = \
597         $(test_libs) \
598         libuterm.la
599
600 test_key_SOURCES = \
601         $(test_sources) \
602         tests/test_key.c
603 test_key_CPPFLAGS = \
604         $(AM_CPPFLAGS) \
605         $(test_cflags)
606 test_key_LDADD = \
607         $(test_libs)
608
609 #
610 # Manpages
611 #
612
613 man_MANS =
614 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
615 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
616
617 if BUILD_HAVE_XSLTPROC
618 if BUILD_HAVE_MANPAGES_STYLESHEET
619
620 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
621
622 XSLTPROC_FLAGS = \
623         --stringparam man.authors.section.enabled 0 \
624         --stringparam man.copyright.section.enabled 0 \
625         --stringparam funcsynopsis.style ansi \
626         --stringparam man.output.quietly 1 \
627         --nonet
628
629 XSLTPROC_PROCESS_MAN = \
630         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
631         $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
632         touch .man_fixup
633
634 # Force .man_fixup if $(MANPAGES) are not built
635 .man_fixup: | $(MANPAGES)
636         @touch .man_fixup
637
638 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
639         $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
640
641 docs/man/%.1: docs/man/%.xml
642         $(XSLTPROC_PROCESS_MAN)
643
644 docs/man/%.3: docs/man/%.xml
645         $(XSLTPROC_PROCESS_MAN)
646
647 docs/man/%.5: docs/man/%.xml
648         $(XSLTPROC_PROCESS_MAN)
649
650 docs/man/%.7: docs/man/%.xml
651         $(XSLTPROC_PROCESS_MAN)
652
653 endif # BUILD_HAVE_MANPAGES_STYLESHEET
654 endif # BUILD_HAVE_XSLTPROC
655
656 #
657 # Phony targets
658 #
659
660 .PHONY: $(TPHONY)