Ticket #13081: fix-vs-build-win3.txt

File fix-vs-build-win3.txt, 9.3 KB (added by NewEraCracker, 5 years ago)

3rd version of patch to build Tor with VS. Fixes problems with OpenSSL.

Line 
1diff -uNraw tor-0.2.5.6-alpha/Makefile.nmake tor-0.2.5.6-alpha.new/Makefile.nmake
2--- tor-0.2.5.6-alpha/Makefile.nmake    Sat Jun 21 21:16:03 2014
3+++ tor-0.2.5.6-alpha.new/Makefile.nmake        Mon Sep  8 16:10:27 2014
4@@ -1,15 +1,23 @@
5 all:
6        cd src/common
7        $(MAKE) /F Makefile.nmake
8+       cd ../../src/ext
9+       $(MAKE) /F Makefile.nmake
10        cd ../../src/or
11        $(MAKE) /F Makefile.nmake
12        cd ../../src/test
13        $(MAKE) /F Makefile.nmake
14+       cd ../../src/tools
15+       $(MAKE) /F Makefile.nmake
16 
17 clean:
18        cd src/common
19        $(MAKE) /F Makefile.nmake clean
20+       cd ../../src/ext
21+       $(MAKE) /F Makefile.nmake clean
22        cd ../../src/or
23        $(MAKE) /F Makefile.nmake clean
24        cd ../../src/test
25        $(MAKE) /F Makefile.nmake clean
26+       cd ../../src/tools
27+       $(MAKE) /F Makefile.nmake clean
28diff -uNraw tor-0.2.5.6-alpha/src/common/Makefile.nmake tor-0.2.5.6-alpha.new/src/common/Makefile.nmake
29--- tor-0.2.5.6-alpha/src/common/Makefile.nmake Sat Jun 21 21:16:03 2014
30+++ tor-0.2.5.6-alpha.new/src/common/Makefile.nmake     Mon Sep  8 16:10:27 2014
31@@ -1,12 +1,12 @@
32 all: libor.lib libor-crypto.lib libor-event.lib
33 
34-CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\ext
35+CFLAGS = /D TOR_UNIT_TESTS /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
36 
37-LIBOR_OBJECTS = address.obj compat.obj container.obj di_ops.obj \
38-       log.obj memarea.obj mempool.obj procmon.obj util.obj \
39+LIBOR_OBJECTS = address.obj backtrace.obj compat.obj container.obj di_ops.obj \
40+       log.obj memarea.obj mempool.obj procmon.obj sandbox.obj util.obj \
41        util_codedigest.obj
42 
43-LIBOR_CRYPTO_OBJECTS = aes.obj crypto.obj torgzip.obj tortls.obj \
44+LIBOR_CRYPTO_OBJECTS = aes.obj crypto.obj crypto_format.obj torgzip.obj tortls.obj \
45        crypto_curve25519.obj curve25519-donna.obj
46 
47 LIBOR_EVENT_OBJECTS = compat_libevent.obj
48diff -uNraw tor-0.2.5.6-alpha/src/common/backtrace.c tor-0.2.5.6-alpha.new/src/common/backtrace.c
49--- tor-0.2.5.6-alpha/src/common/backtrace.c    Mon Jul 28 10:00:13 2014
50+++ tor-0.2.5.6-alpha.new/src/common/backtrace.c        Mon Sep  8 16:44:21 2014
51@@ -4,11 +4,6 @@
52 #define __USE_GNU
53 #define _GNU_SOURCE 1
54 
55-#include "orconfig.h"
56-#include "compat.h"
57-#include "util.h"
58-#include "torlog.h"
59-
60 #ifdef HAVE_EXECINFO_H
61 #include <execinfo.h>
62 #endif
63@@ -21,6 +16,11 @@
64 #ifdef HAVE_SIGNAL_H
65 #include <signal.h>
66 #endif
67+
68+#include "orconfig.h"
69+#include "compat.h"
70+#include "util.h"
71+#include "torlog.h"
72 
73 #ifdef HAVE_CYGWIN_SIGNAL_H
74 #include <cygwin/signal.h>
75diff -uNraw tor-0.2.5.6-alpha/src/common/crypto.c tor-0.2.5.6-alpha.new/src/common/crypto.c
76--- tor-0.2.5.6-alpha/src/common/crypto.c       Mon Jul 28 10:00:13 2014
77+++ tor-0.2.5.6-alpha.new/src/common/crypto.c   Mon Sep  8 16:54:07 2014
78@@ -24,6 +24,10 @@
79 #undef OCSP_RESPONSE
80 #endif
81 
82+#ifdef _MSC_VER
83+#include <openssl/applink.c>
84+#endif
85+
86 #include <openssl/err.h>
87 #include <openssl/rsa.h>
88 #include <openssl/pem.h>
89diff -uNraw tor-0.2.5.6-alpha/src/ext/Makefile.nmake tor-0.2.5.6-alpha.new/src/ext/Makefile.nmake
90--- tor-0.2.5.6-alpha/src/ext/Makefile.nmake    Thu Jan  1 00:00:00 1970
91+++ tor-0.2.5.6-alpha.new/src/ext/Makefile.nmake        Mon Sep  8 16:10:27 2014
92@@ -0,0 +1,12 @@
93+all: csiphash.lib tinytest.lib
94+
95+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
96+
97+csiphash.lib: csiphash.obj
98+       lib csiphash.obj /out:csiphash.lib
99+
100+tinytest.lib: tinytest.obj
101+       lib tinytest.obj /out:tinytest.lib
102+
103+clean:
104+       del *.obj *.lib
105diff -uNraw tor-0.2.5.6-alpha/src/ext/tinytest.c tor-0.2.5.6-alpha.new/src/ext/tinytest.c
106--- tor-0.2.5.6-alpha/src/ext/tinytest.c        Mon Jul 28 10:00:13 2014
107+++ tor-0.2.5.6-alpha.new/src/ext/tinytest.c    Mon Sep  8 16:53:11 2014
108@@ -56,6 +56,10 @@
109 #define __attribute__(x)
110 #endif
111 
112+#ifdef _MSC_VER
113+#define snprintf _snprintf
114+#endif
115+
116 #include "tinytest.h"
117 #include "tinytest_macros.h"
118 
119diff -uNraw tor-0.2.5.6-alpha/src/or/Makefile.nmake tor-0.2.5.6-alpha.new/src/or/Makefile.nmake
120--- tor-0.2.5.6-alpha/src/or/Makefile.nmake     Sat Jun 21 21:16:03 2014
121+++ tor-0.2.5.6-alpha.new/src/or/Makefile.nmake Mon Sep  8 16:40:58 2014
122@@ -1,7 +1,6 @@
123 all: tor.exe
124 
125-CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common \
126-    /I ..\ext
127+CFLAGS = /D TOR_UNIT_TESTS /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
128 
129 LIBS = ..\..\..\build-alpha\lib\libevent.lib \
130  ..\..\..\build-alpha\lib\libcrypto.lib \
131@@ -15,6 +14,7 @@
132   buffers.obj \
133   channel.obj \
134   channeltls.obj \
135+  circpathbias.obj \
136   circuitbuild.obj \
137   circuitlist.obj \
138   circuitmux.obj \
139@@ -35,6 +35,7 @@
140   dirvote.obj \
141   dns.obj \
142   dnsserv.obj \
143+  ext_orport.obj \
144   fp_pair.obj \
145   entrynodes.obj \
146   geoip.obj \
147@@ -69,7 +70,7 @@
148        lib $(LIBTOR_OBJECTS) /out:$@
149 
150 tor.exe: libtor.lib tor_main.obj
151-       $(CC) $(CFLAGS) $(LIBS) libtor.lib ..\common\*.lib tor_main.obj /Fe$@
152+       $(CC) $(CFLAGS) $(LIBS) libtor.lib ..\common\*.lib ..\ext\*.lib tor_main.obj /Fe$@
153 
154 clean:
155-       del $(LIBTOR_OBJECTS) *.lib tor.exe
156+       del $(LIBTOR_OBJECTS) tor_main.obj *.lib tor.exe tor.exp
157diff -uNraw tor-0.2.5.6-alpha/src/test/Makefile.nmake tor-0.2.5.6-alpha.new/src/test/Makefile.nmake
158--- tor-0.2.5.6-alpha/src/test/Makefile.nmake   Thu Jan  1 00:00:00 1970
159+++ tor-0.2.5.6-alpha.new/src/test/Makefile.nmake       Mon Sep  8 16:40:59 2014
160@@ -0,0 +1,52 @@
161+all: bench.exe test.exe
162+
163+CFLAGS = /D TOR_UNIT_TESTS /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
164+
165+LIBS = ..\..\..\build-alpha\lib\libevent.lib \
166+ ..\..\..\build-alpha\lib\libcrypto.lib \
167+ ..\..\..\build-alpha\lib\libssl.lib \
168+ ..\..\..\build-alpha\lib\libz.lib \
169+ ws2_32.lib advapi32.lib shell32.lib \
170+ crypt32.lib gdi32.lib user32.lib
171+
172+TEST_OBJECTS = \
173+  test.obj                   \
174+  test_addr.obj              \
175+# test_bt_cl.obj             \
176+  test_buffers.obj           \
177+  test_cell_formats.obj      \
178+  test_cell_queue.obj        \
179+  test_circuitlist.obj       \
180+  test_circuitmux.obj        \
181+  test_config.obj            \
182+  test_containers.obj        \
183+  test_controller_events.obj \
184+  test_crypto.obj            \
185+  test_data.obj              \
186+  test_dir.obj               \
187+  test_extorport.obj         \
188+  test_hs.obj                \
189+  test_introduce.obj         \
190+  test_logging.obj           \
191+  test_microdesc.obj         \
192+  test_nodelist.obj          \
193+# test_ntor_cl.obj           \
194+  test_oom.obj               \
195+  test_options.obj           \
196+  test_policy.obj            \
197+  test_pt.obj                \
198+  test_relaycell.obj         \
199+  test_replay.obj            \
200+  test_routerkeys.obj        \
201+  test_socks.obj             \
202+  test_status.obj            \
203+  test_util.obj
204+
205+bench.exe: bench.obj
206+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib bench.obj /Fe$@
207+
208+test.exe: $(TEST_OBJECTS)
209+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib $(TEST_OBJECTS) /Fe$@
210+
211+clean:
212+       del bench.obj $(TEST_OBJECTS) bench.exe bench.exp test.exe test.exp
213diff -uNraw tor-0.2.5.6-alpha/src/test/test.h tor-0.2.5.6-alpha.new/src/test/test.h
214--- tor-0.2.5.6-alpha/src/test/test.h   Mon Jul 28 10:00:13 2014
215+++ tor-0.2.5.6-alpha.new/src/test/test.h       Mon Sep  8 16:10:27 2014
216@@ -61,7 +61,7 @@
217 
218 #ifdef _MSC_VER
219 #define U64_PRINTF_TYPE uint64_t
220-#define U64_PRINTF_TYPE int64_t
221+#define I64_PRINTF_TYPE int64_t
222 #else
223 #define U64_PRINTF_TYPE unsigned long long
224 #define I64_PRINTF_TYPE long long
225diff -uNraw tor-0.2.5.6-alpha/src/test/test_bt_cl.c tor-0.2.5.6-alpha.new/src/test/test_bt_cl.c
226--- tor-0.2.5.6-alpha/src/test/test_bt_cl.c     Mon Jul 28 10:00:13 2014
227+++ tor-0.2.5.6-alpha.new/src/test/test_bt_cl.c Mon Sep  8 16:10:27 2014
228@@ -18,6 +18,9 @@
229 #ifdef __GNUC__
230 #define NOINLINE __attribute__((noinline))
231 #define NORETURN __attribute__((noreturn))
232+#else
233+#define NOINLINE
234+#define NORETURN
235 #endif
236 
237 int crash(int x) NOINLINE;
238diff -uNraw tor-0.2.5.6-alpha/src/tools/Makefile.nmake tor-0.2.5.6-alpha.new/src/tools/Makefile.nmake
239--- tor-0.2.5.6-alpha/src/tools/Makefile.nmake  Thu Jan  1 00:00:00 1970
240+++ tor-0.2.5.6-alpha.new/src/tools/Makefile.nmake      Mon Sep  8 16:40:53 2014
241@@ -0,0 +1,22 @@
242+all: tor-checkkey.exe tor-gencert.exe tor-resolve.exe
243+
244+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
245+
246+LIBS = ..\..\..\build-alpha\lib\libevent.lib \
247+ ..\..\..\build-alpha\lib\libcrypto.lib \
248+ ..\..\..\build-alpha\lib\libssl.lib \
249+ ..\..\..\build-alpha\lib\libz.lib \
250+ ws2_32.lib advapi32.lib shell32.lib \
251+ crypt32.lib gdi32.lib user32.lib
252+
253+tor-checkkey.exe: tor-checkkey.obj
254+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib tor-checkkey.obj /Fe$@
255+
256+tor-gencert.exe: tor-gencert.obj
257+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib tor-gencert.obj /Fe$@
258+
259+tor-resolve.exe: tor-resolve.obj
260+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib tor-resolve.obj /Fe$@
261+
262+clean:
263+       del tor-checkkey.obj tor-gencert.obj tor-resolve.obj tor-checkkey.exe tor-gencert.exe tor-resolve.exe tor-checkkey.exp tor-gencert.exp
264diff -uNraw tor-0.2.5.6-alpha/src/win32/orconfig.h tor-0.2.5.6-alpha.new/src/win32/orconfig.h
265--- tor-0.2.5.6-alpha/src/win32/orconfig.h      Mon Jul 28 10:00:13 2014
266+++ tor-0.2.5.6-alpha.new/src/win32/orconfig.h  Mon Sep  8 16:10:27 2014
267@@ -257,3 +257,11 @@
268 #define USE_CURVE25519_DONNA
269 
270 #define ENUM_VALS_ARE_SIGNED 1
271+
272+#ifndef STDOUT_FILENO
273+#define STDOUT_FILENO 1
274+#endif
275+
276+#ifndef STDERR_FILENO
277+#define STDERR_FILENO 2
278+#endif