chiark / gitweb /
Prep v234.2: Apply upstream fixes in tools (6/6)
[elogind.git] / Makefile.am
1 #  -*- Mode: makefile; indent-tabs-mode: t -*-
2 #
3 #  This file is part of elogind.
4 #
5 #  Copyright 2010-2012 Lennart Poettering
6 #  Copyright 2010-2012 Kay Sievers
7 #  Copyright 2013 Zbigniew Jędrzejewski-Szmek
8 #  Copyright 2013 David Strauss
9 #
10 #  elogind is free software; you can redistribute it and/or modify it
11 #  under the terms of the GNU Lesser General Public License as published by
12 #  the Free Software Foundation; either version 2.1 of the License, or
13 #  (at your option) any later version.
14 #
15 #  elogind is distributed in the hope that it will be useful, but
16 #  WITHOUT ANY WARRANTY; without even the implied warranty of
17 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 #  Lesser General Public License for more details.
19 #
20 #  You should have received a copy of the GNU Lesser General Public License
21 #  along with elogind; If not, see <http://www.gnu.org/licenses/>.
22
23 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
24 AM_MAKEFLAGS = --no-print-directory
25 AUTOMAKE_OPTIONS = color-tests parallel-tests
26
27 GCC_COLORS ?= 'ooh, shiny!'
28 export GCC_COLORS
29
30 SUBDIRS = . po
31
32 # remove targets if the command fails
33 .DELETE_ON_ERROR:
34
35 # keep intermediate files
36 .SECONDARY:
37
38 # Keep the test-suite.log
39 .PRECIOUS: $(TEST_SUITE_LOG) Makefile
40
41 LIBELOGIND_CURRENT=19
42 LIBELOGIND_REVISION=1
43 LIBELOGIND_AGE=19
44
45 # Dirs of external packages
46 dbuspolicydir=@dbuspolicydir@
47 dbussystemservicedir=@dbussystemservicedir@
48 pamlibdir=@pamlibdir@
49 pamconfdir=@pamconfdir@
50 pkgconfigdatadir=$(datadir)/pkgconfig
51 pkgconfiglibdir=$(libdir)/pkgconfig
52 polkitpolicydir=$(datadir)/polkit-1/actions
53 polkitrulesdir=$(datadir)/polkit-1/rules.d
54 polkitpkladir=$(localstatedir)/lib/polkit-1/localauthority/10-vendor.d
55 bashcompletiondir=@bashcompletiondir@
56 zshcompletiondir=@zshcompletiondir@
57
58 CGROUP_CONTROLLER=@cgroup_controller@
59 PKTTYAGENT=$(bindir)/pkttyagent
60
61 # Our own, non-special dirs
62 pkgsysconfdir=$(sysconfdir)/elogind
63 pkgincludedir=$(includedir)/elogind/systemd
64 udevrulesdir=@udevrulesdir@
65 udevbindir=@udevbindir@
66 udevlibexecdir=$(udevbindir)
67 udevhomedir=$(udevlibexecdir)
68 factory_pamdir = $(datadir)/factory/etc/pam.d
69
70 # And these are the special ones for /
71
72 rootprefix=@rootprefix@
73 rootbindir=$(rootprefix)/bin
74 rootlibdir=@rootlibdir@
75 rootlibexecdir=@rootlibexecdir@
76 systemshutdowndir=$(rootlibexecdir)/system-shutdown
77 systemsleepdir=$(rootlibexecdir)/system-sleep
78
79 EXTRA_DIST =
80 BUILT_SOURCES =
81 INSTALL_EXEC_HOOKS =
82 UNINSTALL_EXEC_HOOKS =
83 DISTCLEAN_LOCAL_HOOKS =
84 CLEAN_LOCAL_HOOKS =
85 pkginclude_HEADERS =
86 noinst_LTLIBRARIES =
87 lib_LTLIBRARIES =
88 noinst_DATA =
89 pkgconfiglib_DATA =
90 polkitpolicy_in_files =
91 polkitpolicy_files =
92 polkitrules_files =
93 polkitpkla_files =
94 dist_udevrules_DATA =
95 nodist_udevrules_DATA =
96 dist_pkgsysconf_DATA =
97 nodist_pkgsysconf_DATA =
98 dist_dbuspolicy_DATA =
99 dist_dbussystemservice_DATA =
100 check_PROGRAMS =
101 check_DATA =
102 dist_rootlibexec_DATA =
103 rootlib_LTLIBRARIES =
104 tests=
105 manual_tests =
106 TEST_DATA_FILES =
107 if ENABLE_TESTS
108 noinst_PROGRAMS = $(manual_tests) $(tests) $(unsafe_tests)
109 TESTS = $(tests)
110 if ENABLE_UNSAFE_TESTS
111 TESTS += \
112         $(unsafe_tests)
113 endif
114 else
115 noinst_PROGRAMS =
116 TESTS =
117 endif
118
119 if ENABLE_BASH_COMPLETION
120 dist_bashcompletion_DATA = $(dist_bashcompletion_data)
121 endif
122 if ENABLE_ZSH_COMPLETION
123 dist_zshcompletion_DATA = $(dist_zshcompletion_data)
124 endif
125
126 in_files = $(filter %.in,$(EXTRA_DIST))
127 in_in_files = $(filter %.in.in, $(in_files))
128 m4_files = $(filter %.m4,$(EXTRA_DIST) $(in_files:.m4.in=.m4))
129
130 CLEANFILES = $(BUILT_SOURCES) \
131         $(pkgconfiglib_DATA) \
132         $(in_files:.in=) $(in_in_files:.in.in=) \
133         $(m4_files:.m4=)
134
135 .PHONY: $(INSTALL_EXEC_HOOKS) $(UNINSTALL_EXEC_HOOKS) \
136         $(DISTCLEAN_LOCAL_HOOKS) $(CLEAN_LOCAL_HOOKS)
137
138 AM_CPPFLAGS = \
139         -include $(top_builddir)/config.h \
140         -DPKGSYSCONFDIR=\"$(pkgsysconfdir)\" \
141         -DSYSTEMD_CGROUP_CONTROLLER=\"_$(CGROUP_CONTROLLER)\" \
142         -DSYSTEMD_CGROUP_CONTROLLER_LEGACY=\"name=$(CGROUP_CONTROLLER)\" \
143         -DSYSTEMD_CGROUP_CONTROLLER_HYBRID=\"name=$(CGROUP_CONTROLLER)\" \
144         -DSYSTEMD_CGROUP_AGENT_PATH=\"$(rootlibexecdir)/elogind-cgroups-agent\" \
145         -DSYSTEMD_BINARY_PATH=\"$(rootlibexecdir)/elogind\" \
146         -DUDEVLIBEXECDIR=\"$(udevlibexecdir)\" \
147         -DPOLKIT_AGENT_BINARY_PATH=\"$(PKTTYAGENT)\" \
148         -DSYSTEM_SLEEP_PATH=\"$(systemsleepdir)\" \
149         -DSYSTEM_SHUTDOWN_PATH=\"$(systemshutdowndir)\" \
150         -DHALT=\"$(HALT)\" \
151         -DREBOOT=\"$(REBOOT)\" \
152         -DKEXEC=\"$(KEXEC)\" \
153         -DLIBDIR=\"$(libdir)\" \
154         -DROOTLIBDIR=\"$(rootlibdir)\" \
155         -DROOTLIBEXECDIR=\"$(rootlibexecdir)\" \
156         -DTEST_DIR=\"$(abs_top_srcdir)/test\" \
157         -I $(top_srcdir)/src \
158         -I $(top_builddir)/src/basic \
159         -I $(top_srcdir)/src/basic \
160         -I $(top_srcdir)/src/core \
161         -I $(top_srcdir)/src/shared \
162         -I $(top_builddir)/src/shared \
163         -I $(top_srcdir)/src/login \
164         -I $(top_srcdir)/src/systemd \
165         -I $(top_srcdir)/src/libelogind/sd-bus \
166         -I $(top_srcdir)/src/libelogind/sd-event \
167         -I $(top_srcdir)/src/libelogind/sd-login \
168         -I $(top_srcdir)/src/libelogind/sd-id128 \
169         -I $(top_srcdir)/src/update-utmp \
170         -I $(top_srcdir)/src/sleep \
171         -DABS_SRC_DIR=\"$(abs_top_srcdir)\" \
172         -DABS_BUILD_DIR=\"$(abs_top_builddir)\" \
173         $(OUR_CPPFLAGS)
174
175 AM_CFLAGS = $(OUR_CFLAGS)
176 AM_LDFLAGS = $(OUR_LDFLAGS)
177
178 # ------------------------------------------------------------------------------
179 install-touch-usr-hook:
180         touch -c $(DESTDIR)/$(prefix)
181
182 INSTALL_EXEC_HOOKS += \
183         install-touch-usr-hook
184
185
186 # ------------------------------------------------------------------------------
187 AM_V_M4 = $(AM_V_M4_$(V))
188 AM_V_M4_ = $(AM_V_M4_$(AM_DEFAULT_VERBOSITY))
189 AM_V_M4_0 = @echo "  M4      " $@;
190
191 AM_V_XSLT = $(AM_V_XSLT_$(V))
192 AM_V_XSLT_ = $(AM_V_XSLT_$(AM_DEFAULT_VERBOSITY))
193 AM_V_XSLT_0 = @echo "  XSLT    " $@;
194
195 AM_V_GPERF = $(AM_V_GPERF_$(V))
196 AM_V_GPERF_ = $(AM_V_GPERF_$(AM_DEFAULT_VERBOSITY))
197 AM_V_GPERF_0 = @echo "  GPERF   " $@;
198
199 AM_V_LN = $(AM_V_LN_$(V))
200 AM_V_LN_ = $(AM_V_LN_$(AM_DEFAULT_VERBOSITY))
201 AM_V_LN_0 = @echo "  LN      " $@;
202
203 AM_V_RM = $(AM_V_RM_$(V))
204 AM_V_RM_ = $(AM_V_RM_$(AM_DEFAULT_VERBOSITY))
205 AM_V_RM_0 = @echo "  RM      " $@;
206
207 # ------------------------------------------------------------------------------
208 rootbin_PROGRAMS =
209 rootlibexec_PROGRAMS =
210
211 dist_doc_DATA = \
212         README \
213         NEWS \
214         LICENSE.LGPL2.1 \
215         LICENSE.GPL2
216
217 @INTLTOOL_POLICY_RULE@
218
219 # ------------------------------------------------------------------------------
220
221 MANPAGES =
222 MANPAGES_ALIAS =
223
224 include Makefile-man.am
225
226 .PHONY: man update-man-list
227 man: $(MANPAGES) $(MANPAGES_ALIAS) $(HTML_FILES) $(HTML_ALIAS)
228
229 XML_FILES = \
230         ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,${patsubst %.8,%.xml,$(MANPAGES)}}}}}
231 HTML_FILES = \
232         ${XML_FILES:.xml=.html}
233 HTML_ALIAS = \
234         ${patsubst %.1,%.html,${patsubst %.3,%.html,${patsubst %.5,%.html,${patsubst %.7,%.html,${patsubst %.8,%.html,$(MANPAGES_ALIAS)}}}}}
235
236 if ENABLE_MANPAGES
237 man_MANS = \
238         $(MANPAGES) \
239         $(MANPAGES_ALIAS)
240
241 noinst_DATA += \
242         $(HTML_FILES) \
243         $(HTML_ALIAS) \
244         docs/html/man
245 endif
246
247 CLEANFILES += \
248         $(man_MANS) \
249         $(HTML_FILES) \
250         $(HTML_ALIAS) \
251         docs/html/man
252
253 docs/html/man:
254         $(AM_V_at)$(MKDIR_P) $(dir $@)
255         $(AM_V_LN)$(LN_S) -f ../../man $@
256
257 man/index.html: man/elogind.index.html
258         $(AM_V_LN)$(LN_S) -f elogind.index.html $@
259
260 if HAVE_PYTHON
261 if ENABLE_MANPAGES
262 noinst_DATA += \
263        man/index.html
264 endif
265 endif
266
267 CLEANFILES += \
268        man/index.html
269
270 XML_GLOB            := $(wildcard $(top_srcdir)/man/*.xml)
271 DIRECTIVE_FILE      := man/elogind.directives.xml
272 INDEX_XML_FILE      := man/elogind.index.xml
273 NON_INDEX_XML_FILES := $(DIRECTIVE_FILE) $(filter-out $(INDEX_XML_FILE) $(DIRECTIVE_FILE),$(XML_FILES))
274 ALL_XML_FILES       := $(INDEX_XML_FILE) $(DIRECTIVE_FILE) $(filter-out $(INDEX_XML_FILE) $(DIRECTIVE_FILE),$(XML_GLOB))
275 SOURCE_XML_FILES    := ${patsubst %,$(top_srcdir)/%,$(filter-out $(DIRECTIVE_FILE),$(NON_INDEX_XML_FILES))}
276
277 # This target should only be run manually. It recreates Makefile-man.am
278 # file in the source directory based on all man/*.xml files. Run it after
279 # adding, removing, or changing the conditional in a man page.
280 update-man-list: $(top_srcdir)/tools/make-man-rules.py $(ALL_XML_FILES) man/custom-entities.ent
281         $(AM_V_GEN)$(PYTHON) $< $(ALL_XML_FILES) > $(top_srcdir)/Makefile-man.tmp
282         $(AM_V_at)mv $(top_srcdir)/Makefile-man.tmp $(top_srcdir)/Makefile-man.am
283         @echo "Makefile-man.am has been regenerated"
284
285 $(INDEX_XML_FILE): $(top_srcdir)/tools/make-man-index.py $(NON_INDEX_XML_FILES)
286         $(AM_V_at)$(MKDIR_P) $(dir $@)
287         $(AM_V_GEN)$(PYTHON) $< $@ $(filter-out $<,$^)
288
289 $(DIRECTIVE_FILE): $(top_srcdir)/tools/make-directive-index.py man/custom-entities.ent $(SOURCE_XML_FILES)
290         $(AM_V_at)$(MKDIR_P) $(dir $@)
291         $(AM_V_GEN)$(PYTHON) $< $@ $(SOURCE_XML_FILES)
292
293 CLEANFILES += \
294        $(INDEX_XML_FILE) \
295        $(DIRECTIVE_FILE)
296
297 EXTRA_DIST += \
298         $(filter-out $(DIRECTIVE_FILE) $(INDEX_XML_FILE),$(XML_FILES)) \
299         tools/make-man-index.py \
300         tools/make-man-rules.py \
301         tools/make-directive-index.py \
302         tools/xml_helper.py \
303         man/glib-event-glue.c
304
305 # ------------------------------------------------------------------------------
306 noinst_LTLIBRARIES += \
307         libbasic.la
308
309 libbasic_la_SOURCES = \
310         src/basic/missing.h \
311         src/basic/capability-util.c \
312         src/basic/capability-util.h \
313         src/basic/conf-files.c \
314         src/basic/conf-files.h \
315         src/basic/stdio-util.h \
316         src/basic/hostname-util.h \
317         src/basic/hostname-util.c \
318         src/basic/unit-name.c \
319         src/basic/unit-name.h \
320         src/basic/unaligned.h \
321         src/basic/util.c \
322         src/basic/util.h \
323         src/basic/io-util.c \
324         src/basic/io-util.h \
325         src/basic/string-util.c \
326         src/basic/string-util.h \
327         src/basic/parse-util.c \
328         src/basic/parse-util.h \
329         src/basic/fd-util.c \
330         src/basic/fd-util.h \
331         src/basic/user-util.c \
332         src/basic/user-util.h \
333         src/basic/dirent-util.c \
334         src/basic/dirent-util.h \
335         src/basic/xattr-util.c \
336         src/basic/xattr-util.h \
337         src/basic/proc-cmdline.c \
338         src/basic/proc-cmdline.h \
339         src/basic/fs-util.c \
340         src/basic/fs-util.h \
341         src/basic/syslog-util.c \
342         src/basic/syslog-util.h \
343         src/basic/stat-util.c \
344         src/basic/stat-util.h \
345         src/basic/mount-util.c \
346         src/basic/mount-util.h \
347         src/basic/hexdecoct.c \
348         src/basic/hexdecoct.h \
349         src/basic/extract-word.c \
350         src/basic/extract-word.h \
351         src/basic/escape.c \
352         src/basic/escape.h \
353         src/basic/path-util.c \
354         src/basic/path-util.h \
355         src/basic/parse-printf-format.c \
356         src/basic/parse-printf-format.h \
357         src/basic/time-util.c \
358         src/basic/time-util.h \
359         src/basic/locale-util.c \
360         src/basic/locale-util.h \
361         src/basic/umask-util.h \
362         src/basic/signal-util.c \
363         src/basic/signal-util.h \
364         src/basic/string-table.c \
365         src/basic/string-table.h \
366         src/basic/mempool.c \
367         src/basic/mempool.h \
368         src/basic/hashmap.c \
369         src/basic/hashmap.h \
370         src/basic/hash-funcs.c \
371         src/basic/hash-funcs.h \
372         src/basic/siphash24.c \
373         src/basic/siphash24.h \
374         src/basic/prioq.c \
375         src/basic/prioq.h \
376         src/basic/strv.c \
377         src/basic/strv.h \
378         src/basic/env-util.c \
379         src/basic/env-util.h \
380         src/basic/log.c \
381         src/basic/log.h \
382         src/basic/bus-label.c \
383         src/basic/bus-label.h \
384         src/basic/exec-util.c \
385         src/basic/exec-util.h \
386         src/basic/virt.c \
387         src/basic/virt.h \
388         src/basic/smack-util.c \
389         src/basic/smack-util.h \
390         src/basic/utf8.c \
391         src/basic/utf8.h \
392         src/basic/gunicode.c \
393         src/basic/gunicode.h \
394         src/basic/socket-util.c \
395         src/basic/socket-util.h \
396         src/basic/fileio.c \
397         src/basic/fileio.h \
398         src/basic/mkdir.c \
399         src/basic/mkdir.h \
400         src/basic/cgroup-util.c \
401         src/basic/cgroup-util.h \
402         src/basic/errno-list.c \
403         src/basic/errno-list.h \
404         src/basic/terminal-util.c \
405         src/basic/terminal-util.h \
406         src/basic/login-util.h \
407         src/basic/login-util.c \
408         src/basic/audit-util.c \
409         src/basic/audit-util.h \
410         src/basic/memfd-util.c \
411         src/basic/memfd-util.h \
412         src/basic/process-util.c \
413         src/basic/process-util.h \
414         src/basic/random-util.c \
415         src/basic/random-util.h \
416         src/basic/verbs.c \
417         src/basic/verbs.h \
418         src/basic/label.c \
419         src/basic/label.h \
420         src/basic/selinux-util.c \
421         src/basic/selinux-util.h \
422         src/basic/mkdir-label.c \
423         src/basic/fileio-label.c \
424         src/basic/fileio-label.h \
425         src/basic/rm-rf.c \
426         src/basic/rm-rf.h \
427         src/basic/copy.c \
428         src/basic/copy.h \
429         src/basic/alloc-util.h \
430         src/basic/alloc-util.c \
431         src/basic/format-util.h \
432         src/basic/khash.h \
433         src/basic/khash.c
434
435 nodist_libbasic_la_SOURCES = \
436         src/basic/errno-from-name.h \
437         src/basic/errno-to-name.h
438
439 libbasic_la_CFLAGS = \
440         $(AM_CFLAGS) \
441         $(SELINUX_CFLAGS) \
442         $(CAP_CFLAGS) \
443         -pthread
444
445 libbasic_la_LDFLAGS = \
446         $(CAP_LDFLAGS)
447
448 libbasic_la_LIBADD = \
449         $(SELINUX_LIBS) \
450         $(CAP_LIBS) \
451         -ldl \
452         -lm
453
454 # -----------------------------------------------------------------------------
455 noinst_LTLIBRARIES += \
456         libshared.la
457
458 libshared_la_SOURCES = \
459         src/shared/udev-util.h \
460         src/shared/udev-util.c \
461         src/shared/bus-util.c \
462         src/shared/bus-util.h \
463         src/shared/clean-ipc.c \
464         src/shared/clean-ipc.h \
465         src/shared/conf-parser.c \
466         src/shared/conf-parser.h \
467         src/shared/musl_missing.h \
468         src/shared/musl_missing.c \
469         src/shared/pager.c \
470         src/shared/pager.h \
471         src/shared/sleep-config.c \
472         src/shared/sleep-config.h \
473         src/shared/spawn-polkit-agent.c \
474         src/shared/spawn-polkit-agent.h \
475         src/shared/tests.h \
476         src/shared/tests.c \
477         src/shared/nsflags.h \
478         src/shared/nsflags.c
479
480 if HAVE_ACL
481 libshared_la_SOURCES += \
482         src/shared/acl-util.c \
483         src/shared/acl-util.h
484 endif
485
486 libshared_la_CFLAGS = \
487         $(AM_CFLAGS) \
488         $(ACL_CFLAGS)
489
490 libshared_la_LIBADD = \
491         libelogind-internal.la \
492         libbasic.la \
493         $(UDEV_LIBS) \
494         $(ACL_LIBS)
495
496 noinst_LTLIBRARIES += \
497         libelogind-shared.la
498
499 libelogind_shared_la_SOURCES = \
500         $(libbasic_la_SOURCES) \
501         $(libshared_la_SOURCES) \
502         $(libelogind_internal_la_SOURCES)
503
504 libelogind_shared_la_CFLAGS = \
505         $(AM_CFLAGS) \
506         $(libbasic_la_CFLAGS) \
507         $(libshared_la_CFLAGS) \
508         $(libelogind_internal_la_CFLAGS) \
509         $(libelogind_journal_internal_la_CFLAGS) \
510         $(libudev_internal_la_CFLAGS) \
511         $(ACL_CFLAGS) \
512         $(SECCOMP_CFLAGS) \
513         -fvisibility=default
514
515 # We can't use libshared_la_LIBADD here because it would
516 # pull in libelogind*-internal.la
517 libelogind_shared_la_LIBADD = \
518         $(libbasic_la_LIBADD) \
519         $(libelogind_internal_la_LIBADD) \
520         $(UDEV_LIBS) \
521         $(ACL_LIBS) \
522         $(SECCOMP_LIBS)
523
524 libelogind_shared_la_LDFLAGS = \
525         $(AM_LDFLAGS)
526  # -----------------------------------------------------------------------------
527 gperf_txt_sources = \
528         src/basic/errno-list.txt
529
530 BUILT_SOURCES += \
531         $(gperf_gperf_m4_sources:-gperf.gperf.m4=-gperf.c) \
532         $(gperf_gperf_sources:-gperf.gperf=-gperf.c) \
533         $(gperf_txt_sources:-list.txt=-from-name.h) \
534         $(gperf_txt_sources:-list.txt=-to-name.h)
535
536 CLEANFILES += \
537         $(gperf_txt_sources:-list.txt=-from-name.gperf)
538 DISTCLEANFILES = \
539         $(gperf_txt_sources)
540
541 EXTRA_DIST += \
542         $(gperf_gperf_m4_sources) \
543         $(gperf_gperf_sources)
544
545 CLEANFILES += \
546         $(gperf_txt_sources)
547
548 %-from-name.gperf: %-list.txt
549         $(AM_V_at)$(MKDIR_P) $(dir $@)
550         $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct $(notdir $*)_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@
551
552 %-from-name.h: %-from-name.gperf
553         $(AM_V_at)$(MKDIR_P) $(dir $@)
554         $(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_$(notdir $*) -H hash_$(notdir $*)_name -p -C <$< >$@
555
556
557 src/basic/errno-list.txt:
558         $(AM_V_at)$(MKDIR_P) $(dir $@)
559         $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - </dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+/ { print $$2; }' >$@
560
561 src/basic/errno-to-name.h: src/basic/errno-list.txt
562         $(AM_V_at)$(MKDIR_P) $(dir $@)
563         $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
564
565 # ------------------------------------------------------------------------------
566
567 manual_tests += \
568         test-cgroup
569
570 unsafe_tests = \
571         test-ipcrm
572
573 tests += \
574         test-log \
575         test-path-util \
576         test-siphash24 \
577         test-utf8 \
578         test-ellipsize \
579         test-util \
580         test-exec-util \
581         test-hexdecoct \
582         test-escape \
583         test-alloc-util \
584         test-proc-cmdline \
585         test-io-util \
586         test-fs-util \
587         test-stat-util \
588         test-fd-util \
589         test-string-util \
590         test-extract-word \
591         test-parse-util \
592         test-user-util \
593         test-process-util \
594         test-strip-tab-ansi \
595         test-prioq \
596         test-hashmap \
597         test-set \
598         test-list \
599         test-unaligned \
600         test-conf-files \
601         test-random-util \
602         test-conf-parser \
603         test-locale-util \
604         test-copy \
605         test-verbs \
606         test-signal-util \
607         test-selinux \
608         test-sizeof
609
610 TEST_DATA_FILES += \
611         test/bus-policy/hello.conf \
612         test/bus-policy/methods.conf \
613         test/bus-policy/ownerships.conf \
614         test/bus-policy/signals.conf \
615         test/bus-policy/check-own-rules.conf \
616         test/bus-policy/many-rules.conf \
617         test/bus-policy/test.conf
618
619
620 EXTRA_DIST += \
621         src/test/test-helper.h
622
623 test_utf8_SOURCES = \
624         src/test/test-utf8.c
625
626 test_utf8_LDADD = \
627         libelogind-shared.la
628
629 test_locale_util_SOURCES = \
630         src/test/test-locale-util.c
631
632 test_locale_util_LDADD = \
633         libelogind-shared.la
634
635 test_copy_SOURCES = \
636         src/test/test-copy.c
637
638 # Link statically to ensure file is large
639 test_copy_LDADD = \
640         libshared.la
641
642 test_random_util_SOURCES = \
643         src/test/test-random-util.c
644
645 test_random_util_LDADD = \
646         libelogind-shared.la
647
648 test_util_SOURCES = \
649         src/test/test-util.c
650
651 test_util_LDADD = \
652         libelogind-shared.la
653
654 test_exec_util_SOURCES = \
655         src/test/test-exec-util.c
656
657 test_exec_util_LDADD = \
658         libelogind-shared.la
659
660 test_hexdecoct_SOURCES = \
661         src/test/test-hexdecoct.c
662
663 test_hexdecoct_LDADD = \
664         libelogind-shared.la
665
666 test_alloc_util_SOURCES = \
667         src/test/test-alloc-util.c
668
669 test_alloc_util_LDADD = \
670         libelogind-shared.la
671
672 test_io_util_SOURCES = \
673         src/test/test-io-util.c
674
675 test_io_util_LDADD = \
676         libelogind-shared.la
677
678 test_fs_util_SOURCES = \
679         src/test/test-fs-util.c
680
681 test_fs_util_LDADD = \
682         libelogind-shared.la
683
684 test_proc_cmdline_SOURCES = \
685         src/test/test-proc-cmdline.c
686
687 test_proc_cmdline_LDADD = \
688         libelogind-shared.la
689
690 test_fd_util_SOURCES = \
691         src/test/test-fd-util.c
692
693 test_fd_util_LDADD = \
694         libelogind-shared.la
695
696 test_stat_util_SOURCES = \
697         src/test/test-stat-util.c
698
699 test_stat_util_LDADD = \
700         libelogind-shared.la
701
702 test_escape_SOURCES = \
703         src/test/test-escape.c
704
705 test_escape_LDADD = \
706         libelogind-shared.la
707
708 test_string_util_SOURCES = \
709         src/test/test-string-util.c
710
711 test_string_util_LDADD = \
712         libelogind-shared.la
713
714 test_extract_word_SOURCES = \
715         src/test/test-extract-word.c
716
717 test_extract_word_LDADD = \
718         libelogind-shared.la
719
720 test_parse_util_SOURCES = \
721         src/test/test-parse-util.c
722
723 test_parse_util_LDADD = \
724         libelogind-shared.la
725
726 test_user_util_SOURCES = \
727         src/test/test-user-util.c
728
729 test_user_util_LDADD = \
730         libelogind-shared.la
731
732 test_process_util_SOURCES = \
733         src/test/test-process-util.c
734
735 test_process_util_LDADD = \
736         libelogind-shared.la
737
738 test_verbs_SOURCES = \
739         src/test/test-verbs.c
740
741 test_verbs_LDADD = \
742         libelogind-shared.la
743
744 test_signal_util_SOURCES = \
745         src/test/test-signal-util.c
746
747 test_signal_util_LDADD = \
748         libelogind-shared.la
749
750 test_selinux_SOURCES = \
751         src/test/test-selinux.c
752
753 test_selinux_LDADD = \
754         libelogind-shared.la
755
756 test_sizeof_SOURCES = \
757         src/test/test-sizeof.c
758
759 BUILT_SOURCES += \
760         src/test/test-hashmap-ordered.c
761
762 src/test/test-hashmap-ordered.c: src/test/test-hashmap-plain.c
763         $(AM_V_at)$(MKDIR_P) $(dir $@)
764         $(AM_V_GEN)$(AWK) 'BEGIN { print "/* GENERATED FILE */\n#define ORDERED" } \
765                            { if (!match($$0, "^#include"))          \
766                                  gsub(/hashmap/, "ordered_hashmap"); \
767                              gsub(/HASHMAP/, "ORDERED_HASHMAP");     \
768                              gsub(/Hashmap/, "OrderedHashmap");      \
769                              print }' <$< >$@
770
771 nodist_test_hashmap_SOURCES = \
772         src/test/test-hashmap-ordered.c
773
774 test_hashmap_SOURCES = \
775         src/test/test-hashmap.c \
776         src/test/test-hashmap-plain.c
777
778 test_hashmap_LDADD = \
779         libelogind-shared.la
780
781 test_set_SOURCES = \
782         src/test/test-set.c
783
784 test_set_LDADD = \
785         libelogind-shared.la
786
787 test_list_SOURCES = \
788         src/test/test-list.c
789
790 test_list_LDADD = \
791         libelogind-shared.la
792
793 test_unaligned_LDADD = \
794         libelogind-shared.la
795
796 test_unaligned_SOURCES = \
797         src/test/test-unaligned.c
798
799 test_prioq_SOURCES = \
800         src/test/test-prioq.c
801
802 test_prioq_LDADD = \
803         libelogind-shared.la
804
805 test_log_SOURCES = \
806         src/test/test-log.c
807
808 test_log_LDADD = \
809         libelogind-shared.la
810
811 test_ipcrm_SOURCES = \
812         src/test/test-ipcrm.c
813
814 test_ipcrm_LDADD = \
815         libelogind-shared.la
816
817 test_ellipsize_SOURCES = \
818         src/test/test-ellipsize.c
819
820 test_ellipsize_LDADD = \
821         libelogind-shared.la
822
823 test_strip_tab_ansi_SOURCES = \
824         src/test/test-strip-tab-ansi.c
825
826 test_strip_tab_ansi_LDADD = \
827         libelogind-shared.la
828
829 test_cgroup_SOURCES = \
830         src/test/test-cgroup.c
831
832 test_cgroup_LDADD = \
833         libelogind-shared.la
834
835 test_path_util_SOURCES = \
836         src/test/test-path-util.c
837
838 test_path_util_LDADD = \
839         libelogind-shared.la
840
841 test_siphash24_SOURCES = \
842         src/test/test-siphash24.c
843
844 test_siphash24_LDADD = \
845         libelogind-shared.la
846
847 test_conf_files_SOURCES = \
848         src/test/test-conf-files.c
849
850 test_conf_files_LDADD = \
851         libelogind-shared.la
852
853 test_conf_parser_SOURCES = \
854         src/test/test-conf-parser.c
855
856 test_conf_parser_LDADD = \
857         libelogind-shared.la
858
859 # ------------------------------------------------------------------------------
860 ## .PHONY so it always rebuilds it
861 .PHONY: coverage lcov-run lcov-report coverage-sync
862
863 # run lcov from scratch, always
864 coverage: all
865         $(MAKE) lcov-run
866         $(MAKE) lcov-report
867
868 coverage_dir = coverage
869 coverage_opts = --base-directory $(srcdir) --directory $(builddir) --rc 'geninfo_adjust_src_path=$(abspath $(srcdir))=>$(abspath $(builddir))'
870
871 if ENABLE_COVERAGE
872 # reset run coverage tests
873 lcov-run:
874         @rm -rf $(coverage_dir)
875         lcov $(coverage_opts) --zerocounters
876         -$(MAKE) check
877
878 # generate report based on current coverage data
879 lcov-report:
880         $(MKDIR_P) $(coverage_dir)
881         lcov $(coverage_opts) --compat-libtool --capture --no-external \
882                 | sed 's|$(abspath $(builddir))|$(abspath $(srcdir))|' > $(coverage_dir)/.lcov.info
883         lcov --remove $(coverage_dir)/.lcov.info --output-file $(coverage_dir)/.lcov-clean.info 'test-*'
884         genhtml -t "systemd test coverage" -o $(coverage_dir) $(coverage_dir)/.lcov-clean.info
885         @echo "Coverage report generated in $(abs_builddir)/$(coverage_dir)/index.html"
886
887 # lcov doesn't work properly with vpath builds, make sure that bad
888 # output is not uploaded by mistake.
889 coverage-sync: coverage
890         test "$(builddir)" = "$(srcdir)"
891         rsync -rlv --delete --omit-dir-times coverage/ $(www_target)/coverage
892
893 else
894 lcov-run lcov-report:
895         echo "Need to reconfigure with --enable-coverage"
896 endif
897
898 # ------------------------------------------------------------------------------
899
900 if HAVE_PAM
901 dist_factory_pam_DATA = \
902         factory/etc/pam.d/system-auth \
903         factory/etc/pam.d/other
904 endif
905
906 # ------------------------------------------------------------------------------
907 rootlibexec_PROGRAMS += \
908        elogind-cgroups-agent
909
910 elogind_cgroups_agent_SOURCES = \
911        src/cgroups-agent/cgroups-agent.c
912
913 elogind_cgroups_agent_LDADD = \
914        libelogind-shared.la
915
916 # ------------------------------------------------------------------------------
917 libelogind_internal_la_SOURCES = \
918         src/systemd/sd-bus.h \
919         src/systemd/sd-bus-protocol.h \
920         src/systemd/sd-bus-vtable.h \
921         src/systemd/sd-event.h \
922         src/systemd/sd-login.h \
923         src/systemd/sd-id128.h \
924         src/systemd/sd-daemon.h \
925         src/libelogind/libelogind.sym \
926         src/libelogind/sd-bus/sd-bus.c \
927         src/libelogind/sd-bus/bus-control.c \
928         src/libelogind/sd-bus/bus-control.h \
929         src/libelogind/sd-bus/bus-error.c \
930         src/libelogind/sd-bus/bus-error.h \
931         src/libelogind/sd-bus/bus-common-errors.h \
932         src/libelogind/sd-bus/bus-common-errors.c \
933         src/libelogind/sd-bus/bus-internal.c \
934         src/libelogind/sd-bus/bus-internal.h \
935         src/libelogind/sd-bus/bus-socket.c \
936         src/libelogind/sd-bus/bus-socket.h \
937         src/libelogind/sd-bus/bus-kernel.c \
938         src/libelogind/sd-bus/bus-kernel.h \
939         src/libelogind/sd-bus/bus-container.c \
940         src/libelogind/sd-bus/bus-container.h \
941         src/libelogind/sd-bus/bus-message.c \
942         src/libelogind/sd-bus/bus-message.h \
943         src/libelogind/sd-bus/bus-creds.c \
944         src/libelogind/sd-bus/bus-creds.h \
945         src/libelogind/sd-bus/bus-signature.c \
946         src/libelogind/sd-bus/bus-signature.h \
947         src/libelogind/sd-bus/bus-type.c \
948         src/libelogind/sd-bus/bus-type.h \
949         src/libelogind/sd-bus/bus-match.c \
950         src/libelogind/sd-bus/bus-match.h \
951         src/libelogind/sd-bus/bus-bloom.c \
952         src/libelogind/sd-bus/bus-bloom.h \
953         src/libelogind/sd-bus/bus-introspect.c \
954         src/libelogind/sd-bus/bus-introspect.h \
955         src/libelogind/sd-bus/bus-objects.c \
956         src/libelogind/sd-bus/bus-objects.h \
957         src/libelogind/sd-bus/bus-gvariant.c \
958         src/libelogind/sd-bus/bus-gvariant.h \
959         src/libelogind/sd-bus/bus-convenience.c \
960         src/libelogind/sd-bus/bus-track.c \
961         src/libelogind/sd-bus/bus-track.h \
962         src/libelogind/sd-bus/bus-slot.c \
963         src/libelogind/sd-bus/bus-slot.h \
964         src/libelogind/sd-bus/bus-protocol.h \
965         src/libelogind/sd-event/sd-event.c \
966         src/libelogind/sd-id128/sd-id128.c \
967         src/libelogind/sd-id128/id128-util.h \
968         src/libelogind/sd-id128/id128-util.c \
969         src/libelogind/sd-daemon/sd-daemon.c \
970         src/libelogind/sd-login/sd-login.c
971
972 noinst_LTLIBRARIES += \
973         libelogind-internal.la
974
975 EXTRA_DIST += \
976         src/libelogind/libelogind.pc.in \
977         src/libelogind/sd-bus/GVARIANT-SERIALIZATION
978
979 libelogind_la_SOURCES =
980
981 libelogind_la_LDFLAGS = \
982         $(AM_LDFLAGS) \
983         -version-info $(LIBELOGIND_CURRENT):$(LIBELOGIND_REVISION):$(LIBELOGIND_AGE) \
984         -Wl,--version-script=$(top_srcdir)/src/libelogind/libelogind.sym
985
986 libelogind_la_LIBADD = \
987         libelogind-internal.la \
988         libbasic.la
989
990 pkgconfiglib_DATA += \
991         src/libelogind/libelogind.pc
992
993 pkginclude_HEADERS += \
994         src/systemd/sd-login.h \
995         src/systemd/sd-messages.h \
996         src/systemd/sd-id128.h \
997         src/systemd/_sd-common.h
998
999 header-install-hook:
1000         $(MKDIR_P) $(DESTDIR)/$(pkgincludedir)
1001         cd $(DESTDIR)/$(includedir)/elogind && \
1002                 for hdr in $(notdir $(pkginclude_HEADERS)) ; do \
1003                         rm -f $$hdr ; \
1004                         $(LN_S) systemd/$$hdr $$hdr ; \
1005                 done
1006
1007 header-uninstall-hook:
1008         m -f $(DESTDIR)/$(includedir)/elogind/*.h
1009
1010 INSTALL_EXEC_HOOKS += header-install-hook
1011 UNINSTALL_EXEC_HOOKS += header-uninstall-hook
1012
1013 rootlib_LTLIBRARIES += \
1014         libelogind.la
1015
1016 tests += \
1017         test-bus-signature \
1018         test-bus-server \
1019         test-bus-match \
1020         test-bus-introspect \
1021         test-bus-vtable \
1022         test-bus-error \
1023         test-event
1024
1025 test_bus_signature_SOURCES = \
1026         src/libelogind/sd-bus/test-bus-signature.c
1027
1028 test_bus_signature_LDADD = \
1029         libelogind-shared.la
1030
1031 test_bus_server_SOURCES = \
1032         src/libelogind/sd-bus/test-bus-server.c
1033
1034 test_bus_server_LDADD = \
1035         libelogind-shared.la
1036
1037 test_bus_vtable_SOURCES = \
1038         src/libelogind/sd-bus/test-bus-vtable.c
1039
1040 test_bus_vtable_LDADD = \
1041         libelogind-shared.la
1042
1043 test_bus_error_SOURCES = \
1044         src/libelogind/sd-bus/test-bus-error.c
1045
1046 # Link statically because this test uses BUS_ERROR_MAP_ELF_REGISTER
1047 test_bus_error_LDADD = \
1048         libshared.la
1049
1050 test_bus_match_SOURCES = \
1051         src/libelogind/sd-bus/test-bus-match.c
1052
1053 test_bus_match_LDADD = \
1054         libelogind-shared.la
1055
1056 test_bus_introspect_SOURCES = \
1057         src/libelogind/sd-bus/test-bus-introspect.c
1058
1059 test_bus_introspect_LDADD = \
1060         libelogind-shared.la
1061
1062 test_event_SOURCES = \
1063         src/libelogind/sd-event/test-event.c
1064
1065 test_event_LDADD = \
1066         libelogind-shared.la
1067
1068 # ------------------------------------------------------------------------------
1069 test_id128_SOURCES = \
1070         src/test/test-id128.c
1071
1072 test_id128_LDADD = \
1073         libelogind-shared.la
1074
1075 tests += \
1076         test-id128
1077
1078 # ------------------------------------------------------------------------------
1079 test_hash_SOURCES = \
1080         src/test/test-hash.c
1081
1082 test_hash_LDADD = \
1083         libelogind-shared.la
1084
1085 tests += \
1086         test-hash
1087
1088 # ------------------------------------------------------------------------------
1089 elogind_SOURCES = \
1090         src/login/logind.c \
1091         src/login/logind.h
1092
1093 nodist_elogind_SOURCES = \
1094         src/login/logind-gperf.c
1095
1096 elogind_LDADD = \
1097         libelogind-core.la
1098
1099 libelogind_core_la_SOURCES = \
1100         src/core/cgroup.h \
1101         src/core/cgroup.c \
1102         src/core/mount-setup.h \
1103         src/core/mount-setup.c \
1104         src/login/elogind.c \
1105         src/login/elogind.h \
1106         src/login/elogind-dbus.c \
1107         src/login/elogind-dbus.h \
1108         src/login/logind-core.c \
1109         src/login/logind-device.c \
1110         src/login/logind-device.h \
1111         src/login/logind-button.c \
1112         src/login/logind-button.h \
1113         src/login/logind-action.c \
1114         src/login/logind-action.h \
1115         src/login/logind-seat.c \
1116         src/login/logind-seat.h \
1117         src/login/logind-session.c \
1118         src/login/logind-session.h \
1119         src/login/logind-session-device.c \
1120         src/login/logind-session-device.h \
1121         src/login/logind-user.c \
1122         src/login/logind-user.h \
1123         src/login/logind-inhibit.c \
1124         src/login/logind-inhibit.h \
1125         src/login/logind-dbus.c \
1126         src/login/logind-session-dbus.c \
1127         src/login/logind-seat-dbus.c \
1128         src/login/logind-user-dbus.c \
1129         src/login/logind-utmp.c \
1130         src/login/logind-acl.h \
1131         src/sleep/sleep.c \
1132         src/sleep/sleep.h
1133
1134 if HAVE_UTMP
1135 libelogind_core_la_SOURCES += \
1136         src/shared/utmp-wtmp.c \
1137         src/update-utmp/update-utmp.c
1138 endif
1139
1140 libelogind_core_la_LIBADD = \
1141         libelogind-shared.la
1142
1143 if HAVE_ACL
1144 libelogind_core_la_SOURCES += \
1145         src/login/logind-acl.c
1146 endif
1147
1148 noinst_LTLIBRARIES += \
1149         libelogind-core.la
1150
1151 rootlibexec_PROGRAMS += \
1152         elogind
1153
1154 loginctl_SOURCES = \
1155         src/login/eloginctl.c \
1156         src/login/eloginctl.h \
1157         src/login/loginctl.c \
1158         src/login/sysfs-show.h \
1159         src/login/sysfs-show.c
1160
1161 loginctl_LDADD = \
1162         libelogind-shared.la
1163
1164 rootbin_PROGRAMS += \
1165         loginctl
1166
1167 dist_bashcompletion_data = \
1168         shell-completion/bash/loginctl
1169
1170 dist_zshcompletion_data = \
1171         shell-completion/zsh/_loginctl \
1172         shell-completion/zsh/_elogind-inhibit
1173
1174 elogind_inhibit_SOURCES = \
1175         src/login/inhibit.c
1176
1177 elogind_inhibit_LDADD = \
1178         libelogind-shared.la
1179
1180 rootbin_PROGRAMS += \
1181         elogind-inhibit
1182
1183 test_login_SOURCES = \
1184         src/libelogind/sd-login/test-login.c
1185
1186 test_login_LDADD = \
1187         libelogind-shared.la
1188
1189 test_login_shared_SOURCES = \
1190         src/login/test-login-shared.c
1191
1192 test_login_shared_LDADD = \
1193         libelogind-shared.la
1194
1195 test_inhibit_SOURCES = \
1196         src/login/test-inhibit.c
1197
1198 test_inhibit_LDADD = \
1199         libelogind-shared.la
1200
1201 test_login_tables_SOURCES = \
1202         src/login/test-login-tables.c
1203
1204 test_login_tables_LDADD = \
1205         libelogind-core.la
1206
1207 manual_tests += \
1208         test-inhibit
1209
1210 tests += \
1211         test-login \
1212         test-login-tables \
1213         test-login-shared
1214
1215 if HAVE_PAM
1216 pam_elogind_la_SOURCES = \
1217         src/login/pam_elogind.sym \
1218         src/login/pam_elogind.c
1219
1220 pam_elogind_la_CFLAGS = \
1221         $(AM_CFLAGS) \
1222         $(PAM_CFLAGS)
1223
1224 pam_elogind_la_LDFLAGS = \
1225         $(AM_LDFLAGS) \
1226         -module \
1227         -export-dynamic \
1228         -avoid-version \
1229         -shared \
1230         -Wl,--version-script=$(top_srcdir)/src/login/pam_elogind.sym
1231
1232 pam_elogind_la_LIBADD = \
1233         libshared.la \
1234         $(PAM_LIBS)
1235
1236 pamlib_LTLIBRARIES = \
1237         pam_elogind.la
1238
1239 if ENABLE_PAM_CONFIG
1240 dist_pamconf_DATA = \
1241         src/login/elogind-user
1242 endif
1243
1244 EXTRA_DIST += \
1245         src/login/elogind-user.m4
1246 endif
1247
1248 dist_dbussystemservice_DATA += \
1249         src/login/org.freedesktop.login1.service
1250
1251 dist_dbuspolicy_DATA += \
1252         src/login/org.freedesktop.login1.conf
1253
1254 nodist_pkgsysconf_DATA += \
1255         src/login/logind.conf
1256
1257 polkitpolicy_files += \
1258         src/login/org.freedesktop.login1.policy
1259
1260 dist_udevrules_DATA += \
1261         src/login/70-uaccess.rules \
1262         src/login/70-power-switch.rules
1263
1264 nodist_udevrules_DATA += \
1265         src/login/71-seat.rules \
1266         src/login/73-seat-late.rules
1267
1268 polkitpolicy_in_files += \
1269         src/login/org.freedesktop.login1.policy.in
1270
1271 gperf_gperf_sources = \
1272         src/login/logind-gperf.gperf
1273
1274 EXTRA_DIST += \
1275         src/login/71-seat.rules.in \
1276         src/login/73-seat-late.rules.in \
1277         src/login/logind.conf.in
1278
1279 # ------------------------------------------------------------------------------
1280 substitutions = \
1281        '|rootlibdir=$(rootlibdir)|' \
1282        '|rootlibexecdir=$(rootlibexecdir)|' \
1283        '|rootbindir=$(rootbindir)|' \
1284        '|bindir=$(bindir)|' \
1285        '|pkgsysconfdir=$(pkgsysconfdir)|' \
1286        '|pkgdatadir=$(pkgdatadir)|' \
1287        '|udevrulesdir=$(udevrulesdir)|' \
1288        '|PACKAGE_VERSION=$(PACKAGE_VERSION)|' \
1289        '|PACKAGE_NAME=$(PACKAGE_NAME)|' \
1290        '|PACKAGE_URL=$(PACKAGE_URL)|' \
1291        '|prefix=$(prefix)|' \
1292        '|exec_prefix=$(exec_prefix)|' \
1293        '|libdir=$(libdir)|' \
1294        '|includedir=$(includedir)|' \
1295        '|rootprefix=$(rootprefix)|' \
1296        '|udevlibexecdir=$(udevlibexecdir)|' \
1297        '|KILL=$(KILL)|' \
1298        '|MKDIR_P=$(MKDIR_P)|' \
1299        '|KILL_USER_PROCESSES=$(KILL_USER_PROCESSES)|' \
1300        '|systemuidmax=$(SYSTEM_UID_MAX)|' \
1301        '|systemgidmax=$(SYSTEM_GID_MAX)|'
1302
1303 SED_PROCESS = \
1304         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
1305         $(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) \
1306                 -e '/^\#\# /d' \
1307                 < $< > $@
1308
1309 man/%: man/%.in
1310         $(SED_PROCESS)
1311
1312 sysctl.d/%: sysctl.d/%.in
1313         $(SED_PROCESS)
1314
1315 %.pc: %.pc.in
1316         $(SED_PROCESS)
1317
1318 shell-completion/%: shell-completion/%.in
1319         $(SED_PROCESS)
1320
1321 %.rules: %.rules.in
1322         $(SED_PROCESS)
1323
1324 %.conf: %.conf.in
1325         $(SED_PROCESS)
1326
1327 %.sh: %.sh.in
1328         $(SED_PROCESS)
1329         $(AM_V_GEN)chmod +x $@
1330
1331 src/%.c: src/%.gperf
1332         $(AM_V_at)$(MKDIR_P) $(dir $@)
1333         $(AM_V_GPERF)$(GPERF) < $< > $@
1334
1335 src/%: src/%.m4
1336         $(AM_V_at)$(MKDIR_P) $(dir $@)
1337         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
1338
1339 sysusers.d/%: sysusers.d/%.m4
1340         $(AM_V_at)$(MKDIR_P) $(dir $@)
1341         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
1342
1343 tmpfiles.d/%: tmpfiles.d/%.m4
1344         $(AM_V_at)$(MKDIR_P) $(dir $@)
1345         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
1346
1347
1348 units/%: units/%.m4
1349         $(AM_V_at)$(MKDIR_P) $(dir $@)
1350         $(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_SYSTEM=1 < $< > $@
1351
1352 units/user/%: units/user/%.m4
1353         $(AM_V_at)$(MKDIR_P) $(dir $@)
1354         $(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_USER=1 < $< > $@
1355
1356 if ENABLE_POLKIT
1357 nodist_polkitpolicy_DATA = \
1358         $(polkitpolicy_files)
1359 polkitrules_DATA = $(polkitrules_files)
1360 if ENABLE_POLKIT_PKLA
1361 polkitpkla_DATA = $(polkitpkla_files)
1362 endif
1363 endif
1364
1365 EXTRA_DIST += \
1366         $(polkitpolicy_in_files)
1367
1368 # ------------------------------------------------------------------------------
1369 if ENABLE_MANPAGES
1370 man/custom-entities.ent: configure.ac
1371         $(AM_V_GEN)$(MKDIR_P) $(dir $@)
1372         $(AM_V_GEN)(echo '<?xml version="1.0" encoding="utf-8" ?>' && \
1373          printf '$(subst '|,<!ENTITY ,$(subst =, ",$(subst |',">\n,$(substitutions))))') \
1374          > $@ # '
1375
1376 CLEANFILES += \
1377         man/custom-entities.ent
1378
1379 XSLTPROC_FLAGS = \
1380         --nonet \
1381         --xinclude \
1382         --stringparam man.output.quietly 1 \
1383         --stringparam funcsynopsis.style ansi \
1384         --stringparam man.authors.section.enabled 0 \
1385         --stringparam man.copyright.section.enabled 0 \
1386         --stringparam elogind.version $(PACKAGE_VERSION) \
1387         --path '$(builddir)/man:$(srcdir)/man'
1388
1389 XSLTPROC_PROCESS_MAN = \
1390         $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-man.xsl $<
1391
1392 XSLTPROC_PROCESS_HTML = \
1393         $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-html.xsl $<
1394
1395 man/%.1: man/%.xml man/custom-man.xsl man/custom-entities.ent
1396         $(XSLTPROC_PROCESS_MAN)
1397
1398 man/%.3: man/%.xml man/custom-man.xsl man/custom-entities.ent
1399         $(XSLTPROC_PROCESS_MAN)
1400
1401 man/%.5: man/%.xml man/custom-man.xsl man/custom-entities.ent
1402         $(XSLTPROC_PROCESS_MAN)
1403
1404 man/%.7: man/%.xml man/custom-man.xsl man/custom-entities.ent
1405         $(XSLTPROC_PROCESS_MAN)
1406
1407 man/%.8: man/%.xml man/custom-man.xsl man/custom-entities.ent
1408         $(XSLTPROC_PROCESS_MAN)
1409
1410 man/%.html: man/%.xml man/custom-html.xsl man/custom-entities.ent
1411         $(XSLTPROC_PROCESS_HTML)
1412
1413 define html-alias
1414         $(AM_V_LN)$(LN_S) -f $(notdir $<) $@
1415 endef
1416
1417 endif
1418
1419 EXTRA_DIST += \
1420         man/custom-html.xsl \
1421         man/custom-man.xsl
1422
1423 install-exec-hook: $(INSTALL_EXEC_HOOKS)
1424
1425 uninstall-hook: $(UNINSTALL_EXEC_HOOKS)
1426
1427 distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
1428
1429 clean-local: $(CLEAN_LOCAL_HOOKS)
1430         rm -rf $(abs_srcdir)/install-tree
1431         rm -f $(abs_srcdir)/hwdb/usb.ids $(abs_srcdir)/hwdb/pci.ids $(abs_srcdir)/hwdb/oui.txt \
1432               $(abs_srcdir)/hwdb/iab.txt
1433
1434 DISTCHECK_CONFIGURE_FLAGS = \
1435         --with-dbuspolicydir=$$dc_install_base/$(dbuspolicydir) \
1436         --with-dbussystemservicedir=$$dc_install_base/$(dbussystemservicedir) \
1437         --with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir) \
1438         --with-zshcompletiondir=$$dc_install_base/$(zshcompletiondir) \
1439         --with-pamlibdir=$$dc_install_base/$(pamlibdir) \
1440         --with-pamconfdir=$$dc_install_base/$(pamconfdir) \
1441         --with-rootprefix=$$dc_install_base
1442
1443 if ENABLE_SPLIT_USR
1444 DISTCHECK_CONFIGURE_FLAGS += \
1445         --enable-split-usr
1446 else
1447 DISTCHECK_CONFIGURE_FLAGS += \
1448         --disable-split-usr
1449 endif
1450
1451 .PHONY: dist-check-help
1452 dist-check-help: $(rootbin_PROGRAMS)
1453         for i in $(abspath $^); do                                             \
1454             if $$i  --help | grep -v 'default:' | grep -E -q '.{80}.' ; then   \
1455                 echo "$(basename $$i) --help output is too wide:";             \
1456                 $$i  --help | awk 'length > 80' | grep -E --color=yes '.{80}'; \
1457                 exit 1;                                                        \
1458             fi; done
1459
1460 include_compilers = "$(CC)" "$(CC) -ansi" "$(CC) -std=iso9899:1990"
1461 public_headers = $(filter-out src/systemd/_sd-common.h, $(pkginclude_HEADERS) $(include_HEADERS))
1462 .PHONY: dist-check-includes
1463 dist-check-includes: $(public_headers)
1464         @res=0;                                                                 \
1465         for i in $(abspath $^); do                                              \
1466             for cc in $(include_compilers); do                                  \
1467                 echo "$$cc -o/dev/null -c -x c -include "$$i" - </dev/null";    \
1468                 $$cc -o/dev/null -c -x c -include "$$i" - </dev/null || res=1;  \
1469             done;                                                               \
1470         done; exit $$res
1471
1472 dist:
1473
1474 .PHONY: git-tag
1475 git-tag:
1476         git tag -s "v$(PACKAGE_VERSION)" -m "elogind $(PACKAGE_VERSION)"
1477
1478 .PHONY: git-tar
1479 git-tar:
1480         $(AM_V_at)git archive --format=tar --prefix=elogind-$(PACKAGE_VERSION)-raw/ HEAD | \
1481                 (cd /var/tmp/ && tar xf -)
1482         $(AM_V_GEN)(cd /var/tmp &&                                              \
1483                 rm -rf elogind-$(PACKAGE_VERSION) &&                            \
1484                 $(MKDIR_P) elogind-$(PACKAGE_VERSION) &&                        \
1485          for f in `find elogind-$(PACKAGE_VERSION)-raw/ -type f |               \
1486                         cut -d '/' -f 2-` ; do                                  \
1487                 $(MKDIR_P) elogind-$(PACKAGE_VERSION)/`dirname $$f` ;           \
1488                 $(AWK) 'BEGIN                    { i=0;e=0      }               \
1489                         /^#if\s+0.*elogind.*$$/  { i=1;next     }               \
1490                         /^#else\s*$$/            {                              \
1491                             { if ( i==1 ) e=1; else print }{next}               \
1492                         }                                                       \
1493                         /^#endif\s*\/\/\s*0\s*$$/ {                             \
1494                             { if ( i==1 ) { i=0;e=0 } else print }{next}        \
1495                         }                                                       \
1496                         /^\s*\/\/\/.*elogind.*$$/{ next         }               \
1497                         /^\s*\/\/\s*#include.+$$/{ next         }               \
1498                         { if ( (i==0) || (e==1) ) print         }'              \
1499                           elogind-$(PACKAGE_VERSION)-raw/$$f                    \
1500                         > elogind-$(PACKAGE_VERSION)/$$f ;                      \
1501                         chmod `stat -c '%a' elogind-$(PACKAGE_VERSION)-raw/$$f` \
1502                                             elogind-$(PACKAGE_VERSION)/$$f ;    \
1503          done ;                                                                 \
1504          for l in `find elogind-$(PACKAGE_VERSION)-raw/ -type l |               \
1505                         cut -d '/' -f 2-` ; do                                  \
1506                 $(MKDIR_P) elogind-$(PACKAGE_VERSION)/`dirname $$l` ;           \
1507                 cp -P elogind-$(PACKAGE_VERSION)-raw/$$l                        \
1508                         elogind-$(PACKAGE_VERSION)/$$l ;                        \
1509          done ;                                                                 \
1510          tar czf elogind-$(PACKAGE_VERSION).tar.gz elogind-$(PACKAGE_VERSION) ; \
1511          rm -rf elogind-$(PACKAGE_VERSION) elogind-$(PACKAGE_VERSION)-raw) ;    \
1512         $(AM_V_at)mv /var/tmp/elogind-$(PACKAGE_VERSION).tar.gz ./
1513
1514 .PHONY: install-tree
1515 install-tree: all
1516         rm -rf $(abs_srcdir)/install-tree
1517         $(MAKE) install DESTDIR=$(abs_srcdir)/install-tree
1518         tree $(abs_srcdir)/install-tree
1519
1520 # Let's run all tests of the test suite, but under valgrind. Let's
1521 # exclude perl/python/shell scripts we have in there
1522 .PHONY: valgrind-tests
1523 valgrind-tests: $(TESTS)
1524         $(AM_V_GEN)for f in $(filter-out %.pl %.py, $^); do \
1525                 if $(LIBTOOL) --mode=execute file $$f | grep -q shell; then \
1526                 echo -e "$${x}Skipping non-binary $$f"; else \
1527                 echo -e "$${x}Running $$f"; \
1528                 $(AM_TESTS_ENVIRONMENT) $(LIBTOOL) --mode=execute valgrind -q --leak-check=full --max-stackframe=5242880 --error-exitcode=55 $(builddir)/$$f ; fi; \
1529                 x="\n\n"; \
1530         done
1531
1532 exported-%: %
1533         $(AM_V_GEN)$(NM) -g --defined-only $(builddir)/.libs/$(<:.la=.so) 2>&1 /dev/null | grep " T " | cut -d" " -f3 > $@
1534
1535 exported: $(addprefix exported-, $(rootlib_LTLIBRARIES))
1536         $(AM_V_GEN)cat $^ > $@
1537
1538 .PHONY: check-api-docs
1539 check-api-docs: exported man
1540         $(AM_V_GEN)for symbol in `cat exported` ; do \
1541                 if test -f $(builddir)/man/$$symbol.html ; then \
1542                         echo "  Symbol $$symbol() is documented." ; \
1543                 else \
1544                         echo "‣ Symbol $$symbol() lacks documentation." ; \
1545                 fi ; \
1546         done
1547
1548 OBJECT_VARIABLES:=$(filter %_OBJECTS,$(.VARIABLES))
1549 ALL_OBJECTS:=$(foreach v,$(OBJECT_VARIABLES),$($(v)))
1550
1551 undefined defined: $(ALL_OBJECTS)
1552         $(AM_V_GEN)for f in $(ALL_OBJECTS) ; do \
1553                 $(NM) -g --$@-only `echo $(builddir)/"$$f" | sed -e 's,\([^/]*\).lo$$,.libs/\1.o,'` ; \
1554         done | cut -c 20- | cut -d @ -f 1 | sort -u > $@
1555
1556 CLEANFILES += \
1557         defined \
1558         undefined
1559
1560 .PHONY: check-api-unused
1561 check-api-unused: defined undefined exported
1562         ( cat exported undefined ) | sort -u  | diff -u - defined | grep ^+ | grep -v ^+++ | cut -c2-
1563
1564 .PHONY: check-includes
1565 check-includes: $(top_srcdir)/tools/check-includes.pl
1566         $(AM_V_GEN) find * -name '*.[hcS]' -type f -print | sort -u \
1567                 | xargs $(top_srcdir)/tools/check-includes.pl
1568
1569 EXTRA_DIST += \
1570         $(top_srcdir)/tools/check-includes.pl
1571
1572 # Stupid test that everything purported to be exported really is
1573 define generate-sym-test
1574         $(AM_V_at)$(MKDIR_P) $(dir $@)
1575         $(AM_V_at)printf '#include <stdio.h>\n' > $@
1576         $(AM_V_at)printf '#include "%s"\n' $(notdir $(filter %.h, $^)) >> $@
1577         $(AM_V_at)printf 'void* functions[] = {\n' >> $@
1578         $(AM_V_GEN)sed -r -n 's/^ +([a-zA-Z0-9_]+);/\1,/p' $< >> $@
1579         $(AM_V_at)printf '};\nint main(void) {\n' >> $@
1580         $(AM_V_at)printf 'unsigned i; for (i=0;i<sizeof(functions)/sizeof(void*);i++) printf("%%p\\n", functions[i]);\n' >> $@
1581         $(AM_V_at)printf 'return 0; }\n' >> $@
1582 endef
1583
1584 test-libelogind-sym.c: \
1585                 $(top_builddir)/src/libelogind/libelogind.sym \
1586                 src/systemd/sd-daemon.h \
1587                 src/systemd/sd-login.h \
1588                 src/systemd/sd-bus.h \
1589                 src/systemd/sd-event.h
1590         $(generate-sym-test)
1591
1592 test_libelogind_sym_SOURCES = \
1593         test-libelogind-sym.c
1594 test_libelogind_sym_LDADD = \
1595         libelogind.la
1596
1597 BUILT_SOURCES += \
1598         $(test_libelogind_sym_SOURCES)
1599
1600 tests += \
1601         test-libelogind-sym
1602
1603 .PHONY: install-tests
1604 install-tests: $(tests) $(TEST_DATA_FILES)
1605         for f in $(tests); do \
1606             if [ -x $(top_builddir)/.libs/$$f ]; then \
1607                 install -D -m 755 $(top_builddir)/.libs/$$f $(DESTDIR)/$(testsdir)/$$f; \
1608             else \
1609                 install -D -m 755 $(top_builddir)/$$f $(DESTDIR)/$(testsdir)/$$f; \
1610             fi; \
1611         done
1612         for f in $(TEST_DATA_FILES); do \
1613             install -D -m 644 $(top_srcdir)/$$f $(DESTDIR)/$(testsdir)/testdata/$${f#test/}; \
1614         done
1615
1616 .PHONY: cccc cppcheck
1617 cccc: all
1618         cccc --outdir=$(top_builddir)/cccc \
1619         `find $(top_srcdir)/src/ -name '*.h' -or -name '*.c'`
1620
1621 cppcheck:
1622         cppcheck --enable=all -q \
1623         -I $(top_srcdir)/src \
1624         -I $(top_builddir)/src/basic \
1625         -I $(top_srcdir)/src/basic \
1626         -I $(top_srcdir)/src/core \
1627         -I $(top_srcdir)/src/shared \
1628         -I $(top_builddir)/src/shared \
1629         -I $(top_srcdir)/src/login \
1630         -I $(top_srcdir)/src/systemd \
1631         -I $(top_srcdir)/src/libelogind/sd-bus \
1632         -I $(top_srcdir)/src/libelogind/sd-event \
1633         -I $(top_srcdir)/src/libelogind/sd-login \
1634         -I $(top_srcdir)/src/libelogind/sd-id128 \
1635         -I $(top_srcdir)/src/update-utmp \
1636         -I $(top_srcdir)/src/sleep \
1637         --force \
1638         $(top_srcdir)
1639
1640 # Used to extract compile flags for YCM.
1641 print-%:
1642         @echo $($*)
1643
1644 git-contrib:
1645         @git shortlog -s `git describe --abbrev=0`.. | cut -c8- | sed 's/ / /g' | awk '{ print $$0 "," }' | sort -u
1646
1647 EXTRA_DIST += \
1648         tools/gdb-sd_dump_hashmaps.py
1649
1650 list-keys:
1651         gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --list-keys
1652
1653 add-key:
1654         gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --import -