sbsv2/raptor/lib/flm/tools2common.flm
author kunmitta <>
Tue, 02 Feb 2010 11:38:34 +0000
branchwip
changeset 326 fe46d8e37943
parent 319 17156855fe69
child 342 f0e42ff3359f
permissions -rw-r--r--
Release note: Add a workaround to enable the Qt team to link their code against Symbian DLL's

# Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
# All rights reserved.
# This component and the accompanying materials are made available
# under the terms of the License "Eclipse Public License v1.0"
# which accompanies this distribution, and is available
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
#
# Initial Contributors:
# Nokia Corporation - initial contribution.
#
# Contributors:
#
# Description:
# Function-Like Makefile to build common TOOLS2 objects with gcc
# (included by tools2exe.flm and tools2lib.flm)
#
#

## Input parameters

ifeq ($(filter win,$(HOSTPLATFORM)),win)
CDEFS.TOOLS2:=$(CDEFS.WIN32) $(CDEFS)
CFLAGS:=$(CFLAGS.WIN32) $(CFLAGS) $(OPTION_GCC)
COMPILER_PATH:=$(COMPILER_PATH.WIN32)
OUTPUTPATH:=$(OUTPUTPATH)/$(TARGET)_$(TARGETTYPE)/tools2/$(VARIANTTYPE)$(TOOLPLATFORMDIR)
else
ifneq ($(TOOLS2WIN32),)
# Build win32 tools in Linux
CDEFS.TOOLS2:=$(CDEFS.WIN32) $(CDEFS)
CFLAGS:=$(CFLAGS.WIN32) $(CFLAGS) $(OPTION_GCC)
COMPILER_PATH:=$(COMPILER_PATH.WIN32)
OUTPUTPATH:=$(OUTPUTPATH)/$(TARGET)_$(TARGETTYPE)/tools2/$(VARIANTTYPE)
else
# Build linux tools in Linux
CDEFS.TOOLS2:=$(CDEFS.LINUX) $(CDEFS)
CFLAGS:=$(CFLAGS) $(OPTION_GCC)
COMPILER_PATH=$(COMPILER_PATH.LINUX)
OUTPUTPATH:=$(OUTPUTPATH)/$(TARGET)_$(TARGETTYPE)/tools2/$(VARIANTTYPE)$(TOOLPLATFORMDIR)
endif
endif


CDEFS.TOOLS2:=$(call makemacrodef,$(OPT.D),$(CDEFS.TOOLS2))

## Locally used variables
CREATABLEPATHS:=$(OUTPUTPATH) $(RELEASEPATH) $(TOOLSPATH)

## Global targets
$(ALLTARGET):: $(TARGETS)
TARGET:: $(TARGETS)

## Pre-Include directories
ifneq ($(INC.COMPILER),)
PINCLUDE:=$(patsubst %,$(OPT.PREINCLUDE)%,$(INC.COMPILER))
endif

## User and System Include directories
ifneq ($(USERINCLUDE),)
UINCLUDE:=$(patsubst %,$(OPT.USERINCLUDE)%,$(USERINCLUDE))
endif
ifneq ($(SYSTEMINCLUDE),)
SINCLUDE:=$(patsubst %,$(OPT.SYSTEMINCLUDE)%,$(SYSTEMINCLUDE))
endif

INCLUDES:=$(PINCLUDE) $(UINCLUDE) $(SINCLUDE)

## Source files
CPPFILES:=$(filter %.CPP,$(SOURCE))
cppFILES:=$(filter %.cpp,$(SOURCE))
CFILES:=$(filter %.C,$(SOURCE))
cFILES:=$(filter %.c,$(SOURCE))

## Object files
CPPOBJFILES:=$(patsubst %,$(OUTPUTPATH)/%,$(notdir $(patsubst %.CPP,%.o,$(CPPFILES))))
cppOBJFILES:=$(patsubst %,$(OUTPUTPATH)/%,$(notdir $(patsubst %.cpp,%.o,$(cppFILES))))
COBJFILES:=$(patsubst %,$(OUTPUTPATH)/%,$(notdir $(patsubst %.C,%.o,$(CFILES))))
cOBJFILES:=$(patsubst %,$(OUTPUTPATH)/%,$(notdir $(patsubst %.c,%.o,$(cFILES))))
OBJECTFILES:=$(CPPOBJFILES) $(cppOBJFILES) $(cOBJFILES) $(COBJFILES)

CLEANTARGETS:=
## Compile CPP and cpp files
define compile2object
$(eval compile2object_TARGET:=$(OUTPUTPATH)/$(patsubst %.$(2),%.o,$(notdir $(1))))
$(eval DEPENDFILENAME:=$(compile2object_TARGET).d)
$(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME)))
$(compile2object_TARGET): $(1) $(if (DEPENDFILE),,EXPORT)
	$(call startrule,compile2object,,$(1)) \
	$(if $(COMPILER_PATH),COMPILER_PATH="$(COMPILER_PATH)",) \
	$(COMPILER) $(CFLAGS) $(CDEFS.TOOLS2) -MD -MT"$$@" -MF"$(DEPENDFILENAME)" $(INCLUDES) $(OPT.O)"$$@" "$(1)" \
	$(call endrule,compile2object)

CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME)
ifneq "$(DEPENDFILE)" ""
ifeq ($(NO_DEPEND_INCLUDE),)
  ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" ""
    -include $(DEPENDFILE)
  endif
endif
endif

endef

$(foreach SRC,$(CPPFILES),$(eval $(call compile2object,$(SRC),CPP)))
$(foreach SRC,$(cppFILES),$(eval $(call compile2object,$(SRC),cpp)))
$(foreach SRC,$(CFILES),$(eval $(call compile2object,$(SRC),C)))
$(foreach SRC,$(cFILES),$(eval $(call compile2object,$(SRC),c)))

### Conclusion - cleanup and introspection #######################

# make the output directories while reading makefile - some build engines prefer this
$(call makepath,$(CREATABLEPATHS))

## Clean up
$(call raptor_clean,$(CLEANTARGETS) $(OBJECTFILES))
## for the --what option and the log file
$(call raptor_release,$(RELEASABLES))

## The End