Skip to content

Commit

Permalink
modifications to allow cross-compilation to win32
Browse files Browse the repository at this point in the history
  • Loading branch information
duthils committed Jun 8, 2013
1 parent cf7f468 commit 97bb679
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ CONTENT:

To make:
make -e os=XXX arch=YYY
Windows (cross-compilation):
make CXX='compiler' os=WIN32

XXX: [LINUX(default), BSD, OSX]
YYY: [IA32(default), POWERPC, IA64, AMD64]
Expand Down
31 changes: 22 additions & 9 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
C++ = g++ -g
ifndef CXX
CXX = g++
endif

ifndef os
os = LINUX
Expand All @@ -8,7 +10,10 @@ ifndef arch
arch = IA32
endif

CCFLAGS = -fPIC -Wall -pthread -Wextra -D$(os) #-finline-functions -O3 -fno-strict-aliasing #-msse3
CCFLAGS = -g -fPIC -Wall -pthread -Wextra -D$(os) #-finline-functions -O3 -fno-strict-aliasing #-msse3
ifeq ($(os), WIN32)
CCFLAGS = -g -fPIC -Wall -pthread -Wextra -D$(os) -DUDT_EXPORTS -D_WIN32_WINNT=0x0501
endif

ifeq ($(arch), IA32)
CCFLAGS += -DIA32
Expand All @@ -33,16 +38,24 @@ endif
OBJS = md5.o common.o window.o list.o buffer.o packet.o channel.o queue.o ccc.o cache.o core.o epoll.o api.o
DIR = $(shell pwd)

all: libudt.so libudt.a udt
ifneq ($(os), WIN32)
all: libudt udt
else
all: libudt libudt.a udt
endif

%.o: %.cpp %.h udt.h
$(C++) $(CCFLAGS) $< -c
$(CXX) $(CCFLAGS) $< -c

libudt.so: $(OBJS)
ifneq ($(os), OSX)
$(C++) -shared -o $@ $^
else
$(C++) -dynamiclib -o libudt.dylib -lstdc++ -lpthread -lm $^
libudt: $(OBJS)
ifeq ($(os), LINUX)
$(CXX) -shared -o libudt.so $^
endif
ifeq ($(os), OS_X)
$(CXX) -dynamiclib -o libudt.dylib -lstdc++ -lpthread -lm $^
endif
ifeq ($(os), WIN32)
$(CXX) -shared -o libudt.dll $^ -Wl,--out-implib,libudt_dll.a -L/usr/i486-mingw32/lib -lws2_32
endif

libudt.a: $(OBJS)
Expand Down
18 changes: 9 additions & 9 deletions src/udt.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ written by
#ifdef WIN32
#ifndef __MINGW__
// Explicitly define 32-bit and 64-bit numbers
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int32 uint32_t;
#ifndef LEGACY_WIN32
typedef unsigned __int64 uint64_t;
#else
// VC 6.0 does not support unsigned __int64: may cause potential problems.
typedef __int64 uint64_t;
#endif
/* typedef __int32 int32_t; */
/* typedef __int64 int64_t; */
/* typedef unsigned __int32 uint32_t; */
/* #ifndef LEGACY_WIN32 */
/* typedef unsigned __int64 uint64_t; */
/* #else */
/* // VC 6.0 does not support unsigned __int64: may cause potential problems. */
/* typedef __int64 uint64_t; */
/* #endif */

#ifdef UDT_EXPORTS
#define UDT_API __declspec(dllexport)
Expand Down

0 comments on commit 97bb679

Please sign in to comment.