1# Time-stamp: <08/02/28 10:25:46 ptr> 2# 3# Copyright (c) 1997-1999, 2002, 2003, 2005-2008 4# Petr Ovtchenkov 5# 6# Portion Copyright (c) 1999-2001 7# Parallel Graphics Ltd. 8# 9# Licensed under the Academic Free License version 3.0 10# 11 12ifndef _FORCE_CXX 13CXX := c++ 14else 15CXX := ${_FORCE_CXX} 16endif 17 18ifndef _FORCE_CC 19CC := gcc 20else 21CC := ${_FORCE_CC} 22endif 23 24ifeq ($(OSNAME), cygming) 25RC := windres 26endif 27 28ifdef TARGET_OS 29CXX := ${TARGET_OS}-${CXX} 30CC := ${TARGET_OS}-${CC} 31AS := ${TARGET_OS}-${AS} 32endif 33 34CXX_VERSION := $(shell ${CXX} -dumpversion) 35CXX_VERSION_MAJOR := $(shell echo ${CXX_VERSION} | awk 'BEGIN { FS = "."; } { print $$1; }') 36CXX_VERSION_MINOR := $(shell echo ${CXX_VERSION} | awk 'BEGIN { FS = "."; } { print $$2; }') 37CXX_VERSION_PATCH := $(shell echo ${CXX_VERSION} | awk 'BEGIN { FS = "."; } { print $$3; }') 38 39# Check that we need option -fuse-cxa-atexit for compiler 40_CXA_ATEXIT := $(shell ${CXX} -v 2>&1 | grep -q -e "--enable-__cxa_atexit" || echo "-fuse-cxa-atexit") 41 42ifeq ($(OSNAME), darwin) 43# This is to differentiate Apple-builded compiler from original 44# GNU compiler (it has different behaviour) 45ifneq ("$(shell ${CXX} -v 2>&1 | grep Apple)", "") 46GCC_APPLE_CC := 1 47endif 48endif 49 50DEFS ?= 51OPT ?= 52 53ifdef WITHOUT_STLPORT 54INCLUDES = 55else 56INCLUDES = -I${STLPORT_INCLUDE_DIR} 57endif 58 59ifdef BOOST_INCLUDE_DIR 60INCLUDES += -I${BOOST_INCLUDE_DIR} 61endif 62 63ifeq ($(OSNAME), cygming) 64ifeq ($(OSREALNAME), mingw) 65# MinGW has problem with /usr/local reference in gcc or linker command line so 66# we use a local install for this platform. 67BASE_INSTALL_DIR ?= ${STLPORT_DIR} 68endif 69endif 70 71OUTPUT_OPTION = -o $@ 72LINK_OUTPUT_OPTION = ${OUTPUT_OPTION} 73CPPFLAGS = $(DEFS) $(INCLUDES) 74 75ifdef WITHOUT_RTTI 76# -fno-rtti shouldn't be pass to the C compiler, we cannot use OPT so we add it 77# directly to the compiler command name. 78CXX += -fno-rtti 79ifdef STLP_BUILD 80# gcc do not define any macro to signal that there is no rtti support: 81DEFS += -D_STLP_NO_RTTI 82endif 83endif 84 85ifeq ($(OSNAME), cygming) 86WINVER ?= 0x0501 87RCFLAGS = --include-dir=${STLPORT_INCLUDE_DIR} --output-format coff -DCOMP=gcc 88release-shared : RCFLAGS += -DBUILD_INFOS=-O2 89dbg-shared : RCFLAGS += -DBUILD=g -DBUILD_INFOS=-g 90stldbg-shared : RCFLAGS += -DBUILD=stlg -DBUILD_INFOS="-g -D_STLP_DEBUG" 91RC_OUTPUT_OPTION = -o $@ 92CXXFLAGS = -Wall -Wsign-promo -Wcast-qual -fexceptions 93ifndef WITHOUT_THREAD 94ifeq ($(OSREALNAME), mingw) 95CCFLAGS += -mthreads 96CFLAGS += -mthreads 97CXXFLAGS += -mthreads 98ifeq ($(CXX_VERSION_MAJOR),2) 99CCFLAGS += -fvtable-thunks 100CFLAGS += -fvtable-thunks 101CXXFLAGS += -fvtable-thunks 102endif 103else 104ifneq (,$(findstring no-cygwin,$(EXTRA_CXXFLAGS))) 105CCFLAGS += -mthreads 106CFLAGS += -mthreads 107CXXFLAGS += -mthreads 108else 109DEFS += -D_REENTRANT 110endif 111endif 112endif 113CCFLAGS += $(OPT) 114CFLAGS += $(OPT) 115CXXFLAGS += $(OPT) 116COMPILE.rc = $(RC) $(RCFLAGS) 117release-static : DEFS += -D_STLP_USE_STATIC_LIB 118dbg-static : DEFS += -D_STLP_USE_STATIC_LIB 119stldbg-static : DEFS += -D_STLP_USE_STATIC_LIB 120ifeq ($(OSREALNAME), mingw) 121dbg-shared : DEFS += -D_DEBUG 122stldbg-shared : DEFS += -D_DEBUG 123dbg-static : DEFS += -D_DEBUG 124stldbg-static : DEFS += -D_DEBUG 125DEFS += -DWINVER=${WINVER} 126else 127# When using the -mno-cygwin option we need to take into account WINVER. 128# As there is no DEFS for C compiler and an other for C++ we use CFLAGS 129# and CXXFLAGS 130ifdef EXTRA_CXXFLAGS 131ifneq (,$(findstring no-cygwin,$(EXTRA_CXXFLAGS))) 132CXXFLAGS += -DWINVER=${WINVER} 133endif 134endif 135ifdef EXTRA_CFLAGS 136ifneq (,$(findstring no-cygwin,$(EXTRA_CFLAGS))) 137CFLAGS += -DWINVER=${WINVER} 138endif 139endif 140endif 141endif 142 143ifndef WITHOUT_THREAD 144PTHREAD := -pthread 145else 146PTHREAD := 147endif 148 149ifeq ($(OSNAME),sunos) 150ifndef WITHOUT_THREAD 151PTHREADS := -pthreads 152else 153PTHREADS := 154endif 155 156CCFLAGS = $(PTHREADS) $(OPT) 157CFLAGS = $(PTHREADS) $(OPT) 158# CXXFLAGS = $(PTHREADS) -nostdinc++ -fexceptions $(OPT) 159CXXFLAGS = $(PTHREADS) -fexceptions $(OPT) 160endif 161 162ifeq ($(OSNAME),linux) 163CCFLAGS = $(PTHREAD) $(OPT) 164CFLAGS = $(PTHREAD) $(OPT) 165# CXXFLAGS = $(PTHREAD) -nostdinc++ -fexceptions $(OPT) 166CXXFLAGS = $(PTHREAD) -fexceptions $(OPT) 167endif 168 169ifeq ($(OSNAME),openbsd) 170CCFLAGS = $(PTHREAD) $(OPT) 171CFLAGS = $(PTHREAD) $(OPT) 172# CXXFLAGS = $(PTHREAD) -nostdinc++ -fexceptions $(OPT) 173CXXFLAGS = $(PTHREAD) -fexceptions $(OPT) 174endif 175 176ifeq ($(OSNAME),freebsd) 177CCFLAGS = $(PTHREAD) $(OPT) 178CFLAGS = $(PTHREAD) $(OPT) 179ifndef WITHOUT_THREAD 180DEFS += -D_REENTRANT 181endif 182# CXXFLAGS = $(PTHREAD) -nostdinc++ -fexceptions $(OPT) 183CXXFLAGS = $(PTHREAD) -fexceptions $(OPT) 184endif 185 186ifeq ($(OSNAME),darwin) 187CCFLAGS = $(OPT) 188CFLAGS = $(OPT) 189ifndef WITHOUT_THREAD 190DEFS += -D_REENTRANT 191endif 192CXXFLAGS = -fexceptions $(OPT) 193release-shared : CXXFLAGS += -dynamic 194dbg-shared : CXXFLAGS += -dynamic 195stldbg-shared : CXXFLAGS += -dynamic 196endif 197 198ifeq ($(OSNAME),hp-ux) 199ifneq ($(M_ARCH),ia64) 200release-static : OPT += -fno-reorder-blocks 201release-shared : OPT += -fno-reorder-blocks 202endif 203CCFLAGS = $(PTHREAD) $(OPT) 204CFLAGS = $(PTHREAD) $(OPT) 205# CXXFLAGS = $(PTHREAD) -nostdinc++ -fexceptions $(OPT) 206CXXFLAGS = $(PTHREAD) -fexceptions $(OPT) 207endif 208 209ifeq ($(CXX_VERSION_MAJOR),2) 210CXXFLAGS += -ftemplate-depth-32 211endif 212 213# Required for correct order of static objects dtors calls: 214ifeq ("$(findstring $(OSNAME),darwin cygming)","") 215ifneq ($(CXX_VERSION_MAJOR),2) 216CXXFLAGS += $(_CXA_ATEXIT) 217endif 218endif 219 220# Code should be ready for this option 221ifneq ($(OSNAME),cygming) 222ifneq ($(CXX_VERSION_MAJOR),2) 223ifneq ($(CXX_VERSION_MAJOR),3) 224CXXFLAGS += -fvisibility=hidden 225CFLAGS += -fvisibility=hidden 226endif 227endif 228endif 229 230ifdef EXTRA_CXXFLAGS 231CXXFLAGS += ${EXTRA_CXXFLAGS} 232endif 233 234ifdef EXTRA_CFLAGS 235CFLAGS += ${EXTRA_CFLAGS} 236endif 237 238CDEPFLAGS = -E -M 239CCDEPFLAGS = -E -M 240 241# STLport DEBUG mode specific defines 242stldbg-static : DEFS += -D_STLP_DEBUG 243stldbg-shared : DEFS += -D_STLP_DEBUG 244stldbg-static-dep : DEFS += -D_STLP_DEBUG 245stldbg-shared-dep : DEFS += -D_STLP_DEBUG 246 247# optimization and debug compiler flags 248release-static : OPT += -O2 249release-shared : OPT += -O2 250 251dbg-static : OPT += -g 252dbg-shared : OPT += -g 253#dbg-static-dep : OPT += -g 254#dbg-shared-dep : OPT += -g 255 256stldbg-static : OPT += -g 257stldbg-shared : OPT += -g 258#stldbg-static-dep : OPT += -g 259#stldbg-shared-dep : OPT += -g 260 261# dependency output parser (dependencies collector) 262 263DP_OUTPUT_DIR = | sed 's|\($*\)\.o[ :]*|$(OUTPUT_DIR)/\1.o $@ : |g' > $@; \ 264 [ -s $@ ] || rm -f $@ 265 266DP_OUTPUT_DIR_DBG = | sed 's|\($*\)\.o[ :]*|$(OUTPUT_DIR_DBG)/\1.o $@ : |g' > $@; \ 267 [ -s $@ ] || rm -f $@ 268 269DP_OUTPUT_DIR_STLDBG = | sed 's|\($*\)\.o[ :]*|$(OUTPUT_DIR_STLDBG)/\1.o $@ : |g' > $@; \ 270 [ -s $@ ] || rm -f $@ 271 272