OsmAnd/Osmand-kernel/Makefile.vars
2012-06-21 08:39:01 +03:00

151 lines
4.2 KiB
Text
Executable file

# Autodetermine target if not set
ifeq ($(TARGET),)
ifeq ($(shell uname),Darwin)
TARGET := darwin
else ifeq ($(shell uname),Linux)
TARGET := linux
else ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
TARGET := windows
else ifeq ($(findstring MINGW,$(shell uname)),MINGW)
TARGET := windows
endif
endif
############################################
# Google NaCl target
ifeq ($(TARGET),nacl)
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" -std=gnu++0x
DYNAMICLIB_FLAGS := -shared
############################################
# MacOSX/Darwin target
else ifeq ($(TARGET),darwin)
MACOSX_TOOLCHAIN_ROOT := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer
MACOSX_SDK := $(IOS_TOOLCHAIN_ROOT)/SDKs/MacOSX10.6.sdk/
ifeq ($(JAVA_HOME),)
JAVA_HOME = /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
endif
# Skia on Darwin supports only i386
ARCH := i386
CXXFLAGS += -arch $(ARCH)
CFLAGS += -arch $(ARCH)
CXX := /usr/bin/g++
CC := /usr/bin/gcc
AR := /usr/bin/ar
GLOBAL_INCLUDES := -I../zlib/zlib_library
ZLIB_BUILD := defined
STATICLIB_EXT := a
DYNAMICLIB_EXT := dylib
LIBRARY_PREFIX := lib
DYNAMICLIB_FLAGS := -dynamiclib
############################################
# iOS target
else ifeq ($(TARGET),ios)
IOS_TOOLCHAIN_ROOT := /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
IOS_SDK := $(IOS_TOOLCHAIN_ROOT)/SDKs/iPhoneOS5.1.sdk/
ifeq ($(ARCH),)
ARCH := armv6
endif
CXX := $(IOS_TOOLCHAIN_ROOT)/usr/bin/arm-apple-darwin10-llvm-g++-4.2
CC := $(IOS_TOOLCHAIN_ROOT)/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
AR := $(IOS_TOOLCHAIN_ROOT)/usr/bin/ar
GLOBAL_INCLUDES := -I../zlib/zlib_library
ZLIB_BUILD := defined
STATICLIB_EXT := a
DYNAMICLIB_EXT := dylib
LIBRARY_PREFIX := lib
CXXFLAGS += -isysroot $(IOS_SDK)
CFLAGS += -isysroot $(IOS_SDK)
DYNAMICLIB_FLAGS := -dynamiclib
LDFLAGS := # empty
# -arch armv6
############################################
### EVERYTHING ELSE REQUIRES JAVA_HOME #####
else
# Just don't ask
ifndef JAVA_HOME
$(error Set JAVA_HOME environment variable)
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
CFLAGS += # empty
CXXFLAGS += -std=gnu++0x
DYNAMICLIB_FLAGS := -shared
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 target
else
STATICLIB_EXT := a
DYNAMICLIB_EXT := so
LIBRARY_PREFIX := lib
DYNAMICLIB_FLAGS := -shared -Wl,-Bsymbolic-functions -Wl,--dynamic-list-cpp-new
CFLAGS += # empty
CXXFLAGS += -std=gnu++0x
endif
endif
############################################
# CPU architectures support
# Make default definitions
ifeq ($(ARCH),)
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
# Cygwin returns 'unknown'
ARCH := i386
else
ARCH := $(shell uname -i)
endif
endif
# Modify compiler flags
ifeq ($(ARCH),i386)
CFLAGS += -m32
CXXFLAGS += -m32
LDFLAGS += -m32
else ifeq ($(ARCH),x86_64)
CFLAGS += -m64
CXXFLAGS += -m64
LDFLAGS += -m64
else ifeq ($(ARCH),armv6)
else
$(error Undefined ARCH $(ARCH))
endif