chiark / gitweb /
Merge pull request #7 from elogind/dev_v228-r1
[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=13
42 LIBELOGIND_REVISION=0
43 LIBELOGIND_AGE=13
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 in_files = $(filter %.in,$(EXTRA_DIST))
108 in_in_files = $(filter %.in.in, $(in_files))
109 m4_files = $(filter %.m4,$(EXTRA_DIST) $(in_files:.m4.in=.m4))
110
111 CLEANFILES = $(BUILT_SOURCES) \
112         $(pkgconfiglib_DATA) \
113         $(in_files:.in=) $(in_in_files:.in.in=) \
114         $(m4_files:.m4=)
115
116 .PHONY: $(INSTALL_EXEC_HOOKS) $(UNINSTALL_EXEC_HOOKS) \
117         $(INSTALL_DATA_HOOKS) $(UNINSTALL_DATA_HOOKS) \
118         $(DISTCLEAN_LOCAL_HOOKS) $(CLEAN_LOCAL_HOOKS)
119
120 AM_CPPFLAGS = \
121         -include $(top_builddir)/config.h \
122         -DPKGSYSCONFDIR=\"$(pkgsysconfdir)\" \
123         -DSYSTEMD_CGROUP_CONTROLLER=\"$(CGROUP_CONTROLLER)\" \
124         -DELOGIND_CGROUP_AGENT_PATH=\"$(rootlibexecdir)/elogind-cgroups-agent\" \
125         -DUDEVLIBEXECDIR=\"$(udevlibexecdir)\" \
126         -DPOLKIT_AGENT_BINARY_PATH=\"$(PKTTYAGENT)\" \
127         -DSYSTEM_SLEEP_PATH=\"$(systemsleepdir)\" \
128         -DSYSTEM_SHUTDOWN_PATH=\"$(systemshutdowndir)\" \
129         -DHALT=\"$(HALT)\" \
130         -DREBOOT=\"$(REBOOT)\" \
131         -DKEXEC=\"$(KEXEC)\" \
132         -DLIBDIR=\"$(libdir)\" \
133         -DROOTLIBDIR=\"$(rootlibdir)\" \
134         -DROOTLIBEXECDIR=\"$(rootlibexecdir)\" \
135         -DTEST_DIR=\"$(abs_top_srcdir)/test\" \
136         -I $(top_srcdir)/src \
137         -I $(top_builddir)/src/basic \
138         -I $(top_srcdir)/src/basic \
139         -I $(top_srcdir)/src/core \
140         -I $(top_srcdir)/src/shared \
141         -I $(top_builddir)/src/shared \
142         -I $(top_srcdir)/src/login \
143         -I $(top_srcdir)/src/systemd \
144         -I $(top_srcdir)/src/libelogind/sd-bus \
145         -I $(top_srcdir)/src/libelogind/sd-event \
146         -I $(top_srcdir)/src/libelogind/sd-login \
147         $(OUR_CPPFLAGS)
148
149 AM_CFLAGS = $(OUR_CFLAGS)
150 AM_LDFLAGS = $(OUR_LDFLAGS)
151
152 # ------------------------------------------------------------------------------
153 define move-to-rootlibdir
154         if test "$(libdir)" != "$(rootlibdir)"; then \
155                 $(MKDIR_P) $(DESTDIR)$(rootlibdir) && \
156                 so_img_name=$$(readlink $(DESTDIR)$(libdir)/$$libname) && \
157                 rm -f $(DESTDIR)$(libdir)/$$libname && \
158                 $(LN_S) --relative -f $(DESTDIR)$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/$$libname && \
159                 mv $(DESTDIR)$(libdir)/$$libname.* $(DESTDIR)$(rootlibdir); \
160         fi
161 endef
162
163 install-touch-usr-hook:
164         touch -c $(DESTDIR)/$(prefix)
165
166 INSTALL_EXEC_HOOKS += \
167         install-touch-usr-hook
168
169
170 # ------------------------------------------------------------------------------
171 AM_V_M4 = $(AM_V_M4_$(V))
172 AM_V_M4_ = $(AM_V_M4_$(AM_DEFAULT_VERBOSITY))
173 AM_V_M4_0 = @echo "  M4      " $@;
174
175 AM_V_XSLT = $(AM_V_XSLT_$(V))
176 AM_V_XSLT_ = $(AM_V_XSLT_$(AM_DEFAULT_VERBOSITY))
177 AM_V_XSLT_0 = @echo "  XSLT    " $@;
178
179 AM_V_GPERF = $(AM_V_GPERF_$(V))
180 AM_V_GPERF_ = $(AM_V_GPERF_$(AM_DEFAULT_VERBOSITY))
181 AM_V_GPERF_0 = @echo "  GPERF   " $@;
182
183 AM_V_LN = $(AM_V_LN_$(V))
184 AM_V_LN_ = $(AM_V_LN_$(AM_DEFAULT_VERBOSITY))
185 AM_V_LN_0 = @echo "  LN      " $@;
186
187 AM_V_RM = $(AM_V_RM_$(V))
188 AM_V_RM_ = $(AM_V_RM_$(AM_DEFAULT_VERBOSITY))
189 AM_V_RM_0 = @echo "  RM      " $@;
190
191 # ------------------------------------------------------------------------------
192 rootbin_PROGRAMS =
193 pkglibexec_PROGRAMS =
194
195 dist_doc_DATA = \
196         README \
197         NEWS \
198         LICENSE.LGPL2.1 \
199         LICENSE.GPL2
200
201 @INTLTOOL_POLICY_RULE@
202
203 # ------------------------------------------------------------------------------
204
205 MANPAGES =
206 MANPAGES_ALIAS =
207
208 include Makefile-man.am
209
210 .PHONY: man update-man-list
211 man: $(MANPAGES) $(MANPAGES_ALIAS) $(HTML_FILES) $(HTML_ALIAS)
212
213 XML_FILES = \
214         ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,${patsubst %.8,%.xml,$(MANPAGES)}}}}}
215 HTML_FILES = \
216         ${XML_FILES:.xml=.html}
217 HTML_ALIAS = \
218         ${patsubst %.1,%.html,${patsubst %.3,%.html,${patsubst %.5,%.html,${patsubst %.7,%.html,${patsubst %.8,%.html,$(MANPAGES_ALIAS)}}}}}
219
220 if ENABLE_MANPAGES
221 man_MANS = \
222         $(MANPAGES) \
223         $(MANPAGES_ALIAS)
224
225 noinst_DATA += \
226         $(HTML_FILES) \
227         $(HTML_ALIAS)
228
229 CLEANFILES += \
230         $(man_MANS) \
231         $(HTML_FILES) \
232         $(HTML_ALIAS)
233
234 docs/html/man:
235         $(AM_V_at)$(MKDIR_P) $(dir $@)
236         $(AM_V_LN)$(LN_S) -f ../../man $@
237
238 noinst_DATA += \
239         docs/html/man
240
241 CLEANFILES += \
242         docs/html/man
243
244 if HAVE_PYTHON
245 man/index.html: man/elogind.index.html
246         $(AM_V_LN)$(LN_S) -f elogind.index.html $@
247
248 noinst_DATA += \
249        man/index.html
250
251 CLEANFILES += \
252        man/index.html
253
254 XML_GLOB = $(wildcard $(top_srcdir)/man/*.xml)
255 NON_INDEX_XML_FILES = $(filter-out man/elogind.index.xml,$(XML_FILES))
256 SOURCE_XML_FILES = ${patsubst %,$(top_srcdir)/%,$(filter-out man/elogind.directives.xml,$(NON_INDEX_XML_FILES))}
257
258 # This target should only be run manually. It recreates Makefile-man.am
259 # file in the source directory based on all man/*.xml files. Run it after
260 # adding, removing, or changing the conditional in a man page.
261 update-man-list: $(top_srcdir)/tools/make-man-rules.py $(XML_GLOB)
262         $(AM_V_GEN)$(PYTHON) $^ > $(top_srcdir)/Makefile-man.tmp
263         $(AM_V_at)mv $(top_srcdir)/Makefile-man.tmp $(top_srcdir)/Makefile-man.am
264                 @echo "Makefile-man.am has been regenerated"
265
266 man/elogind.index.xml: $(top_srcdir)/tools/make-man-index.py $(NON_INDEX_XML_FILES)
267         $(AM_V_at)$(MKDIR_P) $(dir $@)
268         $(AM_V_GEN)$(PYTHON) $< $@ $(filter-out $<,$^)
269
270 man/elogind.directives.xml: $(top_srcdir)/tools/make-directive-index.py man/custom-entities.ent $(SOURCE_XML_FILES)
271         $(AM_V_at)$(MKDIR_P) $(dir $@)
272         $(AM_V_GEN)$(PYTHON) $< $@ $(SOURCE_XML_FILES)
273
274 CLEANFILES += \
275        man/elogind.index.xml \
276        man/elogind.directives.xml
277
278 EXTRA_DIST += \
279        tools/make-man-rules.py
280
281 endif
282
283 endif
284
285 EXTRA_DIST += \
286         $(filter-out man/elogind.directives.xml,$(XML_FILES)) \
287         $(HTML_FILES) \
288         $(HTML_ALIAS) \
289         $(man_MANS) \
290         $(NULL)
291
292 # ------------------------------------------------------------------------------
293 noinst_LTLIBRARIES += \
294         libbasic.la
295
296 libbasic_la_SOURCES = \
297         src/basic/missing.h \
298         src/basic/musl_missing.h \
299         src/basic/musl_missing.c \
300         src/basic/capability-util.c \
301         src/basic/capability-util.h \
302         src/basic/conf-files.c \
303         src/basic/conf-files.h \
304         src/basic/stdio-util.h \
305         src/basic/hostname-util.h \
306         src/basic/hostname-util.c \
307         src/basic/unit-name.c \
308         src/basic/unit-name.h \
309         src/basic/unaligned.h \
310         src/basic/util.c \
311         src/basic/util.h \
312         src/basic/io-util.c \
313         src/basic/io-util.h \
314         src/basic/string-util.c \
315         src/basic/string-util.h \
316         src/basic/parse-util.c \
317         src/basic/parse-util.h \
318         src/basic/fd-util.c \
319         src/basic/fd-util.h \
320         src/basic/user-util.c \
321         src/basic/user-util.h \
322         src/basic/dirent-util.c \
323         src/basic/dirent-util.h \
324         src/basic/xattr-util.c \
325         src/basic/xattr-util.h \
326         src/basic/proc-cmdline.c \
327         src/basic/proc-cmdline.h \
328         src/basic/fs-util.c \
329         src/basic/fs-util.h \
330         src/basic/syslog-util.c \
331         src/basic/syslog-util.h \
332         src/basic/stat-util.c \
333         src/basic/stat-util.h \
334         src/basic/mount-util.c \
335         src/basic/mount-util.h \
336         src/basic/hexdecoct.c \
337         src/basic/hexdecoct.h \
338         src/basic/extract-word.c \
339         src/basic/extract-word.h \
340         src/basic/escape.c \
341         src/basic/escape.h \
342         src/basic/path-util.c \
343         src/basic/path-util.h \
344         src/basic/time-util.c \
345         src/basic/time-util.h \
346         src/basic/locale-util.c \
347         src/basic/locale-util.h \
348         src/basic/umask-util.h \
349         src/basic/signal-util.c \
350         src/basic/signal-util.h \
351         src/basic/string-table.c \
352         src/basic/string-table.h \
353         src/basic/mempool.c \
354         src/basic/mempool.h \
355         src/basic/hashmap.c \
356         src/basic/hashmap.h \
357         src/basic/siphash24.c \
358         src/basic/siphash24.h \
359         src/basic/prioq.c \
360         src/basic/prioq.h \
361         src/basic/strv.c \
362         src/basic/strv.h \
363         src/basic/log.c \
364         src/basic/log.h \
365         src/basic/bus-label.c \
366         src/basic/bus-label.h \
367         src/basic/virt.c \
368         src/basic/virt.h \
369         src/basic/smack-util.c \
370         src/basic/smack-util.h \
371         src/basic/utf8.c \
372         src/basic/utf8.h \
373         src/basic/gunicode.c \
374         src/basic/gunicode.h \
375         src/basic/socket-util.c \
376         src/basic/socket-util.h \
377         src/basic/fileio.c \
378         src/basic/fileio.h \
379         src/basic/mkdir.c \
380         src/basic/mkdir.h \
381         src/basic/cgroup-util.c \
382         src/basic/cgroup-util.h \
383         src/basic/errno-list.c \
384         src/basic/errno-list.h \
385         src/basic/terminal-util.c \
386         src/basic/terminal-util.h \
387         src/basic/login-util.h \
388         src/basic/login-util.c \
389         src/basic/audit-util.c \
390         src/basic/audit-util.h \
391         src/basic/memfd-util.c \
392         src/basic/memfd-util.h \
393         src/basic/process-util.c \
394         src/basic/process-util.h \
395         src/basic/random-util.c \
396         src/basic/random-util.h \
397         src/basic/verbs.c \
398         src/basic/verbs.h \
399         src/basic/label.c \
400         src/basic/label.h \
401         src/basic/selinux-util.c \
402         src/basic/selinux-util.h \
403         src/basic/mkdir-label.c \
404         src/basic/fileio-label.c \
405         src/basic/fileio-label.h \
406         src/basic/rm-rf.c \
407         src/basic/rm-rf.h \
408         src/basic/copy.c \
409         src/basic/copy.h \
410         src/basic/alloc-util.h \
411         src/basic/alloc-util.c \
412         src/basic/parse-printf-format.c \
413         src/basic/parse-printf-format.h
414
415 nodist_libbasic_la_SOURCES = \
416         src/basic/errno-from-name.h \
417         src/basic/errno-to-name.h
418
419 libbasic_la_CFLAGS = \
420         $(AM_CFLAGS) \
421         $(SELINUX_CFLAGS) \
422         $(CAP_CFLAGS) \
423         -pthread
424
425 libbasic_la_LDFLAGS = \
426         $(CAP_LDFLAGS)
427
428 libbasic_la_LIBADD = \
429         $(SELINUX_LIBS) \
430         $(CAP_LIBS) \
431         -ldl \
432         -lm
433
434 # -----------------------------------------------------------------------------
435 noinst_LTLIBRARIES += \
436         libshared.la
437
438 libshared_la_SOURCES = \
439         src/shared/sleep-config.c \
440         src/shared/sleep-config.h \
441         src/shared/conf-parser.c \
442         src/shared/conf-parser.h \
443         src/shared/pager.c \
444         src/shared/pager.h \
445         src/shared/spawn-polkit-agent.c \
446         src/shared/spawn-polkit-agent.h \
447         src/shared/clean-ipc.c \
448         src/shared/clean-ipc.h \
449         src/shared/bus-util.c \
450         src/shared/bus-util.h
451
452 if HAVE_ACL
453 libshared_la_SOURCES += \
454         src/shared/acl-util.c \
455         src/shared/acl-util.h
456 endif
457
458 libshared_la_CFLAGS = \
459         $(AM_CFLAGS) \
460         $(ACL_CFLAGS)
461
462 libshared_la_LIBADD = \
463         libelogind-internal.la \
464         $(UDEV_LIBS) \
465         $(ACL_LIBS)
466
467 gperf_txt_sources = \
468         src/basic/errno-list.txt
469
470 BUILT_SOURCES += \
471         $(gperf_gperf_m4_sources:-gperf.gperf.m4=-gperf.c) \
472         $(gperf_gperf_sources:-gperf.gperf=-gperf.c) \
473         $(gperf_txt_sources:-list.txt=-from-name.h) \
474         $(gperf_txt_sources:-list.txt=-to-name.h)
475
476 CLEANFILES += \
477         $(gperf_txt_sources:-list.txt=-from-name.gperf)
478 DISTCLEANFILES = \
479         $(gperf_txt_sources)
480
481 EXTRA_DIST += \
482         $(gperf_gperf_m4_sources) \
483         $(gperf_gperf_sources)
484
485 CLEANFILES += \
486         $(gperf_txt_sources)
487
488 %-from-name.gperf: %-list.txt
489         $(AM_V_at)$(MKDIR_P) $(dir $@)
490         $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct $(notdir $*)_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@
491
492 %-from-name.h: %-from-name.gperf
493         $(AM_V_at)$(MKDIR_P) $(dir $@)
494         $(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_$(notdir $*) -H hash_$(notdir $*)_name -p -C <$< >$@
495
496
497 src/basic/errno-list.txt:
498         $(AM_V_at)$(MKDIR_P) $(dir $@)
499         $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - </dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+/ { print $$2; }' >$@
500
501 src/basic/errno-to-name.h: src/basic/errno-list.txt
502         $(AM_V_at)$(MKDIR_P) $(dir $@)
503         $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
504
505
506 # ------------------------------------------------------------------------------
507
508 if HAVE_PAM
509 dist_factory_pam_DATA = \
510         factory/etc/pam.d/system-auth \
511         factory/etc/pam.d/other
512 endif
513
514 # ------------------------------------------------------------------------------
515 pkglibexec_PROGRAMS += \
516        elogind-cgroups-agent
517
518 elogind_cgroups_agent_SOURCES = \
519        src/cgroups-agent/cgroups-agent.c
520
521 elogind_cgroups_agent_LDADD = \
522        libshared.la
523
524 # ------------------------------------------------------------------------------
525 libelogind_internal_la_SOURCES = \
526         src/systemd/sd-bus.h \
527         src/systemd/sd-bus-protocol.h \
528         src/systemd/sd-bus-vtable.h \
529         src/systemd/sd-event.h \
530         src/systemd/sd-login.h \
531         src/systemd/sd-id128.h \
532         src/systemd/sd-daemon.h \
533         src/libelogind/libelogind.sym \
534         src/libelogind/sd-bus/sd-bus.c \
535         src/libelogind/sd-bus/bus-control.c \
536         src/libelogind/sd-bus/bus-control.h \
537         src/libelogind/sd-bus/bus-error.c \
538         src/libelogind/sd-bus/bus-error.h \
539         src/libelogind/sd-bus/bus-common-errors.h \
540         src/libelogind/sd-bus/bus-common-errors.c \
541         src/libelogind/sd-bus/bus-internal.c \
542         src/libelogind/sd-bus/bus-internal.h \
543         src/libelogind/sd-bus/bus-socket.c \
544         src/libelogind/sd-bus/bus-socket.h \
545         src/libelogind/sd-bus/bus-kernel.c \
546         src/libelogind/sd-bus/bus-kernel.h \
547         src/libelogind/sd-bus/bus-container.c \
548         src/libelogind/sd-bus/bus-container.h \
549         src/libelogind/sd-bus/bus-message.c \
550         src/libelogind/sd-bus/bus-message.h \
551         src/libelogind/sd-bus/bus-creds.c \
552         src/libelogind/sd-bus/bus-creds.h \
553         src/libelogind/sd-bus/bus-signature.c \
554         src/libelogind/sd-bus/bus-signature.h \
555         src/libelogind/sd-bus/bus-type.c \
556         src/libelogind/sd-bus/bus-type.h \
557         src/libelogind/sd-bus/bus-match.c \
558         src/libelogind/sd-bus/bus-match.h \
559         src/libelogind/sd-bus/bus-bloom.c \
560         src/libelogind/sd-bus/bus-bloom.h \
561         src/libelogind/sd-bus/bus-introspect.c \
562         src/libelogind/sd-bus/bus-introspect.h \
563         src/libelogind/sd-bus/bus-objects.c \
564         src/libelogind/sd-bus/bus-objects.h \
565         src/libelogind/sd-bus/bus-gvariant.c \
566         src/libelogind/sd-bus/bus-gvariant.h \
567         src/libelogind/sd-bus/bus-convenience.c \
568         src/libelogind/sd-bus/bus-track.c \
569         src/libelogind/sd-bus/bus-track.h \
570         src/libelogind/sd-bus/bus-slot.c \
571         src/libelogind/sd-bus/bus-slot.h \
572         src/libelogind/sd-bus/bus-protocol.h \
573         src/libelogind/sd-event/sd-event.c \
574         src/libelogind/sd-id128/sd-id128.c \
575         src/libelogind/sd-daemon/sd-daemon.c \
576         src/libelogind/sd-login/sd-login.c
577
578 libelogind_internal_la_LIBADD = \
579         libbasic.la \
580         -lresolv
581
582 noinst_LTLIBRARIES += \
583         libelogind-internal.la
584
585 EXTRA_DIST += \
586         src/libelogind/libelogind.pc.in \
587         src/libelogind/sd-bus/DIFFERENCES \
588         src/libelogind/sd-bus/GVARIANT-SERIALIZATION
589
590 libelogind_la_SOURCES = \
591         $(libelogind_internal_la_SOURCES)
592
593 nodist_libelogind_la_SOURCES = \
594         $(nodist_libelogind_internal_la_SOURCES)
595
596 libelogind_la_CFLAGS = \
597         $(libelogind_internal_la_CFLAGS)
598
599 libelogind_la_LDFLAGS = \
600         $(AM_LDFLAGS) \
601         -version-info $(LIBELOGIND_CURRENT):$(LIBELOGIND_REVISION):$(LIBELOGIND_AGE) \
602         -Wl,--version-script=$(top_srcdir)/src/libelogind/libelogind.sym
603
604 libelogind_la_LIBADD = \
605         $(libelogind_internal_la_LIBADD)
606
607 libelogind-install-hook:
608         libname=libelogind.so && $(move-to-rootlibdir)
609
610 libelogind-uninstall-hook:
611         rm -f $(DESTDIR)$(rootlibdir)/libelogind.so*
612
613 INSTALL_EXEC_HOOKS += libelogind-install-hook
614 UNINSTALL_EXEC_HOOKS += libelogind-uninstall-hook
615
616 pkgconfiglib_DATA += \
617         src/libelogind/libelogind.pc
618
619 pkginclude_HEADERS += \
620         src/systemd/sd-login.h \
621         src/systemd/sd-messages.h \
622         src/systemd/sd-id128.h \
623         src/systemd/_sd-common.h
624
625
626 lib_LTLIBRARIES += \
627         libelogind.la
628
629 # ------------------------------------------------------------------------------
630 elogind_SOURCES = \
631         src/login/logind.c \
632         src/login/logind.h
633
634 nodist_elogind_SOURCES = \
635         src/login/logind-gperf.c
636
637 elogind_LDADD = \
638         libelogind-core.la
639
640 libelogind_core_la_SOURCES = \
641         src/login/logind-core.c \
642         src/login/logind-device.c \
643         src/login/logind-device.h \
644         src/login/logind-button.c \
645         src/login/logind-button.h \
646         src/login/logind-action.c \
647         src/login/logind-action.h \
648         src/login/logind-seat.c \
649         src/login/logind-seat.h \
650         src/login/logind-session.c \
651         src/login/logind-session.h \
652         src/login/logind-session-device.c \
653         src/login/logind-session-device.h \
654         src/login/logind-user.c \
655         src/login/logind-user.h \
656         src/login/logind-inhibit.c \
657         src/login/logind-inhibit.h \
658         src/login/logind-dbus.c \
659         src/login/logind-session-dbus.c \
660         src/login/logind-seat-dbus.c \
661         src/login/logind-user-dbus.c \
662         src/login/logind-acl.h \
663         src/core/cgroup.h \
664         src/core/cgroup.c \
665         src/core/mount-setup.h \
666         src/core/mount-setup.c
667
668 libelogind_core_la_LIBADD = \
669         libshared.la
670
671 if HAVE_ACL
672 libelogind_core_la_SOURCES += \
673         src/login/logind-acl.c
674 endif
675
676 noinst_LTLIBRARIES += \
677         libelogind-core.la
678
679 pkglibexec_PROGRAMS += \
680         elogind
681
682 loginctl_SOURCES = \
683         src/login/loginctl.c \
684         src/login/sysfs-show.h \
685         src/login/sysfs-show.c
686
687 loginctl_LDADD = \
688         libshared.la
689
690 rootbin_PROGRAMS += \
691         loginctl
692
693 if ENABLE_BASH_COMPLETION
694 dist_bashcompletion_DATA = \
695         shell-completion/bash/loginctl
696 endif
697
698 if ENABLE_ZSH_COMPLETION
699 dist_zshcompletion_DATA = \
700         shell-completion/zsh/_loginctl \
701         shell-completion/zsh/_elogind-inhibit
702 endif
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 -