-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (53 loc) · 1.47 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
# Makefile
DESTDIR ?= dist
PYLIB ?= libwg
WGDIR = ../wireguard-tools/src
WGLIBDIR = $(WGDIR)/build/$(CONF)
CSTD = gnu99
CC = gcc
AR = ar
ARFLAGS = rcs
CFLAGS ?= -fPIC -std=$(CSTD) -O3 -fstack-protector
CFLAGS += -D_GNU_SOURCE
CFLAGS += -Wall -Wextra
CFLAGS += -MMD -MP
LDFLAGS = -L. -lc -shared
INCLUDES = -Isrc
# BUILD environment
GITCOMMIT=$(shell git rev-list -1 HEAD)
NOW=$(shell date "+%Y%m%d%H%M")
# OBJ paths match their src folder equivalents
INCDIR = include
OBJDIR = build
SRCDIR = src
LIBDIR = lib
BINDIR = $(DESTDIR)/shared
BIN = $(BINDIR)/libwg.so
LIB = $(LIBDIR)/$(LIBNAME).a
DISTDIR = dist
OBJS ?= $(OBJDIR)/config.o
OBJS += $(OBJDIR)/wireguard.o
OBJS += $(OBJDIR)/wglib.o
default: setup $(BIN)
echo "Copying binaries to $(DESTDIR)"; \
cp -uv $(SRCDIR)/libwg.py $(DESTDIR); \
cp -uv $(SRCDIR)/logger.py $(DESTDIR); \
cp -uv $(SRCDIR)/$(PYLIB)so.py $(DESTDIR)/shared/
setup:
mkdir -p $(DESTDIR); \
mkdir -p $(BINDIR); \
mkdir -p $(OBJDIR);
$(BIN): $(OBJS)
$(CC) $(LDFLAGS) -o $(BIN) $(OBJS);\
checksec --format=cli --file=$(BIN)
py3compile $(DESTDIR)
build/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
rm -rf $(DISTDIR) $(OBJDIR) $(LIBDIR) $(OBJS) $(LIB) *~
find . -name "*.o" -exec rm -f {} \;
fix-spaces:
find . -name "*.c" -exec perl -pi -e 's/\( /\(/' {} \;
find . -name "*.h" -exec perl -pi -e 's/\( /\(/' {} \;
format:
clang-format -i src/*.c src/*.h