-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
90 lines (66 loc) · 2.39 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
83
84
85
86
87
88
89
90
.POSIX:
TARGET = batsignal
CC.$(CC)=$(CC)
CC.=cc
CC.c99=cc
CC:=$(CC.$(CC))
RM = rm -f
INSTALL = install
SED = sed
GREP = grep
CUT = cut
VERSION != $(GREP) VERSION main.h | $(CUT) -d \" -f2
PROGNAME != $(GREP) PROGNAME main.h | $(CUT) -d \" -f2
PROGUPPER != $(GREP) PROGUPPER main.h | $(CUT) -d \" -f2
PREFIX = /usr/local
MANPREFIX.$(PREFIX)=$(PREFIX)/share/man
MANPREFIX./usr/local=/usr/local/man
MANPREFIX.=/usr/share/man
MANPREFIX=$(MANPREFIX.$(PREFIX))
INCLUDES != pkg-config --cflags libnotify
CFLAGS_EXTRA = -pedantic -Wall -Wextra -Werror -Wno-unused-parameter -Os
CFLAGS := $(CFLAGS_EXTRA) $(INCLUDES) $(CFLAGS)
LIBS != pkg-config --libs libnotify
LIBS := $(LIBS) -lm
LDFLAGS_EXTRA = -s
LDFLAGS := $(LDFLAGS_EXTRA) $(LDFLAGS)
SRC = main.c options.c battery.c notify.c
OBJ = $(SRC:.c=.o)
HDR = $(SRC:.c=.h)
.PHONY: all install install-service clean test compile-test
all: $(TARGET) $(TARGET).1
$(TARGET): $(OBJ)
$(CC) -o $(TARGET) $(LDFLAGS) $(OBJ) $(LIBS)
%.o: $(HDR)
$(TARGET).1: $(TARGET).1.in main.h
$(SED) "s/VERSION/$(VERSION)/g" < $(TARGET).1.in | $(SED) "s/PROGNAME/$(PROGNAME)/g" | $(SED) "s/PROGUPPER/$(PROGUPPER)/g" > $@
install: all
@echo Installing in $(DESTDIR)$(PREFIX)
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
$(INSTALL) -d $(DESTDIR)$(MANPREFIX)/man1
$(INSTALL) -m 0755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/
$(INSTALL) -m 0644 $(TARGET).1 $(DESTDIR)$(MANPREFIX)/man1/
install-service: install
$(INSTALL) -d $(DESTDIR)$(PREFIX)/lib/systemd/user
$(INSTALL) -m 0644 $(TARGET).service $(DESTDIR)$(PREFIX)/lib/systemd/user/
uninstall:
@echo Removing files from $(DESTDIR)$(PREFIX)
$(RM) $(DESTDIR)$(PREFIX)/bin/$(TARGET)
$(RM) $(DESTDIR)$(MANPREFIX)/man1/$(TARGET).1
$(RM) $(DESTDIR)$(PREFIX)/lib/systemd/user/$(TARGET).service
clean-all: clean clean-images
clean:
@echo Cleaning build files
$(RM) $(TARGET) $(OBJ) $(TARGET).1
clean-images: arch-clean debian-stable-clean debian-testing-clean ubuntu-latest-clean fedora-latest-clean
%-clean: test/Dockerfile.%
@echo Removing images for $*
-docker container prune --force --filter="label=$(TARGET)-$*"
-docker rmi -f $(TARGET)-$*
test: compile-test
compile-test: arch-test debian-stable-test debian-testing-test ubuntu-latest-test fedora-latest-test
@echo Completed compile testing
%-test: test/Dockerfile.%
@echo Starting compile test for $*
docker build --label=$(TARGET)-$* --tag=$(TARGET)-$* --file=$< .
docker run -it $(TARGET)-$*