Ticket #13081: tor-maint-0.2.5-8eed82b.build-with-VS.diff.txt

File tor-maint-0.2.5-8eed82b.build-with-VS.diff.txt, 14.0 KB (added by NewEraCracker, 5 years ago)

Patch to sync maint-0.2.5 8eed82b3d4bc8d15bd4ec7f229717f903dd6d6c7 with my tor-0.2.5.6-alpha-build-with-VS patch

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