shl: move static_gl_* to shl_gl_*
[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 # SHL - Static Helper Library
149 # The SHL subsystem contains several small code pieces used all over kmscon and
150 # other applications.
151 #
152
153 noinst_LTLIBRARIES += libshl.la
154
155 libshl_la_SOURCES = \
156         src/shl_githead.h \
157         src/shl_githead.c \
158         src/shl_dlist.h \
159         src/shl_array.h \
160         src/shl_hashtable.h \
161         external/htable.h \
162         external/htable.c \
163         src/shl_ring.h \
164         src/shl_timer.h \
165         src/shl_llog.h \
166         src/shl_log.h \
167         src/shl_log.c \
168         src/shl_hook.h \
169         src/shl_misc.h \
170         src/shl_register.h \
171         src/shl_flagset.h \
172         src/shl_gl.h \
173         src/shl_gl_math.c
174 libshl_la_CPPFLAGS = \
175         $(AM_CPPFLAGS) \
176         $(XKBCOMMON_CFLAGS) \
177         -pthread
178 libshl_la_LDFLAGS = \
179         $(AM_LDFLAGS) \
180         -pthread
181 libshl_la_LIBADD = \
182         $(AM_LIBADD) \
183         $(XKBCOMMON_LIBS)
184
185 if BUILD_HAVE_GLES2
186 libshl_la_SOURCES += src/shl_gl_shader.c
187 libshl_la_CPPFLAGS += $(GLES2_CFLAGS)
188 libshl_la_LIBADD += $(GLES2_LIBS)
189 endif
190
191 #
192 # libeloop
193 # This library contains the whole event-loop implementation of kmscon. It is
194 # compiled into a separate object to allow using it in several other programs.
195 #
196
197 noinst_LTLIBRARIES += libeloop.la
198
199 libeloop_la_SOURCES = \
200         src/eloop.h \
201         src/eloop.c
202
203 libeloop_la_LIBADD = libshl.la
204 libeloop_la_CPPFLAGS = $(AM_CPPFLAGS)
205 libeloop_la_LDFLAGS = $(AM_LDFLAGS)
206
207 #
208 # libuterm
209 # The uterm library provides helpers to create terminals in user-space. They
210 # are not limited to text-based terminals but rather provide graphics contexts
211 # so arbitrary output can be displayed. Additionally, they provide VT
212 # abstractions and an input layer
213 #
214
215 noinst_LTLIBRARIES += libuterm.la
216
217 libuterm_la_SOURCES = \
218         src/uterm_input.h \
219         src/uterm_monitor.h \
220         src/uterm_video.h \
221         src/uterm_vt.h \
222         src/uterm_input_internal.h \
223         src/uterm_video_internal.h \
224         src/uterm_systemd_internal.h \
225         src/uterm_video.c \
226         src/uterm_monitor.c \
227         src/uterm_vt.c \
228         src/uterm_input.c \
229         src/uterm_input_uxkb.c
230
231 nodist_libuterm_la_SOURCES =
232
233 libuterm_la_CPPFLAGS = \
234         $(AM_CPPFLAGS) \
235         $(UDEV_CFLAGS) \
236         $(XKBCOMMON_CFLAGS)
237 libuterm_la_LIBADD = \
238         $(UDEV_LIBS) \
239         $(XKBCOMMON_LIBS) \
240         libeloop.la \
241         libshl.la
242 libuterm_la_LDFLAGS = \
243         $(AM_LDFLAGS)
244
245 if BUILD_ENABLE_MULTI_SEAT
246 libuterm_la_SOURCES += src/uterm_systemd.c
247 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
248 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
249 endif
250
251 if BUILD_ENABLE_VIDEO_FBDEV
252 libuterm_la_SOURCES += \
253         src/uterm_fbdev_internal.h \
254         src/uterm_fbdev_video.c \
255         src/uterm_fbdev_render.c
256 endif
257
258 if BUILD_ENABLE_VIDEO_DRM2D
259 libuterm_la_SOURCES += \
260         src/uterm_drm2d_internal.h \
261         src/uterm_drm2d_video.c \
262         src/uterm_drm2d_render.c
263 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
264 libuterm_la_LIBADD += $(DRM_LIBS)
265 endif
266
267 if BUILD_ENABLE_VIDEO_DRM3D
268 noinst_PROGRAMS += genshader
269 libuterm_la_SOURCES += \
270         src/uterm_drm3d_internal.h \
271         src/uterm_drm3d_video.c \
272         src/uterm_drm3d_render.c
273 nodist_libuterm_la_SOURCES += src/static_shaders.c
274 libuterm_la_CPPFLAGS += \
275         $(DRM_CFLAGS) \
276         $(EGL_CFLAGS) \
277         $(GBM_CFLAGS) \
278         $(GLES2_CFLAGS)
279 libuterm_la_LIBADD += \
280         $(DRM_LIBS) \
281         $(EGL_LIBS) \
282         $(GBM_LIBS) \
283         $(GLES2_LIBS)
284 endif
285
286 # add shared sources only once
287 UTERM_DRM_SHARED_SRC = \
288         src/uterm_drm_shared_internal.h \
289         src/uterm_drm_shared.c
290 if BUILD_ENABLE_VIDEO_DRM2D
291 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
292 else
293 if BUILD_ENABLE_VIDEO_DRM3D
294 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
295 endif
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 # TODO: Using $(BUILD_EXEEXT) breaks if it doesn't equal $(EXEEXT). But stupid
322 # automake doesn't allow $(EXEEXT) so lets just rely on both being the same.
323
324 src/static_shaders.c: $(SHADERS) genshader$(BUILD_EXEEXT)
325         $(AM_V_GEN)./genshader$(BUILD_EXEEXT) src/static_shaders.c $(SHADERS)
326
327 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CC = $(CC_FOR_BUILD)
328 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
329 genshader$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
330
331 #
332 # Unifont Generator
333 # This generates the unifont sources from raw hex-encoded font data.
334 #
335
336 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
337 UNIFONT_BIN = src/font_unifont_data.bin
338 UNIFONT_LT = src/font_unifont_data.bin.lo
339
340 EXTRA_DIST += $(UNIFONT)
341 CLEANFILES += $(UNIFONT_BIN)
342 genunifont_SOURCES = src/genunifont.c
343
344 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CC = $(CC_FOR_BUILD)
345 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
346 genunifont$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
347
348 $(UNIFONT_BIN): $(UNIFONT) genunifont$(BUILD_EXEEXT)
349         $(AM_V_GEN)./genunifont$(BUILD_EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
350
351 #
352 # Kmscon Modules
353 #
354
355 if BUILD_ENABLE_FONT_UNIFONT
356 module_LTLIBRARIES += mod-unifont.la
357 noinst_PROGRAMS += genunifont
358 endif
359
360 mod_unifont_la_SOURCES = \
361         src/kmscon_module_interface.h \
362         src/font_unifont.c \
363         src/kmscon_mod_unifont.c
364 mod_unifont_la_LIBADD = \
365         $(UNIFONT_LT) \
366         libshl.la
367 mod_unifont_la_LDFLAGS = \
368         $(AM_LDFLAGS) \
369         -module \
370         -avoid-version
371
372 if BUILD_ENABLE_FONT_PANGO
373 module_LTLIBRARIES += mod-pango.la
374 endif
375
376 mod_pango_la_SOURCES = \
377         src/kmscon_module_interface.h \
378         src/font_pango.c \
379         src/kmscon_mod_pango.c
380 mod_pango_la_CPPFLAGS = \
381         $(AM_CPPFLAGS) \
382         $(PANGO_CFLAGS) \
383         $(TSM_CFLAGS)
384 mod_pango_la_LIBADD = \
385         $(PANGO_LIBS) \
386         $(TSM_LIBS) \
387         -lpthread \
388         libshl.la
389 mod_pango_la_LDFLAGS = \
390         $(AM_LDFLAGS) \
391         -module \
392         -avoid-version
393
394 if BUILD_ENABLE_RENDERER_BBULK
395 module_LTLIBRARIES += mod-bbulk.la
396 endif
397
398 mod_bbulk_la_SOURCES = \
399         src/kmscon_module_interface.h \
400         src/text_bbulk.c \
401         src/kmscon_mod_bbulk.c
402 mod_bbulk_la_LIBADD = libshl.la
403 mod_bbulk_la_LDFLAGS = \
404         $(AM_LDFLAGS) \
405         -module \
406         -avoid-version
407
408 if BUILD_ENABLE_RENDERER_GLTEX
409 module_LTLIBRARIES += mod-gltex.la
410 noinst_PROGRAMS += genshader
411 endif
412
413 mod_gltex_la_SOURCES = \
414         src/kmscon_module_interface.h \
415         src/text_gltex.c \
416         src/kmscon_mod_gltex.c
417 nodist_mod_gltex_la_SOURCES = \
418         src/static_shaders.c
419 mod_gltex_la_CPPFLAGS = \
420         $(AM_CPPFLAGS) \
421         $(GLES2_CFLAGS)
422 mod_gltex_la_LIBADD = \
423         $(GLES2_LIBS) \
424         libshl.la
425 mod_gltex_la_LDFLAGS = \
426         $(AM_LDFLAGS) \
427         -module \
428         -avoid-version
429
430 if BUILD_ENABLE_RENDERER_PIXMAN
431 module_LTLIBRARIES += mod-pixman.la
432 endif
433
434 mod_pixman_la_SOURCES = \
435         src/kmscon_module_interface.h \
436         src/text_pixman.c \
437         src/kmscon_mod_pixman.c
438 mod_pixman_la_CPPFLAGS = \
439         $(AM_CPPFLAGS) \
440         $(PIXMAN_CFLAGS)
441 mod_pixman_la_LIBADD = \
442         $(PIXMAN_LIBS) \
443         libshl.la
444 mod_pixman_la_LDFLAGS = \
445         $(AM_LDFLAGS) \
446         -module \
447         -avoid-version
448
449 #
450 # Binaries
451 # These are the sources for the main binaries and test programs. They mostly
452 # consists of a single source file only and include all the libraries that are
453 # built as part of kmscon.
454 #
455
456 bin_PROGRAMS += kmscon
457 check_PROGRAMS += \
458         test_output \
459         test_vt \
460         test_input \
461         test_key
462 MANPAGES += docs/man/kmscon.1
463
464 kmscon_SOURCES = \
465         src/conf.h \
466         src/conf.c \
467         src/pty.h \
468         src/pty.c \
469         src/font.h \
470         src/font.c \
471         src/font_8x16.c \
472         src/text.h \
473         src/text.c \
474         src/text_bblit.c \
475         src/kmscon_module_interface.h \
476         src/kmscon_module.h \
477         src/kmscon_module.c \
478         src/kmscon_terminal.h \
479         src/kmscon_dummy.h \
480         src/kmscon_seat.h \
481         src/kmscon_seat.c \
482         src/kmscon_conf.h \
483         src/kmscon_conf.c \
484         src/kmscon_main.c
485 nodist_kmscon_SOURCES =
486
487 kmscon_CPPFLAGS = \
488         $(AM_CPPFLAGS) \
489         $(XKBCOMMON_CFLAGS) \
490         $(TSM_CFLAGS)
491 kmscon_LDADD = \
492         $(XKBCOMMON_LIBS) \
493         $(TSM_LIBS) \
494         libeloop.la \
495         libuterm.la \
496         libshl.la \
497         -lpthread \
498         -ldl
499 kmscon_LDFLAGS = \
500         $(AM_LDFLAGS) \
501         -rdynamic
502
503 if BUILD_ENABLE_SESSION_DUMMY
504 kmscon_SOURCES += src/kmscon_dummy.c
505 endif
506
507 if BUILD_ENABLE_SESSION_TERMINAL
508 kmscon_SOURCES += src/kmscon_terminal.c
509 endif
510
511 #
512 # Tests
513 #
514
515 test_sources = \
516         src/conf.h \
517         src/conf.c \
518         tests/test_include.h
519 test_cflags = \
520         $(AM_CPPFLAGS) \
521         $(XKBCOMMON_CFLAGS)
522 test_libs = \
523         $(XKBCOMMON_LIBS) \
524         libeloop.la \
525         libshl.la
526
527 test_output_SOURCES = \
528         $(test_sources) \
529         tests/test_output.c
530 test_output_CPPFLAGS = $(test_cflags)
531 test_output_LDADD = \
532         $(test_libs) \
533         libuterm.la
534
535 test_vt_SOURCES = \
536         $(test_sources) \
537         tests/test_vt.c
538 test_vt_CPPFLAGS = $(test_cflags)
539 test_vt_LDADD = \
540         $(test_libs) \
541         libuterm.la
542
543 test_input_SOURCES = \
544         $(test_sources) \
545         tests/test_input.c
546 test_input_CPPFLAGS = $(test_cflags)
547 test_input_LDADD = \
548         $(test_libs) \
549         libuterm.la
550
551 test_key_SOURCES = \
552         $(test_sources) \
553         tests/test_key.c
554 test_key_CPPFLAGS = $(test_cflags)
555 test_key_LDADD = $(test_libs)
556
557 #
558 # Manpages
559 #
560
561 man_MANS =
562 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
563 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
564
565 if BUILD_HAVE_XSLTPROC
566 if BUILD_HAVE_MANPAGES_STYLESHEET
567
568 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
569
570 XSLTPROC_FLAGS = \
571         --stringparam man.authors.section.enabled 0 \
572         --stringparam man.copyright.section.enabled 0 \
573         --stringparam funcsynopsis.style ansi \
574         --stringparam man.output.quietly 1 \
575         --nonet
576
577 XSLTPROC_PROCESS_MAN = \
578         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
579         $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
580         touch .man_fixup
581
582 # Force .man_fixup if $(MANPAGES) are not built
583 .man_fixup: | $(MANPAGES)
584         @touch .man_fixup
585
586 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
587         $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
588
589 docs/man/%.1: docs/man/%.xml
590         $(XSLTPROC_PROCESS_MAN)
591
592 docs/man/%.3: docs/man/%.xml
593         $(XSLTPROC_PROCESS_MAN)
594
595 docs/man/%.5: docs/man/%.xml
596         $(XSLTPROC_PROCESS_MAN)
597
598 docs/man/%.7: docs/man/%.xml
599         $(XSLTPROC_PROCESS_MAN)
600
601 endif # BUILD_HAVE_MANPAGES_STYLESHEET
602 endif # BUILD_HAVE_XSLTPROC
603
604 #
605 # Phony targets
606 #
607
608 .PHONY: $(TPHONY)