New compilation suite for automatic makefile

This commit is contained in:
Edouard Dupin 2012-07-16 18:01:14 +02:00
parent 7bce71d2db
commit e0bed8b1c9
30 changed files with 1548 additions and 474 deletions

View File

@ -1,4 +1,6 @@
USER_PACKAGES += $(EWOL_FOLDER)/Sources/
include $(EWOL_FOLDER)/Build/coreLinux/main.mk

View File

@ -2,7 +2,7 @@
###############################################################################
### Platform specificity : ###
###############################################################################
SUPPORTED_PLATFORM=Linux IMac IOs Android
SUPPORTED_PLATFORM=Linux CygWin MacOS IOS Android
DEFAULT_PLATFORM=Linux
# default platform can be overridden
@ -14,9 +14,11 @@ PROJECT_MODULE=$(PROJECT_PATH)/../
ifeq ($(PLATFORM), Linux)
PROJECT_NDK?=$(realpath $(PROJECT_MODULE)/ewol/)
else ifeq ($(PLATFORM), IMac)
else ifeq ($(PLATFORM), MacOS)
else ifeq ($(PLATFORM), IOs)
else ifeq ($(PLATFORM), IOS)
else ifeq ($(PLATFORM), CygWin)
else ifeq ($(PLATFORM), Android)
PROJECT_NDK:=$(PROJECT_MODULE)/android/ndk/

View File

@ -8,69 +8,10 @@
# Do NOT clear LOCAL_PATH, it is set BEFORE including this makefile
# Name of what's supposed to be generated
LOCAL_MODULE :=
# Source files to compile
LOCAL_SRC_FILES :=
# Files to copy verbatim
LOCAL_COPY_FILES :=
# Static libraries that you want to include in your module
LOCAL_STATIC_LIBRARIES :=
# Libraries you directly link against
# Specify the name without the suffix
LOCAL_SHARED_LIBRARIES :=
# Additional directories to instruct the C/C++ compilers to look for header files in.
# Format : -I<fullpath>
LOCAL_C_INCLUDES :=
# Additional flags to pass into the C or C++ compiler
LOCAL_CFLAGS :=
# Additional flags to pass into only the C++ compiler
LOCAL_CPPFLAGS :=
# Additional flags to pass into the static library generator
LOCAL_ARFLAGS :=
# Additional flags to pass into the resource compiler (Windows only)
LOCAL_RCFLAGS :=
# Additional flags to pass into the linker
LOCAL_LDFLAGS :=
# Additional libraries to pass into the linker
# Format : -l<name>
LOCAL_LDLIBS :=
# Resource list file
LOCAL_RESLIST :=
# Xrc file
LOCAL_XRC :=
# Additionnal dependecies for rc files
LOCAL_RC_DEPS :=
# Precompiled file
LOCAL_PRECOMPILED_FILE :=
# Other variables used internally
LOCAL_BUILT_MODULE :=
LOCAL_INSTALLED_MODULE :=
LOCAL_INTERMEDIATE_TARGETS :=
LOCAL_MODULE_SUFFIX :=
LOCAL_BUILDING_STATIC_LIBRARY :=
LOCAL_BUILDING_SHARED_LIBRARY :=
LOCAL_BUILDING_EXECUTABLE :=
$(call clear-vars, $(filter-out LOCAL_PATH,$(modules-LOCALS:%=LOCAL_%)))
# Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
# iterate over thousands of entries every time.
# Leave the current makefile to make sure we don't break anything
# that expects to be able to find the name of the current makefile.
MAKEFILE_LIST := $(lastword $(MAKEFILE_LIST))

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>$(SolutionDir)out_vc10\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)build_vc10\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

BIN
Build/coreLinux/conf Executable file

Binary file not shown.

View File

@ -1,67 +1,330 @@
###############################################################################
## @file config.mk
## @author Y.M. Morgan
## @date 2011/05/14
## @date 2012/07/09
##
## Configuration management.
###############################################################################
# Tools (absolute path)
CONF := KCONFIG_NOTIMESTAMP=1 $(call fullpath,$(BUILD_SYSTEM)/conf)
QCONF := KCONFIG_NOTIMESTAMP=1 $(call fullpath,$(BUILD_SYSTEM)/qconf)
# Directory where original configurations are stored
CONFIG_ORIG_DIR := $(TOP_DIR)/config-ymm
# File where global configuration is stored
CONFIG_GLOBAL_FILE := $(CONFIG_ORIG_DIR)/global.config
###############################################################################
## Make sure that there are no spaces in the absolute path; the build system
## can't deal with them.
## Begin conf/qconf by copying configuration file to a temp .config file.
## $1 : configuration file.
###############################################################################
__begin-conf = \
__tmpconfdir=$$(mktemp --directory); \
__tmpconf=$${__tmpconfdir}/.config; \
if [ -f $1 ]; then \
cp -pf $1 $${__tmpconf}; \
fi;
###############################################################################
## End conf/qconf by copying temp .config file to configuration file.
## $1 : configuration file.
###############################################################################
__end-conf = \
if [ -f $${__tmpconf} ]; then \
mv -f $${__tmpconf} $1; \
fi; \
rm -rf $${__tmpconfdir};
###############################################################################
## Exceute qconf/conf.
## $1 : Config.in file.
## $2 : options.
###############################################################################
__exec-conf = (cd $$(dirname $${__tmpconf}) && $(CONF) $2 $1);
__exec-qconf = (cd $$(dirname $${__tmpconf}) && $(QCONF) $2 $1);
###############################################################################
## Get the name of the configuration file of a module.
## $1 : module name.
###############################################################################
__get_module-config = $(CONFIG_ORIG_DIR)/$1.config
###############################################################################
## Get the list of path to Config.in files of a module.
## $1 : module name.
## Remark : should be called only after the module database have been built.
###############################################################################
__get_module-config-in-files = \
$(eval __path := $(__modules.$1.PATH)) \
$(eval __files := $(__modules.$1.CONFIG_FILES)) \
$(addprefix $(__path)/,$(__files))
###############################################################################
## Begin the update/check operation by creating a temp diff file.
###############################################################################
__begin-diff = \
__tmpdiff=$$(mktemp); \
###############################################################################
## End the update/check operation.
## $1 : 1 to exit, 0 or empty to continue.
###############################################################################
__end-diff = \
if [ "$$(stat -c %s $${__tmpdiff})" != "0" ]; then \
echo "Configuration diff can be found in $${__tmpdiff}"; \
if [ "$1" == "1" ]; then exit 1; fi; \
else \
rm -f $${__tmpdiff}; \
fi;
###############################################################################
## Generate Config.in for global configuration.
## $1 : destination file.
###############################################################################
define __generate-config-in-global
rm -f $1; \
mkdir -p $(dir $1); \
touch $1; \
echo "menu Modules" >> $1; \
$(foreach __mod,$(__modules), \
$(eval __build := BUILD_$(call get-define,$(__mod))) \
echo "config $(__build)" >> $1; \
echo " bool 'Build $(__mod)'" >> $1; \
echo " default y" >> $1; \
echo " help" >> $1; \
echo " Build $(__mod)" >> $1; \
) \
echo "endmenu" >> $1;
endef
###############################################################################
## Generate Config.in for one module.
## $1 : destination file.
## $2 : module name.
## $3 : list of path to Config.in files.
###############################################################################
define __generate-config-in-module
rm -f $1; \
mkdir -p $(dir $1); \
touch $1; \
echo "menu $2" >> $1; \
$(if $(strip $3), \
$(foreach __f,$3, \
echo "source $(call fullpath,$(__f))" >> $1; \
) \
) \
echo "endmenu" >> $1;
endef
###############################################################################
## Update a configuration automatically.
## $1 Config.in input file.
## $2 current config file.
## $3 update config file (can be the same as $2).
###############################################################################
define __update-config-internal
$(call __begin-conf,$2,) \
(yes "" | $(call __exec-conf,$1,-o)) > /dev/null; \
$(call __end-conf,$3)
endef
###############################################################################
## Update a configuration automatically.
## $1 Config.in input file.
## $2 current config file.
###############################################################################
define __update-config
__tmpcheck=$$(mktemp); \
$(call __update-config-internal,$1,$2,$${__tmpcheck}) \
if ! cmp -s $2 $${__tmpcheck}; then \
cp -pf $${__tmpcheck} $2; \
echo "Configuration file $2 has been updated"; \
fi; \
rm -f $${__tmpcheck};
endef
###############################################################################
## Check a configuration.
## $1 Config.in input file.
## $2 current config file.
###############################################################################
define __check-config
__tmpcheck=$$(mktemp); \
if [ ! -f $2 ]; then \
echo "Configuration file $2 does not exist" | tee $${__tmpdiff}; \
else \
$(call __update-config-internal,$1,$2,$${__tmpcheck}) \
if ! cmp -s $2 $${__tmpcheck}; then \
echo "Configuration file $2 is not up to date"; \
diff -u $2 $${__tmpcheck} >> $${__tmpdiff}; \
fi; \
fi; \
rm -f $${__tmpcheck};
endef
###############################################################################
## Load configuration of a module.
###############################################################################
ifneq ("$(words $(shell pwd))","1")
$(error Top directory contains space characters)
# Do NOT check the config if a config is explicitely requested
define __load-config-internal
$(eval __config := $(call __get_module-config,$1))
-include $(__config)
ifeq ("$(findstring config,$(MAKECMDGOALS))","")
$(__config): __config-modules-check-$1
endif
endef
###############################################################################
## OS type.
## Load configuration of a module.
## Simply evaluate a call to simplify job of caller.
###############################################################################
# set MingW32 flags
ifneq ("$(shell echo $$OSTYPE | grep msys)","")
OS_MINGW32 := 1
DIR_SUFFIX := _mingw
else
OS_MINGW32 := 0
DIR_SUFFIX :=
endif
# Exe/dll suffix under mingw
TARGET_STATIC_LIB_SUFFIX := .a
ifeq ("$(OS_MINGW32)","1")
TARGET_EXE_SUFFIX := .exe
TARGET_SHARED_LIB_SUFFIX := .dll
else
TARGET_EXE_SUFFIX :=
TARGET_SHARED_LIB_SUFFIX := .so
endif
ifeq ("$(OS_MINGW32)","1")
TARGET_GLOBAL_CFLAGS += -D__MINGW_FEATURES__=0
endif
load-config = $(eval $(call __load-config-internal,$(LOCAL_MODULE)))
###############################################################################
## Variables based on DEBUG/STATIC.
## Rules.
###############################################################################
ifeq ("$(DEBUG)","0")
TARGET_GLOBAL_CFLAGS += -O2 -g0 -DNDEBUG -DUNICODE -D_UNICODE
TARGET_GLOBAL_LDFLAGS += -Wl,--strip-all
TARGET_OUT_INTERMEDIATES := $(TOP_DIR)/linux/obj$(DIR_SUFFIX)/release
TARGET_OUT := $(TOP_DIR)/linux/bin$(DIR_SUFFIX)/release
else
TARGET_GLOBAL_CFLAGS += -O0 -g2 -DDEBUG -D_DEBUG -DUNICODE -D_UNICODE
TARGET_GLOBAL_LDFLAGS +=
TARGET_OUT_INTERMEDIATES := $(TOP_DIR)/linux/obj$(DIR_SUFFIX)/debug
TARGET_OUT := $(TOP_DIR)/linux/bin$(DIR_SUFFIX)/debug
endif
# Update everything
.PHONY: config-update
config-update: config-global-update config-modules-update
# Check everything
.PHONY: config-check
config-check: config-global-check config-modules-check
###############################################################################
## Determine gcc path and version.
###############################################################################
# Display the global configuration
.PHONY: config-global
config-global:
@( \
__tmpconfigin=$$(mktemp); \
$(eval __config := $(CONFIG_GLOBAL_FILE)) \
$(call __generate-config-in-global,$${__tmpconfigin}) \
$(call __begin-conf,$(__config)) \
$(call __exec-qconf,$${__tmpconfigin}) \
$(call __end-conf,$(__config)) \
rm -f $${__tmpconfigin}; \
)
GCC_PATH := $(shell which $(GCC))
GCC_VERSION := $(shell $(GCC) --version | head -1 \
| sed "s/.*\([0-9]\.[0-9]\.[0-9]\).*/\1/")
# Update the global configuration by selecting new option at their default value
.PHONY: config-global-update
config-global-update:
@( \
__tmpconfigin=$$(mktemp); \
$(eval __config := $(CONFIG_GLOBAL_FILE)) \
$(call __generate-config-in-global,$${__tmpconfigin}) \
$(call __update-config,$${__tmpconfigin},$(__config)) \
rm -f $${__tmpconfigin}; \
)
# Check the global configuration
.PHONY: config-global-check
config-global-check:
@( \
__tmpconfigin=$$(mktemp); \
$(eval __config := $(CONFIG_GLOBAL_FILE)) \
$(call __generate-config-in-global,$${__tmpconfigin}) \
$(call __check-config,$${__tmpconfigin},$(__config)) \
rm -f $${__tmpconfigin}; \
)
@echo "Global configuration is up to date";
# Update all module configurations by selecting new option at their default value
.PHONY: config-modules-update
config-modules-update:
@( \
$(foreach __mod,$(__modules), \
$(eval __config := $(call __get_module-config,$(__mod))) \
$(eval __files := $(call __get_module-config-in-files,$(__mod))) \
if [ "$(__files)" != "" ]; then \
__tmpconfigin=$$(mktemp); \
$(call __generate-config-in-module,$${__tmpconfigin},$(__mod),$(__files)) \
$(call __update-config,$${__tmpconfigin},$(__config)) \
rm -f $${__tmpconfigin}; \
fi; \
) \
)
# Update a specific module configuration by selecting new option at their default value
.PHONY: config-modules-update-%
config-modules-update-%:
@( \
$(eval __mod := $*) \
$(eval __config := $(call __get_module-config,$(__mod))) \
$(eval __files := $(call __get_module-config-in-files,$(__mod))) \
if [ "$(__files)" != "" ]; then \
__tmpconfigin=$$(mktemp); \
$(call __generate-config-in-module,$${__tmpconfigin},$(__mod),$(__files)) \
$(call __update-config,$${__tmpconfigin},$(__config)) \
rm -f $${__tmpconfigin}; \
fi; \
)
# Check if module configurations are OK
.PHONY: config-modules-check
config-modules-check: __config-modules-check
@echo "Modules configuration are up to date";
# Internal version with no message
.PHONY: __config-modules-check
__config-modules-check:
@( \
$(call __begin-diff) \
$(foreach __mod,$(__modules), \
$(eval __config := $(call __get_module-config,$(__mod))) \
$(eval __files := $(call __get_module-config-in-files,$(__mod))) \
if [ "$(__files)" != "" ]; then \
__tmpconfigin=$$(mktemp); \
$(call __generate-config-in-module,$${__tmpconfigin},$(__mod),$(__files)) \
$(call __check-config,$${__tmpconfigin},$(__config)) \
rm -f $${__tmpconfigin}; \
fi; \
) \
$(call __end-diff,1) \
)
# Check if a specific module configuration is OK
.PHONY: config-modules-check-%
config-modules-check-%: __config-modules-check-%
$(eval __mod := $*)
@echo "Configuration of $(__mod) is up to date";
# Internal version with no message
.PHONY: __config-modules-check-%
__config-modules-check-%:
@( \
$(call __begin-diff) \
$(eval __mod := $*) \
$(eval __config := $(call __get_module-config,$(__mod))) \
$(eval __files := $(call __get_module-config-in-files,$(__mod))) \
if [ "$(__files)" != "" ]; then \
__tmpconfigin=$$(mktemp); \
$(call __generate-config-in-module,$${__tmpconfigin},$(__mod),$(__files)) \
$(call __check-config,$${__tmpconfigin},$(__config)) \
rm -f $${__tmpconfigin}; \
fi; \
$(call __end-diff,1) \
)
# Configure a module specifically
.PHONY: config-modules-%
config-modules-%:
@( \
$(eval __mod := $*) \
$(eval __config := $(call __get_module-config,$(__mod))) \
$(eval __files := $(call __get_module-config-in-files,$(__mod))) \
if [ "$(__files)" == "" ]; then \
echo "Nothing to configure for $(__mod)"; \
else \
__tmpconfigin=$$(mktemp); \
$(call __generate-config-in-module,$${__tmpconfigin},$(__mod),$(__files)) \
$(call __begin-conf,$(__config)) \
$(call __exec-qconf,$${__tmpconfigin}) \
$(call __end-conf,$(__config)) \
rm -f $${__tmpconfigin}; \
echo "Configuration of $(__mod) saved in $(__config)"; \
fi; \
)

View File

@ -7,25 +7,379 @@
###############################################################################
###############################################################################
## Figure out where we are.
## Some useful macros.
###############################################################################
empty :=
space := $(empty) $(empty)
space4 := $(space)$(space)$(space)$(space)
# Return the first element of a list.
# $ 1 : input list.
first = $(firstword $1)
# Return the list with the first element removed.
# $ 1 : input list.
rest = $(wordlist 2,$(words $1),$1)
# Get a path relative to top directory.
# $1 : full path to convert.
path-from-top = $(patsubst $(TOP_DIR)%,.%,$1)
# Translate characters.
# $1 : text to convert.
# $2 : characters to convert from.
# $3 : characters to convert to.
tr = $(shell echo $1 | tr $2 $3)
# Convert to upper case.
# $1 : text to convert.
upcase = $(shell echo $1 | tr [:lower:] [:upper:])
# Convert to lower case.
# $1 : text to convert.
locase = $(shell echo $1 | tr [:upper:] [:lower:])
# Replace '-' by '_' and convert to upper case.
# $1 : text to convert.
get-define = $(strip $(call upcase,$(call tr,$1,-,_)))
# Remove quotes from string
remove-quotes = $(strip $(subst ",,$1))
#"
# Check that the current directory is the top directory
check-pwd-is-top-dir = \
$(if $(patsubst $(TOP_DIR)%,%,$(shell pwd)), \
$(error Not at the top directory))
###############################################################################
## Use some colors if requested.
###############################################################################
ifeq ("$(USE_COLORS)","1")
CLR_DEFAULT := $(shell echo -e "\033[00m")
CLR_RED := $(shell echo -e "\033[31m")
CLR_GREEN := $(shell echo -e "\033[32m")
CLR_YELLOW := $(shell echo -e "\033[33m")
CLR_BLUE := $(shell echo -e "\033[34m")
CLR_PURPLE := $(shell echo -e "\033[35m")
CLR_CYAN := $(shell echo -e "\033[36m")
else
CLR_DEFAULT :=
CLR_RED :=
CLR_GREEN :=
CLR_YELLOW :=
CLR_BLUE :=
CLR_PURPLE :=
CLR_CYAN :=
endif
###############################################################################
## Modules database.
## For each module 'mod', __modules.mod.<field> is used to store
## module-specific information.
###############################################################################
__modules := $(empty)
###############################################################################
## Clear a list of variables.
###############################################################################
clear-vars = $(foreach __varname,$1,$(eval $(__varname) := $(empty)))
###############################################################################
## List of LOCAL_XXX variables that can be set by makefiles.
###############################################################################
modules-LOCALS :=
# Path of the root of module
modules-LOCALS += PATH
# Name of what's supposed to be generated
modules-LOCALS += MODULE
# Override the name of what will be generated
modules-LOCALS += MODULE_FILENAME
# Source files to compile
# All files are relative to LOCAL_PATH
modules-LOCALS += SRC_FILES
# Static libraries that you want to include in your module
# Names of modules in the build system, without path/prefix/suffix
modules-LOCALS += STATIC_LIBRARIES
# Static libraries that you want to include as a whole in your module
# To generate a .so for ex
# Names of modules in the build system, without path/prefix/suffix
modules-LOCALS += WHOLE_STATIC_LIBRARIES
# Libraries you directly link against
# Names of modules in the build system, without path/prefix/suffix
modules-LOCALS += SHARED_LIBRARIES
# External libraries (not built directly by the build system rules)
# Used as dependencies to trigger indirect build.
modules-LOCALS += EXTERNAL_LIBRARIES
# Additional include directories to pass into the C/C++ compilers
# Format : -I<fullpath>
modules-LOCALS += C_INCLUDES
# Additional flags to pass into the C or C++ compiler
modules-LOCALS += CFLAGS
# Additional flags to pass into only the C++ compiler
modules-LOCALS += CPPFLAGS
# Additional flags to pass into the static library generator
modules-LOCALS += ARFLAGS
# Additional flags to pass into the linker
modules-LOCALS += LDFLAGS
# Additional libraries to pass into the linker
# Format : -l<name>
modules-LOCALS += LDLIBS
# Precompiled file
# Relative to LOCAL_PATH
modules-LOCALS += PRECOMPILED_FILE
# Arm compilation mode (arm or thumb)
modules-LOCALS += ARM_MODE
# Paths to config.in files to configure the module
# Relative to LOCAL_PATH
modules-LOCALS += CONFIG_FILES
# List of prerequisites for all objects
modules-LOCALS += PREREQUISITES
# Exported stuff (will be added in modules depending on this one)
modules-LOCALS += EXPORT_C_INCLUDES
modules-LOCALS += EXPORT_CFLAGS
modules-LOCALS += EXPORT_CPPFLAGS
modules-LOCALS += EXPORT_LDLIBS
modules-LOCALS += EXPORT_PREREQUISITES
# Module class : STATIC_LIBRARY SHARED_LIBRARY EXECUTABLE
modules-LOCALS += MODULE_CLASS
# Other variables used internally
modules-LOCALS += BUILD_MODULE
modules-LOCALS += STAGING_MODULE
modules-LOCALS += DESTDIR
modules-LOCALS += TARGETS
# the list of managed fields per module
modules-fields := \
depends \
$(modules-LOCALS)
###############################################################################
## Dump all module information. Only use this for debugging.
###############################################################################
modules-dump-database = \
$(info Modules: $(__modules)) \
$(foreach __mod,$(__modules), \
$(info $(space4)$(__mod):) \
$(foreach __field,$(modules-fields), \
$(eval __fieldval := $(strip $(__modules.$(__mod).$(__field)))) \
$(if $(__fieldval), \
$(if $(filter 1,$(words $(__fieldval))), \
$(info $(space4)$(space4)$(__field): $(__fieldval)), \
$(info $(space4)$(space4)$(__field): ) \
$(foreach __fielditem,$(__fieldval), \
$(info $(space4)$(space4)$(space4)$(__fielditem)) \
) \
) \
) \
) \
) \
$(info --- end of modules list)
###############################################################################
## Add a module in the build system and save its LOCAL_xxx variables.
## $1 : name of module to add. All LOCAL_xxx variables will be saved in
## module database.
###############################################################################
module-add = \
$(eval __modules += $1) \
$(foreach __local,$(modules-LOCALS), \
$(eval __modules.$1.$(__local) := $(LOCAL_$(__local))) \
)
###############################################################################
## Restore the recorded LOCAL_XXX definitions for a given module. Called
## for each module once they have all been registered and their dependencies
## have been computed to actually define rules.
## $1 : name of module to restore.
###############################################################################
module-restore-locals = \
$(foreach __local,$(modules-LOCALS), \
$(eval LOCAL_$(__local) := $(__modules.$1.$(__local))) \
)
###############################################################################
## Used to recompute all dependencies once all module information has been
## recorded.
###############################################################################
define my-dir
$(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST),$(MAKEFILE_LIST))))
# Compute dependencies of all modules
modules-compute-dependencies = \
$(foreach __mod,$(__modules), \
$(eval __modules.$(__mod).depends := ) \
$(call __module-compute-depends,$(__mod)) \
)
# Compute dependencies of a single module
# $1 : module name.
__module-compute-depends = \
$(call __module-add-depends,$1,$(__modules.$1.STATIC_LIBRARIES)) \
$(call __module-add-depends,$1,$(__modules.$1.WHOLE_STATIC_LIBRARIES)) \
$(call __module-add-depends,$1,$(__modules.$1.SHARED_LIBRARIES)) \
$(call __module-add-depends,$1,$(__modules.$1.EXTERNAL_LIBRARIES))
# Add dependencies to a module
# $1 : module name.
# $2 : list of modules to add in dependency list.
__module-add-depends = \
$(eval __modules.$1.depends += $(filter-out $(__modules.$1.depends),$2))
###############################################################################
## Automatic extraction from dependencies of a module.
###############################################################################
# Return the recorded value of LOCAL_EXPORT_$2, if any, for module $1.
# $1 : module name.
# $2 : export variable name without LOCAL_EXPORT_ prefix (e.g. 'CFLAGS').
module-get-export = $(__modules.$1.EXPORT_$2)
# Return the recorded value of LOCAL_EXPORT_$2, if any, for modules listed in $1.
# $1 : list of module names.
# $2 : export variable name without LOCAL_EXPORT_ prefix (e.g. 'CFLAGS').
module-get-listed-export = \
$(strip $(foreach __mod,$1, \
$(call module-get-export,$(__mod),$2) \
))
# Return the autoconf.h file, if any, for module $1.
# $1 : module name.
module-get-autoconf = \
$(if $(__modules.$1.CONFIG_FILES),$(TARGET_OUT_BUILD)/$1/autoconf-$1.h)
# Return the autoconf.h files, if any, for modules listed in $1.
# $1 : list of module names.
module-get-listed-autoconf = \
$(strip $(foreach __mod,$1, \
$(call module-get-autoconf,$(__mod)) \
))
###############################################################################
## Dependecy management
###############################################################################
# Return list all the <local-type> modules $1 depends on transitively.
# $1 : list of module names.
# $2 : local module type (e.g. SHARED_LIBRARIES).
module-get-depends = $(strip $(call __modules-get-closure,$1,$2))
# Return list of all the modules $1 depends on transitively.
# $1: list of module names.
module-get-all-dependencies = \
$(strip $(call __modules-get-closure,$1,depends))
# Recursively get dependency of a modules
__modules-get-closure = \
$(eval __closure_deps := $(strip $1)) \
$(if $(__closure_deps), \
$(eval __closure_wq := $(__closure_deps)) \
$(eval __closure_field := $(strip $2)) \
$(call __modules-closure)) \
$(__closure_deps)
# Used internally by modules-get-all-dependencies. Note the tricky use of
# conditional recursion to work around the fact that the GNU Make language does
# not have any conditional looping construct like 'while'.
__modules-closure = \
$(eval __closure_mod := $(call first,$(__closure_wq))) \
$(eval __closure_wq := $(call rest,$(__closure_wq))) \
$(eval __closure_val := $(__modules.$(__closure_mod).$(__closure_field))) \
$(eval __closure_new := $(filter-out $(__closure_deps),$(__closure_val))) \
$(eval __closure_deps += $(__closure_new)) \
$(eval __closure_wq := $(strip $(__closure_wq) $(__closure_new))) \
$(if $(__closure_wq),$(call __modules-closure)) \
###############################################################################
## Get path of module main target file (in build or staging directory).
## $1 : module name.
###############################################################################
module-get-build-dir = \
$(TARGET_OUT_BUILD)/$1
module-get-build-filename = \
$(TARGET_OUT_BUILD)/$1/$(__modules.$1.MODULE_FILENAME)
module-get-staging-filename = \
$(TARGET_OUT_STAGING)/$(__modules.$1.DESTDIR)/$(__modules.$1.MODULE_FILENAME)
###############################################################################
## Generate autoconf.h file from config file.
## $1 : input config file.
## $2 : output autoconf.h file.
##
## Remove CONFIG_ prefix.
## Remove CONFIG_ in commented lines.
## Put lines begining with '#' between '/*' '*/'.
## Replace 'key=value' by '#define key value'.
## Replace leading ' y' by ' 1'.
## Remove leading and trailing quotes from string.
## Replace '\"' by '"'.
###############################################################################
define generate-autoconf-file
echo "Generating $(call path-from-top,$2) from $(call path-from-top,$1)"; \
mkdir -p $(dir $2); \
sed \
-e 's/^CONFIG_//' \
-e 's/^\# CONFIG_/\# /' \
-e 's/^\#\(.*\)/\/*\1 *\//' \
-e 's/\(.*\)=\(.*\)/\#define \1 \2/' \
-e 's/ y$$/ 1/' \
-e 's/\"\(.*\)\"/\1/' \
-e 's/\\\"/\"/g' \
$1 > $2;
endef
###############################################################################
## Print some banners.
## $1 : operation.
## $2 : module.
## $3 : file.
###############################################################################
CLR_TOOL := $(CLR_PURPLE)
CLR_MODULE := $(CLR_CYAN)
CLR_FILE := $(CLR_YELLOW)
print-banner1 = \
@echo "$(CLR_TOOL)$1:$(CLR_DEFAULT) $(CLR_MODULE)$2$(CLR_DEFAULT) <= $(CLR_FILE)$3$(CLR_DEFAULT)"
print-banner2 = \
@echo "$(CLR_TOOL)$1:$(CLR_DEFAULT) $(CLR_MODULE)$2$(CLR_DEFAULT) => $(CLR_FILE)$3$(CLR_DEFAULT)"
###############################################################################
## Commands for running gcc to generate a precompiled file.
###############################################################################
define transform-h-to-gch
@mkdir -p $(dir $@)
@echo "Precompile: $(PRIVATE_MODULE) <= $<"
$(Q)$(GXX) \
$(TARGET_PROJECT_INCLUDES) $(TARGET_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(call print-banner1,"Precompile",$(PRIVATE_MODULE),$(call path-from-top,$<))
$(call check-pwd-is-top-dir)
$(Q)$(CCACHE) $(GXX) \
$(TARGET_GLOBAL_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(GXX_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \
-c -MMD -MP -o $@ $<
$(TARGET_PCH_FLAGS) -MMD -MP -o $@ \
$(call path-from-top,$<)
endef
###############################################################################
@ -34,12 +388,15 @@ endef
define transform-cpp-to-o
@mkdir -p $(dir $@)
@echo "C++: $(PRIVATE_MODULE) <= $<"
$(Q)$(GXX) \
$(TARGET_PROJECT_INCLUDES) $(TARGET_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(call print-banner1,"$(PRIVATE_ARM_MODE) CPP",$(PRIVATE_MODULE),$(call path-from-top,$<))
$(call check-pwd-is-top-dir)
$(Q)$(CCACHE) $(GXX) \
$(TARGET_GLOBAL_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \
$(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(GXX_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \
-c -MMD -MP -o $@ $<
-c -MMD -MP -o $@ \
$(call path-from-top,$<)
endef
###############################################################################
@ -47,27 +404,33 @@ endef
###############################################################################
define transform-c-to-o
@echo "C: $(PRIVATE_MODULE) <= $<"
$(call print-banner1,"$(PRIVATE_ARM_MODE) C",$(PRIVATE_MODULE),$(call path-from-top,$<))
$(call check-pwd-is-top-dir)
@mkdir -p $(dir $@)
$(Q)$(GCC) \
$(TARGET_PROJECT_INCLUDES) $(TARGET_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(Q)$(CCACHE) $(GCC) \
$(TARGET_GLOBAL_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \
$(TARGET_GLOBAL_CFLAGS) $(GCC_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) \
-c -MMD -MP -o $@ $<
-c -MMD -MP -o $@ \
$(call path-from-top,$<)
endef
###############################################################################
## Commands for compiling rc files.
## Commands for running gcc to compile a S file.
###############################################################################
define transform-rc-to-o
@echo "RC: $(PRIVATE_MODULE) <= $<"
define transform-s-to-o
$(call print-banner1,"ASM",$(PRIVATE_MODULE),$(call path-from-top,$<))
$(call check-pwd-is-top-dir)
@mkdir -p $(dir $@)
@rm -f $@
$(Q)$(WINDRES) \
--use-temp-file -i$< -o$@ -I$(dir $<) \
$(filter -D%, $(TARGET_GLOBAL_CFLAGS)) \
$(filter -D%, $(PRIVATE_CFLAGS)) \
$(TARGET_GLOBAL_RCFLAGS) $(PRIVATE_RCFLAGS)
$(Q)$(CCACHE) $(GCC) \
$(TARGET_GLOBAL_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \
$(TARGET_GLOBAL_CFLAGS) $(GCC_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) \
-c -MMD -MP -o $@ \
$(call path-from-top,$<)
endef
###############################################################################
@ -78,9 +441,10 @@ endef
# try to add to an existing archive.
define transform-o-to-static-lib
@mkdir -p $(dir $@)
@echo "StaticLib: $(PRIVATE_MODULE) ($@)"
$(call print-banner2,"StaticLib",$(PRIVATE_MODULE),$(call path-from-top,$@))
$(call check-pwd-is-top-dir)
@rm -f $@
$(Q)$(AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $^
$(Q)$(AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS)
endef
###############################################################################
@ -89,20 +453,25 @@ endef
define transform-o-to-shared-lib
@mkdir -p $(dir $@)
@echo "SharedLib: $(PRIVATE_MODULE) ($@)"
$(call print-banner2,"SharedLib",$(PRIVATE_MODULE),$(call path-from-top,$@))
$(call check-pwd-is-top-dir)
$(Q)$(GXX) \
$(TARGET_GLOBAL_LDFLAGS) \
$(TARGET_GLOBAL_LDFLAGS_SHARED) \
-Wl,-Map -Wl,$(basename $@).map \
-shared \
-Wl,-soname -Wl,$(notdir $@) \
-Wl,--unresolved-symbols=ignore-in-shared-libs \
-Wl,--no-undefined \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
-Wl,--no-whole-archive \
-Wl,--as-needed \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
-o $@ \
$(PRIVATE_LDLIBS)
$(PRIVATE_LDLIBS) \
$(TARGET_GLOBAL_LDLIBS_SHARED)
endef
###############################################################################
@ -111,40 +480,24 @@ endef
define transform-o-to-executable
@mkdir -p $(dir $@)
@echo "Executable: $(PRIVATE_MODULE) ($@)"
$(call print-banner2,"Executable",$(PRIVATE_MODULE),$(call path-from-top,$@))
$(call check-pwd-is-top-dir)
$(Q)$(GXX) \
$(TARGET_GLOBAL_LDFLAGS) \
-Wl,-Map -Wl,$(basename $@).map \
-Wl,-rpath-link=$(TARGET_OUT_STAGING)/lib \
-Wl,-rpath-link=$(TARGET_OUT_STAGING)/usr/lib \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
-Wl,--no-whole-archive \
-Wl,--as-needed \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
$(TARGET_GLOBAL_LDFLAGS) \
$(PRIVATE_LDFLAGS) \
-o $@ \
$(PRIVATE_LDLIBS)
endef
###############################################################################
## Commands to generate resource list
###############################################################################
# $(1) : ResListMaker full path
# $(2) : source directory
# $(3) : destination directory
define transform-reslist
@mkdir -p $(dir $@)
@echo "ResList: $(PRIVATE_MODULE) ($@)"
$(Q)$(1) $(2)/ResList.txt $(3)/ResList.h $(3)/ResList.c $(2)
$(Q)date | cat > $@
endef
# $(1) : source directory
# $(2) : destination directory
define generate-reslistmaker
@mkdir -p $(dir $@)
@echo "ResListMaker: $(PRIVATE_MODULE) ($@)"
$(Q)$(GCC) -O2 -g0 -c -o $(2)/ResListMaker.o $(1)/ResListMaker.c
$(Q)$(GCC) -o $@ $(2)/ResListMaker.o
$(PRIVATE_LDLIBS) \
$(TARGET_GLOBAL_LDLIBS)
endef
###############################################################################
@ -159,18 +512,42 @@ $(Q)cp -fp $< $@
endef
# Define a rule to copy a file. For use via $(eval).
# $(1): source file
# $(2): destination file
# $(1) : source file
# $(2) : destination file
define copy-one-file
$(2): $(1)
@echo "Copy: $$@"
@echo "$(CLR_TOOL)Copy: $(CLR_FILE)$$(call path-from-top,$$@)$(CLR_DEFAULT)"
$$(copy-file-to-target)
endef
###############################################################################
## Default rules for a module.
## $1 : module name.
###############################################################################
define def-rules
.PHONY: $1
$1: $(call module-get-build-filename,$1)
.PHONY: clean-$1
clean-$1:
@rm -f $(call module-get-build-filename,$1)
@rm -rf $(call module-get-build-dir,$1)
endef
###############################################################################
## Commands for importing module files.
## Commands callable from user makefiles.
###############################################################################
import-module = \
$(eval include $(shell find $(PROJECT_MODULE)$1 -name Linux.mk))
# Get local path
local-get-path = $(call my-dir)
# Get build directory
local-get-build-dir = $(call module-get-build-dir,$(LOCAL_MODULE))
# Register module
local-add-module = \
$(call module-add,$(LOCAL_MODULE)) \
$(eval $(call def-rules,$(LOCAL_MODULE)))

View File

@ -6,11 +6,11 @@
## Build an executable.
###############################################################################
LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
LOCAL_BUILDING_EXECUTABLE := 1
LOCAL_MODULE_CLASS := EXECUTABLE
LOCAL_DESTDIR := usr/bin
include $(RULES)
$(LOCAL_BUILT_MODULE): $(all_libraries) $(all_objects)
$(transform-o-to-executable)
ifndef LOCAL_MODULE_FILENAME
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_EXE_SUFFIX)
endif
$(call module-add,$(LOCAL_MODULE))

View File

@ -6,87 +6,95 @@
## Main Makefile.
###############################################################################
###############################################################################
## General setup.
###############################################################################
# Make sure SHELL is correctly set
SHELL := /bin/bash
# Turns off suffix rules built into make
.SUFFIXES:
# Installation variables
PACKAGE := fsanalyser
DESTDIR :=
PREFIX := /usr/local
# Tools for target
GCC ?= $(CROSS)gcc
GXX ?= $(CROSS)g++
AR ?= $(CROSS)ar
LD ?= $(CROSS)ld
NM ?= $(CROSS)nm
STRIP ?= $(CROSS)strip
# Tools
WINDRES := windres
# Tools for host
HOST_GCC ?= gcc
HOST_GXX ?= g++
HOST_AR ?= ar
HOST_LD ?= ld
HOST_STRIP ?= strip
# Overridable settings
V := 0
W := 0
DEBUG := 0
STATIC := 0
CLANG := 0
USE_CLANG := 0
USE_CCACHE := 0
ifneq ("$(CLANG)","1")
GCC := gcc
GXX := g++
AR := ar
LD := ld
else
GCC := clang
GXX := clang++
AR := ar
LD := ld
endif
# Quiet command if V is not 1
ifneq ("$(V)","1")
# Quiet command if V is 0
ifeq ("$(V)","0")
Q := @
endif
# Directories
TOP_DIR := .
#BUILD_SYSTEM := $(TOP_DIR)/Build/coreLinux
BUILD_SYSTEM := $(PROJECT_NDK)/Build/coreLinux/
# This is the default target. It must be the first declared target.
all:
# Global variables
TARGET_PROJECT_INCLUDES :=
TARGET_C_INCLUDES :=
TARGET_GLOBAL_CFLAGS := -fno-exceptions -fstrict-aliasing
TARGET_GLOBAL_CPPFLAGS :=
TARGET_GLOBAL_RCFLAGS :=
TARGET_GLOBAL_ARFLAGS := -rcs
TARGET_GLOBAL_LDFLAGS := -Wl,--gc-sections -Wl,--warn-common -Wl,--warn-constructors
ALL_MODULES :=
# To be able to load automatically .so libraries located in the same
# folder than the application, we need to add $ORIGIN to DT_RPATH
# '\' is to escape the '$' in the shell command
# '$$' is to escape the '$' in the makefile
TARGET_GLOBAL_LDFLAGS += -Wl,-rpath,\$$ORIGIN
# Target global variables
TARGET_GLOBAL_C_INCLUDES ?=
TARGET_GLOBAL_CFLAGS ?=
TARGET_GLOBAL_CPPFLAGS ?=
TARGET_GLOBAL_RCFLAGS ?=
TARGET_GLOBAL_ARFLAGS ?= rcs
TARGET_GLOBAL_LDFLAGS ?=
TARGET_GLOBAL_LDFLAGS_SHARED ?=
TARGET_GLOBAL_LDLIBS ?=
TARGET_GLOBAL_LDLIBS_SHARED ?=
TARGET_PCH_FLAGS ?=
TARGET_DEFAULT_ARM_MODE ?= THUMB
TARGET_GLOBAL_CFLAGS_ARM ?=
TARGET_GLOBAL_CFLAGS_THUMB ?=
###############################################################################
# Version
## The folowing 2 macros can NOT be put in defs.mk as it will be included
## only after.
###############################################################################
VERSION_MAJOR := 111
VERSION_MINOR := 2222
VERSION_REVISION := 3453
VERSION := $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)
# Get full path.
# $1 : path to extend.
fullpath = $(shell readlink -m -n $1)
# Figure out where we are
# It returns the full path without trailing '/'
my-dir = $(call fullpath,$(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))))
###############################################################################
## Build system setup.
###############################################################################
# Directories (full path)
TOP_DIR := $(shell pwd)
BUILD_SYSTEM := $(call my-dir)
# Setup configuration
include $(BUILD_SYSTEM)/setup.mk
# Setup macros definitions
include $(BUILD_SYSTEM)/defs.mk
# Setup configuration
# Setup warnings flags
include $(BUILD_SYSTEM)/warnings.mk
# Load configuration
include $(BUILD_SYSTEM)/config.mk
# Names of makefiles that can be included by "local.mk" Makefiles
# Names of makefiles that can be included by user Makefiles
CLEAR_VARS := $(BUILD_SYSTEM)/clearvars.mk
BUILD_STATIC_LIBRARY := $(BUILD_SYSTEM)/static.mk
BUILD_SHARED_LIBRARY := $(BUILD_SYSTEM)/shared.mk
@ -94,96 +102,119 @@ BUILD_EXECUTABLE := $(BUILD_SYSTEM)/executable.mk
RULES := $(BUILD_SYSTEM)/rules.mk
###############################################################################
## Flags to activate warnings.
## Makefile scan and includes.
###############################################################################
ifeq ("$(DEBUG)","1")
BUILD_DIRECTORY_MODE := debug
else
BUILD_DIRECTORY_MODE := release
endif
COMMON_FLAGS_WARNINGS :=
GCC_FLAGS_WARNINGS :=
GXX_FLAGS_WARNINGS :=
TARGET_OUT_BUILD ?= $(shell pwd)/out_$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/obj
TARGET_OUT_STAGING ?= $(shell pwd)/out_$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/obj
TARGET_OUT_FINAL ?= $(shell pwd)/out_$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/bin
COMMON_FLAGS_WARNINGS += -Wall
# Makefile with the list of all makefiles available and include them
SCAN_TARGET := scan
#TODO : change this in function of the platform ...
USER_MAKEFILE_NAME := Linux.mk
USER_MAKEFILES:=$(TARGET_OUT_BUILD)/makefiles.mk
# Add common flags to specific flags
GCC_FLAGS_WARNINGS += $(COMMON_FLAGS_WARNINGS)
GXX_FLAGS_WARNINGS += $(COMMON_FLAGS_WARNINGS)
# Include makefile containing all available makefile
# If it does not exists, it will trigger its creation
ifeq ("$(findstring $(SCAN_TARGET),$(MAKECMDGOALS))","")
include $(USER_MAKEFILES)
endif
$(info mydir="$(my-dir)")
$(info pwd="$(shell pwd)")
$(info TOP_DIR="$(TOP_DIR)")
$(info USER_PACKAGES="$(USER_PACKAGES)")
# Create a file that will contain all user makefiles available
define create-user-makefiles-file
rm -f $(USER_MAKEFILES); \
mkdir -p $(dir $(USER_MAKEFILES)); \
touch $(USER_MAKEFILES); \
echo "Scanning $(TOP_DIR) for makefiles..."; \
for f in `find $(USER_PACKAGES) -name $(USER_MAKEFILE_NAME)`; do \
echo "$$f"; \
echo "include $$f" >> $(USER_MAKEFILES); \
done;
endef
# Rule that will trigger creation of list of makefiles when needed
$(USER_MAKEFILES):
@$(create-user-makefiles-file)
# Rule to force creation of list of makefiles
.PHONY: $(SCAN_TARGET)
$(SCAN_TARGET):
@$(create-user-makefiles-file)
###############################################################################
# Module dependencies generation.
###############################################################################
# Get the list of all makefiles available and include them
makefiles += $(shell find $(TOP_DIR) -name Linux.mk)
include $(makefiles)
# Recompute all dependencies between modules
$(call modules-compute-dependencies)
# Now, really build the modules, the second pass allows to deal with exported values
$(foreach __mod,$(__modules), \
$(eval LOCAL_MODULE := $(__mod)) \
$(eval include $(BUILD_SYSTEM)/module.mk) \
)
###############################################################################
# Rule to merge autoconf.h files.
###############################################################################
# List of all available autoconf.h files
__autoconf-list := $(foreach __mod,$(__modules),$(call module-get-autoconf,$(__mod)))
# Concatenate all in one
AUTOCONF_MERGE_FILE := $(TARGET_OUT_BUILD)/autoconf-merge.h
$(AUTOCONF_MERGE_FILE): $(__autoconf-list)
@echo "Generating autoconf-merge.h"
@mkdir -p $(dir $@)
@rm -f $@
@for f in $^; do cat $$f >> $@; done
TARGET_GLOBAL_CPPFLAGS := $(addprefix -I, $(LIB_EXTERN_C_INCLUDE))
TARGET_GLOBAL_LDFLAGS := $(TARGET_GLOBAL_LDFLAGS) $(LIB_EXTERN_LDLIBS)
###############################################################################
# Main rules.
###############################################################################
.PHONY: all
all: $(foreach m,$(ALL_MODULES),$(m))
all: $(foreach __mod,$(__modules),$(__mod)) $(AUTOCONF_MERGE_FILE)
.PHONY: clean
clean: $(foreach m,$(ALL_MODULES),clean-$(m))
clean: $(foreach __mod,$(__modules),clean-$(__mod))
@rm -f $(AUTOCONF_MERGE_FILE)
@rm -f $(USER_MAKEFILES)
.PHONY: distclean
distclean: clean
# Generate final tree
.PHONY: final
final: all
@echo "Generating final tree..."
@$(BUILD_SYSTEM)/make-final.py \
--strip="$(STRIP)" \
$(TARGET_OUT_STAGING) $(TARGET_OUT_FINAL)
@echo "Done generating final tree"
.PHONY: test
test:
.PHONY: install
install: $(foreach m,$(ALL_MODULES),install-$(m))
###############################################################################
# debian package generation.
###############################################################################
.PHONY: deb
deb:
@chmod +x debian/rules
$(Q)fakeroot debian/rules binary
.PHONY: deb-clean
deb-clean:
@chmod +x debian/rules
$(Q)fakeroot debian/rules clean
###############################################################################
# source/binary pakage generation.
###############################################################################
# Generate archive with source files from git
SRCZIP_NAME := $(PACKAGE)-src-$(VERSION)
.PHONY: src-zip
src-zip:
@rm -f $(SRCZIP_NAME).tar
@rm -f $(SRCZIP_NAME).tar.bz2
$(Q)git archive --format=tar --prefix=$(SRCZIP_NAME)/ \
-o $(SRCZIP_NAME).tar HEAD
$(Q)bzip2 $(SRCZIP_NAME).tar
# Generate archive with binary files
BINZIP_NAME := $(PACKAGE)-bin-$(VERSION)
.PHONY: bin-zip
bin-zip:
@rm -f $(BINZIP_NAME).tar
@rm -f $(BINZIP_NAME).tar.bz2
$(Q)tar -cf $(BINZIP_NAME).tar -C $(TARGET_OUT) \
--transform "s/\.\(\/.*\)/$(BINZIP_NAME)\\1/" .
$(Q)bzip2 $(BINZIP_NAME).tar
# Dump the module database for debuging the build system
.PHONY: dump
dump:
$(call modules-dump-database)
###############################################################################
# Display configuration.
###############################################################################
msg = $(info $(CLR_CYAN)$1$(CLR_DEFAULT))
$(info ----------------------------------------------------------------------)
$(info + VERSION = $(VERSION))
$(info + DEBUG = $(DEBUG))
$(info + STATIC = $(STATIC))
$(info + TARGET_OUT_INTERMEDIATES = $(TARGET_OUT_INTERMEDIATES))
$(info + TARGET_OUT = $(TARGET_OUT))
$(info + GCC_PATH = $(GCC_PATH))
$(info + GCC_VERSION = $(GCC_VERSION))
$(call msg, + HOST_OS = $(HOST_OS))
$(call msg, + TARGET_OS = $(TARGET_OS))
$(call msg, + TARGET_ARCH = $(TARGET_ARCH))
$(call msg, + TARGET_OUT_BUILD = $(TARGET_OUT_BUILD))
$(call msg, + TARGET_OUT_STAGING = $(TARGET_OUT_STAGING))
$(call msg, + TARGET_OUT_FINAL = $(TARGET_OUT_FINAL))
$(call msg, + GCC_PATH = $(GCC_PATH))
$(call msg, + GCC_VERSION = $(GCC_VERSION))
$(info ----------------------------------------------------------------------)

View File

@ -0,0 +1,24 @@
#!/bin/bash
if [ "$#" != "2" ]; then
echo "Usage : $0 <input> <output>"
exit 1
fi
# Remove CONFIG_ prefix
# Put lines beginig with '#' between '/*' '*/'
# Replace 'key=value' by '#define key value'
# Replace leading ' y' by ' 1'
# Remove leading and trailing quotes from string
# Replace '\"' by '"'
sed \
-e 's/^CONFIG_//' \
-e 's/^# CONFIG_/# /' \
-e "s/^#\(.*\)/\/*\1 *\//" \
-e 's/\(.*\)=\(.*\)/#define \1 \2 /' \
-e 's/ y$/ 1/' \
-e 's/\"\(.*\)\"/\1/' \
-e 's/\\\"/\"/g' \
$1 > $2

141
Build/coreLinux/make-final.py Executable file
View File

@ -0,0 +1,141 @@
#!/usr/bin/env python
#
# @file make-final.py
# @author Y.M. Morgan
# @date 2012/07/09
#
# Generate the final directory by copying files from staging directories
#
import sys, os, logging
import optparse
import shutil
#===============================================================================
# Global variables.
#===============================================================================
# Directories to exclude
EXCLUDE_DIRS = ["include", "man"]
# Extension to exclude
EXCLUDE_FILTERS = [".a", ".la"]
#===============================================================================
# Determine if a file is an executable.
#===============================================================================
def isExec(filePath):
result = False
try:
file = open(filePath, "r")
header = str(file.read(4))
if header.find("ELF") >= 0:
result = True
file.close()
except IOError as ex:
logging.error("Unable to open %s ([err=%d] %s)",
filePath, ex.errno, ex.strerror)
return result
#===============================================================================
# Main function.
#===============================================================================
def main():
(options, args) = parseArgs()
setupLog(options)
# get parameters
stagingDir = args[0]
finalDir = args[1]
logging.info("staging-dir : %s", stagingDir)
logging.info("final-dir : %s", finalDir)
# check that staging directory exists
if not os.path.isdir(stagingDir):
logging.error("%s is not a directory", stagingDir)
# browse staging directory
for (dirPath, dirNames, fileNames) in os.walk(stagingDir):
# exclude some directories
for dirName in EXCLUDE_DIRS:
if dirName in dirNames:
logging.debug("Exclude directory : %s",
os.path.relpath(os.path.join(dirPath, dirName), stagingDir))
dirNames.remove(dirName)
for fileName in fileNames:
# skip dome extensions
srcFileName = os.path.join(dirPath, fileName)
relPath = os.path.relpath(srcFileName, stagingDir)
if os.path.splitext(srcFileName)[1] in EXCLUDE_FILTERS:
logging.debug("Exclude file : %s", relPath)
continue
logging.info("File : %s", relPath)
# destination
dstFileName = os.path.join(finalDir, relPath)
dstDirName = os.path.split(dstFileName)[0]
if not os.path.exists(dstDirName):
os.makedirs(dstDirName, 0755)
# copy and strip executables
if isExec(srcFileName):
os.system("%s -o %s %s" % (options.strip, dstFileName, srcFileName))
else:
shutil.copy2(srcFileName, dstFileName)
#===============================================================================
# Setup option parser and parse command line.
#===============================================================================
def parseArgs():
usage = "usage: %prog [options] <staging-dir> <final-dir>"
parser = optparse.OptionParser(usage = usage)
parser.add_option("--strip",
dest="strip",
default=None,
help="strip program to use to remove symbols")
parser.add_option("-q",
dest="quiet",
action="store_true",
default=False,
help="be quiet")
parser.add_option("-v",
dest="verbose",
action="count",
default=0,
help="verbose output (more verbose if specified twice)")
(options, args) = parser.parse_args()
if len(args) > 2:
parser.error("Too many parameters")
elif len(args) < 2:
parser.error("Not enough parameters")
if options.strip == None:
parser.error("Missing strip option")
return (options, args)
#===============================================================================
# Setup logging system.
#===============================================================================
def setupLog(options):
logging.basicConfig(
level=logging.WARNING,
format="[%(levelname)s] %(message)s",
stream=sys.stderr)
logging.addLevelName(logging.CRITICAL, "C")
logging.addLevelName(logging.ERROR, "E")
logging.addLevelName(logging.WARNING, "W")
logging.addLevelName(logging.INFO, "I")
logging.addLevelName(logging.DEBUG, "D")
# setup log level
if options.quiet == True:
logging.getLogger().setLevel(logging.CRITICAL)
elif options.verbose >= 2:
logging.getLogger().setLevel(logging.DEBUG)
elif options.verbose >= 1:
logging.getLogger().setLevel(logging.INFO)
#===============================================================================
# Entry point.
#===============================================================================
if __name__ == "__main__":
main()

66
Build/coreLinux/module.mk Normal file
View File

@ -0,0 +1,66 @@
###############################################################################
## @file module.mk
## @author Y.M. Morgan
## @date 2012/04/17
##
## Build a module.
###############################################################################
# Bring back all LOCAL_XXX variables defined by LOCAL_MODULE
$(call module-restore-locals,$(LOCAL_MODULE))
copy_to_staging := 0
###############################################################################
## Static library.
###############################################################################
ifeq ("$(LOCAL_MODULE_CLASS)","STATIC_LIBRARY")
include $(RULES)
$(LOCAL_BUILD_MODULE): $(all_objects)
$(transform-o-to-static-lib)
copy_to_staging := 1
endif
###############################################################################
## Shared library.
###############################################################################
ifeq ("$(LOCAL_MODULE_CLASS)","SHARED_LIBRARY")
include $(RULES)
$(LOCAL_BUILD_MODULE): $(all_objects) $(all_libraries)
$(transform-o-to-shared-lib)
copy_to_staging := 1
endif
###############################################################################
## Executable.
###############################################################################
ifeq ("$(LOCAL_MODULE_CLASS)","EXECUTABLE")
include $(RULES)
$(LOCAL_BUILD_MODULE): $(all_objects) $(all_libraries)
$(transform-o-to-executable)
copy_to_staging := 1
endif
###############################################################################
## Copy to staging dir
###############################################################################
ifeq ("$(copy_to_staging)","1")
$(eval $(call copy-one-file,$(LOCAL_BUILD_MODULE),$(LOCAL_STAGING_MODULE)))
endif

BIN
Build/coreLinux/qconf Executable file

Binary file not shown.

View File

@ -12,188 +12,251 @@ ifeq ("$(LOCAL_MODULE)","")
$(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
endif
# Intermediates directory
intermediates := $(TARGET_OUT_INTERMEDIATES)/$(LOCAL_MODULE)
# Intermediate/Build directory
build_dir := $(TARGET_OUT_BUILD)/$(LOCAL_MODULE)
# Full path to build module
LOCAL_BUILT_MODULE := $(intermediates)/$(LOCAL_MODULE)$(LOCAL_MODULE_SUFFIX)
LOCAL_BUILD_MODULE := $(call module-get-build-filename,$(LOCAL_MODULE))
# Full path to final module
LOCAL_FINAL_MODULE := $(TARGET_OUT)/$(LOCAL_MODULE)$(LOCAL_MODULE_SUFFIX)
# Full path to staging module
LOCAL_STAGING_MODULE := $(call module-get-staging-filename,$(LOCAL_MODULE))
# Assemble the list of targets to create PRIVATE_ variables for.
LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
LOCAL_TARGETS += $(LOCAL_BUILD_MODULE)
# Prepend some directories in include list
LOCAL_C_INCLUDES := -I$(intermediates) -I$(TOP_DIR)/$(LOCAL_PATH) $(LOCAL_C_INCLUDES)
LOCAL_C_INCLUDES := -I$(build_dir) -I$(LOCAL_PATH) $(LOCAL_C_INCLUDES)
# Register the module
ALL_MODULES += $(LOCAL_MODULE)
###############################################################################
## ARM specific checks.
###############################################################################
ifeq ("$(TARGET_ARCH)","ARM")
# Make sure LOCAL_ARM_MODE is valid
# If not set, use default mode
# Convert to upper case for further use
LOCAL_ARM_MODE := $(call upcase,$(strip $(LOCAL_ARM_MODE)))
ifeq ("$(LOCAL_ARM_MODE)","")
LOCAL_ARM_MODE := $(TARGET_DEFAULT_ARM_MODE)
endif
ifneq ("$(LOCAL_ARM_MODE)","ARM")
ifneq ("$(LOCAL_ARM_MODE)","THUMB")
$(error $(LOCAL_PATH): LOCAL_ARM_MODE is not valid : $(LOCAL_ARM_MODE))
endif
endif
## Check that compilation flags do not include forbidden stuff.
check-flags-arm-mode := -marm -mthumb
check-flags = \
$(foreach flags,$1, \
$(if $(findstring $($3),$(flags)), \
$(error $(LOCAL_PATH): $3 contains $(flags) : $2) \
) \
)
# Check that -marm or -mthumb is not forced in compilation flags
flags-arm-mode := -marm -mthumb
check-message := please use LOCAL_ARM_MODE
check-flags-arm-mode = $(call check-flags,$(flags-arm-mode),$(check-message),$1)
$(call check-flags-arm-mode,LOCAL_CFLAGS)
$(call check-flags-arm-mode,LOCAL_CPPFLAGS)
$(call check-flags-arm-mode,LOCAL_EXPORT_CFLAGS)
$(call check-flags-arm-mode,LOCAL_EXPORT_CPPFLAGS)
endif
###############################################################################
## List of sources, objects and libraries.
###############################################################################
cpp_sources := $(filter %.cpp,$(LOCAL_SRC_FILES))
cpp_objects := $(addprefix $(intermediates)/,$(cpp_sources:.cpp=.o))
cpp_objects := $(addprefix $(build_dir)/,$(cpp_sources:.cpp=.o))
cxx_sources := $(filter %.cxx,$(LOCAL_SRC_FILES))
cxx_objects := $(addprefix $(intermediates)/,$(cxx_sources:.cxx=.o))
cxx_objects := $(addprefix $(build_dir)/,$(cxx_sources:.cxx=.o))
c_sources := $(filter %.c,$(LOCAL_SRC_FILES))
c_objects := $(addprefix $(intermediates)/,$(c_sources:.c=.o))
c_objects := $(addprefix $(build_dir)/,$(c_sources:.c=.o))
# rc files are used only under Mingw32
ifeq ("$(OS_MINGW32)","1")
rc_sources := $(filter %.rc,$(LOCAL_SRC_FILES))
rc_objects := $(addprefix $(intermediates)/,$(rc_sources:.rc=.rc.o))
endif
s_sources := $(filter %.s,$(LOCAL_SRC_FILES))
s_objects := $(addprefix $(build_dir)/,$(s_sources:.s=.o))
S_sources := $(filter %.S,$(LOCAL_SRC_FILES))
S_objects := $(addprefix $(build_dir)/,$(S_sources:.S=.o))
all_objects := \
$(cpp_objects) \
$(cxx_objects) \
$(c_objects) \
$(rc_objects) \
$(s_objects) \
$(S_objects) \
# Under mingw32, use .dll.a to link against shared libraries instead of .so
ifeq ("$(OS_MINGW32)","1")
shared_suffix := $(TARGET_SHARED_LIB_SUFFIX)$(TARGET_STATIC_LIB_SUFFIX)
else
shared_suffix := $(TARGET_SHARED_LIB_SUFFIX)
endif
# Get all static libraries this module depends on
LOCAL_STATIC_LIBRARIES := \
$(call module-get-depends,$(LOCAL_STATIC_LIBRARIES),STATIC_LIBRARIES)
LOCAL_WHOLE_STATIC_LIBRARIES := \
$(call module-get-depends,$(LOCAL_WHOLE_STATIC_LIBRARIES),WHOLE_STATIC_LIBRARIES)
built_shared_libraries := \
# Also get shared libraries used by static libraries
LOCAL_SHARED_LIBRARIES += \
$(call module-get-depends,$(LOCAL_STATIC_LIBRARIES),SHARED_LIBRARIES)
LOCAL_SHARED_LIBRARIES += \
$(call module-get-depends,$(LOCAL_WHOLE_STATIC_LIBRARIES),SHARED_LIBRARIES)
# Get path
all_shared_libraries := \
$(foreach lib,$(LOCAL_SHARED_LIBRARIES), \
$(TARGET_OUT_INTERMEDIATES)/$(lib)/$(lib)$(shared_suffix))
built_static_libraries := \
$(call module-get-staging-filename,$(lib)))
all_static_libraries := \
$(foreach lib,$(LOCAL_STATIC_LIBRARIES), \
$(TARGET_OUT_INTERMEDIATES)/$(lib)/$(lib)$(TARGET_STATIC_LIB_SUFFIX))
$(call module-get-staging-filename,$(lib)))
all_whole_static_libraries := \
$(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \
$(call module-get-staging-filename,$(lib)))
# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
all_external_libraries := \
$(foreach lib,$(LOCAL_EXTERNAL_LIBRARIES), \
$(TARGET_OUT_BUILD)/$(lib)/$(lib).done)
# all_libraries is used for the dependencies.
all_libraries := \
$(built_shared_libraries) \
$(built_static_libraries) \
$(all_shared_libraries) \
$(all_static_libraries) \
$(all_whole_static_libraries) \
$(all_external_libraries) \
###############################################################################
## Resource list management.
## Import of dependencies.
###############################################################################
LOCAL_RESLIST := $(strip $(LOCAL_RESLIST))
# Get all modules we depend on
all_depends := $(call module-get-all-dependencies,$(LOCAL_MODULE))
all_depends := $(filter-out $(LOCAL_MODULE),$(all_depends))
ifneq ("$(LOCAL_RESLIST)","")
# Get list of exported stuff by our dependencies
imported_CFLAGS := $(call module-get-listed-export,$(all_depends),CFLAGS)
imported_CPPFLAGS := $(call module-get-listed-export,$(all_depends),CPPFLAGS)
imported_C_INCLUDES := $(call module-get-listed-export,$(all_depends),C_INCLUDES)
imported_LDLIBS := $(call module-get-listed-export,$(all_depends),LDLIBS)
imported_PREREQUISITES := $(call module-get-listed-export,$(all_depends),PREREQUISITES)
# This makes sure resource list is created before compilation (order prerequisite)
$(all_objects): | $(intermediates)/ResList
# The imported/exported compiler flags are prepended to their LOCAL_XXXX value
# (this allows the module to override them).
LOCAL_CFLAGS := $(strip $(imported_CFLAGS) $(LOCAL_EXPORT_CFLAGS) $(LOCAL_CFLAGS))
LOCAL_CPPFLAGS := $(strip $(imported_CPPFLAGS) $(LOCAL_EXPORT_CPPFLAGS) $(LOCAL_CPPFLAGS))
# Additional dependencies
$(intermediates)/ResList.h: $(intermediates)/ResList
$(intermediates)/ResList.c: $(intermediates)/ResList
$(intermediates)/ResList: $(TOP_DIR)/$(LOCAL_PATH)/$(LOCAL_XRC)
# The imported/exported include directories are appended to their LOCAL_XXX value
# (this allows the module to override them)
LOCAL_C_INCLUDES := $(sort $(strip $(subst -I-I,-I,$(addprefix -I,$(LOCAL_C_INCLUDES) $(LOCAL_EXPORT_C_INCLUDES) $(imported_C_INCLUDES)))))
#$(info LOCAL_C_INCLUDES=$(LOCAL_C_INCLUDES))
#$(info -----)
reslist := $(TOP_DIR)/$(LOCAL_PATH)/$(LOCAL_RESLIST)
reslistsrc := $(shell dirname $(reslist))
reslistdst := $(intermediates)
reslistmaker := $(reslistdst)/ResListMaker/ResListMaker$(TARGET_EXE_SUFFIX)
# Similarly, you want the imported/exported flags to appear _after_ the LOCAL_LDLIBS
# due to the way Unix linkers work (depending libraries must appear before
# dependees on final link command).
LOCAL_LDLIBS := $(strip $(LOCAL_LDLIBS) $(LOCAL_EXPORT_LDLIBS) $(imported_LDLIBS))
# Generate resource list
$(intermediates)/ResList: $(reslist) $(reslistmaker)
$(call transform-reslist, $(reslistmaker), $(reslistsrc), $(reslistdst))
# Get all autoconf files that we depend on, don't forget to add ourself
all_autoconf := \
$(call module-get-listed-autoconf,$(all_depends)) \
$(call module-get-autoconf,$(LOCAL_MODULE))
# Generate resource list maker
$(reslistmaker): $(reslistsrc)/ResListMaker.c
$(call generate-reslistmaker, $(reslistsrc), $(dir $(reslistmaker)))
# Force their inclusion (space after -include and before comma is important)
LOCAL_CFLAGS += $(addprefix -include ,$(all_autoconf))
endif
# List of all prerequisites (ours + dependencies)
all_prerequisites := \
$(LOCAL_PREREQUISITES) \
$(LOCAL_EXPORT_PREREQUISITES) \
$(imported_PREREQUISITES)
# All autoconf files are prerequisites
all_prerequisites += $(all_autoconf)
# User makefile is also a prerequisite
all_prerequisites += $(LOCAL_PATH)/$(USER_MAKEFILE_NAME)
# Notify that we build with dependencies
LOCAL_CFLAGS += $(foreach __mod,$(all_depends), \
-DBUILD_$(call get-define,$(__mod)))
###############################################################################
## Actual rules.
###############################################################################
# Final copy (not for static libraries)
$(LOCAL_FINAL_MODULE): $(LOCAL_BUILT_MODULE)
ifeq ("$(LOCAL_BUILDING_STATIC_LIBRARY)","")
@echo "Copy: $@"
$(copy-file-to-target)
endif
# cpp files
ifneq ("$(strip $(cpp_objects))","")
$(cpp_objects): $(intermediates)/%.o: $(LOCAL_PATH)/%.cpp
$(cpp_objects): $(build_dir)/%.o: $(LOCAL_PATH)/%.cpp
$(transform-cpp-to-o)
-include $(cpp_objects:%.o=%.d)
endif
# cxx files
ifneq ("$(strip $(cxx_objects))","")
$(cxx_objects): $(intermediates)/%.o: $(LOCAL_PATH)/%.cxx
$(cxx_objects): $(build_dir)/%.o: $(LOCAL_PATH)/%.cxx
$(transform-cpp-to-o)
-include $(cxx_objects:%.o=%.d)
endif
# c files
ifneq ("$(strip $(c_objects))","")
$(c_objects): $(intermediates)/%.o: $(LOCAL_PATH)/%.c
$(c_objects): $(build_dir)/%.o: $(LOCAL_PATH)/%.c
$(transform-c-to-o)
-include $(c_objects:%.o=%.d)
endif
# rc files
ifneq ("$(strip $(rc_objects))","")
$(rc_objects): $(addprefix $(LOCAL_PATH)/,$(LOCAL_RC_DEPS))
$(rc_objects): $(intermediates)/%.rc.o: $(TOP_DIR)/$(LOCAL_PATH)/%.rc
$(transform-rc-to-o)
# s files
# There is NO dependency files for raw asm code...
ifneq ("$(strip $(s_objects))","")
$(s_objects): $(build_dir)/%.o: $(LOCAL_PATH)/%.s
$(transform-s-to-o)
endif
# copy files verbatim to target (flat copy in output directory)
copy_files :=
$(foreach f,$(LOCAL_COPY_FILES), \
$(eval _src := $(TOP_DIR)/$(LOCAL_PATH)/$(f)) \
$(eval _dst := $(TARGET_OUT)/$(notdir $(f))) \
$(eval copy_files += $(_dst)) \
$(eval $(call copy-one-file,$(_src),$(_dst))) \
)
$(LOCAL_BUILT_MODULE): $(copy_files)
# S files
# There are dependency files for asm code...
ifneq ("$(strip $(S_objects))","")
$(S_objects): $(build_dir)/%.o: $(LOCAL_PATH)/%.S
$(transform-s-to-o)
-include $(S_objects:%.o=%.d)
endif
# clean- targets
cleantarget := clean-$(LOCAL_MODULE)
$(cleantarget) : PRIVATE_MODULE := $(LOCAL_MODULE)
$(cleantarget) : PRIVATE_CLEAN_FILES := \
$(PRIVATE_CLEAN_FILES) \
$(LOCAL_BUILT_MODULE) \
$(LOCAL_FINAL_MODULE) \
$(copy_files) \
$(intermediates)
$(LOCAL_BUILD_MODULE) \
$(LOCAL_STAGING_MODULE) \
$(build_dir)
$(cleantarget)::
@echo "Clean: $(PRIVATE_MODULE)"
$(Q)rm -rf $(PRIVATE_CLEAN_FILES)
# install- targets
installtarget := install-$(LOCAL_MODULE)
$(installtarget) : PRIVATE_MODULE := $(LOCAL_MODULE)
$(installtarget) : PRIVATE_FINAL_MODULE := $(LOCAL_FINAL_MODULE)
$(installtarget) : PRIVATE_COPY_FILES := $(copy_files)
$(installtarget) ::
@echo "Install: $(PRIVATE_MODULE)"
# create directories
$(Q)install -d $(DESTDIR)$(PREFIX)/bin
$(Q)install -d $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)
# install executables and shared libraries in lib/<package> directory
ifeq ("$(LOCAL_BUILDING_STATIC_LIBRARY)","")
$(Q)install $(PRIVATE_FINAL_MODULE) $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)
endif
# install files copied verbatim
ifneq ("$(strip $(copy_files))","")
$(Q)install $(PRIVATE_COPY_FILES) $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)
endif
# create a link for executables in bin
ifeq ("$(LOCAL_BUILDING_EXECUTABLE)","1")
$(Q)ln -s ../lib/$(PACKAGE)/$(PRIVATE_MODULE) $(DESTDIR)$(PREFIX)/bin/$(PRIVATE_MODULE)
endif
## Provide a short-hand for building this module.
.PHONY: $(LOCAL_MODULE)
$(LOCAL_MODULE): $(LOCAL_BUILT_MODULE) $(LOCAL_FINAL_MODULE)
$(LOCAL_MODULE): $(LOCAL_BUILD_MODULE) $(LOCAL_STAGING_MODULE)
# Make sure external libraries are built first
# Do NOT force rebuild at each check (order prerequisite)
# TODO : check why order prerequisite
#$(all_objects): | $(external_libraries)
# Make sure all prerequisites files are generated first
ifneq ("$(all_prerequisites)","")
$(all_objects): $(all_prerequisites)
endif
###############################################################################
## autoconf.h file generation.
###############################################################################
autoconf_file := $(call module-get-autoconf,$(LOCAL_MODULE))
ifneq ("$(autoconf_file)","")
# autoconf.h file depends on module config
$(autoconf_file): $(call __get_module-config,$(LOCAL_MODULE))
@$(call generate-autoconf-file,$<,$@)
endif
###############################################################################
## Precompiled headers.
@ -202,31 +265,43 @@ $(LOCAL_MODULE): $(LOCAL_BUILT_MODULE) $(LOCAL_FINAL_MODULE)
LOCAL_PRECOMPILED_FILE := $(strip $(LOCAL_PRECOMPILED_FILE))
ifneq ("$(LOCAL_PRECOMPILED_FILE)","")
gch_file := $(intermediates)/$(LOCAL_PRECOMPILED_FILE).gch
gch_file := $(build_dir)/$(LOCAL_PRECOMPILED_FILE).gch
# All objects will depends on the precompiled file
$(all_objects): $(gch_file)
# Make sure all prerequisites files are generated first
ifneq ("$(all_prerequisites)","")
$(gch_file): $(all_prerequisites)
endif
# Generate the precompiled file
$(gch_file): $(TOP_DIR)/$(LOCAL_PATH)/$(LOCAL_PRECOMPILED_FILE)
$(gch_file): $(LOCAL_PATH)/$(LOCAL_PRECOMPILED_FILE)
$(transform-h-to-gch)
-include $(gch_file:%.gch=%.d)
# Make sure external libraries are built first (order prerequisite)
# TODO : check why order prerequisite
#$(gch_file): | $(external_libraries)
endif
###############################################################################
# Rule-specific variable definitions.
###############################################################################
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PATH := $(LOCAL_PATH)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MODULE := $(LOCAL_MODULE)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RCFLAGS := $(LOCAL_RCFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(LOCAL_ARFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
$(LOCAL_TARGETS): PRIVATE_PATH := $(LOCAL_PATH)
$(LOCAL_TARGETS): PRIVATE_MODULE := $(LOCAL_MODULE)
$(LOCAL_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS)
$(LOCAL_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
$(LOCAL_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS)
$(LOCAL_TARGETS): PRIVATE_ARFLAGS := $(LOCAL_ARFLAGS)
$(LOCAL_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS)
$(LOCAL_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
$(LOCAL_TARGETS): PRIVATE_ARM_MODE := $(LOCAL_ARM_MODE)
$(LOCAL_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(all_shared_libraries)
$(LOCAL_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(all_static_libraries)
$(LOCAL_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(all_whole_static_libraries)
$(LOCAL_TARGETS): PRIVATE_ALL_EXTERNAL_LIBRARIES := $(all_external_libraries)
$(LOCAL_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)

115
Build/coreLinux/setup.mk Normal file
View File

@ -0,0 +1,115 @@
###############################################################################
## @file config.mk
## @author Y.M. Morgan
## @date 2011/05/14
###############################################################################
###############################################################################
## Make sure that there are no spaces in the absolute path; the build system
## can't deal with them.
###############################################################################
ifneq ("$(words $(shell pwd))","1")
$(error Top directory contains space characters)
endif
###############################################################################
## Host/Target OS.
###############################################################################
# Host OS
ifneq ("$(shell echo $$OSTYPE | grep msys)","")
HOST_OS := MINGW32
HOST_EXE_SUFFIX := .exe
HOST_SHARED_LIB_SUFFIX := .dll
else
HOST_OS := LINUX
HOST_EXE_SUFFIX :=
HOST_SHARED_LIB_SUFFIX := .so
endif
# Target OS : default to HOST_OS unless set
ifndef TARGET_OS
TARGET_OS := $(HOST_OS)
endif
# Exe/dll suffix under mingw
TARGET_STATIC_LIB_SUFFIX := .a
ifeq ("$(TARGET_OS)","MINGW32")
DIR_SUFFIX := _mingw32
TARGET_EXE_SUFFIX := .exe
TARGET_SHARED_LIB_SUFFIX := .dll
else
DIR_SUFFIX :=
TARGET_EXE_SUFFIX :=
TARGET_SHARED_LIB_SUFFIX := .so
endif
ifeq ("$(TARGET_OS)","MINGW32")
# may be overridden in make command line
STATIC := 1
TARGET_GLOBAL_CFLAGS += -D__MINGW_FEATURES__=0
TARGET_GLOBAL_LDFLAGS += -Wl,--enable-auto-import
ifeq ("$(STATIC)","1")
TARGET_GLOBAL_LDFLAGS += -Wl,-Bstatic
endif
endif
# To be able to use ccache with pre-complied headers, some env variables are required
CCACHE :=
ifeq ("$(USE_CCACHE)","1")
ifneq ("$(shell which ccache)","")
CCACHE := CCACHE_SLOPPINESS=time_macros ccache
TARGET_GLOBAL_CFLAGS += -fpch-preprocess
endif
endif
# Pre-compiled header generation flag
ifneq ("$(USE_CLANG)","1")
TARGET_PCH_FLAGS := -c
else
TARGET_PCH_FLAGS := -x c++-header
endif
# Architecture
#ifndef TARGET_ARCH
# ifneq ("$(shell $(GCC) -dumpmachine | grep 64)","")
# TARGET_ARCH := AMD64
# else
# TARGET_ARCH := X86
# endif
#endif
# Update flags based on architecture
# 64-bit requires -fPIC to build shared libraries
#ifeq ("$(TARGET_ARCH)","AMD64")
# TARGET_GLOBAL_CFLAGS += -m64 -fPIC
#else
# TARGET_GLOBAL_CFLAGS += -m32
#endif
###############################################################################
## Variables based on DEBUG/STATIC.
###############################################################################
#ifeq ("$(DEBUG)","0")
# TARGET_GLOBAL_CFLAGS += -O2 -g -DNDEBUG
# TARGET_OUT_INTERMEDIATES := $(TOP_DIR)/build_gcc$(DIR_SUFFIX)/release
# TARGET_OUT := $(TOP_DIR)/out_gcc$(DIR_SUFFIX)/release
#else
# TARGET_GLOBAL_CFLAGS += -O0 -g -DDEBUG -D_DEBUG
# TARGET_OUT_INTERMEDIATES := $(TOP_DIR)/build_gcc$(DIR_SUFFIX)/debug
# TARGET_OUT := $(TOP_DIR)/out_gcc$(DIR_SUFFIX)/debug
#endif
###############################################################################
## Determine gcc path and version.
###############################################################################
GCC_PATH := $(shell which $(GCC))
ifneq ("$(USE_CLANG)","1")
GCC_VERSION := $(shell $(GCC) --version | head -1 | sed "s/.*\([0-9]\.[0-9]\.[0-9]\).*/\1/")
else
GCC_VERSION := 0.0.0
endif

View File

@ -6,17 +6,11 @@
## Build a shared library.
###############################################################################
LOCAL_MODULE_SUFFIX := $(TARGET_SHARED_LIB_SUFFIX)
LOCAL_BUILDING_SHARED_LIBRARY := 1
LOCAL_MODULE_CLASS := SHARED_LIBRARY
LOCAL_DESTDIR := usr/lib
include $(RULES)
# Generate .dll.a file under mingw32
ifeq ("$(OS_MINGW32)","1")
$(LOCAL_BUILT_MODULE)$(TARGET_STATIC_LIB_SUFFIX): $(LOCAL_BUILT_MODULE)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS += \
-Wl,--out-implib -Wl,$(LOCAL_BUILT_MODULE)$(TARGET_STATIC_LIB_SUFFIX)
ifndef LOCAL_MODULE_FILENAME
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_SHARED_LIB_SUFFIX)
endif
$(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries)
$(transform-o-to-shared-lib)
$(call module-add,$(LOCAL_MODULE))

View File

@ -6,14 +6,11 @@
## Build a static library.
###############################################################################
LOCAL_MODULE_SUFFIX := $(TARGET_STATIC_LIB_SUFFIX)
LOCAL_BUILDING_STATIC_LIBRARY := 1
LOCAL_MODULE_CLASS := STATIC_LIBRARY
LOCAL_DESTDIR := usr/lib
include $(RULES)
ifndef LOCAL_MODULE_FILENAME
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_STATIC_LIB_SUFFIX)
endif
#$(info plopppppp=$(LOCAL_BUILT_MODULE)= $(all_libraries))
$(LOCAL_BUILT_MODULE): $(all_libraries) $(all_objects)
$(transform-o-to-static-lib)
LIB_EXTERN_C_INCLUDE := $(LIB_EXTERN_C_INCLUDE) $(LOCAL_EXPORT_C_INCLUDES)
LIB_EXTERN_LDLIBS := $(LIB_EXTERN_LDLIBS) $(LOCAL_EXPORT_LDLIBS)
$(call module-add,$(LOCAL_MODULE))

View File

@ -0,0 +1,68 @@
###############################################################################
## @file warnings.mk
## @author Y.M. Morgan
## @date 2012/06/09
##
## Setup warning flags.
###############################################################################
COMMON_FLAGS_WARNINGS :=
GCC_FLAGS_WARNINGS :=
GXX_FLAGS_WARNINGS :=
# show option associated with warning (gcc >= 4.0.0)
ifneq (0,$(shell expr $(GCC_VERSION) \>= 4.0.0))
COMMON_FLAGS_WARNINGS += -fdiagnostics-show-option
endif
COMMON_FLAGS_WARNINGS += -Wall
#COMMON_FLAGS_WARNINGS += -Wextra
COMMON_FLAGS_WARNINGS += -Wno-unused -Wno-unused-parameter -Wunused-value -Wunused-variable -Wunused-label
#COMMON_FLAGS_WARNINGS += -Wshadow
#COMMON_FLAGS_WARNINGS += -Wswitch-default
#COMMON_FLAGS_WARNINGS += -Wwrite-strings
#COMMON_FLAGS_WARNINGS += -Wundef
#COMMON_FLAGS_WARNINGS += -Wpointer-arith
#COMMON_FLAGS_WARNINGS += -Wformat-nonliteral
#COMMON_FLAGS_WARNINGS += -Wformat-security
#COMMON_FLAGS_WARNINGS += -Winit-self
# C specific
#GCC_FLAGS_WARNINGS += -Wmissing-declarations
#GCC_FLAGS_WARNINGS += -Wmissing-prototypes
#GCC_FLAGS_WARNINGS += -Wjump-misses-init
# c++ specific
#GXX_FLAGS_WARNINGS += -Wctor-dtor-privacy
#GXX_FLAGS_WARNINGS += -Wnon-virtual-dtor
#GXX_FLAGS_WARNINGS += -Wreorder
#GXX_FLAGS_WARNINGS += -Woverloaded-virtual
# gcc >= 4.5.0 (too many false positives with previous versions)
ifneq (0,$(shell expr $(GCC_VERSION) \>= 4.5.0))
#COMMON_FLAGS_WARNINGS += -Wunreachable-code
endif
# gcc >= 4.5.2
ifneq (0,$(shell expr $(GCC_VERSION) \>= 4.5.2))
#COMMON_FLAGS_WARNINGS += -Wlogical-op
endif
# Extra warnings
ifeq ("$(W)","1")
COMMON_FLAGS_WARNINGS += -Wconversion
COMMON_FLAGS_WARNINGS += -Wswitch-enum
COMMON_FLAGS_WARNINGS += -Wcast-qual
# gcc >= 4.4.0
ifneq (0,$(shell expr $(GCC_VERSION) \>= 4.4.0))
COMMON_FLAGS_WARNINGS += -Wframe-larger-than=1024
endif
endif
# Add common flags to specific flags
GCC_FLAGS_WARNINGS += $(COMMON_FLAGS_WARNINGS)
GXX_FLAGS_WARNINGS += $(COMMON_FLAGS_WARNINGS)

View File

@ -8,9 +8,9 @@ LOCAL_MODULE := agg
# name of the dependency
LOCAL_STATIC_LIBRARIES := libfreetype
LOCAL_C_INCLUDES := -I$(LOCAL_PATH) \
-I$(LOCAL_PATH)/agg-2.4/ \
-I$(LOCAL_PATH)/agg-2.4/util/
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/agg-2.4/ \
$(LOCAL_PATH)/agg-2.4/util/
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

View File

@ -5,8 +5,6 @@ include $(CLEAR_VARS)
LOCAL_MODULE := etk
LOCAL_STATIC_LIBRARIES := libzip
LOCAL_C_INCLUDES := -I$(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS :=

View File

@ -13,7 +13,7 @@ $(info $(LOCAL_MODULE) version TAG : $(LOCAL_VERSION_TAG))
# name of the dependency
LOCAL_STATIC_LIBRARIES := etk libfreetype tinyxml libzip libpng agg parsersvg lua portaudio
LOCAL_C_INCLUDES := -I$(LOCAL_PATH)
LOCAL_C_INCLUDES :=
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lGL -lGLU -lz -lX11

View File

@ -92,11 +92,10 @@ namespace ewol {
const char * const GetObjectType(void);
public:
// extern API :
void SetFolder(etk::UString newFolder);
etk::UString GetFolder(void);
// select the specific file
void SetSelect( etk::UString data);
void SetSelect(etk::UString data);
etk::UString GetSelect(void);
// regenerate the view ....
void RegenerateView(void);

View File

@ -8,7 +8,7 @@ include $(LOCAL_PATH)/file.mk
LOCAL_MODULE := libfreetype
LOCAL_STATIC_LIBRARIES :=
LOCAL_C_INCLUDES := -I$(LOCAL_PATH) $(addprefix -I$(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

View File

@ -8,7 +8,7 @@ LOCAL_MODULE := lua
# name of the dependency
LOCAL_STATIC_LIBRARIES := etk
LOCAL_C_INCLUDES := -I$(LOCAL_PATH) -I$(LOCAL_PATH)/lua/
LOCAL_C_INCLUDES := $(LOCAL_PATH)/lua/
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

View File

@ -7,9 +7,8 @@ LOCAL_MODULE := ogg
LOCAL_STATIC_LIBRARIES := etk
LOCAL_C_INCLUDES := -I$(LOCAL_PATH) \
-I$(LOCAL_PATH)/tremor/ \
-I$(LOCAL_PATH)/ogg/
LOCAL_C_INCLUDES := $(LOCAL_PATH)/tremor/ \
$(LOCAL_PATH)/ogg/
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

View File

@ -8,7 +8,7 @@ LOCAL_MODULE := parsersvg
# name of the dependency
LOCAL_STATIC_LIBRARIES := etk agg tinyxml
LOCAL_C_INCLUDES := -I$(LOCAL_PATH)
LOCAL_C_INCLUDES :=
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

View File

@ -20,8 +20,6 @@ LOCAL_CFLAGS := -DPNG_NO_LIMITS_H
LOCAL_MODULE := libpng
LOCAL_C_INCLUDES := -I$(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
# load the common sources file of the platform

View File

@ -8,10 +8,9 @@ LOCAL_MODULE := portaudio
# name of the dependency
LOCAL_STATIC_LIBRARIES :=
LOCAL_C_INCLUDES := -I$(LOCAL_PATH) \
-I$(LOCAL_PATH)/portaudio/ \
-I$(LOCAL_PATH)/portaudio/common \
-I$(LOCAL_PATH)/portaudio/os/unix
LOCAL_C_INCLUDES := $(LOCAL_PATH)/portaudio/ \
$(LOCAL_PATH)/portaudio/common \
$(LOCAL_PATH)/portaudio/os/unix
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lasound

View File

@ -5,7 +5,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := tinyxml
LOCAL_STATIC_LIBRARIES :=
LOCAL_C_INCLUDES := -I$(LOCAL_PATH)/
LOCAL_C_INCLUDES :=
LOCAL_CFLAGS :=

View File

@ -18,7 +18,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libzip
LOCAL_C_INCLUDES := -I$(LOCAL_PATH)
LOCAL_C_INCLUDES :=
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)