1PKG_CONFIG ?= pkg-config
2
3# Installation directories.
4LINGUAS ?= ru
5PREFIX ?= /usr
6SBINDIR ?= $(PREFIX)/sbin
7MANDIR = $(PREFIX)/share/man
8AUTOSTARTDIR = /etc/xdg/autostart
9DBUSSERVICEDIR = $(PREFIX)/share/dbus-1/services
10SYSTEMDDIR ?= $(PREFIX)/lib/systemd
11
12autostart_DATA = sealertauto.desktop
13INITDIR ?= /etc/rc.d/init.d
14SELINUXDIR = /etc/selinux
15
16DBUSFLAGS = -DHAVE_DBUS $(shell $(PKG_CONFIG) --cflags dbus-glib-1)
17DBUSLIB = $(shell $(PKG_CONFIG) --libs dbus-glib-1)
18
19CFLAGS ?= -g -Werror -Wall -W
20override CFLAGS += $(DBUSFLAGS)
21
22override LDLIBS += -lselinux $(DBUSLIB)
23
24all: restorecond
25
26restorecond.o utmpwatcher.o stringslist.o user.o watch.o: restorecond.h
27
28restorecond:  restore.o restorecond.o utmpwatcher.o stringslist.o user.o watch.o
29	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
30
31install: all
32	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
33	-mkdir -p $(DESTDIR)$(SBINDIR)
34	install -m 755 restorecond $(DESTDIR)$(SBINDIR)
35	install -m 644 restorecond.8 $(DESTDIR)$(MANDIR)/man8
36	for lang in $(LINGUAS) ; do \
37		if [ -e $${lang} ] ; then \
38			[ -d $(DESTDIR)$(MANDIR)/$${lang}/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/$${lang}/man8 ; \
39			install -m 644 $${lang}/*.8 $(DESTDIR)$(MANDIR)/$${lang}/man8/ ; \
40		fi ; \
41	done
42	-mkdir -p $(DESTDIR)$(INITDIR)
43	install -m 755 restorecond.init $(DESTDIR)$(INITDIR)/restorecond
44	-mkdir -p $(DESTDIR)$(SELINUXDIR)
45	install -m 644 restorecond.conf $(DESTDIR)$(SELINUXDIR)/restorecond.conf
46	install -m 644 restorecond_user.conf $(DESTDIR)$(SELINUXDIR)/restorecond_user.conf
47	-mkdir -p $(DESTDIR)$(AUTOSTARTDIR)
48	install -m 644 restorecond.desktop $(DESTDIR)$(AUTOSTARTDIR)/restorecond.desktop
49	-mkdir -p $(DESTDIR)$(DBUSSERVICEDIR)
50	install -m 644 org.selinux.Restorecond.service  $(DESTDIR)$(DBUSSERVICEDIR)/org.selinux.Restorecond.service
51	-mkdir -p $(DESTDIR)$(SYSTEMDDIR)/system
52	install -m 644 restorecond.service $(DESTDIR)$(SYSTEMDDIR)/system/
53relabel: install
54	/sbin/restorecon $(DESTDIR)$(SBINDIR)/restorecond
55
56clean:
57	-rm -f restorecond *.o *~
58
59indent:
60	../../scripts/Lindent $(wildcard *.[ch])
61
62test:
63