-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
51 lines (43 loc) · 1.22 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
_CFLAGS=$(CFLAGS) -Wall -D_GNU_SOURCE
_LDFLAGS=$(LDFLAGS) -lcrypt
CC=gcc
OBJS=doas.o env.o shadowauth.o persist.o y.tab.o \
bsd-compat/closefrom.o bsd-compat/errc.o \
bsd-compat/explicit_bzero.o bsd-compat/pledge.o \
bsd-compat/readpassphrase.o bsd-compat/reallocarray.o \
bsd-compat/setprogname.o bsd-compat/strlcat.o \
bsd-compat/strlcpy.o bsd-compat/strtonum.o bsd-compat/unveil.o
ifdef STATE_DIR
_CFLAGS += -DDOAS_STATE_DIR='"'$(STATE_DIR)'"'
endif
ifdef PERSIST_TIMEOUT
_CFLAGS += -DDOAS_PERSIST_TIMEOUT='"'$(PERSIST_TIMEOUT)'"'
endif
ifdef CONF_FILE
_CFLAGS += -DDOAS_CONF_FILE='"'$(CONF_FILE)'"'
endif
ifdef SAFE_PATH
_CFLAGS += -DDOAS_SAFE_PATH='"'$(SAFE_PATH)'"'
endif
ifdef DEFAULT_PATH
_CFLAGS += -DDOAS_DEFAULT_PATH='"'$(DEFAULT_PATH)'"'
endif
ifdef DEFAULT_UMASK
_CFLAGS += -DDOAS_DEFAULT_UMASK='"'$(DEFAULT_UMASK)'"'
endif
all: doas
doas: $(OBJS)
$(CC) -o doas *.o bsd-compat/*.o $(_LDFLAGS)
%.o: %.c version.h
$(CC) $(_CFLAGS) -c $< -o $@
version.h:
printf "const char *version = \"doas r%s.%s\";\n" \
$$(git rev-list --count HEAD) \
$$(git rev-parse --short HEAD) > version.h
y.tab.o:
yacc parse.y
$(CC) $(_CFLAGS) -c y.tab.c -o y.tab.o
clean:
rm -f doas
rm -f $(OBJS) y.tab.c
rm -f version.h