chiark / gitweb /
34de5ea38f1b84bb6949f532bb7bc7ad09e1faed
[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
56 # Our own, non-special dirs
57 pkgsysconfdir=$(sysconfdir)/elogind
58 pkgincludedir=$(includedir)/elogind
59 udevrulesdir=@udevrulesdir@
60 udevbindir=@udevbindir@
61 udevlibexecdir=$(udevbindir)
62 udevhomedir=$(udevlibexecdir)
63 udevhwdbdir=$(udevlibexecdir)/hwdb.d
64 factory_pamdir = $(datadir)/factory/etc/pam.d
65
66 # And these are the special ones for /
67 rootprefix=@rootprefix@
68 rootbindir=$(rootprefix)/bin
69 rootlibexecdir=$(rootprefix)/lib/elogind
70
71 EXTRA_DIST =
72 BUILT_SOURCES =
73 INSTALL_EXEC_HOOKS =
74 UNINSTALL_EXEC_HOOKS =
75 INSTALL_DATA_HOOKS =
76 UNINSTALL_DATA_HOOKS =
77 DISTCLEAN_LOCAL_HOOKS =
78 CLEAN_LOCAL_HOOKS =
79 pkginclude_HEADERS =
80 noinst_LTLIBRARIES =
81 lib_LTLIBRARIES =
82 noinst_DATA =
83 pkgconfiglib_DATA =
84 polkitpolicy_in_files =
85 polkitpolicy_files =
86 dist_udevrules_DATA =
87 nodist_udevrules_DATA =
88 dist_pkgsysconf_DATA =
89 dist_dbuspolicy_DATA =
90 dist_dbussystemservice_DATA =
91 check_PROGRAMS =
92 check_DATA =
93 tests=
94 manual_tests =
95 if ENABLE_TESTS
96 noinst_PROGRAMS = $(manual_tests) $(tests)
97 TESTS = $(tests)
98 else
99 noinst_PROGRAMS =
100 TESTS =
101 endif
102
103 in_files = $(filter %.in,$(EXTRA_DIST))
104 in_in_files = $(filter %.in.in, $(in_files))
105 m4_files = $(filter %.m4,$(EXTRA_DIST) $(in_files:.m4.in=.m4))
106
107 CLEANFILES = $(BUILT_SOURCES) \
108         $(pkgconfiglib_DATA) \
109         $(in_files:.in=) $(in_in_files:.in.in=) \
110         $(m4_files:.m4=)
111
112 .PHONY: $(INSTALL_EXEC_HOOKS) $(UNINSTALL_EXEC_HOOKS) \
113         $(INSTALL_DATA_HOOKS) $(UNINSTALL_DATA_HOOKS) \
114         $(DISTCLEAN_LOCAL_HOOKS) $(CLEAN_LOCAL_HOOKS)
115
116 AM_CPPFLAGS = \
117         -include $(top_builddir)/config.h \
118         -DPKGSYSCONFDIR=\"$(pkgsysconfdir)\" \
119         -DCERTIFICATE_ROOT=\"$(CERTIFICATEROOT)\" \
120         -DELOGIND_CGROUP_AGENT_PATH=\"$(rootlibexecdir)/elogind-cgroups-agent\" \
121         -DROOTPREFIX=\"$(rootprefix)\" \
122         -DUDEVLIBEXECDIR=\"$(udevlibexecdir)\" \
123         -DPOLKIT_AGENT_BINARY_PATH=\"$(bindir)/pkttyagent\" \
124         -DKEXEC=\"$(KEXEC)\" \
125         -DLIBDIR=\"$(libdir)\" \
126         -DROOTLIBDIR=\"$(rootlibdir)\" \
127         -DROOTLIBEXECDIR=\"$(rootlibexecdir)\" \
128         -DTEST_DIR=\"$(abs_top_srcdir)/test\" \
129         -I $(top_srcdir)/src \
130         -I $(top_builddir)/src/basic \
131         -I $(top_srcdir)/src/basic \
132         -I $(top_srcdir)/src/shared \
133         -I $(top_builddir)/src/shared \
134         -I $(top_srcdir)/src/login \
135         -I $(top_srcdir)/src/systemd \
136         -I $(top_builddir)/src/core \
137         -I $(top_srcdir)/src/libudev \
138         -I $(top_srcdir)/src/udev \
139         -I $(top_srcdir)/src/core \
140         -I $(top_srcdir)/src/libelogind/sd-bus \
141         -I $(top_srcdir)/src/libelogind/sd-event \
142         -I $(top_srcdir)/src/libelogind/sd-login \
143         -I $(top_srcdir)/src/libelogind/sd-netlink \
144         $(OUR_CPPFLAGS)
145
146 AM_CFLAGS = $(OUR_CFLAGS)
147 AM_LDFLAGS = $(OUR_LDFLAGS)
148
149 # ------------------------------------------------------------------------------
150 define move-to-rootlibdir
151         if test "$(libdir)" != "$(rootlibdir)"; then \
152                 $(MKDIR_P) $(DESTDIR)$(rootlibdir) && \
153                 so_img_name=$$(readlink $(DESTDIR)$(libdir)/$$libname) && \
154                 rm -f $(DESTDIR)$(libdir)/$$libname && \
155                 $(LN_S) --relative -f $(DESTDIR)$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/$$libname && \
156                 mv $(DESTDIR)$(libdir)/$$libname.* $(DESTDIR)$(rootlibdir); \
157         fi
158 endef
159
160 install-touch-usr-hook:
161         touch -c $(DESTDIR)/$(prefix)
162
163 INSTALL_EXEC_HOOKS += \
164         install-touch-usr-hook
165
166
167 # ------------------------------------------------------------------------------
168 AM_V_M4 = $(AM_V_M4_$(V))
169 AM_V_M4_ = $(AM_V_M4_$(AM_DEFAULT_VERBOSITY))
170 AM_V_M4_0 = @echo "  M4      " $@;
171
172 AM_V_XSLT = $(AM_V_XSLT_$(V))
173 AM_V_XSLT_ = $(AM_V_XSLT_$(AM_DEFAULT_VERBOSITY))
174 AM_V_XSLT_0 = @echo "  XSLT    " $@;
175
176 AM_V_GPERF = $(AM_V_GPERF_$(V))
177 AM_V_GPERF_ = $(AM_V_GPERF_$(AM_DEFAULT_VERBOSITY))
178 AM_V_GPERF_0 = @echo "  GPERF   " $@;
179
180 AM_V_LN = $(AM_V_LN_$(V))
181 AM_V_LN_ = $(AM_V_LN_$(AM_DEFAULT_VERBOSITY))
182 AM_V_LN_0 = @echo "  LN      " $@;
183
184 AM_V_RM = $(AM_V_RM_$(V))
185 AM_V_RM_ = $(AM_V_RM_$(AM_DEFAULT_VERBOSITY))
186 AM_V_RM_0 = @echo "  RM      " $@;
187
188 # ------------------------------------------------------------------------------
189 rootbin_PROGRAMS =
190 bin_PROGRAMS =
191 rootlibexec_PROGRAMS =
192
193 dist_doc_DATA = \
194         README \
195         NEWS \
196         LICENSE.LGPL2.1 \
197         LICENSE.GPL2 \
198         DISTRO_PORTING
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/systemd.index.html
245         $(AM_V_LN)$(LN_S) -f systemd.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/systemd.index.xml,$(XML_FILES))
255 SOURCE_XML_FILES = ${patsubst %,$(top_srcdir)/%,$(filter-out man/systemd.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/systemd.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/systemd.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/systemd.index.xml \
275         man/systemd.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/systemd.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/capability.c \
298         src/basic/capability.h \
299         src/basic/conf-files.c \
300         src/basic/conf-files.h \
301         src/basic/hostname-util.h \
302         src/basic/hostname-util.c \
303         src/basic/unit-name.c \
304         src/basic/unit-name.h \
305         src/basic/util.c \
306         src/basic/util.h \
307         src/basic/path-util.c \
308         src/basic/path-util.h \
309         src/basic/time-util.c \
310         src/basic/time-util.h \
311         src/basic/signal-util.c \
312         src/basic/signal-util.h \
313         src/basic/mempool.c \
314         src/basic/mempool.h \
315         src/basic/hashmap.c \
316         src/basic/hashmap.h \
317         src/basic/siphash24.c \
318         src/basic/siphash24.h \
319         src/basic/prioq.c \
320         src/basic/prioq.h \
321         src/basic/strv.c \
322         src/basic/strv.h \
323         src/basic/log.c \
324         src/basic/log.h \
325         src/basic/bus-label.c \
326         src/basic/bus-label.h \
327         src/basic/virt.c \
328         src/basic/virt.h \
329         src/basic/smack-util.c \
330         src/basic/smack-util.h \
331         src/basic/utf8.c \
332         src/basic/utf8.h \
333         src/basic/gunicode.c \
334         src/basic/gunicode.h \
335         src/basic/fileio.c \
336         src/basic/fileio.h \
337         src/basic/mkdir.c \
338         src/basic/mkdir.h \
339         src/basic/cgroup-util.c \
340         src/basic/cgroup-util.h \
341         src/basic/errno-list.c \
342         src/basic/errno-list.h \
343         src/basic/terminal-util.c \
344         src/basic/terminal-util.h \
345         src/basic/login-util.h \
346         src/basic/login-util.c \
347         src/basic/audit.c \
348         src/basic/audit.h \
349         src/basic/memfd-util.c \
350         src/basic/memfd-util.h \
351         src/basic/process-util.c \
352         src/basic/process-util.h \
353         src/basic/random-util.c \
354         src/basic/random-util.h \
355         src/basic/verbs.c \
356         src/basic/verbs.h \
357         src/basic/label.c \
358         src/basic/label.h \
359         src/basic/selinux-util.c \
360         src/basic/selinux-util.h \
361         src/basic/mkdir-label.c \
362         src/basic/fileio-label.c \
363         src/basic/fileio-label.h \
364         src/basic/rm-rf.c \
365         src/basic/rm-rf.h \
366         src/basic/copy.c \
367         src/basic/copy.h
368
369 nodist_libbasic_la_SOURCES = \
370         src/basic/errno-from-name.h \
371         src/basic/errno-to-name.h
372
373 libbasic_la_CFLAGS = \
374         $(AM_CFLAGS) \
375         $(SELINUX_CFLAGS) \
376         $(CAP_CFLAGS) \
377         -pthread
378
379 libbasic_la_LIBADD = \
380         $(SELINUX_LIBS) \
381         $(CAP_LIBS) \
382         -ldl \
383         -lrt \
384         -lm
385
386 # -----------------------------------------------------------------------------
387 noinst_LTLIBRARIES += \
388         libshared.la
389
390 libshared_la_SOURCES = \
391         src/shared/sleep-config.c \
392         src/shared/sleep-config.h \
393         src/shared/conf-parser.c \
394         src/shared/conf-parser.h \
395         src/shared/pager.c \
396         src/shared/pager.h \
397         src/shared/spawn-polkit-agent.c \
398         src/shared/spawn-polkit-agent.h \
399         src/shared/clean-ipc.c \
400         src/shared/clean-ipc.h \
401         src/shared/cgroup-show.c \
402         src/shared/cgroup-show.h \
403         src/shared/utmp-wtmp.h \
404         src/shared/bus-util.c \
405         src/shared/bus-util.h
406
407 if HAVE_ACL
408 libshared_la_SOURCES += \
409         src/shared/acl-util.c \
410         src/shared/acl-util.h
411 endif
412
413 libshared_la_CFLAGS = \
414         $(AM_CFLAGS) \
415         $(ACL_CFLAGS) \
416         $(LIBIDN_CFLAGS) \
417         $(SECCOMP_CFLAGS)
418
419 libshared_la_LIBADD = \
420         libelogind-internal.la \
421         $(UDEV_LIBS) \
422         $(ACL_LIBS) \
423         $(LIBIDN_LIBS) \
424         $(SECCOMP_LIBS)
425
426 gperf_txt_sources = \
427         src/basic/errno-list.txt
428
429 BUILT_SOURCES += \
430         $(gperf_gperf_m4_sources:-gperf.gperf.m4=-gperf.c) \
431         $(gperf_gperf_sources:-gperf.gperf=-gperf.c) \
432         $(gperf_txt_sources:-list.txt=-from-name.h) \
433         $(gperf_txt_sources:-list.txt=-to-name.h)
434
435 CLEANFILES += \
436         $(gperf_txt_sources:-list.txt=-from-name.gperf)
437 DISTCLEANFILES = \
438         $(gperf_txt_sources)
439
440 EXTRA_DIST += \
441         $(gperf_gperf_m4_sources) \
442         $(gperf_gperf_sources)
443
444 CLEANFILES += \
445         $(gperf_txt_sources)
446
447 %-from-name.gperf: %-list.txt
448         $(AM_V_at)$(MKDIR_P) $(dir $@)
449         $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct $(notdir $*)_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@
450
451 %-from-name.h: %-from-name.gperf
452         $(AM_V_at)$(MKDIR_P) $(dir $@)
453         $(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_$(notdir $*) -H hash_$(notdir $*)_name -p -C <$< >$@
454
455
456 src/basic/errno-list.txt:
457         $(AM_V_at)$(MKDIR_P) $(dir $@)
458         $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - </dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+/ { print $$2; }' >$@
459
460 src/basic/errno-to-name.h: src/basic/errno-list.txt
461         $(AM_V_at)$(MKDIR_P) $(dir $@)
462         $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
463
464
465 # ------------------------------------------------------------------------------
466
467 if HAVE_PAM
468 dist_factory_pam_DATA = \
469         factory/etc/pam.d/system-auth \
470         factory/etc/pam.d/other
471 endif
472
473 # ------------------------------------------------------------------------------
474 rootlibexec_PROGRAMS += \
475         elogind-cgroups-agent
476
477 elogind_cgroups_agent_SOURCES = \
478         src/cgroups-agent/cgroups-agent.c
479
480 elogind_cgroups_agent_LDADD = \
481         libshared.la
482
483 # ------------------------------------------------------------------------------
484 libelogind_internal_la_SOURCES = \
485         src/systemd/sd-bus.h \
486         src/systemd/sd-bus-protocol.h \
487         src/systemd/sd-bus-vtable.h \
488         src/systemd/sd-event.h \
489         src/systemd/sd-netlink.h \
490         src/systemd/sd-login.h \
491         src/systemd/sd-id128.h \
492         src/systemd/sd-daemon.h \
493         src/systemd/sd-path.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-event/event-util.h \
536         src/libelogind/sd-id128/sd-id128.c \
537         src/libelogind/sd-daemon/sd-daemon.c \
538         src/libelogind/sd-login/sd-login.c \
539         src/libelogind/sd-path/sd-path.c
540
541 libelogind_internal_la_LIBADD = \
542         libbasic.la \
543         -lresolv
544
545 noinst_LTLIBRARIES += \
546         libelogind-internal.la
547
548 EXTRA_DIST += \
549         src/libelogind/libelogind.pc.in \
550         src/libelogind/sd-bus/DIFFERENCES \
551         src/libelogind/sd-bus/GVARIANT-SERIALIZATION
552
553 libelogind_la_SOURCES = \
554         $(libelogind_internal_la_SOURCES)
555
556 nodist_libelogind_la_SOURCES = \
557         $(nodist_libelogind_internal_la_SOURCES)
558
559 libelogind_la_CFLAGS = \
560         $(libelogind_internal_la_CFLAGS)
561
562 libelogind_la_LDFLAGS = \
563         $(AM_LDFLAGS) \
564         -version-info $(LIBELOGIND_CURRENT):$(LIBELOGIND_REVISION):$(LIBELOGIND_AGE) \
565         -Wl,--version-script=$(top_srcdir)/src/libelogind/libelogind.sym
566
567 libelogind_la_LIBADD = \
568         $(libelogind_internal_la_LIBADD)
569
570 libelogind-install-hook:
571         libname=libelogind.so && $(move-to-rootlibdir)
572
573 libelogind-uninstall-hook:
574         rm -f $(DESTDIR)$(rootlibdir)/libelogind.so*
575
576 INSTALL_EXEC_HOOKS += libelogind-install-hook
577 UNINSTALL_EXEC_HOOKS += libelogind-uninstall-hook
578
579 pkgconfiglib_DATA += \
580         src/libelogind/libelogind.pc
581
582 pkginclude_HEADERS += \
583         src/systemd/sd-bus.h \
584         src/systemd/sd-bus-protocol.h \
585         src/systemd/sd-bus-vtable.h \
586         src/systemd/sd-event.h \
587         src/systemd/sd-login.h \
588         src/systemd/sd-id128.h \
589         src/systemd/sd-daemon.h
590
591 lib_LTLIBRARIES += \
592         libelogind.la
593
594 # ------------------------------------------------------------------------------
595 elogind_SOURCES = \
596         src/login/logind.c \
597         src/login/logind.h
598
599 nodist_elogind_SOURCES = \
600         src/login/logind-gperf.c
601
602 elogind_LDADD = \
603         libelogind-core.la
604
605 libelogind_core_la_SOURCES = \
606         src/login/logind-core.c \
607         src/login/logind-device.c \
608         src/login/logind-device.h \
609         src/login/logind-button.c \
610         src/login/logind-button.h \
611         src/login/logind-action.c \
612         src/login/logind-action.h \
613         src/login/logind-seat.c \
614         src/login/logind-seat.h \
615         src/login/logind-session.c \
616         src/login/logind-session.h \
617         src/login/logind-session-device.c \
618         src/login/logind-session-device.h \
619         src/login/logind-user.c \
620         src/login/logind-user.h \
621         src/login/logind-inhibit.c \
622         src/login/logind-inhibit.h \
623         src/login/logind-dbus.c \
624         src/login/logind-session-dbus.c \
625         src/login/logind-seat-dbus.c \
626         src/login/logind-user-dbus.c \
627         src/login/logind-utmp.c \
628         src/login/logind-acl.h
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 rootlibexec_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/elogind.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        '|rootlibexecdir=$(rootlibexecdir)|' \
769        '|rootbindir=$(rootbindir)|' \
770        '|bindir=$(bindir)|' \
771        '|pkgsysconfdir=$(pkgsysconfdir)|' \
772        '|pkgdatadir=$(pkgdatadir)|' \
773        '|udevhwdbdir=$(udevhwdbdir)|' \
774        '|udevrulesdir=$(udevrulesdir)|' \
775        '|CERTIFICATEROOT=$(CERTIFICATEROOT)|' \
776        '|PACKAGE_VERSION=$(PACKAGE_VERSION)|' \
777        '|PACKAGE_NAME=$(PACKAGE_NAME)|' \
778        '|PACKAGE_URL=$(PACKAGE_URL)|' \
779        '|prefix=$(prefix)|' \
780        '|exec_prefix=$(exec_prefix)|' \
781        '|libdir=$(libdir)|' \
782        '|includedir=$(includedir)|' \
783        '|VERSION=$(VERSION)|' \
784        '|rootprefix=$(rootprefix)|' \
785        '|udevlibexecdir=$(udevlibexecdir)|' \
786        '|SUSHELL=$(SUSHELL)|' \
787        '|SULOGIN=$(SULOGIN)|' \
788        '|DEBUGTTY=$(DEBUGTTY)|' \
789        '|KILL=$(KILL)|' \
790        '|KMOD=$(KMOD)|' \
791        '|MKDIR_P=$(MKDIR_P)|' \
792        '|QUOTAON=$(QUOTAON)|' \
793        '|RC_LOCAL_SCRIPT_PATH_START=$(RC_LOCAL_SCRIPT_PATH_START)|' \
794        '|RC_LOCAL_SCRIPT_PATH_STOP=$(RC_LOCAL_SCRIPT_PATH_STOP)|' \
795        '|PYTHON=$(PYTHON)|' \
796        '|NTP_SERVERS=$(NTP_SERVERS)|' \
797        '|DNS_SERVERS=$(DNS_SERVERS)|' \
798        '|systemuidmax=$(SYSTEM_UID_MAX)|' \
799        '|systemgidmax=$(SYSTEM_GID_MAX)|' \
800        '|TTY_GID=$(TTY_GID)|'
801
802 SED_PROCESS = \
803         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
804         $(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) \
805                 < $< > $@
806
807 man/%: man/%.in
808         $(SED_PROCESS)
809
810 sysctl.d/%: sysctl.d/%.in
811         $(SED_PROCESS)
812
813 %.pc: %.pc.in
814         $(SED_PROCESS)
815
816 %.conf: %.conf.in
817         $(SED_PROCESS)
818
819 shell-completion/%: shell-completion/%.in
820         $(SED_PROCESS)
821
822 %.rules: %.rules.in
823         $(SED_PROCESS)
824
825 %.conf: %.conf.in
826         $(SED_PROCESS)
827
828 %.sh: %.sh.in
829         $(SED_PROCESS)
830         $(AM_V_GEN)chmod +x $@
831
832 src/%.c: src/%.gperf
833         $(AM_V_at)$(MKDIR_P) $(dir $@)
834         $(AM_V_GPERF)$(GPERF) < $< > $@
835
836 src/%: src/%.m4
837         $(AM_V_at)$(MKDIR_P) $(dir $@)
838         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
839
840 sysusers.d/%: sysusers.d/%.m4
841         $(AM_V_at)$(MKDIR_P) $(dir $@)
842         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
843
844 tmpfiles.d/%: tmpfiles.d/%.m4
845         $(AM_V_at)$(MKDIR_P) $(dir $@)
846         $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
847
848
849 units/%: units/%.m4
850         $(AM_V_at)$(MKDIR_P) $(dir $@)
851         $(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_SYSTEM=1 < $< > $@
852
853 units/user/%: units/user/%.m4
854         $(AM_V_at)$(MKDIR_P) $(dir $@)
855         $(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_USER=1 < $< > $@
856
857 if ENABLE_POLKIT
858 nodist_polkitpolicy_DATA = \
859         $(polkitpolicy_files)
860 endif
861
862 EXTRA_DIST += \
863         $(polkitpolicy_in_files)
864
865 # ------------------------------------------------------------------------------
866 if ENABLE_MANPAGES
867 man/custom-entities.ent: configure.ac
868         $(AM_V_GEN)$(MKDIR_P) $(dir $@)
869         $(AM_V_GEN)(echo '<?xml version="1.0" encoding="utf-8" ?>' && \
870          printf '$(subst '|,<!ENTITY ,$(subst =, ",$(subst |',">\n,$(substitutions))))') \
871          > $@ # '
872
873 CLEANFILES += \
874         man/custom-entities.ent
875
876 XSLTPROC_FLAGS = \
877         --nonet \
878         --xinclude \
879         --stringparam man.output.quietly 1 \
880         --stringparam funcsynopsis.style ansi \
881         --stringparam man.authors.section.enabled 0 \
882         --stringparam man.copyright.section.enabled 0 \
883         --stringparam elogind.version $(VERSION) \
884         --path '$(builddir)/man:$(srcdir)/man'
885
886 XSLTPROC_PROCESS_MAN = \
887         $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-man.xsl $<
888
889 XSLTPROC_PROCESS_HTML = \
890         $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-html.xsl $<
891
892 man/%.1: man/%.xml man/custom-man.xsl man/custom-entities.ent
893         $(XSLTPROC_PROCESS_MAN)
894
895 man/%.3: man/%.xml man/custom-man.xsl man/custom-entities.ent
896         $(XSLTPROC_PROCESS_MAN)
897
898 man/%.5: man/%.xml man/custom-man.xsl man/custom-entities.ent
899         $(XSLTPROC_PROCESS_MAN)
900
901 man/%.7: man/%.xml man/custom-man.xsl man/custom-entities.ent
902         $(XSLTPROC_PROCESS_MAN)
903
904 man/%.8: man/%.xml man/custom-man.xsl man/custom-entities.ent
905         $(XSLTPROC_PROCESS_MAN)
906
907 man/%.html: man/%.xml man/custom-html.xsl man/custom-entities.ent
908         $(XSLTPROC_PROCESS_HTML)
909
910 define html-alias
911         $(AM_V_LN)$(LN_S) -f $(notdir $<) $@
912 endef
913
914 endif
915
916 EXTRA_DIST += \
917         man/custom-html.xsl \
918         man/custom-man.xsl
919
920 install-exec-hook: $(INSTALL_EXEC_HOOKS)
921
922 uninstall-hook: $(UNINSTALL_DATA_HOOKS) $(UNINSTALL_EXEC_HOOKS)
923
924 install-data-hook: $(INSTALL_DATA_HOOKS)
925
926 distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
927
928 clean-local: $(CLEAN_LOCAL_HOOKS)
929         rm -rf $(abs_srcdir)/install-tree
930         rm -f $(abs_srcdir)/hwdb/usb.ids $(abs_srcdir)/hwdb/pci.ids $(abs_srcdir)/hwdb/oui.txt \
931               $(abs_srcdir)/hwdb/iab.txt
932
933 DISTCHECK_CONFIGURE_FLAGS = \
934         --with-dbuspolicydir=$$dc_install_base/$(dbuspolicydir) \
935         --with-dbussystemservicedir=$$dc_install_base/$(dbussystemservicedir) \
936         --with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir) \
937         --with-zshcompletiondir=$$dc_install_base/$(zshcompletiondir) \
938         --with-pamlibdir=$$dc_install_base/$(pamlibdir) \
939         --with-pamconfdir=$$dc_install_base/$(pamconfdir) \
940         --with-rootprefix=$$dc_install_base \
941         --enable-compat-libs
942
943 DISTCHECK_CONFIGURE_FLAGS += \
944         --with-sysvinit-path= \
945         --with-sysvrcnd-path=
946
947 if ENABLE_SPLIT_USR
948 DISTCHECK_CONFIGURE_FLAGS += \
949         --enable-split-usr
950 else
951 DISTCHECK_CONFIGURE_FLAGS += \
952         --disable-split-usr
953 endif
954
955 #
956 # Require python when making dist
957 #
958 .PHONY: dist-check-python dist-check-compat-libs dist-check-help
959 dist-check-python:
960
961 dist-check-compat-libs:
962
963 dist-check-help: $(rootbin_PROGRAMS) $(bin_PROGRAMS)
964         for i in $(abspath $^); do                                             \
965             if $$i  --help | grep -v 'default:' | grep -E -q '.{80}.' ; then   \
966                 echo "$(basename $$i) --help output is too wide:";             \
967                 $$i  --help | awk 'length > 80' | grep -E --color=yes '.{80}'; \
968                 exit 1;                                                        \
969             fi; done
970
971 dist: dist-check-python dist-check-compat-libs
972
973 .PHONY: git-tag
974 git-tag:
975         git tag -s "v$(VERSION)" -m "elogind $(VERSION)"
976
977 .PHONY: install-tree
978 install-tree: all
979         rm -rf $(abs_srcdir)/install-tree
980         $(MAKE) install DESTDIR=$(abs_srcdir)/install-tree
981         tree $(abs_srcdir)/install-tree
982
983 # Let's run all tests of the test suite, but under valgrind. Let's
984 # exclude the one perl script we have in there
985 .PHONY: valgrind-tests
986 valgrind-tests: $(TESTS)
987         $(AM_V_GEN)for f in $(filter-out %.pl, $^); do \
988                 if file $$f | grep -q shell; then \
989                 echo -e "$${x}Skipping non-binary $$f"; else \
990                 echo -e "$${x}Running $$f"; \
991                 libtool --mode=execute valgrind -q --leak-check=full --max-stackframe=5242880 --error-exitcode=55 $(builddir)/$$f ; fi; \
992                 x="\n\n"; \
993         done
994
995 exported-%: %
996         $(AM_V_GEN)$(NM) -g --defined-only $(builddir)/.libs/$(<:.la=.so) 2>&1 /dev/null | grep " T " | cut -d" " -f3 > $@
997
998 exported: $(addprefix exported-, $(lib_LTLIBRARIES))
999         $(AM_V_GEN)cat $^ > $@
1000
1001 .PHONY: check-api-docs
1002 check-api-docs: exported man
1003         $(AM_V_GEN)for symbol in `cat exported` ; do \
1004                 if test -f $(builddir)/man/$$symbol.html ; then \
1005                         echo "  Symbol $$symbol() is documented." ; \
1006                 else \
1007                         echo "‣ Symbol $$symbol() lacks documentation." ; \
1008                 fi ; \
1009         done
1010
1011 OBJECT_VARIABLES:=$(filter %_OBJECTS,$(.VARIABLES))
1012 ALL_OBJECTS:=$(foreach v,$(OBJECT_VARIABLES),$($(v)))
1013
1014 undefined defined: $(ALL_OBJECTS)
1015         $(AM_V_GEN)for f in $(ALL_OBJECTS) ; do \
1016                 $(NM) -g --$@-only `echo $(builddir)/"$$f" | sed -e 's,\([^/]*\).lo$$,.libs/\1.o,'` ; \
1017         done | cut -c 20- | cut -d @ -f 1 | sort -u > $@
1018
1019 CLEANFILES += \
1020         defined \
1021         undefined
1022
1023 .PHONY: check-api-unused
1024 check-api-unused: defined undefined exported
1025         ( cat exported undefined ) | sort -u  | diff -u - defined | grep ^+ | grep -v ^+++ | cut -c2-
1026
1027 .PHONY: check-includes
1028 check-includes: $(top_srcdir)/tools/check-includes.pl
1029         $(AM_V_GEN) find * -name '*.[hcS]' -type f -print | sort -u \
1030                 | xargs $(top_srcdir)/tools/check-includes.pl
1031
1032 EXTRA_DIST += \
1033         $(top_srcdir)/tools/check-includes.pl
1034
1035 # Stupid test that everything purported to be exported really is
1036 define generate-sym-test
1037         $(AM_V_at)$(MKDIR_P) $(dir $@)
1038         $(AM_V_at)printf '#include <stdio.h>\n' > $@
1039         $(AM_V_at)printf '#include "%s"\n' $(notdir $(filter %.h, $^)) >> $@
1040         $(AM_V_at)printf 'void* functions[] = {\n' >> $@
1041         $(AM_V_GEN)sed -r -n 's/^ +([a-zA-Z0-9_]+);/\1,/p' $< >> $@
1042         $(AM_V_at)printf '};\nint main(void) {\n' >> $@
1043         $(AM_V_at)printf 'unsigned i; for (i=0;i<sizeof(functions)/sizeof(void*);i++) printf("%%p\\n", functions[i]);\n' >> $@
1044         $(AM_V_at)printf 'return 0; }\n' >> $@
1045 endef
1046
1047 test-libelogind-sym.c: \
1048                 $(top_builddir)/src/libelogind/libelogind.sym \
1049                 src/systemd/sd-daemon.h \
1050                 src/systemd/sd-login.h \
1051                 src/systemd/sd-bus.h \
1052                 src/systemd/sd-path.h \
1053                 src/systemd/sd-event.h
1054         $(generate-sym-test)
1055
1056 test_libelogind_sym_SOURCES = \
1057         test-libelogind-sym.c
1058 test_libelogind_sym_LDADD = \
1059         libelogind.la
1060
1061 BUILT_SOURCES += \
1062         $(test_libelogind_sym_SOURCES)
1063
1064 tests += \
1065         test-libelogind-sym
1066
1067 .PHONY: cppcheck
1068 cppcheck:
1069         cppcheck --enable=all -q $(top_srcdir)
1070
1071 # Used to extract compile flags for YCM.
1072 print-%:
1073         @echo $($*)
1074
1075 git-contrib:
1076         @git shortlog -s `git describe --abbrev=0`.. | cut -c8- | awk '{ print $$0 "," }' | sort -u
1077
1078 EXTRA_DIST += \
1079         tools/gdb-sd_dump_hashmaps.py
1080
1081 list-keys:
1082         gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --list-keys
1083
1084 add-key:
1085         gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --import -