forked from jedisct1/dsvpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
32 lines (26 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
CFLAGS_FILE?=.cflags
COMPILE_TEST_FILE?=.test.c
PREFIX?=/usr/local
all: dsvpn
dsvpn: $(CFLAGS_FILE) Makefile src/vpn.c src/charm.c src/os.c include/charm.h include/vpn.h include/os.h
$(CC) $$(cat "$(CFLAGS_FILE)") $(OPTFLAGS) -Iinclude -o $@ src/vpn.c src/charm.c src/os.c
strip $@
install: dsvpn
install -d $(PREFIX)/sbin
install -m 0755 dsvpn $(PREFIX)/sbin
uninstall:
rm -f $(PREFIX)/sbin/dsvpn
clean:
rm -f dsvpn *~ $(CFLAGS_FILE) $(COMPILE_TEST_FILE)
$(CFLAGS_FILE):
@CFLAGS="$(CFLAGS)"
@if [ -z "$$CFLAGS" ]; then \
if [ ! -r "$(CFLAGS_FILE)" ]; then \
echo "int main(void) { return 0; }" > "$(COMPILE_TEST_FILE)"; \
for flag in -march=native -mtune=native -Ofast -Wno-unused-command-line-argument; do \
$(CC) $${CFLAGS} $${flag} "$(COMPILE_TEST_FILE)" >/dev/null 2>&1 && CFLAGS="$$CFLAGS $$flag"; \
done; \
CFLAGS="$${CFLAGS} -Wall -W -Wshadow -Wmissing-prototypes"; \
fi \
fi; \
echo "$$CFLAGS" > "$(CFLAGS_FILE)"