-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile.win32
209 lines (165 loc) · 5.87 KB
/
Makefile.win32
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
S2ESRC:=$(CURDIR)/s2e
S2EBUILD:=$(CURDIR)
MINGW:=/mingw64/x86_64-w64-mingw32
#Sometimes the build gets stuck with nb. of jobs > 1.
JOBS:=1
all: all-release
all-release: stamps/qemu-make-release stamps/tools-make-release
all-debug: stamps/qemu-make-debug stamps/tools-make-debug
ifeq ($(shell ls qemu/vl.c 2>&1),qemu/vl.c)
$(error You should not run make in S2E source directory!)
endif
#We don't use llvm-gcc on Windows
#ifeq ($(shell uname -s),Darwin)
# LLVM_GCC_SRC=llvm-gcc-4.2-2.6-i386-darwin9
#else
# LLVM_GCC_SRC=llvm-gcc-4.2-2.6-x86_64-linux
#endif
clean:
rm -Rf tools qemu-release qemu-debug klee stp llvm
rm -Rf llvm-2.6
rm -Rf $(LLVM_GCC_SRC)
rm -Rf stamps
.PHONY: all all-debug all-release clean
ALWAYS:
#############
# Downloads #
#############
#$(LLVM_GCC_SRC).tar.gz:
# wget http://llvm.org/releases/2.6/$(LLVM_GCC_SRC).tar.gz
#stamps/llvm-gcc-unpack: $(LLVM_GCC_SRC).tar.gz
# tar -zxf $(LLVM_GCC_SRC).tar.gz
# mkdir -p stamps && touch $@
llvm-2.6.tar.gz:
wget http://llvm.org/releases/2.6/llvm-2.6.tar.gz
clang-2.6.tar.gz:
wget http://llvm.org/releases/2.6/clang-2.6.tar.gz
stamps/llvm-unpack: llvm-2.6.tar.gz
if [ ! -d "llvm-2.6" ]; then \
tar -zxf llvm-2.6.tar.gz; \
cd llvm-2.6 && patch -p0 < $(S2ESRC)/windows-toolchain/llvm-2.6-mingw.patch; \
fi
mkdir -p stamps && touch $@
stamps/clang-unpack: clang-2.6.tar.gz stamps/llvm-unpack
if [ ! -d "llvm-2.6/tools/clang/clang-2.6" ]; then \
tar -zxf clang-2.6.tar.gz; \
mv clang-2.6 llvm-2.6/tools/clang; \
fi
mkdir -p stamps && touch $@
########
# LLVM #
########
stamps/llvm-configure: stamps/clang-unpack stamps/llvm-unpack
mkdir -p llvm
cd llvm && $(S2EBUILD)/llvm-2.6/configure \
--prefix=$(MINGW) \
--target=x86_64 --enable-jit --enable-targets=x86 --build=x86_64-w64-mingw32 \
--enable-optimized CXXFLAGS="-fexceptions"
mkdir -p stamps && touch $@
stamps/llvm-make-debug: stamps/llvm-configure
cd llvm && make ENABLE_OPTIMIZED=0 CXXFLAGS="-fexceptions -Wno-unused-but-set-variable" -j$(JOBS)
mkdir -p stamps && touch $@
#Install the Release version only
stamps/llvm-make-release: stamps/llvm-configure
cd llvm && make ENABLE_OPTIMIZED=1 CXXFLAGS="-fexceptions -Wno-unused-but-set-variable" install -j$(JOBS)
mv $(MINGW)/bin/clang.exe $(MINGW)/bin/llvm-gcc.exe
cp llvm/Release/bin/clang-cc.exe $(MINGW)/bin/
mkdir -p stamps && touch $@
#Required to fix the path to the clang compiler
stamps/llvm-reconfigure: stamps/llvm-make-release
mkdir -p llvm
cd llvm && $(S2EBUILD)/llvm-2.6/configure \
--prefix=$(MINGW) \
--target=x86_64 --enable-jit --enable-targets=x86 --build=x86_64-w64-mingw32 \
--enable-optimized CXXFLAGS=-fexceptions
mkdir -p stamps && touch $@
#######
# STP #
#######
stamps/stp-copy:
cp -Rup $(S2ESRC)/stp stp
mkdir -p stamps && touch $@
stamps/stp-configure: stamps/stp-copy
cd stp && bash scripts/configure --with-prefix=$(S2EBUILD)/stp
cd stp && cp src/c_interface/c_interface.h include/stp
mkdir -p stamps && touch $@
stamps/stp-make: stamps/stp-configure ALWAYS
cp -Rup $(S2ESRC)/stp stp
cd stp && make -j$(JOBS) CC=g++
mkdir -p stamps && touch $@
stp/include/stp/c_interface.h: stamps/stp-configure
stp/lib/libstp.a: stamps/stp-make
########
# KLEE #
########
stamps/klee-configure: stamps/llvm-reconfigure \
stp/include/stp/c_interface.h \
stp/lib/libstp.a
mkdir -p klee
cd klee && $(S2ESRC)/klee/configure \
--prefix=$(MINGW) \
--with-llvmsrc=$(S2EBUILD)/llvm-2.6 \
--with-llvmobj=$(S2EBUILD)/llvm \
--with-stp=$(S2EBUILD)/stp \
--target=x86_64 \
--enable-exceptions
mkdir -p stamps && touch $@
stamps/klee-make-debug: stamps/klee-configure stamps/llvm-make-debug stamps/stp-make
cd klee && make ENABLE_OPTIMIZED=0 CFLAGS="-D_WIN32" -j$(JOBS)
mkdir -p stamps && touch $@
stamps/klee-make-release: stamps/klee-configure stamps/llvm-make-release stamps/stp-make
cd klee && make ENABLE_OPTIMIZED=1 CFLAGS="-D_WIN32" -j$(JOBS)
mkdir -p stamps && touch $@
########
# QEMU #
########
klee/Debug/bin/klee-config: stamps/klee-make-debug
klee/Release/bin/klee-config: stamps/klee-make-release
stamps/qemu-configure-debug: stamps/klee-configure klee/Debug/bin/klee-config
mkdir -p qemu-debug
cd qemu-debug && $(S2ESRC)/qemu/configure \
--prefix=$(S2EBUILD)/opt \
--with-llvm=$(S2EBUILD)/llvm/Debug \
--with-llvmgcc=$(MINGW)/bin/llvm-gcc \
--with-stp=$(S2EBUILD)/stp \
--with-klee=$(S2EBUILD)/klee/Debug \
--target-list=i386-s2e-softmmu,i386-softmmu \
--enable-llvm \
--enable-s2e \
--enable-debug
mkdir -p stamps && touch $@
stamps/qemu-configure-release: stamps/klee-configure klee/Release/bin/klee-config
mkdir -p qemu-release
cd qemu-release && $(S2ESRC)/qemu/configure \
--prefix=$(S2EBUILD)/opt \
--with-llvm=$(S2EBUILD)/llvm/Release \
--with-llvmgcc=$(MINGW)/bin/llvm-gcc \
--with-stp=$(S2EBUILD)/stp \
--with-klee=$(S2EBUILD)/klee/Release \
--target-list=i386-s2e-softmmu,i386-softmmu \
--enable-llvm \
--enable-s2e --extra-cflags="-D_WIN32 -Wno-unsused-but-used-variable"
mkdir -p stamps && touch $@
stamps/qemu-make-debug: stamps/qemu-configure-debug stamps/klee-make-debug ALWAYS
cd qemu-debug && make -j$(JOBS)
mkdir -p stamps && touch $@
stamps/qemu-make-release: stamps/qemu-configure-release stamps/klee-make-release ALWAYS
cd qemu-release && make -j$(JOBS) CFLAGS=-Wno-unused-but-set-variable CXXFLAGS=-Wno-unused-but-set-variable
mkdir -p stamps && touch $@
#########
# Tools #
#########
stamps/tools-configure: stamps/llvm-configure
mkdir -p tools
cd tools && $(S2ESRC)/tools/configure \
--with-llvmsrc=$(S2EBUILD)/llvm-2.6 \
--with-llvmobj=$(S2EBUILD)/llvm \
--with-s2esrc=$(S2ESRC)/qemu \
--target=x86_64
mkdir -p stamps && touch $@
stamps/tools-make-release: stamps/tools-configure ALWAYS
cd tools && make ENABLE_OPTIMIZED=1 -j$(JOBS)
mkdir -p stamps && touch $@
stamps/tools-make-debug: stamps/tools-configure ALWAYS
cd tools && make ENABLE_OPTIMIZED=0 -j$(JOBS)
mkdir -p stamps && touch $@