forked from fancycode/lzma-fuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (85 loc) · 2.34 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
ROOT = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
SDK_ROOT = $(ROOT)sdk
CORPUS_ROOT = $(ROOT)corpus
SDK_FLAGS = -D_7ZIP_PPMD_SUPPPORT
C_SOURCES = \
$(SDK_ROOT)/C/7zAlloc.c \
$(SDK_ROOT)/C/7zArcIn.c \
$(SDK_ROOT)/C/7zBuf2.c \
$(SDK_ROOT)/C/7zBuf.c \
$(SDK_ROOT)/C/7zCrc.c \
$(SDK_ROOT)/C/7zCrcOpt.c \
$(SDK_ROOT)/C/7zDec.c \
$(SDK_ROOT)/C/7zFile.c \
$(SDK_ROOT)/C/7zStream.c \
$(SDK_ROOT)/C/Aes.c \
$(SDK_ROOT)/C/AesOpt.c \
$(SDK_ROOT)/C/Alloc.c \
$(SDK_ROOT)/C/Bcj2.c \
$(SDK_ROOT)/C/Bcj2Enc.c \
$(SDK_ROOT)/C/Bra86.c \
$(SDK_ROOT)/C/Bra.c \
$(SDK_ROOT)/C/BraIA64.c \
$(SDK_ROOT)/C/CpuArch.c \
$(SDK_ROOT)/C/Delta.c \
$(SDK_ROOT)/C/DllSecur.c \
$(SDK_ROOT)/C/LzFind.c \
$(SDK_ROOT)/C/Lzma2Dec.c \
$(SDK_ROOT)/C/Lzma2DecMt.c \
$(SDK_ROOT)/C/Lzma2Enc.c \
$(SDK_ROOT)/C/Lzma86Dec.c \
$(SDK_ROOT)/C/LzmaDec.c \
$(SDK_ROOT)/C/LzmaEnc.c \
$(SDK_ROOT)/C/LzmaLib.c \
$(SDK_ROOT)/C/MtCoder.c \
$(SDK_ROOT)/C/MtDec.c \
$(SDK_ROOT)/C/Ppmd7.c \
$(SDK_ROOT)/C/Ppmd7Dec.c \
$(SDK_ROOT)/C/Ppmd7Enc.c \
$(SDK_ROOT)/C/Sha256.c \
$(SDK_ROOT)/C/Sort.c \
$(SDK_ROOT)/C/Xz.c \
$(SDK_ROOT)/C/XzCrc64.c \
$(SDK_ROOT)/C/XzCrc64Opt.c \
$(SDK_ROOT)/C/XzDec.c \
$(SDK_ROOT)/C/XzEnc.c \
$(SDK_ROOT)/C/XzIn.c
ifeq ($(ENABLE_MT), 1)
C_SOURCES += \
$(SDK_ROOT)/C/LzFindMt.c \
$(SDK_ROOT)/C/Threads.c
else
SDK_FLAGS += \
-D_7ZIP_ST=1
endif
C_OBJ = $(C_SOURCES:%.c=%.o)
COMMON_FLAGS=-g -Wall -Werror
INCLUDES = -I$(SDK_ROOT)/C
LIB_FUZZING_ENGINE ?= -lFuzzingEngine
FUZZERS_OBJ = $(patsubst %.cc,%.o,$(wildcard *_fuzzer.cc))
FUZZERS = $(patsubst %.cc,%,$(wildcard *_fuzzer.cc))
CORPUS_DIRS = $(wildcard $(CORPUS_ROOT)/*)
CORPUSES = $(patsubst %,%_seed_corpus.zip,$(notdir $(CORPUS_DIRS)))
LIBRARY = liblzma.a
fuzzers: $(FUZZERS)
%_fuzzer: %_fuzzer.o $(LIBRARY)
$(CXX) $(LDFLAGS) $(CXXFLAGS) $(COMMON_FLAGS) -o $@ $(LIB_FUZZING_ENGINE) $+
$(LIBRARY): $(C_OBJ)
$(AR) r $@ $+
clean:
rm -f $(LIBRARY) $(C_OBJ)
rm -f $(FUZZERS_OBJ) $(FUZZERS)
rm -f $(CORPUSES)
%.o: %.c
$(CC) $(CFLAGS) $(SDK_FLAGS) $(INCLUDES) $(COMMON_FLAGS) -c -o $@ $<
%.o: %.cc
$(CXX) $(CXXFLAGS) $(INCLUDES) $(COMMON_FLAGS) -c -o $@ $<
%_seed_corpus.zip:
zip -r $@ $(CORPUS_ROOT)/$*
corpuses: $(CORPUSES)
install: fuzzers corpuses
@[ ! -z "$(DEST)" ] || echo "Run as make DEST=folder"
@[ ! -z "$(DEST)" ] || exit 1
cp $(FUZZERS) $(DEST)
cp $(CORPUSES) $(DEST)
cp *.dict $(DEST)