poco/build/rules/global

298 lines
6.6 KiB
Plaintext
Raw Normal View History

#
# $Id: //poco/1.4/build/rules/global#1 $
#
# global
#
# Global build configuration
#
# Environment variables:
# POCO_BASE: Path to POCO source tree. Must be defined.
# POCO_BUILD: Path to directory where build files are put.
# Defaults to $(POCO_BASE)
# POCO_CONFIG: Build configuration to use.
# Defaults to `uname`.
# POCO_TARGET_OSNAME: Target system operating system name (for cross builds)
# POCO_TARGET_OSARCH: Target system architecture (forr cross builds)
#
#
# Check for POCO_BASE
#
ifndef POCO_BASE
$(error POCO_BASE is not defined.)
endif
#
# Include some optional make configuration
#
sinclude $(POCO_BASE)/config.make
#
# Check for PROJECT_BASE
#
ifndef PROJECT_BASE
PROJECT_BASE = $(POCO_BASE)
endif
export PROJECT_BASE
$(info PROJECT_BASE = $(PROJECT_BASE))
#
# Check for POCO_BUILD
#
ifndef POCO_BUILD
override POCO_BUILD = $(PROJECT_BASE)
endif
ifeq ($(strip $(POCO_BUILD)),)
override POCO_BUILD = $(PROJECT_BASE)
endif
export POCO_BUILD
$(info POCO_BUILD = $(POCO_BUILD))
#
# POCO_BASE/POCO_BUILD/cwd sanity checks
#
# Ensure that the current working directory is either
# under $POCO_BASE or under $PROJECT_BASE
# Also, if we're building under $POCO_BASE, disarm
# $PROJECT_BASE
#
cwd = $(shell pwd)
inpoco = $(shell echo | awk '{print index("$(cwd)","$(POCO_BASE)")}')
inproj = $(shell echo | awk '{print index("$(cwd)","$(PROJECT_BASE)")}')
2012-10-01 02:31:28 +02:00
ifneq ($(inpoco),0)
PROJECT_BASE = $(POCO_BASE)
else
2012-10-01 02:31:28 +02:00
ifneq ($(inproj),0)
else
$(error Current working directory not under $$PROJECT_BASE)
endif
endif
#
# Determine OS
#
POCO_HOST_OSNAME = $(shell uname)
ifeq ($(findstring CYGWIN,$(POCO_HOST_OSNAME)),CYGWIN)
POCO_HOST_OSNAME = CYGWIN
endif
ifeq ($(findstring MINGW,$(POCO_HOST_OSNAME)),MINGW)
POCO_HOST_OSNAME = MinGW
endif
POCO_HOST_OSARCH ?= $(subst /,-,$(shell uname -m | tr ' ' _))
#
# Begin Sun platforms
#
# Pure Solaris or GNU (Nexenta), Sun Forte and Sun Studio compilers supported
# (on Nexenta, the default compiler is g++)
#
ifndef POCO_CONFIG
ifeq ($(findstring SunOS,$(POCO_HOST_OSNAME)),SunOS)
# detect if this is Nexenta platform
POCO_HOST_ALL_OSNAME := $(shell uname -a)
ifeq ($(findstring Nexenta,$(POCO_HOST_ALL_OSNAME)),Nexenta)
POCO_HOST_OSNAME := Nexenta
else # Up to version 5.5 SunOS-SunForte config is used, 5.6 and above use SunOS-SunStudio
POCO_COMPILER_NAME := $(shell CC -V 2>&1)
POCO_COMPILER_VERSION := $(subst .,,$(filter 5.%,$(POCO_COMPILER_NAME)))
ifeq (0, $(shell test $(POCO_COMPILER_VERSION) -gt 55; echo $$?))
POCO_CONFIG := SunOS-SunStudio
else
POCO_CONFIG := SunOS-SunForte
endif
endif
endif
endif
#
# End Sun Platforms
#
#
# If POCO_CONFIG is not set, use the OS name as configuration name
#
ifndef POCO_CONFIG
POCO_CONFIG = $(POCO_HOST_OSNAME)
endif
#
# Include System Specific Settings
#
include $(POCO_BASE)/build/config/$(POCO_CONFIG)
#
# Determine operating system
#
ifndef POCO_TARGET_OSNAME
OSNAME := $(POCO_HOST_OSNAME)
else
OSNAME := $(POCO_TARGET_OSNAME)
endif
ifndef POCO_TARGET_OSARCH
OSARCH := $(subst /,-,$(shell uname -m | tr ' ' _))
else
OSARCH := $(POCO_TARGET_OSARCH)
endif
HOSTNAME := $(shell hostname)
#
# Check if a 64bit build is requested
#
ifndef OSARCH_64BITS
OSARCH_64BITS = 0
endif
ifeq ($(OSARCH_64BITS),1)
OSARCH_POSTFIX = 64
else
OSARCH_POSTFIX =
endif
#
# Detect distro
#
# Fedora, Redhat, Centos.
REDHATISH = $(if $(wildcard /etc/redhat-release /etc/centos-release /etc/fedora-release),1)
# Debian, Ubuntu
DEBIANISH = $(if $(wildcard /etc/debian_version),1)
#
# Adjust suffix for 64-bit lib directory
#
ifneq ($(REDHATISH),)
LIB64SUFFIX = $(if $(filter $(OSARCH),x86_64 sparc64 ppc64),64,)
else ifneq ($(DEBIANISH),)
LIB64SUFFIX = $(if $(filter $(OSARCH),x86_64 sparc64 ppc64),/x86_64-linux-gnu,)
endif
2012-07-10 05:58:41 +02:00
# Default static lib extension
STATICLIBLINKEXT = .a
#
# Find out current component
#
COMPONENT := $(shell $(POCO_BASE)/build/script/projname "$(PROJECT_BASE)")
#
# Define standard directories
#
SRCDIR = src
INCDIR = include
LIBDIR = lib/$(OSNAME)/$(OSARCH)
BINDIR = bin/$(OSNAME)/$(OSARCH)
OBJDIR = obj/$(OSNAME)/$(OSARCH)
DEPDIR = .dep/$(OSNAME)/$(OSARCH)
LIBPATH = $(POCO_BUILD)/$(LIBDIR)
BINPATH = $(POCO_BUILD)/$(COMPONENT)/$(BINDIR)
OBJPATH = $(POCO_BUILD)/$(COMPONENT)/$(OBJDIR)
DEPPATH = $(POCO_BUILD)/$(COMPONENT)/$(DEPDIR)
POCO_HOST_BINDIR = bin/$(POCO_HOST_OSNAME)/$(POCO_HOST_OSARCH)
POCO_TARGET_BINDIR = $(BINDIR)
POCO_HOST_BINPATH = $(POCO_BUILD)/$(POCO_HOST_BINDIR)
POCO_TARGET_BINPATH = $(BINPATH)
POCO_HOST_LIBDIR = lib/$(POCO_HOST_OSNAME)/$(POCO_HOST_OSARCH)
POCO_TARGET_LIBDIR = $(LIBDIR)
POCO_HOST_LIBPATH = $(POCO_BUILD)/$(POCO_HOST_LIBDIR)
POCO_TARGET_LIBPATH = $(LIBPATH)
2015-01-13 14:38:43 +01:00
ifdef POCO_PREFIX
POCO_LIB_INSTALLDIR = $(POCO_PREFIX)/lib
else
POCO_LIB_INSTALLDIR = $(LIBPATH)
endif
ifeq ($(POCO_BASE),$(PROJECT_BASE))
POCO_LIBRARY =
else
POCO_LIBRARY = -L$(POCO_BASE)/$(LIBDIR)
endif
ifndef LIBPREFIX
LIBPREFIX = lib
endif
#
# Build component list
#
COMPONENTS := $(shell cat $(POCO_BASE)/components)
#
# Read global library version number
#
LIBVERSION := $(shell cat $(POCO_BASE)/libversion)
#
# Determine link mode
#
ifndef LINKMODE
LINKMODE = BOTH
endif
ifeq ($(LINKMODE),SHARED)
DEFAULT_TARGET = all_shared
endif
ifeq ($(LINKMODE),STATIC)
DEFAULT_TARGET = all_static
endif
ifeq ($(LINKMODE),BOTH)
DEFAULT_TARGET = all_static all_shared
endif
#
# Compose compiler flags
#
COMMONFLAGS = -DPOCO_BUILD_HOST=$(HOSTNAME) $(POCO_FLAGS)
CFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
CXXFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
LINKFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
ifeq ($(OSARCH_64BITS),1)
CFLAGS += $(CFLAGS64)
CXXFLAGS += $(CXXFLAGS64)
SHLIBFLAGS += $(SHLIBFLAGS64)
DYLIBFLAGS += $(DYLIBFLAGS64)
LINKFLAGS += $(LINKFLAGS64)
else
CFLAGS += $(CFLAGS32)
CXXFLAGS += $(CXXFLAGS32)
SHLIBFLAGS += $(SHLIBFLAGS32)
DYLIBFLAGS += $(DYLIBFLAGS32)
LINKFLAGS += $(LINKFLAGS32)
endif
#
# Compose object file path
#
OBJPATH_RELEASE_STATIC = $(OBJPATH)/release_static$(OSARCH_POSTFIX)
OBJPATH_DEBUG_STATIC = $(OBJPATH)/debug_static$(OSARCH_POSTFIX)
OBJPATH_RELEASE_SHARED = $(OBJPATH)/release_shared$(OSARCH_POSTFIX)
OBJPATH_DEBUG_SHARED = $(OBJPATH)/debug_shared$(OSARCH_POSTFIX)
#
# Build Include directory List
#
INCLUDE = $(foreach p,$(POCO_ADD_INCLUDE),-I$(p)) -Iinclude $(foreach p,$(COMPONENTS),-I$(POCO_BASE)/$(p)/$(INCDIR))
#
# Build Library Directory List
#
LIBRARY = $(foreach p,$(POCO_ADD_LIBRARY),-L$(p)) -L$(LIBPATH) $(POCO_LIBRARY)
#
# Strip Command definition
#
ifeq ($(strip $(STRIP)),)
STRIPCMD =
else
STRIPCMD = $(STRIP) $@$(BINEXT)
endif
#
# Make CC and CXX environment vars
#
export CC
export CXX
2015-10-05 16:18:10 +02:00
export LINK