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