Skip to content

Commit

Permalink
Initial patch to build Tor with msvc and nmake
Browse files Browse the repository at this point in the history
We'll still need to tweak it so that it looks for includes and
libraries somewhere more sensible than "where we happened to find
them on Erinn's system"; so that tests and tools get built too;
so that it's a bit documented; and so that we actually try running
the output.

Work done with Erinn Clark.
  • Loading branch information
nmathewson committed Aug 1, 2011
1 parent 9d77f24 commit e802199
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 16 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ EXTRA_DIST = \
ChangeLog \
INSTALL \
LICENSE \
Makefile.nmake \
README \
ReleaseNotes \
tor.spec \
Expand Down
5 changes: 5 additions & 0 deletions Makefile.nmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all:
cd src/common
$(MAKE) /F Makefile.nmake
cd ../../src/or
$(MAKE) /F Makefile.nmake
3 changes: 3 additions & 0 deletions changes/nmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
o Minor features (build compatibility):
- Limited, experimental support for building with nmake and MSVC.

2 changes: 1 addition & 1 deletion src/common/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

noinst_LIBRARIES = libor.a libor-crypto.a libor-event.a

EXTRA_DIST = common_sha1.i sha256.c
EXTRA_DIST = common_sha1.i sha256.c Makefile.nmake

#CFLAGS = -Wall -Wpointer-arith -O2

Expand Down
20 changes: 20 additions & 0 deletions src/common/Makefile.nmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
all: libor.lib libor-crypto.lib libor-event.lib

CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include

LIBOR_OBJECTS = address.obj compat.obj container.obj di_ops.obj \
log.obj memarea.obj mempool.obj procmon.obj util.obj \
util_codedigest.obj

LIBOR_CRYPTO_OBJECTS = aes.obj crypto.obj torgzip.obj tortls.obj

LIBOR_EVENT_OBJECTS = compat_libevent.obj

libor.lib: $(LIBOR_OBJECTS)
lib $(LIBOR_OBJECTS) /out:libor.lib

libor-crypto.lib: $(LIBOR_CRYPTO_OBJECTS)
lib $(LIBOR_CRYPTO_OBJECTS) /out:libor-crypto.lib

libor-event.lib: $(LIBOR_EVENT_OBJECTS)
lib $(LIBOR_EVENT_OBJECTS) /out:libor-event.lib
4 changes: 0 additions & 4 deletions src/common/torgzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@
#define off64_t int64_t
#endif

#ifdef _MSC_VER
#include "..\..\contrib\zlib\zlib.h"
#else
#include <zlib.h>
#endif

/** Set to 1 if zlib is a version that supports gzip; set to 0 if it doesn't;
* set to -1 if we haven't checked yet. */
Expand Down
6 changes: 3 additions & 3 deletions src/common/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#define _GNU_SOURCE

#include "orconfig.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#define UTIL_PRIVATE
#include "util.h"
#include "torlog.h"
Expand Down Expand Up @@ -68,9 +71,6 @@
#ifdef HAVE_SYS_FCNTL_H
#include <sys/fcntl.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/or/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ else
tor_platform_source=
endif

EXTRA_DIST=ntmain.c or_sha1.i
EXTRA_DIST=ntmain.c or_sha1.i Makefile.nmake

if USE_EXTERNAL_EVDNS
evdns_source=
Expand Down
28 changes: 28 additions & 0 deletions src/or/Makefile.nmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
all: tor.exe

CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common

LIBS = ..\..\..\build-alpha\lib\libevent.a \
..\..\..\build-alpha\lib\libcrypto.a \
..\..\..\build-alpha\lib\libssl.a \
..\..\..\build-alpha\lib\libz.a \
ws2_32.lib advapi32.lib shell32.lib

LIBTOR_OBJECTS = buffers.obj circuitbuild.obj circuitlist.obj circuituse.obj \
command.obj config.obj connection.obj connection_edge.obj \
connection_or.obj control.obj cpuworker.obj directory.obj \
dirserv.obj dirvote.obj dns.obj dnsserv.obj geoip.obj \
hibernate.obj main.obj microdesc.obj networkstatus.obj \
nodelist.obj onion.obj policies.obj reasons.obj relay.obj \
rendclient.obj rendcommon.obj rendmid.obj rendservice.obj \
rephist.obj router.obj routerlist.obj routerparse.obj status.obj \
config_codedigest.obj ntmain.obj

libtor.lib: $(LIBTOR_OBJECTS)
lib $(LIBTOR_OBJECTS) /out:libtor.lib

tor.exe: libtor.lib tor_main.obj
$(CC) $(CFLAGS) $(LIBS) libtor.lib ..\common\*.lib tor_main.obj

clean:
del $(LIBTOR_OBJECTS) *.lib tor.exe
7 changes: 0 additions & 7 deletions src/or/networkstatus.c
Original file line number Diff line number Diff line change
Expand Up @@ -2006,13 +2006,6 @@ routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
tor_memcmp(rs->identity_digest,
router->cache_info.identity_digest, DIGEST_LEN),
{
#if 0
/* We have no routerstatus for this router. Clear flags and skip it. */
if (!authdir) {
if (router->purpose == ROUTER_PURPOSE_GENERAL)
router_clear_status_flags(router);
}
#endif
}) {
/* We have a routerstatus for this router. */
const char *digest = router->cache_info.identity_digest;
Expand Down
10 changes: 10 additions & 0 deletions src/win32/orconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H


/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H

Expand Down Expand Up @@ -234,3 +235,12 @@

/* Version number of package */
#define VERSION "0.2.3.2-alpha-dev"



#define HAVE_STRUCT_SOCKADDR_IN6
#define HAVE_STRUCT_IN6_ADDR
#define RSHIFT_DOES_SIGN_EXTEND
#define FLEXIBLE_ARRAY_MEMBER 0
#define HAVE_EVENT2_EVENT_H
#define SHARE_DATADIR ""

0 comments on commit e802199

Please sign in to comment.