-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
101 lines (82 loc) · 2.65 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
90
91
92
93
94
95
96
97
98
99
100
101
HS_LIBDIR := $(shell cd src && stack ghc -- --print-libdir 2>/dev/null)
PATH_STACK := $(shell cd src && pwd 2>/dev/null)
BIN_PATH := $(shell cd src && stack path --dist-dir --allow-different-user 2>/dev/null)
BIN_PATH_ABS := $(shell pwd)/src/${BIN_PATH}
PATH_STACK_PROGRAMS := $(shell cd src && stack path --programs 2>/dev/null)
BIN := jwtfuzz-exe
BUILD_CONTAINER := ${BIN}-builder
EXE_CONTAINER := jwtfuzz
ifeq ($(OS),Windows_NT)
# 2022-10-12: Not currently supported
# CCFLAGS += -D WIN32
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
#CCFLAGS += -D LINUX
PATH_LIBHS_JWTFUZZ := ${BIN_PATH_ABS}/build/libHSjwtfuzz.so
PATH_LIB_JWTFUZZ := ${BIN_PATH_ABS}/build/jwtfuzz/libjwtfuzz.so
LIB_PRELOAD := LD_PRELOAD="${PATH_LIB_JWTFUZZ} ${PATH_LIBHS_JWTFUZZ}"
endif
ifeq ($(UNAME_S),Darwin)
#CCFLAGS += -D OSX
PATH_LIBHS_JWTFUZZ := ${BIN_PATH_ABS}/build/libHSjwtfuzz.dylib
PATH_LIB_JWTFUZZ := ${BIN_PATH_ABS}/build/jwtfuzz/libjwtfuzz.dylib
LIB_PRELOAD := DYLD_INSERT_LIBRARIES="${PATH_LIB_JWTFUZZ}:${PATH_LIBHS_JWTFUZZ}"
endif
endif
PATH_GHC_INCLUDES := ${PATH_STACK_PROGRAMS}/ghc-tinfo6-9.0.2/lib/ghc-9.0.2/include
bin: FORCE
cd src && \
stack build \
--allow-different-user
make copy
watch: FORCE
cd src && \
stack build \
--allow-different-user \
--file-watch \
--exec "make -C ./.. copy"
copy: FORCE
cp ./src/${BIN_PATH}/build/${BIN}/${BIN} bin/;
so: FORCE
# Clean env
rm ${PATH_LIBHS_JWTFUZZ} 2>/dev/null || true
cd src && \
stack build --allow-different-user
# Create a symlink to libHSjwtfuzz
@if [ $(UNAME_S) = "Linux" ]; then \
ln -s ${BIN_PATH_ABS}/build/libHSjwtfuzz-*.so ${PATH_LIBHS_JWTFUZZ}; \
fi
@if [ $(UNAME_S) = "Darwin" ]; then \
ln -s ${BIN_PATH_ABS}/build/libHSjwtfuzz-*.dylib ${PATH_LIBHS_JWTFUZZ}; \
fi
# Compile test program that links with jwtfuzz lib
cd so/test && \
gcc -o test \
-I ${PATH_STACK}/c \
-I ${PATH_GHC_INCLUDES} \
-I ${BIN_PATH_ABS}/build \
-L${BIN_PATH_ABS}/build/jwtfuzz \
-L${BIN_PATH_ABS}/build \
-ljwtfuzz \
-lHSjwtfuzz \
-Wl,-rpath,'$$ORIGIN' \
main.c
echo "Running Tests.."
cd so/test && \
${LIB_PRELOAD} ./test
docker-image: docker-build-image
sudo docker build -t "${EXE_CONTAINER}" -t "cortisol/jwtfuzz:latest" -f ./docker/Dockerfile .
docker-build-image:
sudo docker build -t ${BUILD_CONTAINER} -f ./docker/Dockerfile-build .
docker-build: docker-build-image
sudo docker run -it -v $$(pwd):/app ${BUILD_CONTAINER} bash -c 'cd /app/; make bin'
docker-build-watch: docker-build-image
sudo docker run -it -v $$(pwd):/app ${BUILD_CONTAINER} bash -c 'cd /app/; make watch'
go:
cd go && \
go build
clean:
rm bin/*
.PHONY: clean
FORCE: ;