1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
|
#
# 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_BUILD_STDERR: Redirect command for build errors log file.
# 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)
#
ifndef POCO_ENABLE_TRACE
target := $(strip $(target))
target_version := $(strip $(target_version))
target_libs := $(strip $(target_libs))
endif
#
# Check for POCO_BASE
#
ifndef POCO_BASE
$(error POCO_BASE is not defined.)
endif
#
# Include some optional make configuration
#
sinclude $(POCO_BASE)/config.build
sinclude $(POCO_BASE)/config.make
#
# Check for PROJECT_BASE
#
ifndef PROJECT_BASE
PROJECT_BASE = $(POCO_BASE)
endif
export PROJECT_BASE
ifdef POCO_VERBOSE
$(info PROJECT_BASE = $(PROJECT_BASE))
endif
#
# Check for POCO_BUILD
#
ifndef POCO_BUILD
POCO_BUILD = $(PROJECT_BASE)
endif
export POCO_BUILD
ifdef POCO_VERBOSE
$(info POCO_BUILD = $(POCO_BUILD))
endif
#
# Build errors/warnings output
#
ifndef POCO_BUILD_STDERR
POCO_BUILD_STDERR_FILE = "$(POCO_BASE)/build/poco_build_stderr.out"
$(shell rm -f $(POCO_BUILD_STDERR_FILE))
POCO_BUILD_STDERR = 2>&1|tee -a $(POCO_BUILD_STDERR_FILE)
endif
#
# 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)")}')
ifneq ($(inpoco),0)
PROJECT_BASE = $(POCO_BASE)
else
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
ifdef POCO_VERBOSE
$(info POCO_HOST_OSNAME = $(POCO_HOST_OSNAME))
endif
POCO_HOST_OSARCH ?= $(subst /,-,$(shell uname -m | tr ' ' _))
ifdef POCO_VERBOSE
$(info POCO_HOST_OSARCH = $(POCO_HOST_OSARCH))
endif
#
# 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
ifdef POCO_VERBOSE
$(info POCO_CONFIG = $(POCO_CONFIG))
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
ifdef POCO_VERBOSE
$(info OSNAME = $(OSNAME))
endif
ifndef POCO_TARGET_OSARCH
OSARCH := $(subst /,-,$(shell uname -m | tr ' ' _))
else
OSARCH := $(POCO_TARGET_OSARCH)
endif
ifdef POCO_VERBOSE
$(info OSARCH = $(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
# 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
GENDIR = gen
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)
ifdef POCO_PREFIX
POCO_LIB_INSTALLDIR = $(POCO_PREFIX)/lib
else
POCO_LIB_INSTALLDIR = $(LIBPATH)
endif
ifdef POCO_VERBOSE
$(info POCO_LIB_INSTALLDIR = $(POCO_LIB_INSTALLDIR))
endif
ifeq ($(POCO_BASE),$(PROJECT_BASE))
POCO_LIBRARY =
else
POCO_LIBRARY = -L$(POCO_BASE)/$(LIBDIR)
endif
ifeq ($(MACCHINA_BASE),)
MACCHINA_LIBRARY =
else ifeq ($(MACCHINA_BASE),$(PROJECT_BASE))
MACCHINA_LIBRARY =
else
MACCHINA_LIBRARY = -L$(MACCHINA_BASE)/$(LIBDIR)
endif
ifndef LIBPREFIX
LIBPREFIX = lib
endif
ifeq ($(POCO_HOST_LIBPATH),$(POCO_BASE)/$(POCO_HOST_LIBDIR))
LD_LIBRARY_PATH = $(POCO_HOST_LIBPATH)
else
LD_LIBRARY_PATH = $(POCO_HOST_LIBPATH):$(POCO_BASE)/$(POCO_HOST_LIBDIR)
endif
ifeq ($(POCO_HOST_OSNAME),Darwin)
SET_LD_LIBRARY_PATH = DYLD_LIBRARY_PATH=$(LD_LIBRARY_PATH)
else
SET_LD_LIBRARY_PATH = LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)
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)'"' -DPOCO_TARGET_OSNAME='"'$(OSNAME)'"' -DPOCO_TARGET_OSARCH='"'$(OSARCH)'"' $(POCO_FLAGS)
CFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
CXXFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
LINKFLAGS += $(COMMONFLAGS) $(SYSFLAGS) $(POCO_LDFLAGS)
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 = -Iinclude $(foreach p,$(COMPONENTS),-I$(POCO_BASE)/$(p)/$(INCDIR)) $(foreach p,$(POCO_ADD_INCLUDE),-I$(p))
#
# Build Library Directory List
#
LIBRARY = -L$(LIBPATH) $(POCO_LIBRARY) $(MACCHINA_LIBRARY) $(foreach p,$(POCO_ADD_LIBRARY),-L$(p))
#
# Strip Command definition
#
ifndef POCO_ENABLE_TRACE
ifeq ($(strip $(STRIP)),)
STRIPCMD =
else
STRIPCMD = $(STRIP) $@$(BINEXT)
endif
else
STRIPCMD =
endif
#
# Make CC and CXX environment vars
#
export CC
export CXX
export LINK
|