blob: 185cc4c0ff4f9cce9f33cb280a7ec41460a1d1fe (
plain) (
blame)
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
|
USR_PREFIX = /usr
LOCAL_PREFIX = $(USR_PREFIX)/local
BIN = /bin
SBIN = /sbin
DEV = /dev
EXTRA_CPP_FLAGS =
# see configurable-definitions
_LB = $(LOCAL_PREFIX)$(BIN)
_UB = $(USR_PREFIX)$(BIN)
_SB = $(BIN)
_LS = $(LOCAL_PREFIX)$(SBIN)
_US = $(USR_PREFIX)$(SBIN)
_SS = $(SBIN)
TTY_GROUP = tty
DEFAULT_HOME = /
DEFAULT_SH = sh
DEFAULT_SHELL = $(BIN)/$(DEFAULT_SH)
DEFAULT_TERM = dumb
VCS = $(DEV)/vcs
VCSA = $(DEV)/vcsa
PATH = $(_LB):$(_UB):$(_SB)
PATH_ROOT = $(_LS):$(_LB):$(_US):$(_UB):$(_SS):$(_SB)
H = \#
VCS_LEN = $(shell vcs="$(VCS)" ; echo "$${$(H)vcs}")
VCSA_LEN = $(shell vcsa="$(VCSA)" ; echo "$${$(H)vcsa}")
VCS_VCSA_LEN = $(shell (echo $(VCS_LEN) ; echo $(VCSA_LEN)) | sort -n | tail -n 1)
STR_DEFS = TTY_GROUP DEFAULT_HOME DEFAULT_SH DEFAULT_SHELL DEFAULT_TERM PATH PATH_ROOT VCS VCSA
INT_DEFS = VCS_LEN VCSA_LEN VCS_VCSA_LEN
STR_CPPFLAGS = $(foreach D, $(STR_DEFS), -D'$(D)="$($(D))"')
INT_CPPFLAGS = $(foreach D, $(INT_DEFS), -D'$(D)=$($(D))')
OPTIMISE = -Os
CPPFLAGS = $(EXTRA_CPP_FLAGS) $(STR_CPPFLAGS) $(INT_CPPFLAGS)
LDFLAGS = -lpam
CFLAGS = -std=gnu99 -Wall -Wextra
CC_FLAGS = $(CPPFLAGS) $(CFLAGS) $(OPTIMISE)
LD_FLAGS = $(LDFLAGS) $(CFLAGS) $(OPTIMISE)
SRC = cerberus passphrase quit security login pam
OBJ = $(foreach S, $(SRC), obj/$(S).o)
.PHONY: all
all: bin/cerberus
bin/cerberus: $(OBJ)
@mkdir -p bin
$(CC) $(LD_FLAGS) -o "$@" $^
obj/cerberus.o: $(foreach H, $(SRC), src/$(H).h)
obj/%.o: src/%.c src/%.h src/config.h
@mkdir -p obj
$(CC) $(CC_FLAGS) -o "$@" -c "$<"
.PHONY: clean
clean:
-rm -r bin obj
|