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