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,4 +1,4 @@
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

View file

@ -88,7 +88,7 @@ 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)

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

@ -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
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)
# 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
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

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

@ -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 += \
OSMAND_FLAGS += \
-DRT_NOT_SUPPORTED
LOCAL_SRC_FILES += \
LOCAL_SRC_FILES += \
src/osmand_nacl.cpp
else
LOCAL_SRC_FILES += \
LOCAL_SRC_FILES += \
src/java_wrap.cpp
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
FIXED_JAVA_HOME := $(shell cygpath -u "$(JAVA_HOME)")
else
else
FIXED_JAVA_HOME := $(JAVA_HOME)
endif
ifeq ($(JAVA_OS),)
endif
ifeq ($(JAVA_OS),)
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
JAVA_OS := win32
endif
ifeq ($(findstring MINGW,$(shell uname)),MINGW)
JAVA_OS := win32
endif
endif
ifeq ($(JAVA_OS),)
endif
ifeq ($(JAVA_OS),)
JAVA_OS := linux
endif
OSMAND_FLAGS += -c -I"$(FIXED_JAVA_HOME)/include" -I"$(FIXED_JAVA_HOME)/include/$(JAVA_OS)"
endif
OSMAND_FLAGS += -c -I"$(FIXED_JAVA_HOME)/include" -I"$(FIXED_JAVA_HOME)/include/$(JAVA_OS)"
endif

View file

@ -7,6 +7,11 @@
#include "osmand_log.h"
#if defined(_WIN32)
# include <windows.h>
# include <mmsystem.h>
#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

View file

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

View file

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