File: Makefile

package info (click to toggle)
earlyoom 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 204 kB
  • sloc: ansic: 718; makefile: 82; sh: 71
file content (83 lines) | stat: -rw-r--r-- 2,288 bytes parent folder | download
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
VERSION ?= $(shell git describe --tags --dirty 2> /dev/null)
CFLAGS += -Wall -Wextra -DVERSION=\"$(VERSION)\" -g -fstack-protector-all -std=gnu99

DESTDIR ?=
PREFIX ?= /usr/local
BINDIR ?= /bin
SYSCONFDIR ?= /etc
SYSTEMDUNITDIR ?= $(SYSCONFDIR)/systemd/system
PANDOC := $(shell command -v pandoc 2> /dev/null)

ifeq ($(VERSION),)
VERSION := "(unknown version)"
endif

.PHONY: all clean install uninstall format test

all: earlyoom earlyoom.1

earlyoom: $(wildcard *.c *.h) Makefile
	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(wildcard *.c)

earlyoom.1: MANPAGE.md
ifdef PANDOC
	pandoc MANPAGE.md -s -t man > earlyoom.1
else
	@echo "pandoc is not installed, skipping earlyoom.1 manpage generation"
endif

clean:
	rm -f earlyoom earlyoom.service earlyoom.initscript earlyoom.1 earlyoom.1.gz

install: earlyoom.service install-bin install-default install-man
	install -d $(DESTDIR)$(SYSTEMDUNITDIR)
	install -m 644 $< $(DESTDIR)$(SYSTEMDUNITDIR)
	-systemctl enable earlyoom

install-initscript: earlyoom.initscript install-bin install-default
	install -d $(DESTDIR)$(SYSCONFDIR)/init.d/
	install -m 755 $< $(DESTDIR)$(SYSCONFDIR)/init.d/earlyoom
	-update-rc.d earlyoom start 18 2 3 4 5 . stop 20 0 1 6 .

earlyoom.%: earlyoom.%.in
	sed "s|:TARGET:|$(PREFIX)$(BINDIR)|g;s|:SYSCONFDIR:|$(SYSCONFDIR)|g" $< > $@

install-default: earlyoom.default install-man
	install -d $(DESTDIR)$(SYSCONFDIR)/default/
	install -m 644 $< $(DESTDIR)$(SYSCONFDIR)/default/earlyoom

install-bin: earlyoom
	install -d $(DESTDIR)$(PREFIX)$(BINDIR)/
	install -m 755 $< $(DESTDIR)$(PREFIX)$(BINDIR)/

install-man: earlyoom.1.gz
ifdef PANDOC
	install -d $(DESTDIR)$(PREFIX)/share/man/man1/
	install -m 644 $< $(DESTDIR)$(PREFIX)/share/man/man1/
endif

earlyoom.1.gz: earlyoom.1
ifdef PANDOC
	gzip -f -k $<
endif

uninstall: uninstall-bin uninstall-man
	systemctl disable earlyoom
	rm -f $(DESTDIR)$(SYSTEMDUNITDIR)/earlyoom.service

uninstall-man:
	rm -f $(DESTDIR)$(PREFIX)/share/man/man1/earlyoom.1.gz

uninstall-initscript: uninstall-bin
	rm -f $(DESTDIR)$(SYSCONFDIR)/init.d/earlyoom
	update-rc.d earlyoom remove

uninstall-bin:
	rm -f $(DESTDIR)$(PREFIX)$(BINDIR)/earlyoom

# Depends on earlyoom compilation to make sure the syntax is ok.
format: earlyoom
	clang-format -i *.h *.c

test: earlyoom
	cd tests ; go test -v