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