-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathMakefile
68 lines (54 loc) · 1.9 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
# SPDX-License-Identifier: MIT
INSTALL ?= install
CARGO ?= cargo
CARGOFLAGS ?=
RONN ?= ronn
PKG_CONFIG ?= pkg-config
PREFIX ?= /usr
BUILDTYPE ?= release
SYSTEMD_UTIL_DIR := $(shell $(PKG_CONFIG) --variable=systemdutildir systemd)
SYSTEMD_SYSTEM_UNIT_DIR := $(shell $(PKG_CONFIG) --variable=systemdsystemunitdir systemd)
SYSTEMD_SYSTEM_GENERATOR_DIR := $(shell $(PKG_CONFIG) --variable=systemdsystemgeneratordir systemd)
export SYSTEMD_UTIL_DIR
ifeq ($(BUILDTYPE),release)
override CARGOFLAGS := --release $(CARGOFLAGS)
endif
require_env = @[ -n "$($(1))" ] || { echo "\$$$(1) empty!" >&2; exit 1; }
.DEFAULT: build
.PHONY: build systemd-service program man check clean install
build: program systemd-service
ifndef NOMAN
build: man
endif
program:
$(call require_env,SYSTEMD_UTIL_DIR)
$(CARGO) build $(CARGOFLAGS)
systemd-service:
$(call require_env,SYSTEMD_SYSTEM_GENERATOR_DIR)
sed -e 's,@SYSTEMD_SYSTEM_GENERATOR_DIR@,$(SYSTEMD_SYSTEM_GENERATOR_DIR),' \
<units/[email protected] \
>units/[email protected]
man:
$(RONN) --organization="zram-generator developers" man/*.md
check: program
$(CARGO) test $(CARGOFLAGS)
clippy:
$(call require_env,SYSTEMD_UTIL_DIR)
$(CARGO) clippy $(CARGOFLAGS)
clean:
$(CARGO) clean
rm -f units/[email protected]
ifndef NOBUILD
install: build
endif
install:
$(call require_env,SYSTEMD_SYSTEM_GENERATOR_DIR)
$(call require_env,SYSTEMD_SYSTEM_UNIT_DIR)
$(call require_env,PREFIX)
$(INSTALL) -Dpm755 target/$(BUILDTYPE)/zram-generator -t $(DESTDIR)$(SYSTEMD_SYSTEM_GENERATOR_DIR)/
$(INSTALL) -Dpm644 units/[email protected] -t $(DESTDIR)$(SYSTEMD_SYSTEM_UNIT_DIR)/
$(INSTALL) -Dpm644 zram-generator.conf.example -t $(DESTDIR)$(PREFIX)/share/doc/zram-generator/
ifndef NOMAN
$(INSTALL) -Dpm644 man/zram-generator.8 -t $(DESTDIR)$(PREFIX)/share/man/man8/
$(INSTALL) -Dpm644 man/zram-generator.conf.5 -t $(DESTDIR)$(PREFIX)/share/man/man5/
endif