-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (69 loc) · 2 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# syncretism Makefile
CC?=cc
OBJDIR?=obj
BIN=syncretism
LIBNYFE=nyfe/libnyfe.a
VERSION=$(OBJDIR)/version.c
DESTDIR?=
PREFIX?=/usr/local
INSTALL_DIR=$(PREFIX)/bin
CFLAGS+=-std=c99 -pedantic -Wall -Werror -Wstrict-prototypes
CFLAGS+=-Wmissing-prototypes -Wmissing-declarations -Wshadow
CFLAGS+=-Wpointer-arith -Wcast-qual -Wsign-compare -O2
CFLAGS+=-fstack-protector-all -Wtype-limits -fno-common -Iinclude
CFLAGS+=-Inyfe/include
CFLAGS+=-g
SRC= src/syncretism.c \
src/client.c \
src/file.c \
src/msg.c \
src/server.c
ifeq ("$(SANITIZE)", "1")
CFLAGS+=-fsanitize=address,undefined
LDFLAGS+=-fsanitize=address,undefined
endif
LDFLAGS+=$(LIBNYFE)
INSTALL_TARGETS=install-bin
OSNAME=$(shell uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
ifeq ("$(OSNAME)", "linux")
CFLAGS+=-D_GNU_SOURCE=1 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
else ifeq ("$(OSNAME)", "darwin")
else ifeq ("$(OSNAME)", "openbsd")
endif
OBJS= $(SRC:src/%.c=$(OBJDIR)/%.o)
OBJS+= $(OBJDIR)/version.o
all: $(BIN)
$(BIN): $(OBJDIR) $(LIBNYFE) $(OBJS) $(VERSION)
$(CC) $(OBJS) $(LDFLAGS) -o $(BIN)
$(VERSION): $(OBJDIR) force
@if [ -f RELEASE ]; then \
printf "const char *syncretism_build_rev = \"%s\";\n" \
`cat RELEASE` > $(VERSION); \
elif [ -d .git ]; then \
GIT_REVISION=`git rev-parse --short=8 HEAD`; \
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`; \
rm -f $(VERSION); \
printf "const char *syncretism_build_rev = \"%s-%s\";\n" \
$$GIT_BRANCH $$GIT_REVISION > $(VERSION); \
else \
echo "No version information found (no .git or RELEASE)"; \
exit 1; \
fi
@printf "const char *syncretism_build_date = \"%s\";\n" \
`date +"%Y-%m-%d"` >> $(VERSION);
install: $(INSTALL_TARGETS)
install-bin: $(BIN)
mkdir -p $(DESTDIR)$(INSTALL_DIR)
install -m 555 $(BIN) $(DESTDIR)$(INSTALL_DIR)/$(BIN)
$(LIBNYFE):
$(MAKE) -C nyfe
src/syncretism.c: $(VERSION)
$(OBJDIR):
@mkdir -p $(OBJDIR)
$(OBJDIR)/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(VERSION)
$(MAKE) -C nyfe clean
rm -rf $(OBJDIR) $(BIN)
.PHONY: all clean force