Windows, Cygwin, Linux and NaCl makefiles

This commit is contained in:
Alexey Pelykh 2012-06-17 16:21:55 +03:00
parent 1c93ecb451
commit 2f4416143d
11 changed files with 126 additions and 173 deletions

View file

@ -1,9 +1,9 @@
projects := protobuf zlib png pthread skia expat freetype osmand projects := protobuf zlib png skia expat freetype osmand
.DEFAULT: installr .DEFAULT: installr
.PHONY: release debug clean installr installd .PHONY: release debug clean installr installd
installr release debug clean installd: installr release debug clean installd:
@- $(foreach project,$(projects), \ @- $(foreach project,$(projects), \
$(MAKE) --directory=./$(project) $@; \ $(MAKE) --directory=./$(project) $@; \
) )

View file

@ -88,7 +88,7 @@ build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(STATICLIB_EXT): $$(addprefix build-%/,$(O
.SECONDEXPANSION: .SECONDEXPANSION:
build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(DYNAMICLIB_EXT): $$(addprefix build-%/,$(OBJECTS)) build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(DYNAMICLIB_EXT): $$(addprefix build-%/,$(OBJECTS))
@mkdir -p `dirname $@` @mkdir -p `dirname $@`
$(CXX) -o $@ $(addprefix build-$*/,$(OBJECTS)) $(LDFLAGS) -L$(BUILD_DIR_PREFIX)-$* $(LDLIBS) $(CXX) -shared -o $@ $(addprefix build-$*/,$(OBJECTS)) $(LDFLAGS) -L$(BUILD_DIR_PREFIX)-$* $(LDLIBS)
# This is for copying binary files to build directory # This is for copying binary files to build directory
$(BUILD_DIR_PREFIX)-%/$(LIBNAME).$(LIBTYPE): build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(LIBTYPE) $(BUILD_DIR_PREFIX)-%/$(LIBNAME).$(LIBTYPE): build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(LIBTYPE)

157
Osmand-kernel/Makefile.vars Normal file → Executable file
View file

@ -1,118 +1,97 @@
# Make default definitions
ifndef $(ARCH) ifndef $(ARCH)
ARCH := x86 ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
# Cygwin returns 'unknown'
ARCH := i386
else
ARCH := $(shell uname -i)
endif
endif endif
############################################ ############################################
############# NACL ### TARGET ############# NACL ### TARGET
ifeq ($(TARGET),nacl) ifeq ($(TARGET),nacl)
ifndef NACL_SDK_ROOT ifndef NACL_SDK_ROOT
$(error Set NACL_SDK_ROOT environment variable) $(error Set NACL_SDK_ROOT environment variable)
endif endif
# ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
# Disable DOS PATH warning when using Cygwin based tools Windows NACL_SDK_ROOT := $(shell cygpath -u "$(NACL_SDK_ROOT)")
# endif
CYGWIN ?= nodosfilewarning
export CYGWIN
OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py) OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)
# Turns on warnings (-Wxxx), builds with zero optimization (-O0) and adds debug NACL_TOOLCHAIN:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_newlib)
# information (-g) for correctness and ease of debugging. CXX := $(NACL_TOOLCHAIN)/bin/i686-nacl-g++
WARNINGS:=-Wno-long-long -Wall CC := $(NACL_TOOLCHAIN)/bin/i686-nacl-gcc
TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_newlib) AR := $(NACL_TOOLCHAIN)/bin/i686-nacl-ar
STATICLIB_EXT := a
CFLAGS:=-pthread $(WARNINGS) DYNAMICLIB_EXT := nexe
CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) LIBRARY_PREFIX := lib
CXX:=$(TC_PATH)/bin/i686-nacl-g++ LDLIBS += -lppapi_cpp -lppapi
CC:=$(TC_PATH)/bin/i686-nacl-gcc GLOBAL_INCLUDES := -I../zlib/zlib_library -I$(NACL_TOOLCHAIN)/i686-nacl/usr/include
STATICLIB_EXT := a ZLIB_BUILD := defined
DYNAMICLIB_EXT := nexe CFLAGS := -D__int64="long long"
LIBRARY_PREFIX := lib CXXFLAGS := -D__int64="long long"
LDFLAGS := -lppapi_cpp -lppapi
GLOBAL_INCLUDES=-I../zlib/zlib_library -I$(TC_PATH)/i686-nacl/usr/include
RT_NOT_SUPPORTED := defined
ZLIB_BUILD := defined
ifeq ($(ARCH),x86)
CFLAGS += -m32
CXXFLAGS += -m32
LDFLAGS += -m32
else ifeq ($(ARCH),x64)
CFLAGS += -m64
CXXFLAGS += -m64
LDFLAGS += -m64
else
$(error Undefined ARCH $(ARCH))
endif
ifeq ($(ARCH),i386)
CFLAGS += -m32
CXXFLAGS += -m32
LDFLAGS += -m32
else ifeq ($(ARCH),x86_64)
CFLAGS += -m64
CXXFLAGS += -m64
LDFLAGS += -m64
else
$(error Undefined ARCH $(ARCH))
endif
else else
############################################ ############################################
### EVERYTHING ELSE REQUIRES JAVA_HOME ##### ### EVERYTHING ELSE REQUIRES JAVA_HOME #####
ifndef JAVA_HOME ifndef JAVA_HOME
$(error Set JAVA_HOME environment variable) $(error Set JAVA_HOME environment variable)
endif endif
ifeq ($(TARGET),) ifeq ($(TARGET),)
ifeq ($(shell uname),Darwin) ifeq ($(shell uname),Darwin)
TARGET := darwin TARGET := darwin
endif endif
ifeq ($(shell uname),Linux)
TARGET := linux
endif
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
TARGET := cygwin TARGET := windows
endif endif
ifeq ($(findstring MINGW,$(shell uname)),MINGW) ifeq ($(findstring MINGW,$(shell uname)),MINGW)
TARGET := win TARGET := windows
endif endif
endif endif
############################################
####### Windows via MinGW/Linux and MinGW/Cygwin target
ifeq ($(TARGET),windows)
CXX := i686-w64-mingw32-g++
CC := i686-w64-mingw32-gcc
AR := i686-w64-mingw32-ar
GLOBAL_INCLUDES := -I../zlib/zlib_library
ZLIB_BUILD := defined
STATICLIB_EXT := lib
DYNAMICLIB_EXT := dll
LIBRARY_PREFIX := # empty
LDFLAGS := -Wl,--kill-at -static-libstdc++ -static-libgcc
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
# Latest MinGW compiler under Cygwin needs this
CFLAGS := -D__int64="long long"
CXXFLAGS := -D__int64="long long"
endif
############################################ ############################################
####### DEFAULT LINUX ########## TARGET ####### DEFAULT LINUX ########## TARGET
CXX := g++ else
CC := gcc CXX := g++
STRIP := strip CC := gcc
STATICLIB_EXT := a STRIP := strip
DYNAMICLIB_EXT := so STATICLIB_EXT := a
LIBRARY_PREFIX := lib DYNAMICLIB_EXT := so
LDFLAGS := -shared -Wl,-Bsymbolic LIBRARY_PREFIX := lib
############################################
####### Windows ########## TARGET
ifeq ($(TARGET),win)
CXX := i586-mingw32msvc-gcc
CC := i586-mingw32msvc-gcc
STRIP := i586-mingw32msvc-strip
WINDRES :=i586-mingw32msvc-windres
RANLIB := i586-mingw32msvc-ranlib
WINDRES := i586-mingw32msvc-windres
AR := i586-mingw32msvc-ar
GLOBAL_INCLUDES := -I../pthread/pthreads_library -I../zlib/zlib_library
RT_NOT_SUPPORTED := defined
ZLIB_BUILD := defined
PTHREAD_BUILD := defined
COMMONFLAGS := -D_Windows -DXMD_H -DHAVE_BOOLEAN -DRT_NOT_SUPPORTED
CPP_FLAGS := $(COMMONFLAGS)
CFLAGS := -D_JNI_IMPLEMENTATION $(COMMONFLAGS)
STATICLIB_EXT := a
DYNAMICLIB_EXT := dll
LIBRARY_PREFIX := lib
LDFLAGS := -shared -Wl,--kill-at
else ifeq ($(TARGET),cygwin)
############################################
####### Cygwin ########## TARGET
CXX := i686-w64-mingw32-g++
CC := i686-w64-mingw32-gcc
STRIP := i686-w64-mingw32-strip
AR := i686-w64-mingw32-ar
LDFLAGS := -shared -Wl,--kill-at -static-libstdc++ -static-libgcc
CFLAGS := -D__int64="long long"
CXXFLAGS := -D__int64="long long"
STATICLIB_EXT := lib
DYNAMICLIB_EXT := dll
LIBRARY_PREFIX := # empty
GLOBAL_INCLUDES := -I../zlib/zlib_library
ZLIB_BUILD := defined
RT_NOT_SUPPORTED := defined
endif endif
endif endif

63
Osmand-kernel/osmand/Makefile Normal file → Executable file
View file

@ -11,44 +11,59 @@ OSMAND_FLAGS = \
-DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 \ -DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 \
-DSK_RELEASE \ -DSK_RELEASE \
-DGR_RELEASE=1 -DGR_RELEASE=1
OSMAND_FLAGS_WINDOWS = \
-DSK_BUILD_FOR_WIN32 \
-DMINGW_HAS_SECURE_API \
-DSkUserConfig_DEFINED \
-DPICTURE_VERSION_ICS=1 \
-DPICTURE_VERSION_JB=2 \
-DSK_SCALAR_IS_FLOAT \
-DSK_CAN_USE_FLOAT \
-DSK_CPU_LENDIAN
LIBNAME = $(LIBRARY_PREFIX)osmand LIBNAME = $(LIBRARY_PREFIX)osmand
LIBTYPE = $(DYNAMICLIB_EXT) LIBTYPE = $(DYNAMICLIB_EXT)
LDLIBS += -Wl,--whole-archive -lskia -Wl,--no-whole-archive -lproto -lpthread -lft2 -lexpat -lpng -lz LDLIBS += -Wl,--whole-archive -lskia -Wl,--no-whole-archive -lproto -lft2 -lexpat -lpng -lz
ifeq ($(TARGET),win) ifeq ($(TARGET),win)
LDLIBS += -lwinmm LDLIBS += -lwinmm -lgdi32 -lusp10
OSMAND_FLAGS += $(OSMAND_FLAGS_WINDOWS)
else ifeq ($(TARGET),cygwin) else ifeq ($(TARGET),cygwin)
LDLIBS += -lwinmm -lGdi32 -lUsp10 LDLIBS += -lwinmm -lgdi32 -lusp10
OSMAND_FLAGS += $(OSMAND_FLAGS_WINDOWS)
else ifeq ($(TARGET),nacl)
LDLIBS += -lpthread
else else
LDLIBS += -lrt LDLIBS += -lrt -lpthread
endif endif
ifeq ($(TARGET),nacl) ifeq ($(TARGET),nacl)
OSMAND_FLAGS += \ OSMAND_FLAGS += \
-DRT_NOT_SUPPORTED -DRT_NOT_SUPPORTED
LOCAL_SRC_FILES += \ LOCAL_SRC_FILES += \
src/osmand_nacl.cpp src/osmand_nacl.cpp
else else
LOCAL_SRC_FILES += \ LOCAL_SRC_FILES += \
src/java_wrap.cpp src/java_wrap.cpp
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
FIXED_JAVA_HOME := $(shell cygpath -u "$(JAVA_HOME)")
else
FIXED_JAVA_HOME := $(JAVA_HOME)
endif
ifeq ($(JAVA_OS),)
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
JAVA_OS := win32 FIXED_JAVA_HOME := $(shell cygpath -u "$(JAVA_HOME)")
else
FIXED_JAVA_HOME := $(JAVA_HOME)
endif endif
ifeq ($(findstring MINGW,$(shell uname)),MINGW) ifeq ($(JAVA_OS),)
JAVA_OS := win32 ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
JAVA_OS := win32
endif
ifeq ($(findstring MINGW,$(shell uname)),MINGW)
JAVA_OS := win32
endif
endif endif
endif ifeq ($(JAVA_OS),)
ifeq ($(JAVA_OS),) JAVA_OS := linux
JAVA_OS := linux endif
endif OSMAND_FLAGS += -c -I"$(FIXED_JAVA_HOME)/include" -I"$(FIXED_JAVA_HOME)/include/$(JAVA_OS)"
OSMAND_FLAGS += -c -I"$(FIXED_JAVA_HOME)/include" -I"$(FIXED_JAVA_HOME)/include/$(JAVA_OS)"
endif endif

View file

@ -7,6 +7,11 @@
#include "osmand_log.h" #include "osmand_log.h"
#if defined(_WIN32)
# include <windows.h>
# include <mmsystem.h>
#endif
TextDrawInfo::TextDrawInfo(std::string itext) TextDrawInfo::TextDrawInfo(std::string itext)
: text(itext) : text(itext)
, drawOnPath(false) , drawOnPath(false)
@ -62,7 +67,7 @@ void ElapsedTimer::start()
return; return;
if (!run) if (!run)
{ {
#if defined(WIN32) #if defined(_WIN32)
startInit = timeGetTime(); startInit = timeGetTime();
#else #else
clock_gettime(CLOCK_MONOTONIC, &startInit); clock_gettime(CLOCK_MONOTONIC, &startInit);
@ -75,7 +80,7 @@ void ElapsedTimer::pause()
{ {
if (!run) if (!run)
return; return;
#if defined(WIN32) #if defined(_WIN32)
endInit = timeGetTime(); endInit = timeGetTime();
elapsedTime += (endInit - startInit) * 1e6; elapsedTime += (endInit - startInit) * 1e6;
#else #else

View file

@ -57,7 +57,7 @@ private:
bool enableFlag; bool enableFlag;
bool run; bool run;
#if defined(WIN32) #if defined(_WIN32)
DWORD startInit; DWORD startInit;
DWORD endInit; DWORD endInit;
#else #else

View file

@ -8,8 +8,8 @@
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <string> #include <string>
#include "ppapi/cpp/completion_callback.h" #include <ppapi/cpp/completion_callback.h>
#include "ppapi/cpp/var.h" #include <ppapi/cpp/var.h>
#include <ppapi/cpp/module.h> #include <ppapi/cpp/module.h>
#include "osmand_nacl.h" #include "osmand_nacl.h"
@ -216,8 +216,8 @@ void* PiGenerator::ComputePi(void* param) {
// initialized. // initialized.
continue; continue;
} }
double x = static_cast<double>(rand_r(&seed)) / RAND_MAX; double x = static_cast<double>(rand()) / RAND_MAX;
double y = static_cast<double>(rand_r(&seed)) / RAND_MAX; double y = static_cast<double>(rand()) / RAND_MAX;
double distance = sqrt(x * x + y * y); double distance = sqrt(x * x + y * y);
int px = x * pi_generator->width(); int px = x * pi_generator->width();
int py = (1.0 - y) * pi_generator->height(); int py = (1.0 - y) * pi_generator->height();

View file

@ -1,2 +0,0 @@
pthreads_library/
build-*

View file

@ -1,40 +0,0 @@
# Include tools definitions
include ../Makefile.vars
# Include project files
LOCAL_PATH = .
OSMAND_PTHREAD_LOC := ./pthreads_library
OSMAND_PTHREAD_ABS := $(LOCAL_PATH)/pthreads_library
LOCAL_SRC_FILES:= \
$(OSMAND_PTHREAD_LOC)/attr.c \
$(OSMAND_PTHREAD_LOC)/barrier.c \
$(OSMAND_PTHREAD_LOC)/cancel.c \
$(OSMAND_PTHREAD_LOC)/cleanup.c \
$(OSMAND_PTHREAD_LOC)/condvar.c \
$(OSMAND_PTHREAD_LOC)/create.c \
$(OSMAND_PTHREAD_LOC)/dll.c \
$(OSMAND_PTHREAD_LOC)/exit.c \
$(OSMAND_PTHREAD_LOC)/fork.c \
$(OSMAND_PTHREAD_LOC)/global.c \
$(OSMAND_PTHREAD_LOC)/misc.c \
$(OSMAND_PTHREAD_LOC)/mutex.c \
$(OSMAND_PTHREAD_LOC)/private.c \
$(OSMAND_PTHREAD_LOC)/rwlock.c \
$(OSMAND_PTHREAD_LOC)/sched.c \
$(OSMAND_PTHREAD_LOC)/semaphore.c \
$(OSMAND_PTHREAD_LOC)/spin.c \
$(OSMAND_PTHREAD_LOC)/sync.c \
$(OSMAND_PTHREAD_LOC)/tsd.c \
$(OSMAND_PTHREAD_LOC)/nonportable.c
# Set library name
LIBNAME = $(LIBRARY_PREFIX)pthread
LIBTYPE = $(STATICLIB_EXT)
# Finally, include generic rules
ifdef PTHREAD_BUILD
include ../Makefile.rules
endif

View file

@ -1,2 +0,0 @@
wget -qO - ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.tar.gz | tar xzvf -
mv pthreads-w32-2-8-0-release pthreads_library

View file

@ -1,2 +0,0 @@
1. SkFontHost_FreeType
ERROR->ERROR_GOTO