set a better makefile and check dependency

This commit is contained in:
Edouard Dupin 2012-08-17 18:30:11 +02:00
parent 29ab385f1a
commit 5db14dcf47
13 changed files with 437 additions and 168 deletions

View File

@ -5,7 +5,7 @@ PROJECT_PACKAGE=$(PROJECT_NAME)package
USER_PACKAGES += $(EWOL_FOLDER)/Sources/ USER_PACKAGES += $(EWOL_FOLDER)/Sources/
TARGET_OS = Android TARGET_OS = Android
TARGET_ARCH = ARM TARGET_ARCH = ARM
CROSS = $(PROJECT_NDK)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- TARGET_CROSS = $(PROJECT_NDK)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
#Add the basic element abstraction of ewol lib #Add the basic element abstraction of ewol lib

View File

@ -4,6 +4,6 @@ USER_PACKAGES += $(EWOL_FOLDER)/Sources/
# defien the target OS of this system # defien the target OS of this system
TARGET_OS=Windows TARGET_OS=Windows
# define the cross compilateur # define the cross compilateur
CROSS=i586-mingw32msvc- TARGET_CROSS=i586-mingw32msvc-
include $(EWOL_FOLDER)/Build/core/main.mk include $(EWOL_FOLDER)/Build/core/main.mk

View File

@ -11,10 +11,11 @@ CONF := KCONFIG_NOTIMESTAMP=1 $(call fullpath,$(BUILD_SYSTEM)/conf)
QCONF := KCONFIG_NOTIMESTAMP=1 $(call fullpath,$(BUILD_SYSTEM)/qconf) QCONF := KCONFIG_NOTIMESTAMP=1 $(call fullpath,$(BUILD_SYSTEM)/qconf)
# Directory where original configurations are stored # Directory where original configurations are stored
CONFIG_ORIG_DIR := $(TOP_DIR)/config-ymm CONFIG_ORIG_DIR := $(TARGET_CONFIG_DIR)
# File where global configuration is stored # File where global configuration is stored
CONFIG_GLOBAL_FILE := $(CONFIG_ORIG_DIR)/global.config CONFIG_GLOBAL_FILE := $(CONFIG_ORIG_DIR)/global.config
-include $(CONFIG_GLOBAL_FILE)
############################################################################### ###############################################################################
## Begin conf/qconf by copying configuration file to a temp .config file. ## Begin conf/qconf by copying configuration file to a temp .config file.

View File

@ -12,6 +12,12 @@
empty := empty :=
space := $(empty) $(empty) space := $(empty) $(empty)
space4 := $(space)$(space)$(space)$(space) space4 := $(space)$(space)$(space)$(space)
true := T
false :=
# Return negation of argument.
# $1 : input boolean argument.
not = $(if $1,$(false),$(true))
# Return the first element of a list. # Return the first element of a list.
# $ 1 : input list. # $ 1 : input list.
@ -52,6 +58,16 @@ check-pwd-is-top-dir = \
$(if $(patsubst $(TOP_DIR)%,%,$(shell pwd)), \ $(if $(patsubst $(TOP_DIR)%,%,$(shell pwd)), \
$(error Not at the top directory)) $(error Not at the top directory))
# Compare 2 strings for equality.
# $1 : first string.
# $2 : second string.
streq = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),$(false),$(true))
# Compare 2 strings for inequality.
# $1 : first string.
# $2 : second string.
strneq = $(call not,$(call streq,$1,$2))
############################################################################### ###############################################################################
## Modules database. ## Modules database.
## For each module 'mod', __modules.mod.<field> is used to store ## For each module 'mod', __modules.mod.<field> is used to store
@ -99,8 +115,11 @@ modules-LOCALS += SHARED_LIBRARIES
# Used as dependencies to trigger indirect build. # Used as dependencies to trigger indirect build.
modules-LOCALS += EXTERNAL_LIBRARIES modules-LOCALS += EXTERNAL_LIBRARIES
# General libraries to add in dependency based on their actual class (STATIC/SHARED/EXTERNAL).
modules-LOCALS += LIBRARIES
# Additional include directories to pass into the C/C++ compilers # Additional include directories to pass into the C/C++ compilers
# Format : <fullpath> # Format : <fullpath> (-I will be prepended automatically)
modules-LOCALS += C_INCLUDES modules-LOCALS += C_INCLUDES
# Additional flags to pass into the C or C++ compiler # Additional flags to pass into the C or C++ compiler
@ -143,6 +162,12 @@ modules-LOCALS += EXPORT_PREREQUISITES
# Module class : STATIC_LIBRARY SHARED_LIBRARY EXECUTABLE # Module class : STATIC_LIBRARY SHARED_LIBRARY EXECUTABLE
modules-LOCALS += MODULE_CLASS modules-LOCALS += MODULE_CLASS
# List of files to copy
# Format <src>:<dst>
# src : source (relative to module path)
# dst : destination (relative to staging dir)
modules-LOCALS += COPY_FILES
# Other variables used internally # Other variables used internally
modules-LOCALS += BUILD_MODULE modules-LOCALS += BUILD_MODULE
modules-LOCALS += STAGING_MODULE modules-LOCALS += STAGING_MODULE
@ -176,17 +201,48 @@ modules-dump-database = \
) \ ) \
$(info --- end of modules list) $(info --- end of modules list)
# This will only dump dependencies
modules-dump-database-depends = \
$(foreach __mod,$(__modules), \
$(info $(__mod):) \
$(info $(space4)$(strip $(__modules.$(__mod).depends))) \
)
############################################################################### ###############################################################################
## Add a module in the build system and save its LOCAL_xxx variables. ## 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 ## All LOCAL_xxx variables will be saved in module database.
## module database.
############################################################################### ###############################################################################
module-add = \ module-add = \
$(eval __modules += $1) \ $(eval LOCAL_MODULE := $(strip $(LOCAL_MODULE))) \
$(if $(LOCAL_MODULE),$(empty), \
$(error $(LOCAL_PATH): LOCAL_MODULE is not defined)) \
$(eval __mod := $(LOCAL_MODULE)) \
$(if $(call is-module-registered,$(__mod)), \
$(eval __path := $(__modules.$(__mod).PATH)) \
$(error $(LOCAL_PATH): module '$(__mod)' already registered at $(__path)) \
) \
$(eval __modules += $(__mod)) \
$(foreach __local,$(modules-LOCALS), \ $(foreach __local,$(modules-LOCALS), \
$(eval __modules.$1.$(__local) := $(LOCAL_$(__local))) \ $(eval __modules.$(__mod).$(__local) := $(LOCAL_$(__local))) \
) )
###############################################################################
## Check that a module is registered.
## $1 : module to check.
###############################################################################
is-module-registered = \
$(strip $(foreach __mod,$(__modules), \
$(if $(call streq,$(__mod),$1),$(true)) \
))
###############################################################################
## Check that a module wil be built.
## $1 : module to check.
###############################################################################
is-module-in-build-config = \
$(if $(CONFIG_BUILD_$(call get-define,$1)),$(true))
############################################################################### ###############################################################################
## Restore the recorded LOCAL_XXX definitions for a given module. Called ## Restore the recorded LOCAL_XXX definitions for a given module. Called
## for each module once they have all been registered and their dependencies ## for each module once they have all been registered and their dependencies
@ -199,17 +255,117 @@ module-restore-locals = \
) )
############################################################################### ###############################################################################
## Used to recompute all dependencies once all module information has been ## Used to check all dependencies once all module information has been
## recorded.
###############################################################################
# Check dependencies of all modules
modules-check-depends = \
$(foreach __mod,$(__modules), \
$(call __module-check-depends,$(__mod)) \
)
# Check dependency of a module
# $1 : module name.
__module-check-depends = \
$(foreach __lib,$(__modules.$1.depends), \
$(if $(call is-module-registered,$(__lib)),$(empty), \
$(eval __path := $(__modules.$1.PATH)) \
$(if $(call is-module-in-build-config,$1), \
$(error $(__path): module '$1' depends on unknown module '$(__lib)'), \
$(warning $(__path): module '$1' depends on unknown module '$(__lib)') \
) \
) \
) \
$(call __module-check-libs-class,$1,WHOLE_STATIC_LIBRARIES,STATIC_LIBRARY) \
$(call __module-check-libs-class,$1,STATIC_LIBRARIES,STATIC_LIBRARY) \
$(call __module-check-libs-class,$1,SHARED_LIBRARIES,SHARED_LIBRARY) \
# $1 : module name of owner.
# $2 : dependency to check (WHOLE_STATIC_LIBRARIES,STATIC_LIBRARIES,SHARED_LIBRARIES).
# $3 : class to check (STATIC_LIBRARY,SHARED_LIBRARY)
__module-check-libs-class = \
$(foreach __lib,$(__modules.$1.$2), \
$(call __module-check-lib-class,$1,$(__lib),$3) \
)
# Check that a dependency is of the correct class
# $1 : module name of owner.
# $2 : library to check.
# $3 : class to check (STATIC_LIBRARY,SHARED_LIBRARY)
__module-check-lib-class = \
$(if $(call strneq,$(__modules.$2.MODULE_CLASS),$3), \
$(eval __path := $(__modules.$1.PATH)) \
$(if $(call is-module-in-build-config,$1), \
$(error $(__path): module '$1' depends on module '$2' which is not of class '$3'), \
$(warning $(__path): module '$1' depends on module '$2' which is not of class '$3') \
) \
)
###############################################################################
## Used to make some internal checks.
###############################################################################
# Check variables of all modules
modules-check-variables = \
$(foreach __mod,$(__modules), \
$(call __module-check-variables,$(__mod)) \
)
# Check variables of a module
# $1 : module name.
__module-check-variables = \
$(call __module-check-src-files,$1) \
$(call __module-check-c-includes,$1)
# Check that all files listed in LOCAL_SRC_FILES exist
# $1 : module name.
__module-check-src-files = \
$(eval __path := $(__modules.$1.PATH)) \
$(foreach __file,$(__modules.$1.SRC_FILES), \
$(if $(wildcard $(__path)/$(__file)),$(empty), \
$(warning $(__path): module '$1' uses missing source file '$(__file)') \
) \
)
# Check that all directory listed in LOCAL_C_INCLUDES exist
__module-check-c-includes = \
$(eval __path := $(__modules.$1.PATH)) \
$(foreach __inc,$(__modules.$1.C_INCLUDES), \
$(eval __inc2 := $(patsubst -I%,%,$(__inc))) \
$(if $(wildcard $(__inc2)),$(empty), \
$(warning $(__path): module '$1' uses missing include '$(__inc2)') \
) \
)
###############################################################################
## Used to compute all dependencies once all module information has been
## recorded. ## recorded.
############################################################################### ###############################################################################
# Compute dependencies of all modules # Compute dependencies of all modules
modules-compute-dependencies = \ modules-compute-depends = \
$(foreach __mod,$(__modules), \ $(foreach __mod,$(__modules), \
$(eval __modules.$(__mod).depends := ) \ $(eval __modules.$(__mod).depends := $(empty)) \
$(call __module-update-depends,$(__mod)) \
$(call __module-compute-depends,$(__mod)) \ $(call __module-compute-depends,$(__mod)) \
) )
# Update dependecies of a single module.
# It updates XXX_LIBRARIES based on LIBRARIES and actual dependency class.
# $1 : module name.
__module-update-depends = \
$(foreach __lib,$(__modules.$1.LIBRARIES), \
$(eval __class := $(__modules.$(__lib).MODULE_CLASS)) \
$(if $(call streq,$(__class),STATIC_LIBRARY), \
$(eval __modules.$1.STATIC_LIBRARIES += $(__lib)), \
$(if $(call streq,$(__class),SHARED_LIBRARY), \
$(eval __modules.$1.SHARED_LIBRARIES += $(__lib)), \
$(eval __modules.$1.EXTERNAL_LIBRARIES += $(__lib)) \
) \
) \
)
# Compute dependencies of a single module # Compute dependencies of a single module
# $1 : module name. # $1 : module name.
__module-compute-depends = \ __module-compute-depends = \
@ -254,7 +410,7 @@ module-get-listed-autoconf = \
)) ))
############################################################################### ###############################################################################
## Dependecy management ## Dependency management
############################################################################### ###############################################################################
# Return list all the <local-type> modules $1 depends on transitively. # Return list all the <local-type> modules $1 depends on transitively.
@ -269,12 +425,11 @@ module-get-all-dependencies = \
# Recursively get dependency of a modules # Recursively get dependency of a modules
__modules-get-closure = \ __modules-get-closure = \
$(eval __closure_deps := $(strip $1)) \ $(eval __closure_deps := $(empty)) \
$(if $(__closure_deps), \ $(eval __closure_wq := $(strip $1)) \
$(eval __closure_wq := $(__closure_deps)) \
$(eval __closure_field := $(strip $2)) \ $(eval __closure_field := $(strip $2)) \
$(call __modules-closure)) \ $(if $(__closure_wq), $(call __modules-closure)) \
$(__closure_deps) \ $(strip $(__closure_deps))
# Used internally by modules-get-all-dependencies. Note the tricky use of # 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 # conditional recursion to work around the fact that the GNU Make language does
@ -286,7 +441,7 @@ __modules-closure = \
$(eval __closure_new := $(filter-out $(__closure_deps),$(__closure_val))) \ $(eval __closure_new := $(filter-out $(__closure_deps),$(__closure_val))) \
$(eval __closure_deps += $(__closure_new)) \ $(eval __closure_deps += $(__closure_new)) \
$(eval __closure_wq := $(strip $(__closure_wq) $(__closure_new))) \ $(eval __closure_wq := $(strip $(__closure_wq) $(__closure_new))) \
$(if $(__closure_wq),$(call __modules-closure)) \ $(if $(__closure_wq),$(call __modules-closure))
############################################################################### ###############################################################################
## Get path of module main target file (in build or staging directory). ## Get path of module main target file (in build or staging directory).
@ -329,6 +484,15 @@ define generate-autoconf-file
$1 > $2; $1 > $2;
endef endef
###############################################################################
## Normalize a list of includes. It adds -I if needed.
## $1 : list of includes
###############################################################################
normalize-c-includes = \
$(strip $(foreach __inc,$1, \
$(addprefix -I,$(patsubst -I%,%,$(__inc))) \
))
############################################################################### ###############################################################################
## Commands for running gcc to generate a precompiled file. ## Commands for running gcc to generate a precompiled file.
############################################################################### ###############################################################################
@ -337,8 +501,9 @@ define transform-h-to-gch
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@echo "Precompile: $(PRIVATE_MODULE) <== $(call path-from-top,$<)" @echo "Precompile: $(PRIVATE_MODULE) <== $(call path-from-top,$<)"
$(call check-pwd-is-top-dir) $(call check-pwd-is-top-dir)
$(Q)$(CCACHE) $(CXX) \ $(Q)$(CCACHE) $(TARGET_CXX) \
$(TARGET_GLOBAL_C_INCLUDES) $(PRIVATE_C_INCLUDES) \ $(TARGET_GLOBAL_C_INCLUDES) \
$(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(CXX_FLAGS_WARNINGS) \ $(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(CXX_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \ $(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \
$(TARGET_PCH_FLAGS) -MMD -MP -o $@ \ $(TARGET_PCH_FLAGS) -MMD -MP -o $@ \
@ -353,8 +518,9 @@ define transform-cpp-to-o
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@echo "$(DISPLAY_ARM_MODE)C++: $(PRIVATE_MODULE) <== $(call path-from-top,$<)" @echo "$(DISPLAY_ARM_MODE)C++: $(PRIVATE_MODULE) <== $(call path-from-top,$<)"
$(call check-pwd-is-top-dir) $(call check-pwd-is-top-dir)
$(Q)$(CCACHE) $(CXX) \ $(Q)$(CCACHE) $(TARGET_CXX) \
$(TARGET_GLOBAL_C_INCLUDES) $(PRIVATE_C_INCLUDES) \ $(TARGET_GLOBAL_C_INCLUDES) \
$(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \ $(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \
$(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(CXX_FLAGS_WARNINGS) \ $(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(CXX_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \ $(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \
@ -370,8 +536,9 @@ define transform-c-to-o
@echo "$(DISPLAY_ARM_MODE)C: $(PRIVATE_MODULE) <== $(call path-from-top,$<)" @echo "$(DISPLAY_ARM_MODE)C: $(PRIVATE_MODULE) <== $(call path-from-top,$<)"
$(call check-pwd-is-top-dir) $(call check-pwd-is-top-dir)
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(Q)$(CCACHE) $(CC) \ $(Q)$(CCACHE) $(TARGET_CC) \
$(TARGET_GLOBAL_C_INCLUDES) $(PRIVATE_C_INCLUDES) \ $(TARGET_GLOBAL_C_INCLUDES) \
$(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \ $(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \
$(TARGET_GLOBAL_CFLAGS) $(CC_FLAGS_WARNINGS) \ $(TARGET_GLOBAL_CFLAGS) $(CC_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) \ $(PRIVATE_CFLAGS) \
@ -387,8 +554,9 @@ define transform-s-to-o
@ echo "ASM: $(PRIVATE_MODULE) <== $(call path-from-top,$<)" @ echo "ASM: $(PRIVATE_MODULE) <== $(call path-from-top,$<)"
$(call check-pwd-is-top-dir) $(call check-pwd-is-top-dir)
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(Q)$(CCACHE) $(CC) \ $(Q)$(CCACHE) $(TARGET_CC) \
$(TARGET_GLOBAL_C_INCLUDES) $(PRIVATE_C_INCLUDES) \ $(TARGET_GLOBAL_C_INCLUDES) \
$(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \ $(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \
$(TARGET_GLOBAL_CFLAGS) $(CC_FLAGS_WARNINGS) \ $(TARGET_GLOBAL_CFLAGS) $(CC_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) \ $(PRIVATE_CFLAGS) \
@ -407,8 +575,8 @@ define transform-o-to-static-lib
@echo "StaticLib: $(PRIVATE_MODULE) ==> $(call path-from-top,$@)" @echo "StaticLib: $(PRIVATE_MODULE) ==> $(call path-from-top,$@)"
$(call check-pwd-is-top-dir) $(call check-pwd-is-top-dir)
@rm -f $@ @rm -f $@
$(Q)$(AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS) $(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS)
$(Q)$(RANLIB) $@ $(Q)$(TARGET_RANLIB) $@
endef endef
############################################################################### ###############################################################################
@ -419,7 +587,7 @@ define transform-o-to-shared-lib
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@echo "SharedLib: $(PRIVATE_MODULE) ==> $(call path-from-top,$@)" @echo "SharedLib: $(PRIVATE_MODULE) ==> $(call path-from-top,$@)"
$(call check-pwd-is-top-dir) $(call check-pwd-is-top-dir)
$(Q)$(CXX) \ $(Q)$(TARGET_CXX) \
$(TARGET_GLOBAL_LDFLAGS_SHARED) \ $(TARGET_GLOBAL_LDFLAGS_SHARED) \
-Wl,-Map -Wl,$(basename $@).map \ -Wl,-Map -Wl,$(basename $@).map \
-shared \ -shared \
@ -446,7 +614,8 @@ define transform-o-to-executable
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@echo "Executable: $(PRIVATE_MODULE) ==> $(call path-from-top,$@)" @echo "Executable: $(PRIVATE_MODULE) ==> $(call path-from-top,$@)"
$(call check-pwd-is-top-dir) $(call check-pwd-is-top-dir)
$(Q)$(CXX) \ @# TODO : Set LD ...
$(Q)$(TARGET_CXX) \
$(TARGET_GLOBAL_LDFLAGS) \ $(TARGET_GLOBAL_LDFLAGS) \
-Wl,-Map -Wl,$(basename $@).map \ -Wl,-Map -Wl,$(basename $@).map \
-Wl,-rpath-link=$(TARGET_OUT_STAGING)/lib \ -Wl,-rpath-link=$(TARGET_OUT_STAGING)/lib \
@ -464,13 +633,19 @@ $(Q)$(CXX) \
$(TARGET_GLOBAL_LDLIBS) $(TARGET_GLOBAL_LDLIBS)
endef endef
# --start-group \
# $(PRIVATE_ALL_STATIC_LIBRARIES) \
# $(PRIVATE_ALL_SHARED_LIBRARIES) \
# --end-group \
# -o $@ \
############################################################################### ###############################################################################
## Commands for copying files. ## Commands for copying files.
############################################################################### ###############################################################################
# Copy a single file from one place to another, preserving permissions and # Copy a single file from one place to another, preserving permissions and
# overwriting any existing file. # overwriting any existing file.
define copy-file-to-target define do-copy-file
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(Q)cp -fp $< $@ $(Q)cp -fp $< $@
endef endef
@ -480,25 +655,8 @@ endef
# $(2) : destination file # $(2) : destination file
define copy-one-file define copy-one-file
$(2): $(1) $(2): $(1)
@echo "Copy: $$(call path-from-top,$$@)" @echo "Copy: $$(call path-from-top,$$<) => $$(call path-from-top,$$@)"
$$(copy-file-to-target) $$(do-copy-file)
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 endef
############################################################################### ###############################################################################
@ -512,7 +670,5 @@ local-get-path = $(call my-dir)
local-get-build-dir = $(call module-get-build-dir,$(LOCAL_MODULE)) local-get-build-dir = $(call module-get-build-dir,$(LOCAL_MODULE))
# Register module # Register module
local-add-module = \ local-add-module = $(module-add)
$(call module-add,$(LOCAL_MODULE)) \
$(eval $(call def-rules,$(LOCAL_MODULE)))

View File

@ -7,10 +7,13 @@
############################################################################### ###############################################################################
LOCAL_MODULE_CLASS := EXECUTABLE LOCAL_MODULE_CLASS := EXECUTABLE
ifeq ("$(LOCAL_DESTDIR)","")
LOCAL_DESTDIR := usr/bin LOCAL_DESTDIR := usr/bin
endif
ifeq ("$(LOCAL_MODULE_FILENAME)","") ifeq ("$(LOCAL_MODULE_FILENAME)","")
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_EXE_SUFFIX) LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_EXE_SUFFIX)
endif endif
$(call module-add,$(LOCAL_MODULE)) $(local-add-module)

View File

@ -30,44 +30,6 @@ ifeq ("$(V)","0")
Q := @ Q := @
endif endif
# Tools for host
HOST_CC ?= gcc
HOST_CXX ?= g++
HOST_AR ?= ar
HOST_LD ?= ld
HOST_STRIP ?= strip
# Tools for target
ifneq ("$(CLANG)","1")
CC := $(CROSS)gcc
CXX := $(CROSS)g++
else
CC := $(CROSS)clang
CXX := $(CROSS)clang++
endif
AR := $(CROSS)ar
LD := $(CROSS)ld
AS := $(CROSS)as
NM := $(CROSS)nm
STRIP := $(CROSS)strip
RANLIB := $(CROSS)ranlib
DLLTOOL := $(CROSS)dlltool
# 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 ?=
############################################################################### ###############################################################################
## The folowing 2 macros can NOT be put in defs.mk as it will be included ## The folowing 2 macros can NOT be put in defs.mk as it will be included
@ -107,7 +69,8 @@ CLEAR_VARS := $(BUILD_SYSTEM)/clearvars.mk
BUILD_STATIC_LIBRARY := $(BUILD_SYSTEM)/static.mk BUILD_STATIC_LIBRARY := $(BUILD_SYSTEM)/static.mk
BUILD_SHARED_LIBRARY := $(BUILD_SYSTEM)/shared.mk BUILD_SHARED_LIBRARY := $(BUILD_SYSTEM)/shared.mk
BUILD_EXECUTABLE := $(BUILD_SYSTEM)/executable.mk BUILD_EXECUTABLE := $(BUILD_SYSTEM)/executable.mk
RULES := $(BUILD_SYSTEM)/rules.mk BUILD_PREBUILT := $(BUILD_SYSTEM)/prebuilt.mk
BUILD_RULES := $(BUILD_SYSTEM)/rules.mk
############################################################################### ###############################################################################
## Makefile scan and includes. ## Makefile scan and includes.
@ -155,9 +118,16 @@ include $(makefiles)
############################################################################### ###############################################################################
# Recompute all dependencies between modules # Recompute all dependencies between modules
$(call modules-compute-dependencies) $(call modules-compute-depends)
# Now, really build the modules, the second pass allows to deal with exported values # Check dependencies
$(call modules-check-depends)
# Check variables of modules
$(call modules-check-variables)
# Now, really generate rules for modules.
# This second pass allows to deal with exported values.
$(foreach __mod,$(__modules), \ $(foreach __mod,$(__modules), \
$(eval LOCAL_MODULE := $(__mod)) \ $(eval LOCAL_MODULE := $(__mod)) \
$(eval include $(BUILD_SYSTEM)/module.mk) \ $(eval include $(BUILD_SYSTEM)/module.mk) \
@ -182,11 +152,21 @@ $(AUTOCONF_MERGE_FILE): $(__autoconf-list)
# Main rules. # Main rules.
############################################################################### ###############################################################################
# All modules
ALL_MODULES := \
$(foreach __mod,$(__modules),$(__mod))
# All module to actually build
ALL_BUILD_MODULES := \
$(foreach __mod,$(__modules), \
$(if $(call is-module-in-build-config,$(__mod)),$(__mod)))
# TODO : Set ALL_BUILD_MODULES ==> find the end point module (SHARED/BINARY)
.PHONY: all .PHONY: all
all: $(foreach __mod,$(__modules),$(__mod)) $(AUTOCONF_MERGE_FILE) all: $(ALL_MODULES) $(AUTOCONF_MERGE_FILE)
.PHONY: clean .PHONY: clean
clean: $(foreach __mod,$(__modules),clean-$(__mod)) clean: $(foreach __mod,$(ALL_MODULES),clean-$(__mod))
@rm -f $(AUTOCONF_MERGE_FILE) @rm -f $(AUTOCONF_MERGE_FILE)
# Dump the module database for debuging the build system # Dump the module database for debuging the build system
@ -194,6 +174,15 @@ clean: $(foreach __mod,$(__modules),clean-$(__mod))
dump: dump:
$(call modules-dump-database) $(call modules-dump-database)
# Dump the module database for debuging the build system
.PHONY: dump-depends
dump-depends:
$(call modules-dump-database-depends)
# Dummy target to check internal variables
.PHONY: check
check:
############################################################################### ###############################################################################
# Display configuration. # Display configuration.
############################################################################### ###############################################################################
@ -204,6 +193,6 @@ $(info TARGET_ARCH: $(TARGET_ARCH))
$(info TARGET_OUT_BUILD: $(TARGET_OUT_BUILD)) $(info TARGET_OUT_BUILD: $(TARGET_OUT_BUILD))
$(info TARGET_OUT_STAGING: $(TARGET_OUT_STAGING)) $(info TARGET_OUT_STAGING: $(TARGET_OUT_STAGING))
$(info TARGET_OUT_FINAL: $(TARGET_OUT_FINAL)) $(info TARGET_OUT_FINAL: $(TARGET_OUT_FINAL))
$(info CC_PATH: $(CC_PATH)) $(info TARGET_CC_PATH: $(TARGET_CC_PATH))
$(info CC_VERSION: $(CC_VERSION)) $(info TARGET_CC_VERSION: $(TARGET_CC_VERSION))
$(info ----------------------------------------------------------------------) $(info ----------------------------------------------------------------------)

View File

@ -9,19 +9,65 @@
# Bring back all LOCAL_XXX variables defined by LOCAL_MODULE # Bring back all LOCAL_XXX variables defined by LOCAL_MODULE
$(call module-restore-locals,$(LOCAL_MODULE)) $(call module-restore-locals,$(LOCAL_MODULE))
# Do we need to copy build module to staging dir
copy_to_staging := 0 copy_to_staging := 0
# Full path to build module
LOCAL_BUILD_MODULE := $(call module-get-build-filename,$(LOCAL_MODULE))
# 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_TARGETS := $(LOCAL_BUILD_MODULE) clean-$(LOCAL_MODULE)
# Add external libraries used by static libraries
LOCAL_EXTERNAL_LIBRARIES += \
$(call module-get-depends,$(LOCAL_STATIC_LIBRARIES),EXTERNAL_LIBRARIES)
LOCAL_EXTERNAL_LIBRARIES += \
$(call module-get-depends,$(LOCAL_WHOLE_STATIC_LIBRARIES),EXTERNAL_LIBRARIES)
# List of external libraries that we need to depend on
all_external_libraries := \
$(foreach lib,$(LOCAL_EXTERNAL_LIBRARIES), \
$(call module-get-build-filename,$(lib)))
###############################################################################
## Rule-specific variable definitions.
###############################################################################
$(LOCAL_TARGETS): PRIVATE_PATH := $(LOCAL_PATH)
$(LOCAL_TARGETS): PRIVATE_MODULE := $(LOCAL_MODULE)
$(LOCAL_TARGETS): PRIVATE_CLEAN_FILES := $(LOCAL_BUILD_MODULE)
$(LOCAL_TARGETS): PRIVATE_CLEAN_DIRS :=
###############################################################################
## General rules.
###############################################################################
# Short hand to build module
.PHONY: $(LOCAL_MODULE)
$(LOCAL_MODULE): $(LOCAL_BUILD_MODULE)
# Clean module (several other rules with commands can be added using ::)
.PHONY: clean-$(LOCAL_MODULE)
clean-$(LOCAL_MODULE)::
@echo "Clean: $(PRIVATE_MODULE)"
$(Q)$(if $(PRIVATE_CLEAN_FILES),rm -f $(PRIVATE_CLEAN_FILES))
$(Q)$(if $(PRIVATE_CLEAN_DIRS),rm -rf $(PRIVATE_CLEAN_DIRS))
############################################################################### ###############################################################################
## Static library. ## Static library.
############################################################################### ###############################################################################
ifeq ("$(LOCAL_MODULE_CLASS)","STATIC_LIBRARY") ifeq ("$(LOCAL_MODULE_CLASS)","STATIC_LIBRARY")
include $(RULES) include $(BUILD_RULES)
$(LOCAL_BUILD_MODULE): $(all_objects) $(LOCAL_BUILD_MODULE): $(all_objects)
$(transform-o-to-static-lib) $(transform-o-to-static-lib)
# TODO : the .a file does not arrive in the staging element ==> they micht stay in the obj folder
copy_to_staging := 1 copy_to_staging := 1
endif endif
@ -32,7 +78,7 @@ endif
ifeq ("$(LOCAL_MODULE_CLASS)","SHARED_LIBRARY") ifeq ("$(LOCAL_MODULE_CLASS)","SHARED_LIBRARY")
include $(RULES) include $(BUILD_RULES)
$(LOCAL_BUILD_MODULE): $(all_objects) $(all_libraries) $(LOCAL_BUILD_MODULE): $(all_objects) $(all_libraries)
$(transform-o-to-shared-lib) $(transform-o-to-shared-lib)
@ -47,7 +93,7 @@ endif
ifeq ("$(LOCAL_MODULE_CLASS)","EXECUTABLE") ifeq ("$(LOCAL_MODULE_CLASS)","EXECUTABLE")
include $(RULES) include $(BUILD_RULES)
$(LOCAL_BUILD_MODULE): $(all_objects) $(all_libraries) $(LOCAL_BUILD_MODULE): $(all_objects) $(all_libraries)
$(transform-o-to-executable) $(transform-o-to-executable)
@ -56,6 +102,44 @@ copy_to_staging := 1
endif endif
###############################################################################
## Prebuilt.
###############################################################################
ifeq ("$(LOCAL_MODULE_CLASS)","PREBUILT")
$(LOCAL_BUILD_MODULE):
@mkdir -p $(dir $@)
@touch $@
endif
###############################################################################
## Files to copy.
###############################################################################
ifneq ("$(LOCAL_COPY_FILES)","")
# List of all destination files
all_copy_files :=
# Generate a rule to copy all files
$(foreach __pair,$(LOCAL_COPY_FILES), \
$(eval __pair2 := $(subst :,$(space),$(__pair))) \
$(eval __src := $(addprefix $(LOCAL_PATH)/,$(word 1,$(__pair2)))) \
$(eval __dst := $(addprefix $(TARGET_OUT_STAGING)/,$(word 2,$(__pair2)))) \
$(eval all_copy_files += $(__dst)) \
$(eval $(call copy-one-file,$(__src),$(__dst))) \
)
# Add files to be copied as pre-requisites
$(LOCAL_BUILD_MODULE): $(all_copy_files)
# Add rule to delete copied files during clean
clean-$(LOCAL_MODULE):: PRIVATE_CLEAN_FILES += $(all_copy_files)
endif
############################################################################### ###############################################################################
## Copy to staging dir ## Copy to staging dir
############################################################################### ###############################################################################

15
core/prebuilt.mk Normal file
View File

@ -0,0 +1,15 @@
###############################################################################
## @file prebuilt.mk
## @author Y.M. Morgan
## @date 2012/08/08
##
## Register a prebuilt module.
###############################################################################
LOCAL_MODULE_CLASS := PREBUILT
ifeq ("$(LOCAL_MODULE_FILENAME)","")
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE).done
endif
$(local-add-module)

View File

@ -1,29 +1,14 @@
############################################################################### ###############################################################################
## @file rules.mk ## @file binary-rules.mk
## @author Y.M. Morgan ## @author Y.M. Morgan
## @date 2011/05/14 ## @date 2011/05/14
## ##
## Generate rules for building an executable or library. ## Generate rules for building an executable or library.
############################################################################### ###############################################################################
# Make sure LOCAL_MODULE is defined and not empty
LOCAL_MODULE := $(strip $(LOCAL_MODULE))
ifeq ("$(LOCAL_MODULE)","")
$(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
endif
# Intermediate/Build directory # Intermediate/Build directory
build_dir := $(TARGET_OUT_BUILD)/$(LOCAL_MODULE) build_dir := $(TARGET_OUT_BUILD)/$(LOCAL_MODULE)
# Full path to build module
LOCAL_BUILD_MODULE := $(call module-get-build-filename,$(LOCAL_MODULE))
# 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_TARGETS += $(LOCAL_BUILD_MODULE)
# Prepend some directories in include list # Prepend some directories in include list
LOCAL_C_INCLUDES := $(build_dir) $(LOCAL_PATH) $(LOCAL_C_INCLUDES) LOCAL_C_INCLUDES := $(build_dir) $(LOCAL_PATH) $(LOCAL_C_INCLUDES)
@ -93,12 +78,12 @@ all_objects := \
$(cxx_objects) \ $(cxx_objects) \
$(c_objects) \ $(c_objects) \
$(s_objects) \ $(s_objects) \
$(S_objects) \ $(S_objects)
# Get all static libraries this module depends on # Get all static libraries this module depends on
LOCAL_STATIC_LIBRARIES := \ LOCAL_STATIC_LIBRARIES += \
$(call module-get-depends,$(LOCAL_STATIC_LIBRARIES),STATIC_LIBRARIES) $(call module-get-depends,$(LOCAL_STATIC_LIBRARIES),STATIC_LIBRARIES)
LOCAL_WHOLE_STATIC_LIBRARIES := \ LOCAL_WHOLE_STATIC_LIBRARIES += \
$(call module-get-depends,$(LOCAL_WHOLE_STATIC_LIBRARIES),WHOLE_STATIC_LIBRARIES) $(call module-get-depends,$(LOCAL_WHOLE_STATIC_LIBRARIES),WHOLE_STATIC_LIBRARIES)
# Also get shared libraries used by static libraries # Also get shared libraries used by static libraries
@ -117,7 +102,6 @@ all_static_libraries := \
all_whole_static_libraries := \ all_whole_static_libraries := \
$(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \ $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \
$(call module-get-staging-filename,$(lib))) $(call module-get-staging-filename,$(lib)))
all_external_libraries := \ all_external_libraries := \
$(foreach lib,$(LOCAL_EXTERNAL_LIBRARIES), \ $(foreach lib,$(LOCAL_EXTERNAL_LIBRARIES), \
$(TARGET_OUT_BUILD)/$(lib)/$(lib).done) $(TARGET_OUT_BUILD)/$(lib)/$(lib).done)
@ -127,7 +111,7 @@ all_libraries := \
$(all_shared_libraries) \ $(all_shared_libraries) \
$(all_static_libraries) \ $(all_static_libraries) \
$(all_whole_static_libraries) \ $(all_whole_static_libraries) \
$(all_external_libraries) \ $(all_external_libraries)
############################################################################### ###############################################################################
## Import of dependencies. ## Import of dependencies.
@ -152,8 +136,6 @@ LOCAL_CPPFLAGS := $(strip $(imported_CPPFLAGS) $(LOCAL_EXPORT_CPPFLAGS) $(LOCA
# The imported/exported include directories are appended to their LOCAL_XXX value # The imported/exported include directories are appended to their LOCAL_XXX value
# (this allows the module to override them) # (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))))) 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 -----)
# Similarly, you want the imported/exported flags to appear _after_ the LOCAL_LDLIBS # 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 # due to the way Unix linkers work (depending libraries must appear before
@ -180,6 +162,9 @@ all_prerequisites += $(all_autoconf)
# User makefile is also a prerequisite # User makefile is also a prerequisite
all_prerequisites += $(LOCAL_PATH)/$(USER_MAKEFILE_NAME) all_prerequisites += $(LOCAL_PATH)/$(USER_MAKEFILE_NAME)
# External libraries are also prerequisites
all_prerequisites += $(all_external_libraries)
# Notify that we build with dependencies # Notify that we build with dependencies
LOCAL_CFLAGS += $(foreach __mod,$(all_depends), \ LOCAL_CFLAGS += $(foreach __mod,$(all_depends), \
-DBUILD_$(call get-define,$(__mod))) -DBUILD_$(call get-define,$(__mod)))
@ -217,33 +202,20 @@ $(s_objects): $(build_dir)/%.o: $(LOCAL_PATH)/%.s
endif endif
# S files # S files
# There are dependency files for asm code... # There is dependency files for asm code...
ifneq ("$(strip $(S_objects))","") ifneq ("$(strip $(S_objects))","")
$(S_objects): $(build_dir)/%.o: $(LOCAL_PATH)/%.S $(S_objects): $(build_dir)/%.o: $(LOCAL_PATH)/%.S
$(transform-s-to-o) $(transform-s-to-o)
-include $(S_objects:%.o=%.d) -include $(S_objects:%.o=%.d)
endif endif
# clean- targets # Additionnal clean
cleantarget := clean-$(LOCAL_MODULE) clean-$(LOCAL_MODULE):: PRIVATE_CLEAN_FILES += $(LOCAL_STAGING_MODULE)
$(cleantarget) : PRIVATE_MODULE := $(LOCAL_MODULE) clean-$(LOCAL_MODULE):: PRIVATE_CLEAN_DIRS += $(build_dir)
$(cleantarget) : PRIVATE_CLEAN_FILES := \
$(LOCAL_BUILD_MODULE) \
$(LOCAL_STAGING_MODULE) \
$(build_dir)
$(cleantarget)::
@echo "Clean: $(PRIVATE_MODULE)"
$(Q)rm -rf $(PRIVATE_CLEAN_FILES)
## Provide a short-hand for building this module. # Additional module dependencies
.PHONY: $(LOCAL_MODULE)
$(LOCAL_MODULE): $(LOCAL_BUILD_MODULE) $(LOCAL_STAGING_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 # Make sure all prerequisites files are generated first
ifneq ("$(all_prerequisites)","") ifneq ("$(all_prerequisites)","")
$(all_objects): $(all_prerequisites) $(all_objects): $(all_prerequisites)
@ -284,14 +256,10 @@ $(gch_file): $(LOCAL_PATH)/$(LOCAL_PRECOMPILED_FILE)
$(transform-h-to-gch) $(transform-h-to-gch)
-include $(gch_file:%.gch=%.d) -include $(gch_file:%.gch=%.d)
# Make sure external libraries are built first (order prerequisite)
# TODO : check why order prerequisite
#$(gch_file): | $(external_libraries)
endif endif
############################################################################### ###############################################################################
# Rule-specific variable definitions. ## Rule-specific variable definitions.
############################################################################### ###############################################################################
$(LOCAL_TARGETS): PRIVATE_PATH := $(LOCAL_PATH) $(LOCAL_TARGETS): PRIVATE_PATH := $(LOCAL_PATH)
@ -309,4 +277,3 @@ $(LOCAL_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(all_whole_static_libra
$(LOCAL_TARGETS): PRIVATE_ALL_EXTERNAL_LIBRARIES := $(all_external_libraries) $(LOCAL_TARGETS): PRIVATE_ALL_EXTERNAL_LIBRARIES := $(all_external_libraries)
$(LOCAL_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) $(LOCAL_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)

View File

@ -13,6 +13,52 @@ ifneq ("$(words $(shell pwd))","1")
$(error Top directory contains space characters) $(error Top directory contains space characters)
endif endif
###############################################################################
## Tools for target.
###############################################################################
ifneq ("$(CLANG)","1")
TARGET_CC := $(TARGET_CROSS)gcc
TARGET_CXX := $(TARGET_CROSS)g++
else
TARGET_CC := $(TARGET_CROSS)clang
TARGET_CXX := $(TARGET_CROSS)clang++
endif
TARGET_AR := $(TARGET_CROSS)ar
TARGET_LD := $(TARGET_CROSS)ld
TARGET_NM := $(TARGET_CROSS)nm
TARGET_STRIP := $(TARGET_CROSS)strip
TARGET_STRIP := $(TARGET_CROSS)strip
TARGET_RANLIB := $(TARGET_CROSS)ranlib
TARGET_DLLTOOL := $(TARGET_CROSS)dlltool
###############################################################################
## Tools for host.
###############################################################################
HOST_GCC ?= gcc
HOST_GXX ?= g++
HOST_AR ?= ar
HOST_LD ?= ld
HOST_NM ?= nm
HOST_STRIP ?= strip
###############################################################################
# Target global variables.
###############################################################################
TARGET_GLOBAL_C_INCLUDES ?=
TARGET_GLOBAL_CFLAGS ?=
TARGET_GLOBAL_CPPFLAGS ?=
TARGET_GLOBAL_ARFLAGS ?= rcs
TARGET_GLOBAL_LDFLAGS ?=
TARGET_GLOBAL_LDFLAGS_SHARED ?=
TARGET_GLOBAL_LDLIBS ?=
TARGET_GLOBAL_LDLIBS_SHARED ?=
TARGET_GLOBAL_CFLAGS_ARM ?=
TARGET_GLOBAL_CFLAGS_THUMB ?=
TARGET_PCH_FLAGS ?=
TARGET_DEFAULT_ARM_MODE ?= THUMB
############################################################################### ###############################################################################
## Host/Target OS. ## Host/Target OS.
############################################################################### ###############################################################################
@ -36,11 +82,9 @@ endif
# Exe/dll suffix under mingw # Exe/dll suffix under mingw
TARGET_STATIC_LIB_SUFFIX := .a TARGET_STATIC_LIB_SUFFIX := .a
ifeq ("$(TARGET_OS)","Windows") ifeq ("$(TARGET_OS)","Windows")
DIR_SUFFIX := _mingw32
TARGET_EXE_SUFFIX := .exe TARGET_EXE_SUFFIX := .exe
TARGET_SHARED_LIB_SUFFIX := .dll TARGET_SHARED_LIB_SUFFIX := .dll
else else
DIR_SUFFIX :=
TARGET_EXE_SUFFIX := TARGET_EXE_SUFFIX :=
TARGET_SHARED_LIB_SUFFIX := .so TARGET_SHARED_LIB_SUFFIX := .so
endif endif
@ -105,7 +149,7 @@ endif
# Architecture # Architecture
#ifndef TARGET_ARCH #ifndef TARGET_ARCH
# ifneq ("$(shell $(CC) -dumpmachine | grep 64)","") # ifneq ("$(shell $(TARGET_CC) -dumpmachine | grep 64)","")
# TARGET_ARCH := AMD64 # TARGET_ARCH := AMD64
# else # else
# TARGET_ARCH := X86 # TARGET_ARCH := X86
@ -120,29 +164,33 @@ endif
# TARGET_GLOBAL_CFLAGS += -m32 # TARGET_GLOBAL_CFLAGS += -m32
#endif #endif
TARGET_GLOBAL_LDFLAGS += -L$(TARGET_OUT_STAGING)/lib
TARGET_GLOBAL_LDFLAGS += -L$(TARGET_OUT_STAGING)/usr/lib
TARGET_GLOBAL_LDFLAGS_SHARED += -L$(TARGET_OUT_STAGING)/lib
TARGET_GLOBAL_LDFLAGS_SHARED += -L$(TARGET_OUT_STAGING)/usr/lib
############################################################################### ###############################################################################
## Determine CC path and version. and check if installed ... ## Determine CC path and version. and check if installed ...
############################################################################### ###############################################################################
CC_PATH := $(shell which $(CC)) TARGET_CC_PATH := $(shell which $(CC))
ifeq ("$(CC_PATH)","") ifeq ("$(TARGET_CC_PATH)","")
ifeq ("$(TARGET_OS)","Windows") ifeq ("$(TARGET_OS)","Windows")
$(error Compilator does not exist : $(CC) ==> if not installed ... "apt-get install mingw32") $(error Compilator does not exist : $(TARGET_CC) ==> if not installed ... "apt-get install mingw32")
else ifeq ("$(TARGET_OS)","Android") else ifeq ("$(TARGET_OS)","Android")
$(error Compilator does not exist : $(CC) ==> add and define the android NDK "http://developer.android.com/tools/sdk/ndk/index.html") $(error Compilator does not exist : $(TARGET_CC) ==> add and define the android NDK "http://developer.android.com/tools/sdk/ndk/index.html")
else else
ifneq ("$(CLANG)","1") ifneq ("$(CLANG)","1")
$(error Compilator does not exist : $(CC) ==> if not installed ... "apt-get install gcc g++") $(error Compilator does not exist : $(TARGET_CC) ==> if not installed ... "apt-get install gcc g++")
else else
$(error Compilator does not exist : $(CC) ==> if not installed ... "apt-get install clang") $(error Compilator does not exist : $(TARGET_CC) ==> if not installed ... "apt-get install clang")
endif endif
endif endif
endif endif
ifneq ("$(CLANG)","1") ifneq ("$(CLANG)","1")
CC_VERSION := $(shell $(CC) --version | head -1 | sed "s/.*\([0-9]\.[0-9]\.[0-9]\).*/\1/") TARGET_CC_VERSION := $(shell $(TARGET_CC) --version | head -1 | sed "s/.*\([0-9]\.[0-9]\.[0-9]\).*/\1/")
else else
CC_VERSION := $(shell $(CC) --version | head -1 | sed "s/.*\([0-9]\.[0-9]-[0-9]\).*/\1/") TARGET_CC_VERSION := $(shell $(TARGET_CC) --version | head -1 | sed "s/.*\([0-9]\.[0-9]-[0-9]\).*/\1/")
endif endif

View File

@ -7,10 +7,13 @@
############################################################################### ###############################################################################
LOCAL_MODULE_CLASS := SHARED_LIBRARY LOCAL_MODULE_CLASS := SHARED_LIBRARY
ifeq ("$(LOCAL_DESTDIR)","")
LOCAL_DESTDIR := usr/lib LOCAL_DESTDIR := usr/lib
endif
ifeq ("$(LOCAL_MODULE_FILENAME)","") ifeq ("$(LOCAL_MODULE_FILENAME)","")
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_SHARED_LIB_SUFFIX) LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_SHARED_LIB_SUFFIX)
endif endif
$(call module-add,$(LOCAL_MODULE)) $(local-add-module)

View File

@ -7,10 +7,13 @@
############################################################################### ###############################################################################
LOCAL_MODULE_CLASS := STATIC_LIBRARY LOCAL_MODULE_CLASS := STATIC_LIBRARY
ifeq ("$(LOCAL_DESTDIR)","")
LOCAL_DESTDIR := usr/lib LOCAL_DESTDIR := usr/lib
endif
ifeq ("$(LOCAL_MODULE_FILENAME)","") ifeq ("$(LOCAL_MODULE_FILENAME)","")
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_STATIC_LIB_SUFFIX) LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_STATIC_LIB_SUFFIX)
endif endif
$(call module-add,$(LOCAL_MODULE)) $(local-add-module)

View File

@ -11,7 +11,7 @@ CC_FLAGS_WARNINGS :=
CXX_FLAGS_WARNINGS := CXX_FLAGS_WARNINGS :=
# show option associated with warning (gcc >= 4.0.0) # show option associated with warning (gcc >= 4.0.0)
ifneq (0,$(shell expr $(CC_VERSION) \>= 4.0.0)) ifneq (0,$(shell expr $(TARGET_CC_VERSION) \>= 4.0.0))
COMMON_FLAGS_WARNINGS += -fdiagnostics-show-option COMMON_FLAGS_WARNINGS += -fdiagnostics-show-option
endif endif
@ -41,11 +41,11 @@ endif
ifneq ("$(CLANG)","1") ifneq ("$(CLANG)","1")
# gcc >= 4.5.0 (too many false positives with previous versions) # gcc >= 4.5.0 (too many false positives with previous versions)
ifneq (0,$(shell expr $(CC_VERSION) \>= 4.5.0)) ifneq (0,$(shell expr $(TARGET_CC_VERSION) \>= 4.5.0))
COMMON_FLAGS_WARNINGS += -Wunreachable-code COMMON_FLAGS_WARNINGS += -Wunreachable-code
endif endif
# gcc >= 4.5.2 # gcc >= 4.5.2
ifneq (0,$(shell expr $(CC_VERSION) \>= 4.5.2)) ifneq (0,$(shell expr $(TARGET_CC_VERSION) \>= 4.5.2))
COMMON_FLAGS_WARNINGS += -Wlogical-op COMMON_FLAGS_WARNINGS += -Wlogical-op
endif endif
endif endif
@ -56,7 +56,7 @@ ifeq ("$(W)","1")
COMMON_FLAGS_WARNINGS += -Wswitch-enum COMMON_FLAGS_WARNINGS += -Wswitch-enum
COMMON_FLAGS_WARNINGS += -Wcast-qual COMMON_FLAGS_WARNINGS += -Wcast-qual
# gcc >= 4.4.0 # gcc >= 4.4.0
ifneq (0,$(shell expr $(CC_VERSION) \>= 4.4.0)) ifneq (0,$(shell expr $(TARGET_CC_VERSION) \>= 4.4.0))
COMMON_FLAGS_WARNINGS += -Wframe-larger-than=1024 COMMON_FLAGS_WARNINGS += -Wframe-larger-than=1024
endif endif
endif endif