chiark / gitweb /
Prep v229: Consolidate system sleep functions.
[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=14
42 LIBELOGIND_REVISION=0
43 LIBELOGIND_AGE=14
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 bashcompletiondir=@bashcompletiondir@
54 zshcompletiondir=@zshcompletiondir@
55
56 CGROUP_CONTROLLER=@cgroup_controller@
57 PKTTYAGENT=$(bindir)/pkttyagent
58
59 # Our own, non-special dirs
60 pkgsysconfdir=$(sysconfdir)/elogind
61 pkgincludedir=$(includedir)/elogind
62 udevrulesdir=@udevrulesdir@
63 udevbindir=@udevbindir@
64 udevlibexecdir=$(udevbindir)
65 udevhomedir=$(udevlibexecdir)
66 systemshutdowndir=$(rootlibexecdir)/system-shutdown
67 systemsleepdir=$(rootlibexecdir)/system-sleep
68 factory_pamdir = $(datadir)/factory/etc/pam.d
69
70 # And these are the special ones for /
71 rootprefix=@rootprefix@
72 rootbindir=$(rootprefix)/bin
73 rootlibexecdir=$(rootprefix)/lib/elogind
74
75 EXTRA_DIST =
76 BUILT_SOURCES =
77 INSTALL_EXEC_HOOKS =
78 UNINSTALL_EXEC_HOOKS =
79 INSTALL_DATA_HOOKS =
80 UNINSTALL_DATA_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 dist_udevrules_DATA =
91 nodist_udevrules_DATA =
92 dist_pkgsysconf_DATA =
93 dist_dbuspolicy_DATA =
94 dist_dbussystemservice_DATA =
95 check_PROGRAMS =
96 check_DATA =
97 tests=
98 manual_tests =
99 if ENABLE_TESTS
100 noinst_PROGRAMS = $(manual_tests) $(tests)
101 TESTS = $(tests)
102 else
103 noinst_PROGRAMS =
104 TESTS =
105 endif
106
107 if ENABLE_BASH_COMPLETION
108 dist_bashcompletion_DATA = $(dist_bashcompletion_data)
109 endif
110 if ENABLE_ZSH_COMPLETION
111 dist_zshcompletion_DATA = $(dist_zshcompletion_data)
112 endif
113
114 in_files = $(filter %.in,$(EXTRA_DIST))
115 in_in_files = $(filter %.in.in, $(in_files))
116 m4_files = $(filter %.m4,$(EXTRA_DIST) $(in_files:.m4.in=.m4))
117
118 CLEANFILES = $(BUILT_SOURCES) \
119         $(pkgconfiglib_DATA) \
120         $(in_files:.in=) $(in_in_files:.in.in=) \
121         $(m4_files:.m4=)
122
123 .PHONY: $(INSTALL_EXEC_HOOKS) $(UNINSTALL_EXEC_HOOKS) \
124         $(INSTALL_DATA_HOOKS) $(UNINSTALL_DATA_HOOKS) \
125         $(DISTCLEAN_LOCAL_HOOKS) $(CLEAN_LOCAL_HOOKS)
126
127 AM_CPPFLAGS = \
128         -include $(top_builddir)/config.h \
129         -DPKGSYSCONFDIR=\"$(pkgsysconfdir)\" \
130         -DSYSTEMD_CGROUP_CONTROLLER=\"$(CGROUP_CONTROLLER)\" \
131         -DELOGIND_CGROUP_AGENT_PATH=\"$(rootlibexecdir)/elogind-cgroups-agent\" \
132         -DUDEVLIBEXECDIR=\"$(udevlibexecdir)\" \
133         -DPOLKIT_AGENT_BINARY_PATH=\"$(PKTTYAGENT)\" \
134         -DSYSTEM_SLEEP_PATH=\"$(systemsleepdir)\" \
135         -DSYSTEM_SHUTDOWN_PATH=\"$(systemshutdowndir)\" \
136         -DHALT=\"$(HALT)\" \
137         -DREBOOT=\"$(REBOOT)\" \
138         -DKEXEC=\"$(KEXEC)\" \
139         -DLIBDIR=\"$(libdir)\" \
140         -DROOTLIBDIR=\"$(rootlibdir)\" \
141         -DROOTLIBEXECDIR=\"$(rootlibexecdir)\" \
142         -DTEST_DIR=\"$(abs_top_srcdir)/test\" \
143         -I $(top_srcdir)/src \
144         -I $(top_builddir)/src/basic \
145         -I $(top_srcdir)/src/basic \
146         -I $(top_srcdir)/src/core \
147         -I $(top_srcdir)/src/shared \
148         -I $(top_builddir)/src/shared \
149         -I $(top_srcdir)/src/login \
150         -I $(top_srcdir)/src/systemd \
151         -I $(top_srcdir)/src/libelogind/sd-bus \
152         -I $(top_srcdir)/src/libelogind/sd-event \
153         -I $(top_srcdir)/src/libelogind/sd-login \
154         $(OUR_CPPFLAGS)
155
156 AM_CFLAGS = $(OUR_CFLAGS)
157 AM_LDFLAGS = $(OUR_LDFLAGS)
158
159 # ------------------------------------------------------------------------------
160 define move-to-rootlibdir
161         if test "$(libdir)" != "$(rootlibdir)"; then \
162                 $(MKDIR_P) $(DESTDIR)$(rootlibdir) && \
163                 so_img_name=$$(readlink $(DESTDIR)$(libdir)/$$libname) && \
164                 rm -f $(DESTDIR)$(libdir)/$$libname && \
165                 $(LN_S) --relative -f $(DESTDIR)$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/$$libname && \
166                 mv $(DESTDIR)$(libdir)/$$libname.* $(DESTDIR)$(rootlibdir); \
167         fi
168 endef
169
170 install-touch-usr-hook:
171         touch -c $(DESTDIR)/$(prefix)
172
173 INSTALL_EXEC_HOOKS += \
174         install-touch-usr-hook
175
176
177 # ------------------------------------------------------------------------------
178 AM_V_M4 = $(AM_V_M4_$(V))
179 AM_V_M4_ = $(AM_V_M4_$(AM_DEFAULT_VERBOSITY))
180 AM_V_M4_0 = @echo "  M4      " $@;
181
182 AM_V_XSLT = $(AM_V_XSLT_$(V))
183 AM_V_XSLT_ = $(AM_V_XSLT_$(AM_DEFAULT_VERBOSITY))
184 AM_V_XSLT_0 = @echo "  XSLT    " $@;
185
186 AM_V_GPERF = $(AM_V_GPERF_$(V))
187 AM_V_GPERF_ = $(AM_V_GPERF_$(AM_DEFAULT_VERBOSITY))
188 AM_V_GPERF_0 = @echo "  GPERF   " $@;
189
190 AM_V_LN = $(AM_V_LN_$(V))
191 AM_V_LN_ = $(AM_V_LN_$(AM_DEFAULT_VERBOSITY))
192 AM_V_LN_0 = @echo "  LN      " $@;
193
194 AM_V_RM = $(AM_V_RM_$(V))
195 AM_V_RM_ = $(AM_V_RM_$(AM_DEFAULT_VERBOSITY))
196 AM_V_RM_0 = @echo "  RM      " $@;
197
198 # ------------------------------------------------------------------------------
199 rootbin_PROGRAMS =
200 pkglibexec_PROGRAMS =
201
202 dist_doc_DATA = \
203         README \
204         NEWS \
205         LICENSE.LGPL2.1 \
206         LICENSE.GPL2
207
208 @INTLTOOL_POLICY_RULE@
209
210 # ------------------------------------------------------------------------------
211
212 MANPAGES =
213 MANPAGES_ALIAS =
214
215 include Makefile-man.am
216
217 .PHONY: man update-man-list
218 man: $(MANPAGES) $(MANPAGES_ALIAS) $(HTML_FILES) $(HTML_ALIAS)
219
220 XML_FILES = \
221         ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,${patsubst %.8,%.xml,$(MANPAGES)}}}}}
222 HTML_FILES = \
223         ${XML_FILES:.xml=.html}
224 HTML_ALIAS = \
225         ${patsubst %.1,%.html,${patsubst %.3,%.html,${patsubst %.5,%.html,${patsubst %.7,%.html,${patsubst %.8,%.html,$(MANPAGES_ALIAS)}}}}}
226
227 if ENABLE_MANPAGES
228 man_MANS = \
229         $(MANPAGES) \
230         $(MANPAGES_ALIAS)
231
232 noinst_DATA += \
233         $(HTML_FILES) \
234         $(HTML_ALIAS) \
235         docs/html/man
236 endif
237
238 CLEANFILES += \
239         $(man_MANS) \
240         $(HTML_FILES) \
241         $(HTML_ALIAS) \
242         docs/html/man
243
244 docs/html/man:
245         $(AM_V_at)$(MKDIR_P) $(dir $@)
246         $(AM_V_LN)$(LN_S) -f ../../man $@
247
248 man/index.html: man/elogind.index.html
249         $(AM_V_LN)$(LN_S) -f elogind.index.html $@
250
251 if HAVE_PYTHON
252 noinst_DATA += \
253        man/index.html
254 endif
255
256 CLEANFILES += \
257        man/index.html
258
259 XML_GLOB            := $(wildcard $(top_srcdir)/man/*.xml)
260 DIRECTIVE_FILE      := man/elogind.directives.xml
261 INDEX_XML_FILE      := man/elogind.index.xml
262 NON_INDEX_XML_FILES := $(DIRECTIVE_FILE) $(filter-out $(INDEX_XML_FILE) $(DIRECTIVE_FILE),$(XML_FILES))
263 ALL_XML_FILES       := $(INDEX_XML_FILE) $(DIRECTIVE_FILE) $(filter-out $(INDEX_XML_FILE) $(DIRECTIVE_FILE),$(XML_GLOB))
264 SOURCE_XML_FILES    := ${patsubst %,$(top_srcdir)/%,$(filter-out $(DIRECTIVE_FILE),$(NON_INDEX_XML_FILES))}
265
266 # This target should only be run manually. It recreates Makefile-man.am
267 # file in the source directory based on all man/*.xml files. Run it after
268 # adding, removing, or changing the conditional in a man page.
269 update-man-list: $(top_srcdir)/tools/make-man-rules.py $(ALL_XML_FILES) man/custom-entities.ent
270         $(AM_V_GEN)$(PYTHON) $< $(ALL_XML_FILES) > $(top_srcdir)/Makefile-man.tmp
271         $(AM_V_at)mv $(top_srcdir)/Makefile-man.tmp $(top_srcdir)/Makefile-man.am
272         @echo "Makefile-man.am has been regenerated"
273
274 $(INDEX_XML_FILE): $(top_srcdir)/tools/make-man-index.py $(NON_INDEX_XML_FILES)
275         $(AM_V_at)$(MKDIR_P) $(dir $@)
276         $(AM_V_GEN)$(PYTHON) $< $@ $(filter-out $<,$^)
277
278 $(DIRECTIVE_FILE): $(top_srcdir)/tools/make-directive-index.py man/custom-entities.ent $(SOURCE_XML_FILES)
279         $(AM_V_at)$(MKDIR_P) $(dir $@)
280         $(AM_V_GEN)$(PYTHON) $< $@ $(SOURCE_XML_FILES)
281
282 CLEANFILES += \
283        $(INDEX_XML_FILE) \
284        $(DIRECTIVE_FILE)
285
286 EXTRA_DIST += \
287         $(filter-out $(DIRECTIVE_FILE) $(INDEX_XML_FILE),$(XML_FILES)) \
288         tools/make-man-index.py \
289         tools/make-man-rules.py \
290         tools/make-directive-index.py \
291         tools/xml_helper.py \
292         man/glib-event-glue.c
293
294 # ------------------------------------------------------------------------------
295 noinst_LTLIBRARIES += \
296         libbasic.la
297
298 libbasic_la_SOURCES = \
299         src/basic/missing.h \
300         src/basic/musl_missing.h \
301         src/basic/musl_missing.c \
302         src/basic/capability-util.c \
303         src/basic/capability-util.h \
304         src/basic/conf-files.c \
305         src/basic/conf-files.h \
306         src/basic/stdio-util.h \
307         src/basic/hostname-util.h \
308         src/basic/hostname-util.c \
309         src/basic/unit-name.c \
310         src/basic/unit-name.h \
311         src/basic/unaligned.h \
312         src/basic/util.c \
313         src/basic/util.h \
314         src/basic/io-util.c \
315         src/basic/io-util.h \
316         src/basic/string-util.c \
317         src/basic/string-util.h \
318         src/basic/parse-util.c \
319         src/basic/parse-util.h \
320         src/basic/fd-util.c \
321         src/basic/fd-util.h \
322         src/basic/user-util.c \
323         src/basic/user-util.h \
324         src/basic/dirent-util.c \
325         src/basic/dirent-util.h \
326         src/basic/xattr-util.c \
327         src/basic/xattr-util.h \
328         src/basic/proc-cmdline.c \
329         src/basic/proc-cmdline.h \
330         src/basic/fs-util.c \
331         src/basic/fs-util.h \
332         src/basic/syslog-util.c \
333         src/basic/syslog-util.h \
334         src/basic/stat-util.c \
335         src/basic/stat-util.h \
336         src/basic/mount-util.c \
337         src/basic/mount-util.h \
338         src/basic/hexdecoct.c \
339         src/basic/hexdecoct.h \
340         src/basic/extract-word.c \
341         src/basic/extract-word.h \
342         src/basic/escape.c \
343         src/basic/escape.h \
344         src/basic/path-util.c \
345         src/basic/path-util.h \
346         src/basic/time-util.c \
347         src/basic/time-util.h \
348         src/basic/locale-util.c \
349         src/basic/locale-util.h \
350         src/basic/umask-util.h \
351         src/basic/signal-util.c \
352         src/basic/signal-util.h \
353         src/basic/string-table.c \
354         src/basic/string-table.h \
355         src/basic/mempool.c \
356         src/basic/mempool.h \
357         src/basic/hashmap.c \
358         src/basic/hashmap.h \
359         src/basic/hash-funcs.c \
360         src/basic/hash-funcs.h \
361         src/basic/siphash24.c \
362         src/basic/siphash24.h \
363         src/basic/prioq.c \
364         src/basic/prioq.h \
365         src/basic/strv.c \
366         src/basic/strv.h \
367         src/basic/log.c \
368         src/basic/log.h \
369         src/basic/bus-label.c \
370         src/basic/bus-label.h \
371         src/basic/virt.c \
372         src/basic/virt.h \
373         src/basic/smack-util.c \
374         src/basic/smack-util.h \
375         src/basic/utf8.c \
376         src/basic/utf8.h \
377         src/basic/gunicode.c \
378         src/basic/gunicode.h \
379         src/basic/socket-util.c \
380         src/basic/socket-util.h \
381         src/basic/fileio.c \
382         src/basic/fileio.h \
383         src/basic/mkdir.c \
384         src/basic/mkdir.h \
385         src/basic/cgroup-util.c \
386         src/basic/cgroup-util.h \
387         src/basic/errno-list.c \
388         src/basic/errno-list.h \
389         src/basic/terminal-util.c \
390         src/basic/terminal-util.h \
391         src/basic/login-util.h \
392         src/basic/login-util.c \
393         src/basic/audit-util.c \
394         src/basic/audit-util.h \
395         src/basic/memfd-util.c \
396         src/basic/memfd-util.h \
397         src/basic/process-util.c \
398         src/basic/process-util.h \
399         src/basic/random-util.c \
400         src/basic/random-util.h \
401         src/basic/verbs.c \
402         src/basic/verbs.h \
403         src/basic/label.c \
404         src/basic/label.h \
405         src/basic/selinux-util.c \
406         src/basic/selinux-util.h \
407         src/basic/mkdir-label.c \
408         src/basic/fileio-label.c \
409         src/basic/fileio-label.h \
410         src/basic/rm-rf.c \
411         src/basic/rm-rf.h \
412         src/basic/copy.c \
413         src/basic/copy.h \
414         src/basic/alloc-util.h \
415         src/basic/alloc-util.c \
416         src/basic/parse-printf-format.c \
417         src/basic/parse-printf-format.h
418
419 nodist_libbasic_la_SOURCES = \
420         src/basic/errno-from-name.h \
421         src/basic/errno-to-name.h
422
423 libbasic_la_CFLAGS = \
424         $(AM_CFLAGS) \
425         $(SELINUX_CFLAGS) \
426         $(CAP_CFLAGS) \
427         -pthread
428
429 libbasic_la_LDFLAGS = \
430         $(CAP_LDFLAGS)
431
432 libbasic_la_LIBADD = \
433         $(SELINUX_LIBS) \
434         $(CAP_LIBS) \
435         -ldl \
436         -lm
437
438 # -----------------------------------------------------------------------------
439 noinst_LTLIBRARIES += \
440         libshared.la
441
442 libshared_la_SOURCES = \
443         src/shared/conf-parser.c \
444         src/shared/conf-parser.h \
445         src/shared/pager.c \
446         src/shared/pager.h \
447         src/shared/spawn-polkit-agent.c \
448         src/shared/spawn-polkit-agent.h \
449         src/shared/clean-ipc.c \
450         src/shared/clean-ipc.h \
451         src/shared/bus-util.c \
452         src/shared/bus-util.h
453
454 if HAVE_ACL
455 libshared_la_SOURCES += \
456         src/shared/acl-util.c \
457         src/shared/acl-util.h
458 endif
459
460 libshared_la_CFLAGS = \
461         $(AM_CFLAGS) \
462         $(ACL_CFLAGS)
463
464 libshared_la_LIBADD = \
465         libelogind-internal.la \
466         $(UDEV_LIBS) \
467         $(ACL_LIBS)
468
469 gperf_txt_sources = \
470         src/basic/errno-list.txt
471
472 BUILT_SOURCES += \
473         $(gperf_gperf_m4_sources:-gperf.gperf.m4=-gperf.c) \
474         $(gperf_gperf_sources:-gperf.gperf=-gperf.c) \
475         $(gperf_txt_sources:-list.txt=-from-name.h) \
476         $(gperf_txt_sources:-list.txt=-to-name.h)
477
478 CLEANFILES += \
479         $(gperf_txt_sources:-list.txt=-from-name.gperf)
480 DISTCLEANFILES = \
481         $(gperf_txt_sources)
482
483 EXTRA_DIST += \
484         $(gperf_gperf_m4_sources) \
485         $(gperf_gperf_sources)
486
487 CLEANFILES += \
488         $(gperf_txt_sources)
489
490 %-from-name.gperf: %-list.txt
491         $(AM_V_at)$(MKDIR_P) $(dir $@)
492         $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct $(notdir $*)_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@
493
494 %-from-name.h: %-from-name.gperf
495         $(AM_V_at)$(MKDIR_P) $(dir $@)
496         $(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_$(notdir $*) -H hash_$(notdir $*)_name -p -C <$< >$@
497
498
499 src/basic/errno-list.txt:
500         $(AM_V_at)$(MKDIR_P) $(dir $@)
501         $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - </dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+/ { print $$2; }' >$@
502
503 src/basic/errno-to-name.h: src/basic/errno-list.txt
504         $(AM_V_at)$(MKDIR_P) $(dir $@)
505         $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
506
507
508 # ------------------------------------------------------------------------------
509
510 if HAVE_PAM
511 dist_factory_pam_DATA = \
512         factory/etc/pam.d/system-auth \
513         factory/etc/pam.d/other
514 endif
515
516 # ------------------------------------------------------------------------------
517 pkglibexec_PROGRAMS += \
518        elogind-cgroups-agent
519
520 elogind_cgroups_agent_SOURCES = \
521        src/cgroups-agent/cgroups-agent.c
522
523 elogind_cgroups_agent_LDADD = \
524        libshared.la
525
526 # ------------------------------------------------------------------------------
527 libelogind_internal_la_SOURCES = \
528         src/systemd/sd-bus.h \
529         src/systemd/sd-bus-protocol.h \
530         src/systemd/sd-bus-vtable.h \
531         src/systemd/sd-event.h \
532         src/systemd/sd-login.h \
533         src/systemd/sd-id128.h \
534         src/systemd/sd-daemon.h \
535         src/libelogind/libelogind.sym \
536         src/libelogind/sd-bus/sd-bus.c \
537         src/libelogind/sd-bus/bus-control.c \
538         src/libelogind/sd-bus/bus-control.h \
539         src/libelogind/sd-bus/bus-error.c \
540         src/libelogind/sd-bus/bus-error.h \
541         src/libelogind/sd-bus/bus-common-errors.h \
542         src/libelogind/sd-bus/bus-common-errors.c \
543         src/libelogind/sd-bus/bus-internal.c \
544         src/libelogind/sd-bus/bus-internal.h \
545         src/libelogind/sd-bus/bus-socket.c \
546         src/libelogind/sd-bus/bus-socket.h \
547         src/libelogind/sd-bus/bus-kernel.c \
548         src/libelogind/sd-bus/bus-kernel.h \
549         src/libelogind/sd-bus/bus-container.c \
550         src/libelogind/sd-bus/bus-container.h \
551         src/libelogind/sd-bus/bus-message.c \
552         src/libelogind/sd-bus/bus-message.h \
553         src/libelogind/sd-bus/bus-creds.c \
554         src/libelogind/sd-bus/bus-creds.h \
555         src/libelogind/sd-bus/bus-signature.c \
556         src/libelogind/sd-bus/bus-signature.h \
557         src/libelogind/sd-bus/bus-type.c \
558         src/libelogind/sd-bus/bus-type.h \
559         src/libelogind/sd-bus/bus-match.c \
560         src/libelogind/sd-bus/bus-match.h \
561         src/libelogind/sd-bus/bus-bloom.c \
562         src/libelogind/sd-bus/bus-bloom.h \
563         src/libelogind/sd-bus/bus-introspect.c \
564         src/libelogind/sd-bus/bus-introspect.h \
565         src/libelogind/sd-bus/bus-objects.c \
566         src/libelogind/sd-bus/bus-objects.h \
567         src/libelogind/sd-bus/bus-gvariant.c \
568         src/libelogind/sd-bus/bus-gvariant.h \
569         src/libelogind/sd-bus/bus-convenience.c \
570         src/libelogind/sd-bus/bus-track.c \
571         src/libelogind/sd-bus/bus-track.h \
572         src/libelogind/sd-bus/bus-slot.c \
573         src/libelogind/sd-bus/bus-slot.h \
574         src/libelogind/sd-bus/bus-protocol.h \
575         src/libelogind/sd-event/sd-event.c \
576         src/libelogind/sd-id128/sd-id128.c \
577         src/libelogind/sd-daemon/sd-daemon.c \
578         src/libelogind/sd-login/sd-login.c
579
580 libelogind_internal_la_LIBADD = \
581         libbasic.la \
582         -lresolv
583
584 noinst_LTLIBRARIES += \
585         libelogind-internal.la
586
587 EXTRA_DIST += \
588         src/libelogind/libelogind.pc.in \
589         src/libelogind/sd-bus/DIFFERENCES \
590         src/libelogind/sd-bus/GVARIANT-SERIALIZATION
591
592 libelogind_la_SOURCES = \
593         $(libelogind_internal_la_SOURCES)
594
595 nodist_libelogind_la_SOURCES = \
596         $(nodist_libelogind_internal_la_SOURCES)
597
598 libelogind_la_CFLAGS = \
599         $(libelogind_internal_la_CFLAGS)
600
601 libelogind_la_LDFLAGS = \
602         $(AM_LDFLAGS) \
603         -version-info $(LIBELOGIND_CURRENT):$(LIBELOGIND_REVISION):$(LIBELOGIND_AGE) \
604         -Wl,--version-script=$(top_srcdir)/src/libelogind/libelogind.sym
605
606 libelogind_la_LIBADD = \
607         $(libelogind_internal_la_LIBADD)
608
609 libelogind-install-hook:
610         libname=libelogind.so && $(move-to-rootlibdir)
611
612 libelogind-uninstall-hook:
613         rm -f $(DESTDIR)$(rootlibdir)/libelogind.so*
614
615 INSTALL_EXEC_HOOKS += libelogind-install-hook
616 UNINSTALL_EXEC_HOOKS += libelogind-uninstall-hook
617
618 pkgconfiglib_DATA += \
619         src/libelogind/libelogind.pc
620
621 pkginclude_HEADERS += \
622         src/systemd/sd-login.h \
623         src/systemd/sd-messages.h \
624         src/systemd/sd-id128.h \
625         src/systemd/_sd-common.h
626
627
628 lib_LTLIBRARIES += \
629         libelogind.la
630
631 # ------------------------------------------------------------------------------
632 elogind_SOURCES = \
633         src/login/logind.c \
634         src/login/logind.h
635
636 nodist_elogind_SOURCES = \
637         src/login/logind-gperf.c
638
639 elogind_LDADD = \
640         libelogind-core.la
641
642 libelogind_core_la_SOURCES = \
643         src/login/logind-core.c \
644         src/login/logind-device.c \
645         src/login/logind-device.h \
646         src/login/logind-button.c \
647         src/login/logind-button.h \
648         src/login/logind-action.c \
649         src/login/logind-action.h \
650         src/login/logind-seat.c \
651         src/login/logind-seat.h \
652         src/login/logind-session.c \
653         src/login/logind-session.h \
654         src/login/logind-session-device.c \
655         src/login/logind-session-device.h \
656         src/login/logind-sleep.c \
657         src/login/logind-sleep.h \
658         src/login/logind-user.c \
659         src/login/logind-user.h \
660         src/login/logind-inhibit.c \
661         src/login/logind-inhibit.h \
662         src/login/logind-dbus.c \
663         src/login/logind-session-dbus.c \
664         src/login/logind-seat-dbus.c \
665         src/login/logind-user-dbus.c \
666         src/login/logind-acl.h \
667         src/core/cgroup.h \
668         src/core/cgroup.c \
669         src/core/mount-setup.h \
670         src/core/mount-setup.c
671
672 libelogind_core_la_LIBADD = \
673         libshared.la
674
675 if HAVE_ACL
676 libelogind_core_la_SOURCES += \
677         src/login/logind-acl.c
678 endif
679
680 noinst_LTLIBRARIES += \
681         libelogind-core.la
682
683 pkglibexec_PROGRAMS += \
684         elogind
685
686 loginctl_SOURCES = \
687         src/login/loginctl.c \
688         src/login/sysfs-show.h \
689         src/login/sysfs-show.c
690
691 loginctl_LDADD = \
692         libshared.la
693
694 rootbin_PROGRAMS += \
695         loginctl
696
697 dist_bashcompletion_data = \
698         shell-completion/bash/loginctl
699
700 dist_zshcompletion_data = \
701         shell-completion/zsh/_loginctl \
702         shell-completion/zsh/_elogind-inhibit
703
704 elogind_inhibit_SOURCES = \
705         src/login/inhibit.c
706
707 elogind_inhibit_LDADD = \
708         libshared.la
709
710 rootbin_PROGRAMS += \
711         elogind-inhibit
712
713 test_login_SOURCES = \
714         src/libelogind/sd-login/test-login.c
715
716 test_login_LDADD = \
717         libshared.la
718
719 test_login_shared_SOURCES = \
720         src/login/test-login-shared.c
721
722 test_login_shared_LDADD = \
723         libshared.la
724
725 test_inhibit_SOURCES = \
726         src/login/test-inhibit.c
727
728 test_inhibit_LDADD = \
729         libshared.la
730
731 test_login_tables_SOURCES = \
732         src/login/test-login-tables.c
733
734 test_login_tables_LDADD = \
735         libelogind-core.la
736
737 manual_tests += \
738         test-login \
739         test-inhibit
740
741 tests += \
742         test-login-tables \
743         test-login-shared
744
745 if HAVE_PAM
746 pam_elogind_la_SOURCES = \
747         src/login/pam_elogind.sym \
748         src/login/pam_elogind.c
749
750 pam_elogind_la_CFLAGS = \
751         $(AM_CFLAGS) \
752         $(PAM_CFLAGS)
753
754 pam_elogind_la_LDFLAGS = \
755         $(AM_LDFLAGS) \
756         -module \
757         -export-dynamic \
758         -avoid-version \
759         -shared \
760         -Wl,--version-script=$(top_srcdir)/src/login/pam_elogind.sym
761
762 pam_elogind_la_LIBADD = \
763         libshared.la \
764         $(PAM_LIBS)
765
766 pamlib_LTLIBRARIES = \
767         pam_elogind.la
768
769 dist_pamconf_DATA = \
770         src/login/elogind-user
771
772 EXTRA_DIST += \
773         src/login/elogind-user.m4
774 endif
775
776 dist_dbussystemservice_DATA += \
777         src/login/org.freedesktop.login1.service
778
779 dist_dbuspolicy_DATA += \
780         src/login/org.freedesktop.login1.conf
781
782 dist_pkgsysconf_DATA += \
783         src/login/logind.conf
784
785 polkitpolicy_files += \
786         src/login/org.freedesktop.login1.policy
787
788 dist_udevrules_DATA += \
789         src/login/70-uaccess.rules \
790         src/login/70-power-switch.rules
791
792 nodist_udevrules_DATA += \
793         src/login/71-seat.rules \
794         src/login/73-seat-late.rules
795
796 polkitpolicy_in_files += \
797         src/login/org.freedesktop.login1.policy.in
798
799 gperf_gperf_sources = \
800         src/login/logind-gperf.gperf
801
802 EXTRA_DIST += \
803         src/login/71-seat.rules.in \
804         src/login/73-seat-late.rules.in
805
806 # ------------------------------------------------------------------------------
807 substitutions = \
808        '|rootlibexecdir=$(rootlibexecdir)|' \
809        '|rootbindir=$(rootbindir)|' \
810        '|bindir=$(bindir)|' \
811        '|pkgsysconfdir=$(pkgsysconfdir)|' \
812        '|pkgdatadir=$(pkgdatadir)|' \
813        '|udevrulesdir=$(udevrulesdir)|' \
814        '|PACKAGE_VERSION=$(PACKAGE_VERSION)|' \
815        '|PACKAGE_NAME=$(PACKAGE_NAME)|' \
816        '|PACKAGE_URL=$(PACKAGE_URL)|' \
817        '|prefix=$(prefix)|' \
818        '|exec_prefix=$(exec_prefix)|' \
819        '|libdir=$(libdir)|' \
820        '|includedir=$(includedir)|' \
821        '|VERSION=$(VERSION)|' \
822        '|rootprefix=$(rootprefix)|' \
823        '|udevlibexecdir=$(udevlibexecdir)|' \
824        '|KILL=$(KILL)|' \
825        '|MKDIR_P=$(MKDIR_P)|' \
826        '|systemuidmax=$(SYSTEM_UID_MAX)|' \
827        '|systemgidmax=$(SYSTEM_GID_MAX)|' \
828        '|TTY_GID=$(TTY_GID)|'
829
830 SED_PROCESS = \
831         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
832         $(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) \
833                 < $< > $@
834
835 man/%: man/%.in
836         $(SED_PROCESS)
837
838 sysctl.d/%: sysctl.d/%.in
839         $(SED_PROCESS)
840
841 %.pc: %.pc.in
842         $(SED_PROCESS)
843
844 shell-completion/%: shell-completion/%.in
845         $(SED_PROCESS)
846
847 %.rules: %.rules.in
848         $(SED_PROCESS)
849
850 %.conf: %.conf.in
851         $(SED_PROCESS)
852
853 %.sh: %.sh.in
854         $(SED_PROCESS)
855         $(AM_V_GEN)chmod +x $@
856
857 src/%.c: src/%.gperf
858         $(AM_V_at)$(MKDIR_P) $(dir $@)
859         $(AM_V_GPERF)$(GPERF) < $< > $@
860
861 src/%: src/%.m4
862         $(AM_V_at)$(MKDIR_P) $(dir $@)
863         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
864
865 sysusers.d/%: sysusers.d/%.m4
866         $(AM_V_at)$(MKDIR_P) $(dir $@)
867         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
868
869 tmpfiles.d/%: tmpfiles.d/%.m4
870         $(AM_V_at)$(MKDIR_P) $(dir $@)
871         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
872
873
874 units/%: units/%.m4
875         $(AM_V_at)$(MKDIR_P) $(dir $@)
876         $(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_SYSTEM=1 < $< > $@
877
878 units/user/%: units/user/%.m4
879         $(AM_V_at)$(MKDIR_P) $(dir $@)
880         $(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_USER=1 < $< > $@
881
882 if ENABLE_POLKIT
883 nodist_polkitpolicy_DATA = \
884         $(polkitpolicy_files)
885 endif
886
887 EXTRA_DIST += \
888         $(polkitpolicy_in_files)
889
890 # ------------------------------------------------------------------------------
891 if ENABLE_MANPAGES
892 man/custom-entities.ent: configure.ac
893         $(AM_V_GEN)$(MKDIR_P) $(dir $@)
894         $(AM_V_GEN)(echo '<?xml version="1.0" encoding="utf-8" ?>' && \
895          printf '$(subst '|,<!ENTITY ,$(subst =, ",$(subst |',">\n,$(substitutions))))') \
896          > $@ # '
897
898 CLEANFILES += \
899         man/custom-entities.ent
900
901 XSLTPROC_FLAGS = \
902         --nonet \
903         --xinclude \
904         --stringparam man.output.quietly 1 \
905         --stringparam funcsynopsis.style ansi \
906         --stringparam man.authors.section.enabled 0 \
907         --stringparam man.copyright.section.enabled 0 \
908         --stringparam elogind.version $(VERSION) \
909         --path '$(builddir)/man:$(srcdir)/man'
910
911 XSLTPROC_PROCESS_MAN = \
912         $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-man.xsl $<
913
914 XSLTPROC_PROCESS_HTML = \
915         $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-html.xsl $<
916
917 man/%.1: man/%.xml man/custom-man.xsl man/custom-entities.ent
918         $(XSLTPROC_PROCESS_MAN)
919
920 man/%.3: man/%.xml man/custom-man.xsl man/custom-entities.ent
921         $(XSLTPROC_PROCESS_MAN)
922
923 man/%.5: man/%.xml man/custom-man.xsl man/custom-entities.ent
924         $(XSLTPROC_PROCESS_MAN)
925
926 man/%.7: man/%.xml man/custom-man.xsl man/custom-entities.ent
927         $(XSLTPROC_PROCESS_MAN)
928
929 man/%.8: man/%.xml man/custom-man.xsl man/custom-entities.ent
930         $(XSLTPROC_PROCESS_MAN)
931
932 man/%.html: man/%.xml man/custom-html.xsl man/custom-entities.ent
933         $(XSLTPROC_PROCESS_HTML)
934
935 define html-alias
936         $(AM_V_LN)$(LN_S) -f $(notdir $<) $@
937 endef
938
939 endif
940
941 EXTRA_DIST += \
942         man/custom-html.xsl \
943         man/custom-man.xsl
944
945 install-exec-hook: $(INSTALL_EXEC_HOOKS)
946
947 uninstall-hook: $(UNINSTALL_DATA_HOOKS) $(UNINSTALL_EXEC_HOOKS)
948
949 install-data-hook: $(INSTALL_DATA_HOOKS)
950
951 distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
952
953 clean-local: $(CLEAN_LOCAL_HOOKS)
954         rm -rf $(abs_srcdir)/install-tree
955         rm -f $(abs_srcdir)/hwdb/usb.ids $(abs_srcdir)/hwdb/pci.ids $(abs_srcdir)/hwdb/oui.txt \
956               $(abs_srcdir)/hwdb/iab.txt
957
958 DISTCHECK_CONFIGURE_FLAGS = \
959         --with-dbuspolicydir=$$dc_install_base/$(dbuspolicydir) \
960         --with-dbussystemservicedir=$$dc_install_base/$(dbussystemservicedir) \
961         --with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir) \
962         --with-zshcompletiondir=$$dc_install_base/$(zshcompletiondir) \
963         --with-pamlibdir=$$dc_install_base/$(pamlibdir) \
964         --with-pamconfdir=$$dc_install_base/$(pamconfdir) \
965         --with-rootprefix=$$dc_install_base
966
967 if ENABLE_SPLIT_USR
968 DISTCHECK_CONFIGURE_FLAGS += \
969         --enable-split-usr
970 else
971 DISTCHECK_CONFIGURE_FLAGS += \
972         --disable-split-usr
973 endif
974
975 .PHONY: dist-check-help
976
977 dist-check-help: $(rootbin_PROGRAMS)
978         for i in $(abspath $^); do                                             \
979             if $$i  --help | grep -v 'default:' | grep -E -q '.{80}.' ; then   \
980                 echo "$(basename $$i) --help output is too wide:";             \
981                 $$i  --help | awk 'length > 80' | grep -E --color=yes '.{80}'; \
982                 exit 1;                                                        \
983             fi; done
984
985 dist:
986
987 .PHONY: git-tag
988 git-tag:
989         git tag -s "v$(VERSION)" -m "elogind $(VERSION)"
990
991 .PHONY: git-tar
992 git-tar:
993         $(AM_V_at)git archive --format=tar --prefix=elogind-$(VERSION)-raw/ HEAD | \
994                 (cd /var/tmp/ && tar xf -)
995         $(AM_V_GEN)(cd /var/tmp && rm -rf elogind-$(VERSION) && $(MKDIR_P) elogind-$(VERSION) && \
996          for f in `find elogind-$(VERSION)-raw/ -type f | cut -d '/' -f 2-` ; do \
997                 $(MKDIR_P) elogind-$(VERSION)/`dirname $$f` ;            \
998                 $(AWK) 'BEGIN                    { i=0;e=0      }        \
999                         /^#if\s+0.*elogind.*$$/  { i=1;next     }        \
1000                         /^#else\s*$$/            {                       \
1001                             { if ( i==1 ) e=1; else print }{next}        \
1002                         }                                                \
1003                         /^#endif\s*\/\/\s*0\s*$$/ {                      \
1004                             { if ( i==1 ) { i=0;e=0 } else print }{next} \
1005                         }                                                \
1006                         /^\s*\/\/\/.*elogind.*$$/{ next         }        \
1007                         /^\s*\/\/\s*#include.+$$/{ next         }        \
1008                         { if ( (i==0) || (e==1) ) print         }'       \
1009                           elogind-$(VERSION)-raw/$$f                     \
1010                         > elogind-$(VERSION)/$$f ;                       \
1011                         chmod `stat -c '%a' elogind-$(VERSION)-raw/$$f`  \
1012                                             elogind-$(VERSION)/$$f ;     \
1013          done ; \
1014          for l in `find elogind-$(VERSION)-raw/ -type l | cut -d '/' -f 2-` ; do \
1015                 $(MKDIR_P) elogind-$(VERSION)/`dirname $$l` ; \
1016                 cp -P elogind-$(VERSION)-raw/$$l elogind-$(VERSION)/$$l ; \
1017          done ; \
1018          tar czf elogind-$(VERSION).tar.gz elogind-$(VERSION) ; \
1019          rm -rf elogind-$(VERSION) elogind-$(VERSION)-raw) ; \
1020         $(AM_V_at)mv /var/tmp/elogind-$(VERSION).tar.gz ./
1021
1022 .PHONY: install-tree
1023 install-tree: all
1024         rm -rf $(abs_srcdir)/install-tree
1025         $(MAKE) install DESTDIR=$(abs_srcdir)/install-tree
1026         tree $(abs_srcdir)/install-tree
1027
1028 # Let's run all tests of the test suite, but under valgrind. Let's
1029 # exclude the one perl script we have in there
1030 .PHONY: valgrind-tests
1031 valgrind-tests: $(TESTS)
1032         $(AM_V_GEN)for f in $(filter-out %.pl, $^); do \
1033                 if file $$f | grep -q shell; then \
1034                 echo -e "$${x}Skipping non-binary $$f"; else \
1035                 echo -e "$${x}Running $$f"; \
1036                 libtool --mode=execute valgrind -q --leak-check=full --max-stackframe=5242880 --error-exitcode=55 $(builddir)/$$f ; fi; \
1037                 x="\n\n"; \
1038         done
1039
1040 exported-%: %
1041         $(AM_V_GEN)$(NM) -g --defined-only $(builddir)/.libs/$(<:.la=.so) 2>&1 /dev/null | grep " T " | cut -d" " -f3 > $@
1042
1043 exported: $(addprefix exported-, $(lib_LTLIBRARIES))
1044         $(AM_V_GEN)cat $^ > $@
1045
1046 .PHONY: check-api-docs
1047 check-api-docs: exported man
1048         $(AM_V_GEN)for symbol in `cat exported` ; do \
1049                 if test -f $(builddir)/man/$$symbol.html ; then \
1050                         echo "  Symbol $$symbol() is documented." ; \
1051                 else \
1052                         echo "‣ Symbol $$symbol() lacks documentation." ; \
1053                 fi ; \
1054         done
1055
1056 OBJECT_VARIABLES:=$(filter %_OBJECTS,$(.VARIABLES))
1057 ALL_OBJECTS:=$(foreach v,$(OBJECT_VARIABLES),$($(v)))
1058
1059 undefined defined: $(ALL_OBJECTS)
1060         $(AM_V_GEN)for f in $(ALL_OBJECTS) ; do \
1061                 $(NM) -g --$@-only `echo $(builddir)/"$$f" | sed -e 's,\([^/]*\).lo$$,.libs/\1.o,'` ; \
1062         done | cut -c 20- | cut -d @ -f 1 | sort -u > $@
1063
1064 CLEANFILES += \
1065         defined \
1066         undefined
1067
1068 .PHONY: check-api-unused
1069 check-api-unused: defined undefined exported
1070         ( cat exported undefined ) | sort -u  | diff -u - defined | grep ^+ | grep -v ^+++ | cut -c2-
1071
1072 .PHONY: check-includes
1073 check-includes: $(top_srcdir)/tools/check-includes.pl
1074         $(AM_V_GEN) find * -name '*.[hcS]' -type f -print | sort -u \
1075                 | xargs $(top_srcdir)/tools/check-includes.pl
1076
1077 EXTRA_DIST += \
1078         $(top_srcdir)/tools/check-includes.pl
1079
1080 # Stupid test that everything purported to be exported really is
1081 define generate-sym-test
1082         $(AM_V_at)$(MKDIR_P) $(dir $@)
1083         $(AM_V_at)printf '#include <stdio.h>\n' > $@
1084         $(AM_V_at)printf '#include "%s"\n' $(notdir $(filter %.h, $^)) >> $@
1085         $(AM_V_at)printf 'void* functions[] = {\n' >> $@
1086         $(AM_V_GEN)sed -r -n 's/^ +([a-zA-Z0-9_]+);/\1,/p' $< >> $@
1087         $(AM_V_at)printf '};\nint main(void) {\n' >> $@
1088         $(AM_V_at)printf 'unsigned i; for (i=0;i<sizeof(functions)/sizeof(void*);i++) printf("%%p\\n", functions[i]);\n' >> $@
1089         $(AM_V_at)printf 'return 0; }\n' >> $@
1090 endef
1091
1092 test-libelogind-sym.c: \
1093                 $(top_builddir)/src/libelogind/libelogind.sym \
1094                 src/systemd/sd-daemon.h \
1095                 src/systemd/sd-login.h \
1096                 src/systemd/sd-bus.h \
1097                 src/systemd/sd-event.h
1098         $(generate-sym-test)
1099
1100 test_libelogind_sym_SOURCES = \
1101         test-libelogind-sym.c
1102 test_libelogind_sym_LDADD = \
1103         libelogind.la
1104
1105 BUILT_SOURCES += \
1106         $(test_libelogind_sym_SOURCES)
1107
1108 tests += \
1109         test-libelogind-sym
1110
1111 .PHONY: cppcheck
1112 cppcheck:
1113         cppcheck --enable=all -q $(top_srcdir)
1114
1115 # Used to extract compile flags for YCM.
1116 print-%:
1117         @echo $($*)
1118
1119 git-contrib:
1120         @git shortlog -s `git describe --abbrev=0`.. | cut -c8- | awk '{ print $$0 "," }' | sort -u
1121
1122 EXTRA_DIST += \
1123         tools/gdb-sd_dump_hashmaps.py
1124
1125 list-keys:
1126         gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --list-keys
1127
1128 add-key:
1129         gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --import -