summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-11 16:45:31 -0700
committerPixel <pixel@nobis-crew.org>2011-10-11 16:45:31 -0700
commitead67afc96cdff3e74bb616e8e3a8b0a7695a28a (patch)
tree4d074d11a7983bdbde3f6da7d311cddd9696ef0d /Makefile
parentd2252afcd74af0248c6141c8086d03e12a0a316f (diff)
Making the project compile with mingw32, on the same Makefile. No more separate Makefiles insanity.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile94
1 files changed, 77 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 16fb160..9241600 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
ifeq ($(SYSTEM),)
- SYSTEM = $(shell uname)
+ SYSTEM = $(shell uname | cut -f 1 -d_)
endif
TRUESYSTEM = $(shell uname)
@@ -12,8 +12,8 @@ LD = g++
AS = gcc -c
AR = ar rcs
-CPPFLAGS += -fPIC
-LDFLAGS += -fPIC
+BINEXT = bin
+
ifeq ($(DEBUG),)
CPPFLAGS += -O3
else
@@ -22,38 +22,87 @@ LDFLAGS += -g
endif
INCLUDES = includes libcoro libeio libev
+LIBS =
ifeq ($(SYSTEM),Darwin)
- LIBS += pthread
+ CPPFLAGS += -fPIC
+ LDFLAGS += -fPIC
+ LIBS += pthread iconv
CONFIG_H = darwin-config.h
ARCH_FLAGS = -arch i386
- LIBS = -liconv
LD = g++ -arch i386
STRIP = strip -x
ifeq ($(TRUESYSTEM),Linux)
+ CROSSCOMPILE = true
CC = i686-apple-darwin9-gcc
CXX = i686-apple-darwin9-g++
LD = i686-apple-darwin-g++ -arch i386 -mmacosx-version-min=10.5
STRIP = i686-apple-darwin-strip -x
AS = i686-apple-darwin-as -arch i386
+ AR = i686-apple-darwin-ar rcs
endif
-else
+endif
+
+ifeq ($(SYSTEM),MINGW32)
+ BINEXT = exe
+ COMPILE_PTHREADS = true
+ CONFIG_H = mingw32-config.h
+ INCLUDES += win32/iconv win32/pthreads-win32
+ LIBS += ws2_32
+ ifeq ($(TRUESYSTEM),Linux)
+ ifeq ($(DISTRIB),CentOS)
+ CROSSCOMPILE = true
+ CC = i686-pc-mingw32-gcc
+ CXX = i686-pc-mingw32-g++
+ LD = i686-pc-mingw32-g++
+ AS = i686-pc-mingw32-gcc -c
+ STRIP = i686-pc-mingw32-strip --strip-unneeded
+ WINDRES = i686-pc-mingw32-windres
+ AR = i686-pc-mingw32-ar rcs
+ else
+ CROSSCOMPILE = true
+ CC = i586-mingw32msvc-gcc
+ CXX = i586-mingw32msvc-g++
+ LD = i586-mingw32msvc-g++
+ AS = i586-mingw32msvc-gcc -c
+ STRIP = i586-mingw32msvc-strip --strip-unneeded
+ WINDRES = i586-mingw32msvc-windres
+ AR = i586-mingw32msvc-ar rcs
+ endif
+ endif
+
+ ifeq ($(TRUESYSTEM),Darwin)
+ CROSSCOMPILE = true
+ CC = i386-mingw32-gcc
+ CXX = i386-mingw32-g++
+ LD = i386-mingw32-g++
+ AS = i386-mingw32-gcc -c
+ STRIP = i386-mingw32-strip --strip-unneeded
+ WINDRES = i386-mingw32-windres
+ AR = i386-mingw32-ar rcs
+ endif
+endif
+
ifeq ($(SYSTEM),Linux)
+ CPPFLAGS += -fPIC
+ LDFLAGS += -fPIC
LIBS += pthread
CONFIG_H = linux-config.h
ARCH_FLAGS = -march=i686 -m32
ASFLAGS = -march=i686 --32
STRIP = strip --strip-unneeded
endif
-endif
-CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) -fexceptions -Wno-deprecated -imacros $(CONFIG_H)
+CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) -fexceptions -imacros $(CONFIG_H)
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
-LDFLAGS += $(ARCH_FLAGS) $(addprefix -l, $(LIBS))
+CXXFLAGS += -Wno-deprecated
+
+LDFLAGS += $(ARCH_FLAGS)
+LDLIBS = $(addprefix -l, $(LIBS))
vpath %.cc src:tests
-vpath %.c libcoro:libeio:libev
+vpath %.c libcoro:libeio:libev:win32/pthreads-win32:win32/iconv
BALAU_SOURCES = \
Local.cc \
@@ -69,6 +118,15 @@ Input.cc \
Task.cc \
TaskMan.cc \
+ifeq ($(SYSTEM),MINGW32)
+WIN32_SOURCES = \
+pthread.c \
+iconv.c \
+localcharset.c \
+relocatable.c \
+
+endif
+
LIBCORO_SOURCES = \
coro.c \
@@ -87,10 +145,10 @@ test-Handles.cc \
LIB = libBalau.a
-BALAU_OBJECTS = $(addsuffix .o, $(notdir $(basename $(BALAU_SOURCES) $(LIBCORO_SOURCES) $(LIBEIO_SOURCES) $(LIBEV_SOURCES))))
+BALAU_OBJECTS = $(addsuffix .o, $(notdir $(basename $(BALAU_SOURCES) $(LIBCORO_SOURCES) $(LIBEIO_SOURCES) $(LIBEV_SOURCES) $(WIN32_SOURCES))))
-WHOLE_SOURCES = $(BALAU_SOURCES) $(LIBCORO_SOURCES) $(LIBEIO_SOURCES) $(LIBEV_SOURCES) $(TEST_SOURCES)
-TESTS = $(addsuffix .bin, $(notdir $(basename $(TEST_SOURCES))))
+WHOLE_SOURCES = $(BALAU_SOURCES) $(LIBCORO_SOURCES) $(LIBEIO_SOURCES) $(LIBEV_SOURCES) $(WIN32_SOURCES) $(TEST_SOURCES)
+TESTS = $(addsuffix .$(BINEXT), $(notdir $(basename $(TEST_SOURCES))))
ALL_OBJECTS = $(addsuffix .o, $(notdir $(basename $(WHOLE_SOURCES))))
ALL_DEPS = $(addsuffix .dep, $(notdir $(basename $(WHOLE_SOURCES))))
@@ -98,7 +156,9 @@ ALL_DEPS = $(addsuffix .dep, $(notdir $(basename $(WHOLE_SOURCES))))
all: dep lib
tests: $(TESTS)
+ifneq ($(CROSSCOMPILE),true)
for t in $(TESTS) ; do ./$$t ; done
+endif
strip: $(TESTS)
for t in $(TESTS) ; do $(STRIP) ./$$t ; done
@@ -108,16 +168,16 @@ lib: $(LIB)
libBalau.a: $(BALAU_OBJECTS)
$(AR) libBalau.a $(BALAU_OBJECTS)
-%.bin : %.o $(LIB)
- $(LD) $(LDFLAGS) -o $@ $< ./$(LIB)
+%.$(BINEXT) : %.o $(LIB)
+ $(LD) $(LDFLAGS) -o $@ $< ./$(LIB) $(LDLIBS)
dep: $(ALL_DEPS)
%.dep : %.cc
- $(CXX) $(CPPFLAGS_NO_ARCH) -M -MF $@ $<
+ $(CXX) $(CXXFLAGS) $(CPPFLAGS_NO_ARCH) -M -MF $@ $<
%.dep : %.c
- $(CC) $(CPPFLAGS_NO_ARCH) -M -MF $@ $<
+ $(CC) $(CFLAGS) $(CPPFLAGS_NO_ARCH) -M -MF $@ $<
-include $(ALL_DEPS)