#
# $Id: //poco/1.4/build/config/iPhone#4 $
#
# iPhone
#
# Build settings for iPhone OS, using Apple's iPhone SDK
# 

#
# General Settings
#
# iPhone OS does not allow dynamic linking to user libraries
#
LINKMODE ?= STATIC

#
# If the SDK is defined use it
# Otherwise find the latest version installed
#
# IPHONE_SDK_VERSION = 2.2.1

# if IPHONE_SDK_VERSION_MIN is defined use that
# Otherwise use the version found. 

IPHONE_SDK             ?= iPhoneOS
IPHONE_SDK_ROOT         = $(shell xcode-select -print-path)/Platforms/$(IPHONE_SDK).platform/Developer/SDKs
IPHONE_SDK_ROOT_DIR     = $(IPHONE_SDK_ROOT)/$(IPHONE_SDK)
IPHONE_SDK_BASE         = $(shell ls -d $(IPHONE_SDK_ROOT_DIR)$(IPHONE_SDK_VERSION)*.sdk | tail -1)
IPHONE_SDK_VERSION_MIN ?= $(patsubst %.sdk,%,$(patsubst $(IPHONE_SDK_ROOT_DIR)%,%,$(IPHONE_SDK_BASE)))

POCO_TARGET_OSNAME     ?= $(IPHONE_SDK)
POCO_TARGET_OSARCH     ?= armv6
TOOL_PREFIX            ?= /Developer/Platforms/$(IPHONE_SDK).platform/Developer/usr/bin
OSFLAGS                ?= -arch $(POCO_TARGET_OSARCH) -isysroot $(IPHONE_SDK_BASE) -mthumb -miphoneos-version-min=$(IPHONE_SDK_VERSION_MIN) -fembed-bitcode

#
# Tools
#
# If GCC_VER is defined then use it.
# Otherwise select the latest version
#
CC		= $(shell ls $(TOOL_PREFIX)/llvm-gcc-$(GCC_VER)* | tail -1)
CXX		= $(shell ls $(TOOL_PREFIX)/llvm-g++-$(GCC_VER)* | tail -1)

LINK    = $(CXX) -bind_at_load
LIB     = libtool -static -o
RANLIB  = ranlib
SHLIB   = $(CXX) $(OSFLAGS) -dynamiclib -Wl,-install_name,$@ -o $@
DYLIB   = $(CXX) $(OSFLAGS) -dynamic -bundle -read_only_relocs suppress -Wl,-bind_at_load -o $@ 
SHLIBLN = $(POCO_BASE)/build/script/shlibln
STRIP   = 
DEP     = $(POCO_BASE)/build/script/makedepend.gcc
SHELL   = sh
RM      = rm -rf
CP      = cp
MKDIR   = mkdir -p

#
# Extension for Shared Libraries
#
SHAREDLIBEXT     = .$(target_version).dylib
SHAREDLIBLINKEXT = .dylib

#
# Compiler and Linker Flags
#
CFLAGS          = $(OSFLAGS)
CFLAGS32        =
CFLAGS64        =
CXXFLAGS        = $(OSFLAGS) -Wall -Wno-sign-compare 
CXXFLAGS32      =
CXXFLAGS64      = 
LINKFLAGS       = $(OSFLAGS)
LINKFLAGS32     =
LINKFLAGS64     =
STATICOPT_CC    =
STATICOPT_CXX   =
STATICOPT_LINK  =
SHAREDOPT_CC    = -fPIC 
SHAREDOPT_CXX   = -fPIC
SHAREDOPT_LINK  = 
DEBUGOPT_CC     = -g -D_DEBUG=$(DEBUGLEVEL)
DEBUGOPT_CXX    = -g -D_DEBUG=$(DEBUGLEVEL) 
DEBUGOPT_LINK   =
RELEASEOPT_CC   = -DNDEBUG -O2
RELEASEOPT_CXX  = -DNDEBUG -O 
RELEASEOPT_LINK =

#
# System Specific Flags
#
SYSFLAGS = -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS

#
# System Specific Libraries
#
SYSLIBS  = -ldl
