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