chiark / gitweb /
Prep 229.9: Make all supportable API functions visible.
[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=2
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-bus.h          \
995         src/systemd/sd-bus-protocol.h \
996         src/systemd/sd-bus-vtable.h   \
997         src/systemd/_sd-common.h      \
998         src/systemd/sd-daemon.h       \
999         src/systemd/sd-event.h        \
1000         src/systemd/sd-id128.h        \
1001         src/systemd/sd-login.h        \
1002         src/systemd/sd-messages.h
1003
1004 header-install-hook:
1005         $(MKDIR_P) $(DESTDIR)/$(pkgincludedir)
1006         cd $(DESTDIR)/$(includedir)/elogind && \
1007                 for hdr in $(notdir $(pkginclude_HEADERS)) ; do \
1008                         rm -f $$hdr ; \
1009                         $(LN_S) systemd/$$hdr $$hdr ; \
1010                 done
1011
1012 header-uninstall-hook:
1013         m -f $(DESTDIR)/$(includedir)/elogind/*.h
1014
1015 INSTALL_EXEC_HOOKS += header-install-hook
1016 UNINSTALL_EXEC_HOOKS += header-uninstall-hook
1017
1018 rootlib_LTLIBRARIES += \
1019         libelogind.la
1020
1021 tests += \
1022         test-bus-signature \
1023         test-bus-server \
1024         test-bus-match \
1025         test-bus-introspect \
1026         test-bus-vtable \
1027         test-bus-error \
1028         test-event
1029
1030 test_bus_signature_SOURCES = \
1031         src/libelogind/sd-bus/test-bus-signature.c
1032
1033 test_bus_signature_LDADD = \
1034         libelogind-shared.la
1035
1036 test_bus_server_SOURCES = \
1037         src/libelogind/sd-bus/test-bus-server.c
1038
1039 test_bus_server_LDADD = \
1040         libelogind-shared.la
1041
1042 test_bus_vtable_SOURCES = \
1043         src/libelogind/sd-bus/test-bus-vtable.c
1044
1045 test_bus_vtable_LDADD = \
1046         libelogind-shared.la
1047
1048 test_bus_error_SOURCES = \
1049         src/libelogind/sd-bus/test-bus-error.c
1050
1051 # Link statically because this test uses BUS_ERROR_MAP_ELF_REGISTER
1052 test_bus_error_LDADD = \
1053         libshared.la
1054
1055 test_bus_match_SOURCES = \
1056         src/libelogind/sd-bus/test-bus-match.c
1057
1058 test_bus_match_LDADD = \
1059         libelogind-shared.la
1060
1061 test_bus_introspect_SOURCES = \
1062         src/libelogind/sd-bus/test-bus-introspect.c
1063
1064 test_bus_introspect_LDADD = \
1065         libelogind-shared.la
1066
1067 test_event_SOURCES = \
1068         src/libelogind/sd-event/test-event.c
1069
1070 test_event_LDADD = \
1071         libelogind-shared.la
1072
1073 # ------------------------------------------------------------------------------
1074 test_id128_SOURCES = \
1075         src/test/test-id128.c
1076
1077 test_id128_LDADD = \
1078         libelogind-shared.la
1079
1080 tests += \
1081         test-id128
1082
1083 # ------------------------------------------------------------------------------
1084 test_hash_SOURCES = \
1085         src/test/test-hash.c
1086
1087 test_hash_LDADD = \
1088         libelogind-shared.la
1089
1090 tests += \
1091         test-hash
1092
1093 # ------------------------------------------------------------------------------
1094 elogind_SOURCES = \
1095         src/login/logind.c \
1096         src/login/logind.h
1097
1098 nodist_elogind_SOURCES = \
1099         src/login/logind-gperf.c
1100
1101 elogind_LDADD = \
1102         libelogind-core.la
1103
1104 libelogind_core_la_SOURCES = \
1105         src/core/cgroup.h \
1106         src/core/cgroup.c \
1107         src/core/mount-setup.h \
1108         src/core/mount-setup.c \
1109         src/login/elogind.c \
1110         src/login/elogind.h \
1111         src/login/elogind-dbus.c \
1112         src/login/elogind-dbus.h \
1113         src/login/logind-core.c \
1114         src/login/logind-device.c \
1115         src/login/logind-device.h \
1116         src/login/logind-button.c \
1117         src/login/logind-button.h \
1118         src/login/logind-action.c \
1119         src/login/logind-action.h \
1120         src/login/logind-seat.c \
1121         src/login/logind-seat.h \
1122         src/login/logind-session.c \
1123         src/login/logind-session.h \
1124         src/login/logind-session-device.c \
1125         src/login/logind-session-device.h \
1126         src/login/logind-user.c \
1127         src/login/logind-user.h \
1128         src/login/logind-inhibit.c \
1129         src/login/logind-inhibit.h \
1130         src/login/logind-dbus.c \
1131         src/login/logind-session-dbus.c \
1132         src/login/logind-seat-dbus.c \
1133         src/login/logind-user-dbus.c \
1134         src/login/logind-utmp.c \
1135         src/login/logind-acl.h \
1136         src/sleep/sleep.c \
1137         src/sleep/sleep.h
1138
1139 if HAVE_UTMP
1140 libelogind_core_la_SOURCES += \
1141         src/shared/utmp-wtmp.c \
1142         src/update-utmp/update-utmp.c
1143 endif
1144
1145 libelogind_core_la_LIBADD = \
1146         libelogind-shared.la
1147
1148 if HAVE_ACL
1149 libelogind_core_la_SOURCES += \
1150         src/login/logind-acl.c
1151 endif
1152
1153 noinst_LTLIBRARIES += \
1154         libelogind-core.la
1155
1156 rootlibexec_PROGRAMS += \
1157         elogind
1158
1159 loginctl_SOURCES = \
1160         src/login/eloginctl.c \
1161         src/login/eloginctl.h \
1162         src/login/loginctl.c \
1163         src/login/sysfs-show.h \
1164         src/login/sysfs-show.c
1165
1166 loginctl_LDADD = \
1167         libelogind-shared.la
1168
1169 rootbin_PROGRAMS += \
1170         loginctl
1171
1172 dist_bashcompletion_data = \
1173         shell-completion/bash/loginctl
1174
1175 dist_zshcompletion_data = \
1176         shell-completion/zsh/_loginctl \
1177         shell-completion/zsh/_elogind-inhibit
1178
1179 elogind_inhibit_SOURCES = \
1180         src/login/inhibit.c
1181
1182 elogind_inhibit_LDADD = \
1183         libelogind-shared.la
1184
1185 rootbin_PROGRAMS += \
1186         elogind-inhibit
1187
1188 test_login_SOURCES = \
1189         src/libelogind/sd-login/test-login.c
1190
1191 test_login_LDADD = \
1192         libelogind-shared.la
1193
1194 test_login_shared_SOURCES = \
1195         src/login/test-login-shared.c
1196
1197 test_login_shared_LDADD = \
1198         libelogind-shared.la
1199
1200 test_inhibit_SOURCES = \
1201         src/login/test-inhibit.c
1202
1203 test_inhibit_LDADD = \
1204         libelogind-shared.la
1205
1206 test_login_tables_SOURCES = \
1207         src/login/test-login-tables.c
1208
1209 test_login_tables_LDADD = \
1210         libelogind-core.la
1211
1212 manual_tests += \
1213         test-inhibit
1214
1215 tests += \
1216         test-login \
1217         test-login-tables \
1218         test-login-shared
1219
1220 if HAVE_PAM
1221 pam_elogind_la_SOURCES = \
1222         src/login/pam_elogind.sym \
1223         src/login/pam_elogind.c
1224
1225 pam_elogind_la_CFLAGS = \
1226         $(AM_CFLAGS) \
1227         $(PAM_CFLAGS)
1228
1229 pam_elogind_la_LDFLAGS = \
1230         $(AM_LDFLAGS) \
1231         -module \
1232         -export-dynamic \
1233         -avoid-version \
1234         -shared \
1235         -Wl,--version-script=$(top_srcdir)/src/login/pam_elogind.sym
1236
1237 pam_elogind_la_LIBADD = \
1238         libshared.la \
1239         $(PAM_LIBS)
1240
1241 pamlib_LTLIBRARIES = \
1242         pam_elogind.la
1243
1244 if ENABLE_PAM_CONFIG
1245 dist_pamconf_DATA = \
1246         src/login/elogind-user
1247 endif
1248
1249 EXTRA_DIST += \
1250         src/login/elogind-user.m4
1251 endif
1252
1253 dist_dbussystemservice_DATA += \
1254         src/login/org.freedesktop.login1.service
1255
1256 dist_dbuspolicy_DATA += \
1257         src/login/org.freedesktop.login1.conf
1258
1259 nodist_pkgsysconf_DATA += \
1260         src/login/logind.conf
1261
1262 polkitpolicy_files += \
1263         src/login/org.freedesktop.login1.policy
1264
1265 dist_udevrules_DATA += \
1266         src/login/70-uaccess.rules \
1267         src/login/70-power-switch.rules
1268
1269 nodist_udevrules_DATA += \
1270         src/login/71-seat.rules \
1271         src/login/73-seat-late.rules
1272
1273 polkitpolicy_in_files += \
1274         src/login/org.freedesktop.login1.policy.in
1275
1276 gperf_gperf_sources = \
1277         src/login/logind-gperf.gperf
1278
1279 EXTRA_DIST += \
1280         src/login/71-seat.rules.in \
1281         src/login/73-seat-late.rules.in \
1282         src/login/logind.conf.in \
1283         src/login/org.freedesktop.login1.service.in
1284
1285 # ------------------------------------------------------------------------------
1286 substitutions = \
1287        '|rootlibdir=$(rootlibdir)|' \
1288        '|rootlibexecdir=$(rootlibexecdir)|' \
1289        '|rootbindir=$(rootbindir)|' \
1290        '|bindir=$(bindir)|' \
1291        '|pkgsysconfdir=$(pkgsysconfdir)|' \
1292        '|pkgdatadir=$(pkgdatadir)|' \
1293        '|udevrulesdir=$(udevrulesdir)|' \
1294        '|PACKAGE_VERSION=$(PACKAGE_VERSION)|' \
1295        '|PACKAGE_NAME=$(PACKAGE_NAME)|' \
1296        '|PACKAGE_URL=$(PACKAGE_URL)|' \
1297        '|prefix=$(prefix)|' \
1298        '|exec_prefix=$(exec_prefix)|' \
1299        '|libdir=$(libdir)|' \
1300        '|includedir=$(includedir)|' \
1301        '|rootprefix=$(rootprefix)|' \
1302        '|udevlibexecdir=$(udevlibexecdir)|' \
1303        '|KILL=$(KILL)|' \
1304        '|MKDIR_P=$(MKDIR_P)|' \
1305        '|KILL_USER_PROCESSES=$(KILL_USER_PROCESSES)|' \
1306        '|systemuidmax=$(SYSTEM_UID_MAX)|' \
1307        '|systemgidmax=$(SYSTEM_GID_MAX)|'
1308
1309 SED_PROCESS = \
1310         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
1311         $(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) \
1312                 -e '/^\#\# /d' \
1313                 < $< > $@
1314
1315 man/%: man/%.in
1316         $(SED_PROCESS)
1317
1318 sysctl.d/%: sysctl.d/%.in
1319         $(SED_PROCESS)
1320
1321 %.pc: %.pc.in
1322         $(SED_PROCESS)
1323
1324 shell-completion/%: shell-completion/%.in
1325         $(SED_PROCESS)
1326
1327 %.rules: %.rules.in
1328         $(SED_PROCESS)
1329
1330 %.conf: %.conf.in
1331         $(SED_PROCESS)
1332
1333 %.login1.service: %.login1.service.in
1334         $(SED_PROCESS)
1335
1336 %.sh: %.sh.in
1337         $(SED_PROCESS)
1338         $(AM_V_GEN)chmod +x $@
1339
1340 src/%.c: src/%.gperf
1341         $(AM_V_at)$(MKDIR_P) $(dir $@)
1342         $(AM_V_GPERF)$(GPERF) < $< > $@
1343
1344 src/%: src/%.m4
1345         $(AM_V_at)$(MKDIR_P) $(dir $@)
1346         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
1347
1348 sysusers.d/%: sysusers.d/%.m4
1349         $(AM_V_at)$(MKDIR_P) $(dir $@)
1350         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
1351
1352 tmpfiles.d/%: tmpfiles.d/%.m4
1353         $(AM_V_at)$(MKDIR_P) $(dir $@)
1354         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
1355
1356
1357 units/%: units/%.m4
1358         $(AM_V_at)$(MKDIR_P) $(dir $@)
1359         $(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_SYSTEM=1 < $< > $@
1360
1361 units/user/%: units/user/%.m4
1362         $(AM_V_at)$(MKDIR_P) $(dir $@)
1363         $(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_USER=1 < $< > $@
1364
1365 if ENABLE_POLKIT
1366 nodist_polkitpolicy_DATA = \
1367         $(polkitpolicy_files)
1368 polkitrules_DATA = $(polkitrules_files)
1369 if ENABLE_POLKIT_PKLA
1370 polkitpkla_DATA = $(polkitpkla_files)
1371 endif
1372 endif
1373
1374 EXTRA_DIST += \
1375         $(polkitpolicy_in_files)
1376
1377 # ------------------------------------------------------------------------------
1378 if ENABLE_MANPAGES
1379 man/custom-entities.ent: configure.ac
1380         $(AM_V_GEN)$(MKDIR_P) $(dir $@)
1381         $(AM_V_GEN)(echo '<?xml version="1.0" encoding="utf-8" ?>' && \
1382          printf '$(subst '|,<!ENTITY ,$(subst =, ",$(subst |',">\n,$(substitutions))))') \
1383          > $@ # '
1384
1385 CLEANFILES += \
1386         man/custom-entities.ent
1387
1388 XSLTPROC_FLAGS = \
1389         --nonet \
1390         --xinclude \
1391         --stringparam man.output.quietly 1 \
1392         --stringparam funcsynopsis.style ansi \
1393         --stringparam man.authors.section.enabled 0 \
1394         --stringparam man.copyright.section.enabled 0 \
1395         --stringparam elogind.version $(PACKAGE_VERSION) \
1396         --path '$(builddir)/man:$(srcdir)/man'
1397
1398 XSLTPROC_PROCESS_MAN = \
1399         $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-man.xsl $<
1400
1401 XSLTPROC_PROCESS_HTML = \
1402         $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-html.xsl $<
1403
1404 man/%.1: man/%.xml man/custom-man.xsl man/custom-entities.ent
1405         $(XSLTPROC_PROCESS_MAN)
1406
1407 man/%.3: man/%.xml man/custom-man.xsl man/custom-entities.ent
1408         $(XSLTPROC_PROCESS_MAN)
1409
1410 man/%.5: man/%.xml man/custom-man.xsl man/custom-entities.ent
1411         $(XSLTPROC_PROCESS_MAN)
1412
1413 man/%.7: man/%.xml man/custom-man.xsl man/custom-entities.ent
1414         $(XSLTPROC_PROCESS_MAN)
1415
1416 man/%.8: man/%.xml man/custom-man.xsl man/custom-entities.ent
1417         $(XSLTPROC_PROCESS_MAN)
1418
1419 man/%.html: man/%.xml man/custom-html.xsl man/custom-entities.ent
1420         $(XSLTPROC_PROCESS_HTML)
1421
1422 define html-alias
1423         $(AM_V_LN)$(LN_S) -f $(notdir $<) $@
1424 endef
1425
1426 endif
1427
1428 EXTRA_DIST += \
1429         man/custom-html.xsl \
1430         man/custom-man.xsl
1431
1432 install-exec-hook: $(INSTALL_EXEC_HOOKS)
1433
1434 uninstall-hook: $(UNINSTALL_EXEC_HOOKS)
1435
1436 distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
1437
1438 clean-local: $(CLEAN_LOCAL_HOOKS)
1439         rm -rf $(abs_srcdir)/install-tree
1440         rm -f $(abs_srcdir)/hwdb/usb.ids $(abs_srcdir)/hwdb/pci.ids $(abs_srcdir)/hwdb/oui.txt \
1441               $(abs_srcdir)/hwdb/iab.txt
1442
1443 DISTCHECK_CONFIGURE_FLAGS = \
1444         --with-dbuspolicydir=$$dc_install_base/$(dbuspolicydir) \
1445         --with-dbussystemservicedir=$$dc_install_base/$(dbussystemservicedir) \
1446         --with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir) \
1447         --with-zshcompletiondir=$$dc_install_base/$(zshcompletiondir) \
1448         --with-pamlibdir=$$dc_install_base/$(pamlibdir) \
1449         --with-pamconfdir=$$dc_install_base/$(pamconfdir) \
1450         --with-rootprefix=$$dc_install_base
1451
1452 if ENABLE_SPLIT_USR
1453 DISTCHECK_CONFIGURE_FLAGS += \
1454         --enable-split-usr
1455 else
1456 DISTCHECK_CONFIGURE_FLAGS += \
1457         --disable-split-usr
1458 endif
1459
1460 .PHONY: dist-check-help
1461 dist-check-help: $(rootbin_PROGRAMS)
1462         for i in $(abspath $^); do                                             \
1463             if $$i  --help | grep -v 'default:' | grep -E -q '.{80}.' ; then   \
1464                 echo "$(basename $$i) --help output is too wide:";             \
1465                 $$i  --help | awk 'length > 80' | grep -E --color=yes '.{80}'; \
1466                 exit 1;                                                        \
1467             fi; done
1468
1469 include_compilers = "$(CC)" "$(CC) -ansi" "$(CC) -std=iso9899:1990"
1470 public_headers = $(filter-out src/systemd/_sd-common.h, $(pkginclude_HEADERS) $(include_HEADERS))
1471 .PHONY: dist-check-includes
1472 dist-check-includes: $(public_headers)
1473         @res=0;                                                                 \
1474         for i in $(abspath $^); do                                              \
1475             for cc in $(include_compilers); do                                  \
1476                 echo "$$cc -o/dev/null -c -x c -include "$$i" - </dev/null";    \
1477                 $$cc -o/dev/null -c -x c -include "$$i" - </dev/null || res=1;  \
1478             done;                                                               \
1479         done; exit $$res
1480
1481 dist:
1482
1483 .PHONY: git-tag
1484 git-tag:
1485         git tag -s "v$(PACKAGE_VERSION)" -m "elogind $(PACKAGE_VERSION)"
1486
1487 .PHONY: git-tar
1488 git-tar:
1489         $(AM_V_at)git archive --format=tar --prefix=elogind-$(PACKAGE_VERSION)-raw/ HEAD | \
1490                 (cd /var/tmp/ && tar xf -)
1491         $(AM_V_GEN)(cd /var/tmp &&                                              \
1492                 rm -rf elogind-$(PACKAGE_VERSION) &&                            \
1493                 $(MKDIR_P) elogind-$(PACKAGE_VERSION) &&                        \
1494          for f in `find elogind-$(PACKAGE_VERSION)-raw/ -type f |               \
1495                         cut -d '/' -f 2-` ; do                                  \
1496                 $(MKDIR_P) elogind-$(PACKAGE_VERSION)/`dirname $$f` ;           \
1497                 $(AWK) 'BEGIN                    { i=0;e=0      }               \
1498                         /^#if\s+0.*elogind.*$$/  { i=1;next     }               \
1499                         /^#else\s*$$/            {                              \
1500                             { if ( i==1 ) e=1; else print }{next}               \
1501                         }                                                       \
1502                         /^#endif\s*\/\/\s*0\s*$$/ {                             \
1503                             { if ( i==1 ) { i=0;e=0 } else print }{next}        \
1504                         }                                                       \
1505                         /^\s*\/\/\/.*elogind.*$$/{ next         }               \
1506                         /^\s*\/\/\s*#include.+$$/{ next         }               \
1507                         { if ( (i==0) || (e==1) ) print         }'              \
1508                           elogind-$(PACKAGE_VERSION)-raw/$$f                    \
1509                         > elogind-$(PACKAGE_VERSION)/$$f ;                      \
1510                         chmod `stat -c '%a' elogind-$(PACKAGE_VERSION)-raw/$$f` \
1511                                             elogind-$(PACKAGE_VERSION)/$$f ;    \
1512          done ;                                                                 \
1513          for l in `find elogind-$(PACKAGE_VERSION)-raw/ -type l |               \
1514                         cut -d '/' -f 2-` ; do                                  \
1515                 $(MKDIR_P) elogind-$(PACKAGE_VERSION)/`dirname $$l` ;           \
1516                 cp -P elogind-$(PACKAGE_VERSION)-raw/$$l                        \
1517                         elogind-$(PACKAGE_VERSION)/$$l ;                        \
1518          done ;                                                                 \
1519          tar czf elogind-$(PACKAGE_VERSION).tar.gz elogind-$(PACKAGE_VERSION) ; \
1520          rm -rf elogind-$(PACKAGE_VERSION) elogind-$(PACKAGE_VERSION)-raw) ;    \
1521         $(AM_V_at)mv /var/tmp/elogind-$(PACKAGE_VERSION).tar.gz ./
1522
1523 .PHONY: install-tree
1524 install-tree: all
1525         rm -rf $(abs_srcdir)/install-tree
1526         $(MAKE) install DESTDIR=$(abs_srcdir)/install-tree
1527         tree $(abs_srcdir)/install-tree
1528
1529 # Let's run all tests of the test suite, but under valgrind. Let's
1530 # exclude perl/python/shell scripts we have in there
1531 .PHONY: valgrind-tests
1532 valgrind-tests: $(TESTS)
1533         $(AM_V_GEN)for f in $(filter-out %.pl %.py, $^); do \
1534                 if $(LIBTOOL) --mode=execute file $$f | grep -q shell; then \
1535                 echo -e "$${x}Skipping non-binary $$f"; else \
1536                 echo -e "$${x}Running $$f"; \
1537                 $(AM_TESTS_ENVIRONMENT) $(LIBTOOL) --mode=execute valgrind -q --leak-check=full --max-stackframe=5242880 --error-exitcode=55 $(builddir)/$$f ; fi; \
1538                 x="\n\n"; \
1539         done
1540
1541 exported-%: %
1542         $(AM_V_GEN)$(NM) -g --defined-only $(builddir)/.libs/$(<:.la=.so) 2>&1 /dev/null | grep " T " | cut -d" " -f3 > $@
1543
1544 exported: $(addprefix exported-, $(rootlib_LTLIBRARIES))
1545         $(AM_V_GEN)cat $^ > $@
1546
1547 .PHONY: check-api-docs
1548 check-api-docs: exported man
1549         $(AM_V_GEN)for symbol in `cat exported` ; do \
1550                 if test -f $(builddir)/man/$$symbol.html ; then \
1551                         echo "  Symbol $$symbol() is documented." ; \
1552                 else \
1553                         echo "‣ Symbol $$symbol() lacks documentation." ; \
1554                 fi ; \
1555         done
1556
1557 OBJECT_VARIABLES:=$(filter %_OBJECTS,$(.VARIABLES))
1558 ALL_OBJECTS:=$(foreach v,$(OBJECT_VARIABLES),$($(v)))
1559
1560 undefined defined: $(ALL_OBJECTS)
1561         $(AM_V_GEN)for f in $(ALL_OBJECTS) ; do \
1562                 $(NM) -g --$@-only `echo $(builddir)/"$$f" | sed -e 's,\([^/]*\).lo$$,.libs/\1.o,'` ; \
1563         done | cut -c 20- | cut -d @ -f 1 | sort -u > $@
1564
1565 CLEANFILES += \
1566         defined \
1567         undefined
1568
1569 .PHONY: check-api-unused
1570 check-api-unused: defined undefined exported
1571         ( cat exported undefined ) | sort -u  | diff -u - defined | grep ^+ | grep -v ^+++ | cut -c2-
1572
1573 .PHONY: check-includes
1574 check-includes: $(top_srcdir)/tools/check-includes.pl
1575         $(AM_V_GEN) find * -name '*.[hcS]' -type f -print | sort -u \
1576                 | xargs $(top_srcdir)/tools/check-includes.pl
1577
1578 EXTRA_DIST += \
1579         $(top_srcdir)/tools/check-includes.pl
1580
1581 # Stupid test that everything purported to be exported really is
1582 define generate-sym-test
1583         $(AM_V_at)$(MKDIR_P) $(dir $@)
1584         $(AM_V_at)printf '#include <stdio.h>\n' > $@
1585         $(AM_V_at)printf '#include "%s"\n' $(notdir $(filter %.h, $^)) >> $@
1586         $(AM_V_at)printf 'void* functions[] = {\n' >> $@
1587         $(AM_V_GEN)sed -r -n 's/^ +([a-zA-Z0-9_]+);/\1,/p' $< >> $@
1588         $(AM_V_at)printf '};\nint main(void) {\n' >> $@
1589         $(AM_V_at)printf 'unsigned i; for (i=0;i<sizeof(functions)/sizeof(void*);i++) printf("%%p\\n", functions[i]);\n' >> $@
1590         $(AM_V_at)printf 'return 0; }\n' >> $@
1591 endef
1592
1593 test-libelogind-sym.c: \
1594                 $(top_builddir)/src/libelogind/libelogind.sym \
1595                 src/systemd/sd-daemon.h \
1596                 src/systemd/sd-login.h \
1597                 src/systemd/sd-bus.h \
1598                 src/systemd/sd-event.h
1599         $(generate-sym-test)
1600
1601 test_libelogind_sym_SOURCES = \
1602         test-libelogind-sym.c
1603 test_libelogind_sym_LDADD = \
1604         libelogind.la
1605
1606 BUILT_SOURCES += \
1607         $(test_libelogind_sym_SOURCES)
1608
1609 tests += \
1610         test-libelogind-sym
1611
1612 .PHONY: install-tests
1613 install-tests: $(tests) $(TEST_DATA_FILES)
1614         for f in $(tests); do \
1615             if [ -x $(top_builddir)/.libs/$$f ]; then \
1616                 install -D -m 755 $(top_builddir)/.libs/$$f $(DESTDIR)/$(testsdir)/$$f; \
1617             else \
1618                 install -D -m 755 $(top_builddir)/$$f $(DESTDIR)/$(testsdir)/$$f; \
1619             fi; \
1620         done
1621         for f in $(TEST_DATA_FILES); do \
1622             install -D -m 644 $(top_srcdir)/$$f $(DESTDIR)/$(testsdir)/testdata/$${f#test/}; \
1623         done
1624
1625 .PHONY: cccc cppcheck
1626 cccc: all
1627         cccc --outdir=$(top_builddir)/cccc \
1628         `find $(top_srcdir)/src/ -name '*.h' -or -name '*.c'`
1629
1630 cppcheck:
1631         cppcheck --enable=all -q \
1632         -I $(top_srcdir)/src \
1633         -I $(top_builddir)/src/basic \
1634         -I $(top_srcdir)/src/basic \
1635         -I $(top_srcdir)/src/core \
1636         -I $(top_srcdir)/src/shared \
1637         -I $(top_builddir)/src/shared \
1638         -I $(top_srcdir)/src/login \
1639         -I $(top_srcdir)/src/systemd \
1640         -I $(top_srcdir)/src/libelogind/sd-bus \
1641         -I $(top_srcdir)/src/libelogind/sd-event \
1642         -I $(top_srcdir)/src/libelogind/sd-login \
1643         -I $(top_srcdir)/src/libelogind/sd-id128 \
1644         -I $(top_srcdir)/src/update-utmp \
1645         -I $(top_srcdir)/src/sleep \
1646         --force \
1647         $(top_srcdir)
1648
1649 # Used to extract compile flags for YCM.
1650 print-%:
1651         @echo $($*)
1652
1653 git-contrib:
1654         @git shortlog -s `git describe --abbrev=0`.. | cut -c8- | sed 's/ / /g' | awk '{ print $$0 "," }' | sort -u
1655
1656 EXTRA_DIST += \
1657         tools/gdb-sd_dump_hashmaps.py
1658
1659 list-keys:
1660         gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --list-keys
1661
1662 add-key:
1663         gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --import -