-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
82 lines (62 loc) · 2.27 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
BINDIR = /usr/lib/trash
BINNAME = trashd
BUSCONFDIR = /etc/dbus-1/system.d/
BUSCONFNAME = org.trash.trashd.conf
BUSSERVICEDIR = /usr/share/dbus-1/services/
BUSSERVICENAME = org.trash.trashd.service
SYSTEMDSERVICE = trashd.service
SYSTEMDDIR = /usr/lib/systemd/user
EXTRADIR = Extra
SAMPLEDIR = Sample
RM = rm -f
RMDIR = rm -rf
INSTALL = install -p
INSTALL_PROGRAM = $(INSTALL) -m755
INSTALL_DATA = $(INSTALL) -m644
INSTALL_DIR = $(INSTALL) -d
SRCDIR = src/
LIBS = -lm $(shell pkg-config --libs libsystemd libudev)
CFLAGS = $(shell pkg-config --cflags libsystemd libudev) -D_GNU_SOURCE -std=c99
ifeq (,$(findstring $(MAKECMDGOALS),"clean install uninstall"))
ifneq ("$(shell pkg-config --atleast-version=221 systemd && echo yes)", "yes")
$(error systemd minimum required version 221.)
endif
endif
TRASHD_VERSION = $(shell git describe --abbrev=0 --always --tags)
all: trashd clean
debug: trashd-debug clean
sample: SRCDIR=$(SAMPLEDIR)
sample: BINNAME=$(SAMPLEDIR)/sample
sample: all
objects:
@cd $(SRCDIR); $(CC) -c *.c $(CFLAGS) -O3
objects-debug:
@cd $(SRCDIR); $(CC) -c *.c -Wall $(CFLAGS) -Wshadow -Wtype-limits -Wstrict-overflow -fno-strict-aliasing -Wno-format -g
trashd: objects
@cd $(SRCDIR); $(CC) -o ../$(BINNAME) *.o $(LIBS)
trashd-debug: objects-debug
@cd $(SRCDIR); $(CC) -o ../$(BINNAME) *.o $(LIBS)
clean:
@cd $(SRCDIR); $(RM) *.o
install:
$(info installing bin.)
@$(INSTALL_DIR) "$(DESTDIR)$(BINDIR)"
@$(INSTALL_PROGRAM) $(BINNAME) "$(DESTDIR)$(BINDIR)"
$(info installing dbus conf file.)
@$(INSTALL_DIR) "$(DESTDIR)$(BUSCONFDIR)"
@$(INSTALL_DATA) $(EXTRADIR)/$(BUSCONFNAME) "$(DESTDIR)$(BUSCONFDIR)"
$(info installing dbus service file.)
@$(INSTALL_DIR) "$(DESTDIR)$(BUSSERVICEDIR)"
@$(INSTALL_DATA) $(EXTRADIR)/$(BUSSERVICENAME) "$(DESTDIR)$(BUSSERVICEDIR)"
$(info installing systemd service file.)
@$(INSTALL_DIR) "$(DESTDIR)$(SYSTEMDDIR)"
@$(INSTALL_DATA) $(EXTRADIR)/$(SYSTEMDSERVICE) "$(DESTDIR)$(SYSTEMDDIR)"
uninstall:
$(info uninstalling bin.)
@$(RM) "$(DESTDIR)$(BINDIR)/$(BINNAME)"
$(info uninstalling dbus conf file.)
@$(RM) "$(DESTDIR)$(BUSCONFDIR)/$(BUSCONFNAME)"
$(info uninstalling dbus service file.)
@$(RM) "$(DESTDIR)$(BUSSERVICEDIR)/$(BUSSERVICENAME)"
$(info uninstalling systemd service file.)
@$(RM) "$(DESTDIR)$(SYSTEMDDIR)/$(SYSTEMDSERVICE)"