-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathMakefile
73 lines (54 loc) · 1.94 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
VERSION=v0.7
VERSION_GIT=$(shell test -d .git && git describe 2> /dev/null)
ifneq "$(VERSION_GIT)" ""
VERSION=$(VERSION_GIT)
endif
CC ?= gcc
CFLAGS += -std=c99 \
-D_GNU_SOURCE \
-Wall -Wunused-parameter -O2 \
-DVERSION_STR="\"$(VERSION)\""
CFDEBUG = -g3 -pedantic -Wlong-long
CFDEBUG += -Wsign-conversion -Wconversion -Wimplicit-function-declaration
LIBS = libudev mount glib-2.0
LDFLAGS := `pkg-config --libs $(LIBS)` $(LDFLAGS)
BINDIR ?= /usr/bin
SBINDIR ?= /sbin
SYSTEMDDIR ?= /usr/lib/systemd
all: ldm ldmc doc
.c.o:
$(CC) $(CFLAGS) `pkg-config --cflags $(LIBS)` -o $@ -c $<
ldm: ipc.o ldm.o
$(CC) -o ldm ipc.o ldm.o $(LDFLAGS)
ldmc: ipc.o ldmc.o
$(CC) -o ldmc ipc.o ldmc.o $(LDFLAGS)
debug: ldm ldmc
debug: CC += $(CFDEBUG)
service:
@sed "s|@@BINDIR@@|$(BINDIR)|" ldm.service.in > ldm.service
doc: ldm.pod ldmc.pod
@pod2man --section=1 --center="ldm Manual" --name "ldm" --release="$(VERSION)" ldm.pod > ldm.1
@pod2man --section=1 --center="ldmc Manual" --name "ldmc" --release="$(VERSION)" ldmc.pod > ldmc.1
readme: ldm.pod
@pod2markdown -u ldm.pod README.md
clean:
$(RM) *.o *.1 ldm ldmc ldm.service
mrproper: clean
$(RM) ldm ldmc
install-main: ldm doc
install -D -m 755 ldm $(DESTDIR)$(BINDIR)/ldm
install -D -m 755 ldmc $(DESTDIR)$(BINDIR)/ldmc
install -D -m 755 umount.ldm $(DESTDIR)$(SBINDIR)/umount.ldm
install -D -m 644 ldm.1 $(DESTDIR)/usr/share/man/man1/ldm.1
install -D -m 644 ldmc.1 $(DESTDIR)/usr/share/man/man1/ldmc.1
install-systemd: service
install -D -m 644 ldm.service $(DESTDIR)$(SYSTEMDDIR)/system/ldm.service
install: all install-main install-systemd
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/ldm
$(RM) $(DESTDIR)$(BINDIR)/ldmc
$(RM) $(DESTDIR)$(SBINDIR)/umount.ldm
$(RM) $(DESTDIR)/usr/share/man/man1/ldm.1
$(RM) $(DESTDIR)/usr/share/man/man1/ldmc.1
$(RM) $(DESTDIR)$(SYSTEMDDIR)/system/ldm.service
.PHONY: all debug clean mrproper install install-main install-systemd uninstall service readme