poco/build/rules/global

215 lines
3.9 KiB
Plaintext
Raw Normal View History

2006-10-23 17:40:50 +02:00
#
2007-06-13 17:32:13 +02:00
# $Id: //poco/Main/build/rules/global#20 $
2006-10-23 17:40:50 +02:00
#
# 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
2006-12-22 11:07:47 +01:00
#
# Include some optional make configuration
#
sinclude $(POCO_BASE)/config.build
2007-06-13 17:32:13 +02:00
#
# Check for PROJECT_BASE
#
ifndef PROJECT_BASE
PROJECT_BASE = $(POCO_BASE)
endif
export PROJECT_BASE
2006-10-23 17:40:50 +02:00
#
# Check for POCO_BUILD
#
ifndef POCO_BUILD
2007-06-13 17:32:13 +02:00
POCO_BUILD = $(PROJECT_BASE)
2006-10-23 17:40:50 +02:00
endif
2007-06-13 17:32:13 +02:00
export POCO_BUILD
2006-10-23 17:40:50 +02:00
#
# 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
2006-10-23 17:40:50 +02:00
#
# If POCO_CONFIG is not set, use the OS name as configuration name
#
ifndef POCO_CONFIG
POCO_CONFIG = $(POCO_HOST_OSNAME)
endif
#
# 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
#
# 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)
#
# Find out current component
#
2007-06-13 17:32:13 +02:00
COMPONENT := $(shell $(POCO_BASE)/build/script/projname "$(PROJECT_BASE)")
2006-10-23 17:40:50 +02:00
#
# 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)
2007-06-13 17:32:13 +02:00
ifeq ($(POCO_BASE),$(PROJECT_BASE))
POCO_LIBRARY =
else
POCO_LIBRARY = -L$(POCO_BASE)/$(LIBDIR)
endif
2006-10-23 17:40:50 +02:00
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
#
2006-12-22 11:07:47 +01:00
COMMONFLAGS = -DPOCO_BUILD_HOST=$(HOSTNAME) $(POCO_FLAGS)
2006-10-23 17:40:50 +02:00
CFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
CXXFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
LINKFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
ifeq ($(OSARCH_64BITS),1)
CFLAGS += $(CFLAGS64)
CXXFLAGS += $(CXXFLAGS64)
LINKFLAGS += $(LINKFLAGS64)
else
CFLAGS += $(CFLAGS32)
CXXFLAGS += $(CXXFLAGS32)
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 = -Iinclude $(foreach p,$(COMPONENTS),-I$(POCO_BASE)/$(p)/$(INCDIR))
#
# Build Library Directory List
#
2007-06-13 17:32:13 +02:00
LIBRARY = -L$(LIBPATH) $(POCO_LIBRARY)
2006-10-23 17:40:50 +02:00
2006-11-17 17:40:16 +01:00
#
# Strip Command definition
#
ifeq ($(strip $(STRIP)),)
STRIPCMD =
else
STRIPCMD = $(STRIP) $@*
2006-11-17 17:40:16 +01:00
endif
2006-12-22 11:07:47 +01:00
#
# Remote debugging support
#
ifeq ($(strip $(STRIPDBG)),)
CPYDBG =
STRIPDBGCMD =
else
CPYDBG = cp $@ $@x
STRIPDBGCMD = $(STRIP) $@x
endif
2006-10-23 17:40:50 +02:00
#
# Make CC and CXX environment vars
#
export CC
export CXX