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