-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
45 lines (31 loc) · 958 Bytes
/
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
DEST ?= /usr/local
SPWD_VERSION ?= $(shell git describe --tags)
BUILD = build
BIN = $(BUILD)/spwd
MANPAGE= $(BUILD)/spwd.1
CFLAGS += -Wall -Wextra -Wpedantic -O2
OBJECTS := $(patsubst src/%.c,$(BUILD)/%.o,$(wildcard src/*.c))
M4_DOCS = m4 -DSPWD_VERSION=$(SPWD_VERSION)
.DEFAULT_GOAL = test
$(BUILD)/%.o: src/%.c $(wildcard src/*.h) $(BUILD)/USAGE.h
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/USAGE.h: doc/USAGE.m4
@mkdir -p $(dir $@)
$(M4_DOCS) $< | xxd -i > $@
$(MANPAGE): doc/spwd.1.scd
@mkdir -p $(dir $@)
$(M4_DOCS) $< | scdoc > $@
$(BIN): $(OBJECTS)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -g -o $@ $(OBJECTS)
all: $(BIN)
clean:
rm -f $(BIN) $(OBJECTS) $(BUILD)/USAGE.h $(MANPAGE)
rmdir $(BUILD)
install: $(BIN) $(MANPAGE)
install -D -s -m 0755 -o root -g root $(BIN) $(DEST)/bin/spwd
install -D -m 0644 -o root -g root $(MANPAGE) $(DEST)/share/man/man1/spwd.1
test: all
@./tests/run
.PHONY: all clean install test