Ticket #13081: tor-0.2.5.6-alpha-build-with-VS-4th-version-diff.txt

File tor-0.2.5.6-alpha-build-with-VS-4th-version-diff.txt, 11.9 KB (added by NewEraCracker, 5 years ago)

New patch for building TOR with VS. Add build profiles and disable test build on Release profile.

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        Tue Sep  9 19:41:12 2014
4@@ -1,15 +1,44 @@
5+# Check user supplied configuration to see if it matches any build profile
6+!IF "$(CFG)" != "Release" && "$(CFG)" != "Debug"
7+!MESSAGE Invalid configuration "$(CFG)" specified.
8+!MESSAGE
9+!MESSAGE You can specify a configuration when running NMAKE by defining
10+!MESSAGE the macro CFG on the command line.
11+!MESSAGE
12+!MESSAGE The following configurations are available:
13+!MESSAGE NMAKE /f "Makefile.nmake" all CFG="Release"
14+!MESSAGE NMAKE /f "Makefile.nmake" all CFG="Debug"
15+!MESSAGE
16+!MESSAGE To clean build tree the following configurations are available:
17+!MESSAGE NMAKE /f "Makefile.nmake" clean CFG="Release"
18+!MESSAGE NMAKE /f "Makefile.nmake" clean CFG="Debug"
19+!MESSAGE
20+!MESSAGE You are advised to clean your build tree before building a
21+!MESSAGE diferent profile.
22+!MESSAGE
23+!ERROR An invalid configuration is specified.
24+!ENDIF
25+
26 all:
27        cd src/common
28-       $(MAKE) /F Makefile.nmake
29+       $(MAKE) /F Makefile.nmake all CFG="$(CFG)"
30+       cd ../../src/ext
31+       $(MAKE) /F Makefile.nmake all CFG="$(CFG)"
32        cd ../../src/or
33-       $(MAKE) /F Makefile.nmake
34+       $(MAKE) /F Makefile.nmake all CFG="$(CFG)"
35        cd ../../src/test
36-       $(MAKE) /F Makefile.nmake
37+       $(MAKE) /F Makefile.nmake all CFG="$(CFG)"
38+       cd ../../src/tools
39+       $(MAKE) /F Makefile.nmake all CFG="$(CFG)"
40 
41 clean:
42        cd src/common
43-       $(MAKE) /F Makefile.nmake clean
44+       $(MAKE) /F Makefile.nmake clean CFG="$(CFG)"
45+       cd ../../src/ext
46+       $(MAKE) /F Makefile.nmake clean CFG="$(CFG)"
47        cd ../../src/or
48-       $(MAKE) /F Makefile.nmake clean
49+       $(MAKE) /F Makefile.nmake clean CFG="$(CFG)"
50        cd ../../src/test
51-       $(MAKE) /F Makefile.nmake clean
52+       $(MAKE) /F Makefile.nmake clean CFG="$(CFG)"
53+       cd ../../src/tools
54+       $(MAKE) /F Makefile.nmake clean CFG="$(CFG)"
55diff -uNraw tor-0.2.5.6-alpha/src/common/Makefile.nmake tor-0.2.5.6-alpha.new/src/common/Makefile.nmake
56--- tor-0.2.5.6-alpha/src/common/Makefile.nmake Sat Jun 21 21:16:03 2014
57+++ tor-0.2.5.6-alpha.new/src/common/Makefile.nmake     Tue Sep  9 19:38:33 2014
58@@ -1,12 +1,25 @@
59-all: libor.lib libor-crypto.lib libor-event.lib
60+# Sanity check
61+!IF "$(CFG)" != "Release" && "$(CFG)" != "Debug"
62+!ERROR An invalid configuration is specified.
63+!ENDIF
64+
65+# Test suite is not included in Release version
66+!IF "$(CFG)" == "Release"
67+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
68+!ENDIF
69+
70+# Test suite is included in Debug version
71+!IF "$(CFG)" == "Debug"
72+CFLAGS = /D TOR_UNIT_TESTS /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
73+!ENDIF
74 
75-CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\ext
76+all: libor.lib libor-crypto.lib libor-event.lib
77 
78-LIBOR_OBJECTS = address.obj compat.obj container.obj di_ops.obj \
79-       log.obj memarea.obj mempool.obj procmon.obj util.obj \
80+LIBOR_OBJECTS = address.obj backtrace.obj compat.obj container.obj di_ops.obj \
81+       log.obj memarea.obj mempool.obj procmon.obj sandbox.obj util.obj \
82        util_codedigest.obj
83 
84-LIBOR_CRYPTO_OBJECTS = aes.obj crypto.obj torgzip.obj tortls.obj \
85+LIBOR_CRYPTO_OBJECTS = aes.obj crypto.obj crypto_format.obj torgzip.obj tortls.obj \
86        crypto_curve25519.obj curve25519-donna.obj
87 
88 LIBOR_EVENT_OBJECTS = compat_libevent.obj
89@@ -24,4 +37,4 @@
90        lib $(LIBOR_EVENT_OBJECTS) /out:libor-event.lib
91 
92 clean:
93-       del *.obj *.lib libor*.lib
94+       del *.obj libor.lib libor-crypto.lib libor-event.lib
95diff -uNraw tor-0.2.5.6-alpha/src/common/backtrace.c tor-0.2.5.6-alpha.new/src/common/backtrace.c
96--- tor-0.2.5.6-alpha/src/common/backtrace.c    Mon Jul 28 10:00:13 2014
97+++ tor-0.2.5.6-alpha.new/src/common/backtrace.c        Tue Sep  9 18:22:27 2014
98@@ -4,11 +4,6 @@
99 #define __USE_GNU
100 #define _GNU_SOURCE 1
101 
102-#include "orconfig.h"
103-#include "compat.h"
104-#include "util.h"
105-#include "torlog.h"
106-
107 #ifdef HAVE_EXECINFO_H
108 #include <execinfo.h>
109 #endif
110@@ -21,6 +16,11 @@
111 #ifdef HAVE_SIGNAL_H
112 #include <signal.h>
113 #endif
114+
115+#include "orconfig.h"
116+#include "compat.h"
117+#include "util.h"
118+#include "torlog.h"
119 
120 #ifdef HAVE_CYGWIN_SIGNAL_H
121 #include <cygwin/signal.h>
122diff -uNraw tor-0.2.5.6-alpha/src/common/crypto.c tor-0.2.5.6-alpha.new/src/common/crypto.c
123--- tor-0.2.5.6-alpha/src/common/crypto.c       Mon Jul 28 10:00:13 2014
124+++ tor-0.2.5.6-alpha.new/src/common/crypto.c   Tue Sep  9 18:22:27 2014
125@@ -24,6 +24,10 @@
126 #undef OCSP_RESPONSE
127 #endif
128 
129+#ifdef _MSC_VER
130+#include <openssl/applink.c>
131+#endif
132+
133 #include <openssl/err.h>
134 #include <openssl/rsa.h>
135 #include <openssl/pem.h>
136diff -uNraw tor-0.2.5.6-alpha/src/ext/Makefile.nmake tor-0.2.5.6-alpha.new/src/ext/Makefile.nmake
137--- tor-0.2.5.6-alpha/src/ext/Makefile.nmake    Thu Jan  1 00:00:00 1970
138+++ tor-0.2.5.6-alpha.new/src/ext/Makefile.nmake        Tue Sep  9 18:22:27 2014
139@@ -0,0 +1,12 @@
140+all: csiphash.lib tinytest.lib
141+
142+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
143+
144+csiphash.lib: csiphash.obj
145+       lib csiphash.obj /out:csiphash.lib
146+
147+tinytest.lib: tinytest.obj
148+       lib tinytest.obj /out:tinytest.lib
149+
150+clean:
151+       del *.obj *.lib
152diff -uNraw tor-0.2.5.6-alpha/src/ext/tinytest.c tor-0.2.5.6-alpha.new/src/ext/tinytest.c
153--- tor-0.2.5.6-alpha/src/ext/tinytest.c        Mon Jul 28 10:00:13 2014
154+++ tor-0.2.5.6-alpha.new/src/ext/tinytest.c    Tue Sep  9 18:22:27 2014
155@@ -56,6 +56,10 @@
156 #define __attribute__(x)
157 #endif
158 
159+#ifdef _MSC_VER
160+#define snprintf _snprintf
161+#endif
162+
163 #include "tinytest.h"
164 #include "tinytest_macros.h"
165 
166diff -uNraw tor-0.2.5.6-alpha/src/or/Makefile.nmake tor-0.2.5.6-alpha.new/src/or/Makefile.nmake
167--- tor-0.2.5.6-alpha/src/or/Makefile.nmake     Sat Jun 21 21:16:03 2014
168+++ tor-0.2.5.6-alpha.new/src/or/Makefile.nmake Tue Sep  9 19:44:36 2014
169@@ -1,7 +1,19 @@
170-all: tor.exe
171+# Sanity check
172+!IF "$(CFG)" != "Release" && "$(CFG)" != "Debug"
173+!ERROR An invalid configuration is specified.
174+!ENDIF
175+
176+# Test suite is not included in Release version
177+!IF "$(CFG)" == "Release"
178+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
179+!ENDIF
180+
181+# Test suite is included in Debug version
182+!IF "$(CFG)" == "Debug"
183+CFLAGS = /D TOR_UNIT_TESTS /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
184+!ENDIF
185 
186-CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common \
187-    /I ..\ext
188+all: tor.exe
189 
190 LIBS = ..\..\..\build-alpha\lib\libevent.lib \
191  ..\..\..\build-alpha\lib\libcrypto.lib \
192@@ -15,6 +27,7 @@
193   buffers.obj \
194   channel.obj \
195   channeltls.obj \
196+  circpathbias.obj \
197   circuitbuild.obj \
198   circuitlist.obj \
199   circuitmux.obj \
200@@ -35,6 +48,7 @@
201   dirvote.obj \
202   dns.obj \
203   dnsserv.obj \
204+  ext_orport.obj \
205   fp_pair.obj \
206   entrynodes.obj \
207   geoip.obj \
208@@ -69,7 +83,7 @@
209        lib $(LIBTOR_OBJECTS) /out:$@
210 
211 tor.exe: libtor.lib tor_main.obj
212-       $(CC) $(CFLAGS) $(LIBS) libtor.lib ..\common\*.lib tor_main.obj /Fe$@
213+       $(CC) $(CFLAGS) $(LIBS) libtor.lib ..\common\*.lib ..\ext\*.lib tor_main.obj /Fe$@
214 
215 clean:
216-       del $(LIBTOR_OBJECTS) *.lib tor.exe
217+       del $(LIBTOR_OBJECTS) tor_main.obj libtor.lib tor.exe tor.exp tor.lib
218diff -uNraw tor-0.2.5.6-alpha/src/test/Makefile.nmake tor-0.2.5.6-alpha.new/src/test/Makefile.nmake
219--- tor-0.2.5.6-alpha/src/test/Makefile.nmake   Thu Jan  1 00:00:00 1970
220+++ tor-0.2.5.6-alpha.new/src/test/Makefile.nmake       Tue Sep  9 19:44:16 2014
221@@ -0,0 +1,65 @@
222+# Sanity check
223+!IF "$(CFG)" != "Release" && "$(CFG)" != "Debug"
224+!ERROR An invalid configuration is specified.
225+!ENDIF
226+
227+# Test suite is not included in Release version
228+!IF "$(CFG)" == "Release"
229+all: bench.exe
230+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
231+!ENDIF
232+
233+# Test suite is included in Debug version
234+!IF "$(CFG)" == "Debug"
235+all: bench.exe test.exe
236+CFLAGS = /D TOR_UNIT_TESTS /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
237+!ENDIF
238+
239+LIBS = ..\..\..\build-alpha\lib\libevent.lib \
240+ ..\..\..\build-alpha\lib\libcrypto.lib \
241+ ..\..\..\build-alpha\lib\libssl.lib \
242+ ..\..\..\build-alpha\lib\libz.lib \
243+ ws2_32.lib advapi32.lib shell32.lib \
244+ crypt32.lib gdi32.lib user32.lib
245+
246+TEST_OBJECTS = \
247+  test.obj                   \
248+  test_addr.obj              \
249+# test_bt_cl.obj             \
250+  test_buffers.obj           \
251+  test_cell_formats.obj      \
252+  test_cell_queue.obj        \
253+  test_circuitlist.obj       \
254+  test_circuitmux.obj        \
255+  test_config.obj            \
256+  test_containers.obj        \
257+  test_controller_events.obj \
258+  test_crypto.obj            \
259+  test_data.obj              \
260+  test_dir.obj               \
261+  test_extorport.obj         \
262+  test_hs.obj                \
263+  test_introduce.obj         \
264+  test_logging.obj           \
265+  test_microdesc.obj         \
266+  test_nodelist.obj          \
267+# test_ntor_cl.obj           \
268+  test_oom.obj               \
269+  test_options.obj           \
270+  test_policy.obj            \
271+  test_pt.obj                \
272+  test_relaycell.obj         \
273+  test_replay.obj            \
274+  test_routerkeys.obj        \
275+  test_socks.obj             \
276+  test_status.obj            \
277+  test_util.obj
278+
279+bench.exe: bench.obj
280+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib bench.obj /Fe$@
281+
282+test.exe: $(TEST_OBJECTS)
283+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib $(TEST_OBJECTS) /Fe$@
284+
285+clean:
286+       del bench.obj $(TEST_OBJECTS) bench.exe bench.exp bench.lib test.exe test.exp test.lib
287diff -uNraw tor-0.2.5.6-alpha/src/test/test.h tor-0.2.5.6-alpha.new/src/test/test.h
288--- tor-0.2.5.6-alpha/src/test/test.h   Mon Jul 28 10:00:13 2014
289+++ tor-0.2.5.6-alpha.new/src/test/test.h       Tue Sep  9 18:22:27 2014
290@@ -61,7 +61,7 @@
291 
292 #ifdef _MSC_VER
293 #define U64_PRINTF_TYPE uint64_t
294-#define U64_PRINTF_TYPE int64_t
295+#define I64_PRINTF_TYPE int64_t
296 #else
297 #define U64_PRINTF_TYPE unsigned long long
298 #define I64_PRINTF_TYPE long long
299diff -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
300--- tor-0.2.5.6-alpha/src/test/test_bt_cl.c     Mon Jul 28 10:00:13 2014
301+++ tor-0.2.5.6-alpha.new/src/test/test_bt_cl.c Tue Sep  9 18:22:27 2014
302@@ -18,6 +18,9 @@
303 #ifdef __GNUC__
304 #define NOINLINE __attribute__((noinline))
305 #define NORETURN __attribute__((noreturn))
306+#else
307+#define NOINLINE
308+#define NORETURN
309 #endif
310 
311 int crash(int x) NOINLINE;
312diff -uNraw tor-0.2.5.6-alpha/src/tools/Makefile.nmake tor-0.2.5.6-alpha.new/src/tools/Makefile.nmake
313--- tor-0.2.5.6-alpha/src/tools/Makefile.nmake  Thu Jan  1 00:00:00 1970
314+++ tor-0.2.5.6-alpha.new/src/tools/Makefile.nmake      Tue Sep  9 19:46:27 2014
315@@ -0,0 +1,25 @@
316+all: tor-checkkey.exe tor-gencert.exe tor-resolve.exe
317+
318+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or /I ..\ext
319+
320+LIBS = ..\..\..\build-alpha\lib\libevent.lib \
321+ ..\..\..\build-alpha\lib\libcrypto.lib \
322+ ..\..\..\build-alpha\lib\libssl.lib \
323+ ..\..\..\build-alpha\lib\libz.lib \
324+ ws2_32.lib advapi32.lib shell32.lib \
325+ crypt32.lib gdi32.lib user32.lib
326+
327+tor-checkkey.exe: tor-checkkey.obj
328+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib tor-checkkey.obj /Fe$@
329+
330+tor-gencert.exe: tor-gencert.obj
331+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib tor-gencert.obj /Fe$@
332+
333+tor-resolve.exe: tor-resolve.obj
334+       $(CC) $(CFLAGS) $(LIBS) ..\or\libtor.lib ..\common\*.lib ..\ext\*.lib tor-resolve.obj /Fe$@
335+
336+clean:
337+       del tor-checkkey.obj tor-gencert.obj tor-resolve.obj \
338+               tor-checkkey.lib tor-gencert.lib tor-resolve.lib \
339+               tor-checkkey.exe tor-gencert.exe tor-resolve.exe \
340+               tor-checkkey.exp tor-gencert.exp
341diff -uNraw tor-0.2.5.6-alpha/src/win32/orconfig.h tor-0.2.5.6-alpha.new/src/win32/orconfig.h
342--- tor-0.2.5.6-alpha/src/win32/orconfig.h      Mon Jul 28 10:00:13 2014
343+++ tor-0.2.5.6-alpha.new/src/win32/orconfig.h  Tue Sep  9 18:22:27 2014
344@@ -257,3 +257,11 @@
345 #define USE_CURVE25519_DONNA
346 
347 #define ENUM_VALS_ARE_SIGNED 1
348+
349+#ifndef STDOUT_FILENO
350+#define STDOUT_FILENO 1
351+#endif
352+
353+#ifndef STDERR_FILENO
354+#define STDERR_FILENO 2
355+#endif