diff --git a/Osmand-kernel/Makefile b/Osmand-kernel/Makefile index 9c0d39adf0..ab86d1221d 100755 --- a/Osmand-kernel/Makefile +++ b/Osmand-kernel/Makefile @@ -1,9 +1,9 @@ -projects := protobuf zlib png pthread skia expat freetype osmand +projects := protobuf zlib png skia expat freetype osmand .DEFAULT: installr .PHONY: release debug clean installr installd installr release debug clean installd: @- $(foreach project,$(projects), \ - $(MAKE) --directory=./$(project) $@; \ - ) + $(MAKE) --directory=./$(project) $@; \ + ) diff --git a/Osmand-kernel/Makefile.rules b/Osmand-kernel/Makefile.rules index ba564ea7a2..870dd727f2 100755 --- a/Osmand-kernel/Makefile.rules +++ b/Osmand-kernel/Makefile.rules @@ -88,9 +88,9 @@ build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(STATICLIB_EXT): $$(addprefix build-%/,$(O .SECONDEXPANSION: build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(DYNAMICLIB_EXT): $$(addprefix build-%/,$(OBJECTS)) @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 $(BUILD_DIR_PREFIX)-%/$(LIBNAME).$(LIBTYPE): build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(LIBTYPE) @mkdir -p $(BUILD_DIR_PREFIX)-$* - cp build-$*/$(TARGET)-$(ARCH)/$(LIBNAME).$(LIBTYPE) $(BUILD_DIR_PREFIX)-$*/$(LIBNAME).$(LIBTYPE) \ No newline at end of file + cp build-$*/$(TARGET)-$(ARCH)/$(LIBNAME).$(LIBTYPE) $(BUILD_DIR_PREFIX)-$*/$(LIBNAME).$(LIBTYPE) diff --git a/Osmand-kernel/Makefile.vars b/Osmand-kernel/Makefile.vars old mode 100644 new mode 100755 index e96a3f1c99..b5181858ce --- a/Osmand-kernel/Makefile.vars +++ b/Osmand-kernel/Makefile.vars @@ -1,118 +1,97 @@ +# Make default definitions ifndef $(ARCH) -ARCH := x86 + ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) + # Cygwin returns 'unknown' + ARCH := i386 + else + ARCH := $(shell uname -i) + endif endif ############################################ ############# NACL ### TARGET ifeq ($(TARGET),nacl) -ifndef NACL_SDK_ROOT -$(error Set NACL_SDK_ROOT environment variable) -endif -# -# Disable DOS PATH warning when using Cygwin based tools Windows -# -CYGWIN ?= nodosfilewarning -export CYGWIN - -OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py) -# Turns on warnings (-Wxxx), builds with zero optimization (-O0) and adds debug -# information (-g) for correctness and ease of debugging. -WARNINGS:=-Wno-long-long -Wall -TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_newlib) - -CFLAGS:=-pthread $(WARNINGS) -CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) -CXX:=$(TC_PATH)/bin/i686-nacl-g++ -CC:=$(TC_PATH)/bin/i686-nacl-gcc -STATICLIB_EXT := a -DYNAMICLIB_EXT := nexe -LIBRARY_PREFIX := lib -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 + ifndef NACL_SDK_ROOT + $(error Set NACL_SDK_ROOT environment variable) + endif + ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) + NACL_SDK_ROOT := $(shell cygpath -u "$(NACL_SDK_ROOT)") + endif + + OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py) + NACL_TOOLCHAIN:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_newlib) + CXX := $(NACL_TOOLCHAIN)/bin/i686-nacl-g++ + CC := $(NACL_TOOLCHAIN)/bin/i686-nacl-gcc + AR := $(NACL_TOOLCHAIN)/bin/i686-nacl-ar + STATICLIB_EXT := a + DYNAMICLIB_EXT := nexe + LIBRARY_PREFIX := lib + LDLIBS += -lppapi_cpp -lppapi + GLOBAL_INCLUDES := -I../zlib/zlib_library -I$(NACL_TOOLCHAIN)/i686-nacl/usr/include + ZLIB_BUILD := defined + CFLAGS := -D__int64="long long" + CXXFLAGS := -D__int64="long long" + 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 ############################################ ### EVERYTHING ELSE REQUIRES JAVA_HOME ##### ifndef JAVA_HOME -$(error Set JAVA_HOME environment variable) + $(error Set JAVA_HOME environment variable) endif ifeq ($(TARGET),) ifeq ($(shell uname),Darwin) TARGET := darwin endif + ifeq ($(shell uname),Linux) + TARGET := linux + endif ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) - TARGET := cygwin + TARGET := windows endif ifeq ($(findstring MINGW,$(shell uname)),MINGW) - TARGET := win + TARGET := windows 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 -CXX := g++ -CC := gcc -STRIP := strip -STATICLIB_EXT := a -DYNAMICLIB_EXT := so -LIBRARY_PREFIX := lib -LDFLAGS := -shared -Wl,-Bsymbolic - -############################################ -####### 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 - +else + CXX := g++ + CC := gcc + STRIP := strip + STATICLIB_EXT := a + DYNAMICLIB_EXT := so + LIBRARY_PREFIX := lib endif endif diff --git a/Osmand-kernel/osmand/Makefile b/Osmand-kernel/osmand/Makefile old mode 100644 new mode 100755 index e18e6c0da1..4e6e038b8d --- a/Osmand-kernel/osmand/Makefile +++ b/Osmand-kernel/osmand/Makefile @@ -11,44 +11,59 @@ OSMAND_FLAGS = \ -DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 \ -DSK_RELEASE \ -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 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) - LDLIBS += -lwinmm + LDLIBS += -lwinmm -lgdi32 -lusp10 + OSMAND_FLAGS += $(OSMAND_FLAGS_WINDOWS) else ifeq ($(TARGET),cygwin) - LDLIBS += -lwinmm -lGdi32 -lUsp10 + LDLIBS += -lwinmm -lgdi32 -lusp10 + OSMAND_FLAGS += $(OSMAND_FLAGS_WINDOWS) +else ifeq ($(TARGET),nacl) + LDLIBS += -lpthread else - LDLIBS += -lrt + LDLIBS += -lrt -lpthread endif ifeq ($(TARGET),nacl) -OSMAND_FLAGS += \ - -DRT_NOT_SUPPORTED -LOCAL_SRC_FILES += \ - src/osmand_nacl.cpp + OSMAND_FLAGS += \ + -DRT_NOT_SUPPORTED + LOCAL_SRC_FILES += \ + src/osmand_nacl.cpp else -LOCAL_SRC_FILES += \ - src/java_wrap.cpp + LOCAL_SRC_FILES += \ + 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) - JAVA_OS := win32 + FIXED_JAVA_HOME := $(shell cygpath -u "$(JAVA_HOME)") + else + FIXED_JAVA_HOME := $(JAVA_HOME) endif - ifeq ($(findstring MINGW,$(shell uname)),MINGW) - JAVA_OS := win32 + ifeq ($(JAVA_OS),) + ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) + JAVA_OS := win32 + endif + ifeq ($(findstring MINGW,$(shell uname)),MINGW) + JAVA_OS := win32 + endif endif -endif -ifeq ($(JAVA_OS),) - JAVA_OS := linux -endif -OSMAND_FLAGS += -c -I"$(FIXED_JAVA_HOME)/include" -I"$(FIXED_JAVA_HOME)/include/$(JAVA_OS)" + ifeq ($(JAVA_OS),) + JAVA_OS := linux + endif + OSMAND_FLAGS += -c -I"$(FIXED_JAVA_HOME)/include" -I"$(FIXED_JAVA_HOME)/include/$(JAVA_OS)" endif @@ -56,4 +71,4 @@ CFLAGS += $(OSMAND_FLAGS) CXXFLAGS += $(OSMAND_FLAGS) # Finally, include generic rules -include ../Makefile.rules \ No newline at end of file +include ../Makefile.rules diff --git a/Osmand-kernel/osmand/src/common.cpp b/Osmand-kernel/osmand/src/common.cpp index ce70f3c650..50728983b4 100644 --- a/Osmand-kernel/osmand/src/common.cpp +++ b/Osmand-kernel/osmand/src/common.cpp @@ -7,6 +7,11 @@ #include "osmand_log.h" +#if defined(_WIN32) +# include +# include +#endif + TextDrawInfo::TextDrawInfo(std::string itext) : text(itext) , drawOnPath(false) @@ -62,7 +67,7 @@ void ElapsedTimer::start() return; if (!run) { -#if defined(WIN32) +#if defined(_WIN32) startInit = timeGetTime(); #else clock_gettime(CLOCK_MONOTONIC, &startInit); @@ -75,7 +80,7 @@ void ElapsedTimer::pause() { if (!run) return; -#if defined(WIN32) +#if defined(_WIN32) endInit = timeGetTime(); elapsedTime += (endInit - startInit) * 1e6; #else diff --git a/Osmand-kernel/osmand/src/common.h b/Osmand-kernel/osmand/src/common.h index bae387a294..e6e4d89a69 100644 --- a/Osmand-kernel/osmand/src/common.h +++ b/Osmand-kernel/osmand/src/common.h @@ -57,7 +57,7 @@ private: bool enableFlag; bool run; -#if defined(WIN32) +#if defined(_WIN32) DWORD startInit; DWORD endInit; #else diff --git a/Osmand-kernel/osmand/src/osmand_nacl.cpp b/Osmand-kernel/osmand/src/osmand_nacl.cpp index ea379979c1..21d0a7e25d 100644 --- a/Osmand-kernel/osmand/src/osmand_nacl.cpp +++ b/Osmand-kernel/osmand/src/osmand_nacl.cpp @@ -8,8 +8,8 @@ #include #include #include -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/var.h" +#include +#include #include #include "osmand_nacl.h" @@ -216,8 +216,8 @@ void* PiGenerator::ComputePi(void* param) { // initialized. continue; } - double x = static_cast(rand_r(&seed)) / RAND_MAX; - double y = static_cast(rand_r(&seed)) / RAND_MAX; + double x = static_cast(rand()) / RAND_MAX; + double y = static_cast(rand()) / RAND_MAX; double distance = sqrt(x * x + y * y); int px = x * pi_generator->width(); int py = (1.0 - y) * pi_generator->height(); diff --git a/Osmand-kernel/pthread/.gitignore b/Osmand-kernel/pthread/.gitignore deleted file mode 100644 index 8a4ecd70ef..0000000000 --- a/Osmand-kernel/pthread/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -pthreads_library/ -build-* diff --git a/Osmand-kernel/pthread/Makefile b/Osmand-kernel/pthread/Makefile deleted file mode 100644 index 9357fdcc1c..0000000000 --- a/Osmand-kernel/pthread/Makefile +++ /dev/null @@ -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 \ No newline at end of file diff --git a/Osmand-kernel/pthread/configure.sh b/Osmand-kernel/pthread/configure.sh deleted file mode 100755 index 2ce8041e82..0000000000 --- a/Osmand-kernel/pthread/configure.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/Osmand-kernel/skia/Osmand.patch b/Osmand-kernel/skia/Osmand.patch deleted file mode 100644 index f3083545a2..0000000000 --- a/Osmand-kernel/skia/Osmand.patch +++ /dev/null @@ -1,2 +0,0 @@ -1. SkFontHost_FreeType - ERROR->ERROR_GOTO \ No newline at end of file