integrated the configuration file system and generate only one configuration

This commit is contained in:
Edouard Dupin 2012-08-31 16:47:49 +02:00
parent d606d2a42f
commit cd149be3fd
4 changed files with 98 additions and 248 deletions

View File

@ -11,12 +11,7 @@
CONF := KCONFIG_NOTIMESTAMP=1 $(call fullpath,$(BUILD_SYSTEM)/conf) 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
CONFIG_ORIG_DIR := $(TARGET_CONFIG_DIR)
# File where global configuration is stored
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.
@ -47,11 +42,9 @@ __end-conf = \
__exec-conf = (cd $$(dirname $${__tmpconf}) && $(CONF) $2 $1); __exec-conf = (cd $$(dirname $${__tmpconf}) && $(CONF) $2 $1);
__exec-qconf = (cd $$(dirname $${__tmpconf}) && $(QCONF) $2 $1); __exec-qconf = (cd $$(dirname $${__tmpconf}) && $(QCONF) $2 $1);
###############################################################################
## Get the name of the configuration file of a module. #TODO : REMOVED
## $1 : module name. #__get_module-config = $(CONFIG_ORIG_DIR)/$1.config
###############################################################################
__get_module-config = $(CONFIG_ORIG_DIR)/$1.config
############################################################################### ###############################################################################
## Get the list of path to Config.in files of a module. ## Get the list of path to Config.in files of a module.
@ -82,10 +75,10 @@ __end-diff = \
fi; fi;
############################################################################### ###############################################################################
## Generate Config.in for global configuration. ## Generate Config configuration for all librairies.
## $1 : destination file. ## $1 : destination file.
############################################################################### ###############################################################################
define __generate-config-in-global define __generate-config
rm -f $1; \ rm -f $1; \
mkdir -p $(dir $1); \ mkdir -p $(dir $1); \
touch $1; \ touch $1; \
@ -98,26 +91,20 @@ define __generate-config-in-global
echo " help" >> $1; \ echo " help" >> $1; \
echo " Build $(__mod)" >> $1; \ echo " Build $(__mod)" >> $1; \
) \ ) \
echo "endmenu" >> $1; echo "endmenu" >> $1; \
endef $(foreach __mod,$(__modules), \
$(eval __build := BUILD_$(call get-define,$(__mod))) \
############################################################################### $(eval __files := $(call __get_module-config-in-files,$(__mod))) \
## Generate Config.in for one module. if [ "$(__files)" != "" ]; then \
## $1 : destination file. echo "if $(__build)" >> $1; \
## $2 : module name. echo " menu $(__mod)" >> $1; \
## $3 : list of path to Config.in files. $(foreach __f,$(__files), \
############################################################################### echo " source $(call fullpath,$(__f))" >> $1; \
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; \
echo "endmenu" >> $1; echo "endif" >> $1; \
fi; \
)
endef endef
############################################################################### ###############################################################################
@ -167,43 +154,46 @@ define __check-config
endef endef
############################################################################### ###############################################################################
## Load configuration of a module. ## 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
# Do NOT check the config if a config is explicitely requested echo "Generating $(call path-from-top,$2) from $(call path-from-top,$1)"; \
define __load-config-internal mkdir -p $(dir $2); \
$(eval __config := $(call __get_module-config,$1)) sed \
-include $(__config) -e 's/^CONFIG_//' \
ifeq ("$(findstring config,$(MAKECMDGOALS))","") -e 's/^\# CONFIG_/\# /' \
$(__config): __config-modules-check-$1 -e 's/^\#\(.*\)/\/*\1 *\//' \
endif -e 's/\(.*\)=\(.*\)/\#define \1 \2/' \
-e 's/ y$$/ 1/' \
-e 's/\"\(.*\)\"/\1/' \
-e 's/\\\"/\"/g' \
$1 > $2;
endef endef
###############################################################################
## Load configuration of a module.
## Simply evaluate a call to simplify job of caller.
###############################################################################
load-config = $(eval $(call __load-config-internal,$(LOCAL_MODULE)))
############################################################################### ###############################################################################
## Rules. ## Rules.
############################################################################### ###############################################################################
# File where global configuration is stored
# Update everything CONFIG_GLOBAL_FOLDER := $(shell pwd)/config
.PHONY: config-update CONFIG_GLOBAL_FILE := $(CONFIG_GLOBAL_FOLDER)/$(TARGET_OS)_$(BUILD_DIRECTORY_MODE).config
config-update: config-global-update config-modules-update
# Check everything
.PHONY: config-check
config-check: config-global-check config-modules-check
# Display the global configuration # Display the global configuration
.PHONY: config-global .PHONY: config
config-global: config:
@( \ @( \
__tmpconfigin=$$(mktemp); \ __tmpconfigin=$$(mktemp); \
$(eval __config := $(CONFIG_GLOBAL_FILE)) \ $(eval __config := $(CONFIG_GLOBAL_FILE)) \
$(call __generate-config-in-global,$${__tmpconfigin}) \ $(call __generate-config,$${__tmpconfigin}) \
$(call __begin-conf,$(__config)) \ $(call __begin-conf,$(__config)) \
$(call __exec-qconf,$${__tmpconfigin}) \ $(call __exec-qconf,$${__tmpconfigin}) \
$(call __end-conf,$(__config)) \ $(call __end-conf,$(__config)) \
@ -211,122 +201,39 @@ config-global:
) )
# Update the global configuration by selecting new option at their default value # Update the global configuration by selecting new option at their default value
.PHONY: config-global-update .PHONY: config-update
config-global-update: config-update:
@( \ @( \
__tmpconfigin=$$(mktemp); \ __tmpconfigin=$$(mktemp); \
$(eval __config := $(CONFIG_GLOBAL_FILE)) \ $(eval __config := $(CONFIG_GLOBAL_FILE)) \
$(call __generate-config-in-global,$${__tmpconfigin}) \ $(call __generate-config,$${__tmpconfigin}) \
$(call __update-config,$${__tmpconfigin},$(__config)) \ $(call __update-config,$${__tmpconfigin},$(__config)) \
rm -f $${__tmpconfigin}; \ rm -f $${__tmpconfigin}; \
) )
# Check the global configuration # Check the global configuration
.PHONY: config-global-check .PHONY: config-check
config-global-check: config-check:
@( \ @( \
__tmpconfigin=$$(mktemp); \ __tmpconfigin=$$(mktemp); \
$(eval __config := $(CONFIG_GLOBAL_FILE)) \ $(eval __config := $(CONFIG_GLOBAL_FILE)) \
$(call __generate-config-in-global,$${__tmpconfigin}) \ $(call __generate-config,$${__tmpconfigin}) \
$(call __check-config,$${__tmpconfigin},$(__config)) \ $(call __check-config,$${__tmpconfigin},$(__config)) \
rm -f $${__tmpconfigin}; \ rm -f $${__tmpconfigin}; \
) )
@echo "Global configuration is up to date"; @echo "Global configuration is up to date";
# Update all module configurations by selecting new option at their default value # create basic folder :
.PHONY: config-modules-update $(shell mkdir -p $(CONFIG_GLOBAL_FOLDER))
config-modules-update: # check if config exist :
@( \ # TODO ...
$(foreach __mod,$(__modules), \ -include $(CONFIG_GLOBAL_FILE)
$(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 #automatic generation of the config file when not existed (default case):
.PHONY: config-modules-update-% #.PHONY: $(CONFIG_GLOBAL_FILE)
config-modules-update-%: #$(CONFIG_GLOBAL_FILE): config-update
@( \ # echo "generating basic confing .. please restart"
$(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 $(CONFIG_GLOBAL_FILE):
.PHONY: config-modules-check @#$(e rror "need to generate config : make ... config")
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

@ -398,18 +398,6 @@ module-get-listed-export = \
$(call module-get-export,$(__mod),$2) \ $(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)) \
))
############################################################################### ###############################################################################
## Dependency management ## Dependency management
############################################################################### ###############################################################################
@ -468,34 +456,6 @@ module-get-build-filename = \
module-get-staging-filename = \ module-get-staging-filename = \
$(if $(__modules.$1.MODULE_FILENAME), $(TARGET_OUT_STAGING)/$(__modules.$1.DESTDIR)/$(__modules.$1.MODULE_FILENAME) ) $(if $(__modules.$1.MODULE_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
############################################################################### ###############################################################################
## Normalize a list of includes. It adds -I if needed. ## Normalize a list of includes. It adds -I if needed.
## $1 : list of includes ## $1 : list of includes

View File

@ -27,8 +27,6 @@ W := 0
DEBUG := 0 DEBUG := 0
# compilation done with Clang system instead of gcc # compilation done with Clang system instead of gcc
CLANG := 0 CLANG := 0
# for openGL : enable the open GL ES 2 or the Shader system for normal system
SHADER := 0
# Quiet command if V is 0 # Quiet command if V is 0
ifeq ("$(V)","0") ifeq ("$(V)","0")
@ -57,6 +55,12 @@ my-dir = $(call fullpath,$(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))))
TOP_DIR := $(shell pwd) TOP_DIR := $(shell pwd)
BUILD_SYSTEM := $(call my-dir) BUILD_SYSTEM := $(call my-dir)
ifeq ("$(DEBUG)","1")
BUILD_DIRECTORY_MODE := debug
else
BUILD_DIRECTORY_MODE := release
endif
# Setup configuration # Setup configuration
include $(BUILD_SYSTEM)/setup-host.mk include $(BUILD_SYSTEM)/setup-host.mk
include $(BUILD_SYSTEM)/setup-target.mk include $(BUILD_SYSTEM)/setup-target.mk
@ -79,19 +83,10 @@ BUILD_RULES := $(BUILD_SYSTEM)/rules.mk
############################################################################### ###############################################################################
## Makefile scan and includes. ## Makefile scan and includes.
############################################################################### ###############################################################################
ifeq ("$(DEBUG)","1")
BUILD_DIRECTORY_MODE := debug TARGET_OUT_BUILD ?= $(shell pwd)/out/$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/obj
else TARGET_OUT_STAGING ?= $(shell pwd)/out/$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/staging
BUILD_DIRECTORY_MODE := release TARGET_OUT_FINAL ?= $(shell pwd)/out/$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/final
endif
ifeq ("$(SHADER)","1")
BUILD_DIRECTORY_SHADER := ogl2
else
BUILD_DIRECTORY_SHADER := ogl1
endif
TARGET_OUT_BUILD ?= $(shell pwd)/out/$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/$(BUILD_DIRECTORY_SHADER)/obj
TARGET_OUT_STAGING ?= $(shell pwd)/out/$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/$(BUILD_DIRECTORY_SHADER)/staging
TARGET_OUT_FINAL ?= $(shell pwd)/out/$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/$(BUILD_DIRECTORY_SHADER)/final
# Makefile with the list of all makefiles available and include them # Makefile with the list of all makefiles available and include them
SCAN_TARGET := scan SCAN_TARGET := scan
@ -134,6 +129,19 @@ $(call modules-check-depends)
# Check variables of modules # Check variables of modules
$(call modules-check-variables) $(call modules-check-variables)
###############################################################################
# Rule to merge autoconf.h files.
###############################################################################
# Concatenate all in one
AUTOCONF_FILE := $(TARGET_OUT_BUILD)/autoconf.h
$(AUTOCONF_FILE): $(CONFIG_GLOBAL_FILE)
@echo "Generating autoconf-merge.h"
@mkdir -p $(dir $@)
@rm -f $@
@$(call generate-autoconf-file,$^,$@)
# Now, really generate rules for modules. # Now, really generate rules for modules.
# This second pass allows to deal with exported values. # This second pass allows to deal with exported values.
$(foreach __mod,$(__modules), \ $(foreach __mod,$(__modules), \
@ -141,21 +149,6 @@ $(foreach __mod,$(__modules), \
$(eval include $(BUILD_SYSTEM)/module.mk) \ $(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
############################################################################### ###############################################################################
# Main rules. # Main rules.
############################################################################### ###############################################################################
@ -164,6 +157,8 @@ $(AUTOCONF_MERGE_FILE): $(__autoconf-list)
ALL_MODULES := \ ALL_MODULES := \
$(foreach __mod,$(__modules),$(__mod)) $(foreach __mod,$(__modules),$(__mod))
#TODO check this ...
# All module to actually build # All module to actually build
ALL_BUILD_MODULES := \ ALL_BUILD_MODULES := \
$(foreach __mod,$(__modules), \ $(foreach __mod,$(__modules), \
@ -171,7 +166,7 @@ ALL_BUILD_MODULES := \
# TODO : Set ALL_BUILD_MODULES ==> find the end point module (SHARED/BINARY) # TODO : Set ALL_BUILD_MODULES ==> find the end point module (SHARED/BINARY)
.PHONY: all .PHONY: all
all: $(ALL_MODULES) $(AUTOCONF_MERGE_FILE) all: $(ALL_MODULES)
.PHONY: clean .PHONY: clean
clean: $(foreach __mod,$(ALL_MODULES),clean-$(__mod)) clean: $(foreach __mod,$(ALL_MODULES),clean-$(__mod))

View File

@ -143,13 +143,14 @@ LOCAL_C_INCLUDES := $(sort $(strip $(subst -I-I,-I,$(addprefix -I,$(LOCAL_C_INCL
# dependees on final link command). # dependees on final link command).
LOCAL_LDLIBS := $(strip $(LOCAL_LDLIBS) $(LOCAL_EXPORT_LDLIBS) $(imported_LDLIBS)) LOCAL_LDLIBS := $(strip $(LOCAL_LDLIBS) $(LOCAL_EXPORT_LDLIBS) $(imported_LDLIBS))
# Get all autoconf files that we depend on, don't forget to add ourself # Get autoconf files only if we depend oursef or dependent librairies does ...
all_autoconf := \ #TODO
$(call module-get-listed-autoconf,$(all_depends)) \ has_autoconf := $(AUTOCONF_FILE)
$(call module-get-autoconf,$(LOCAL_MODULE)) # $(call module-get-listed-autoconf,$(all_depends)) \
# $(call module-get-autoconf,$(LOCAL_MODULE))
# Force their inclusion (space after -include and before comma is important) # Force their inclusion (space after -include and before comma is important)
LOCAL_CFLAGS += $(addprefix -include ,$(all_autoconf)) LOCAL_CFLAGS += $(addprefix -include ,$(has_autoconf))
# List of all prerequisites (ours + dependencies) # List of all prerequisites (ours + dependencies)
all_prerequisites := \ all_prerequisites := \
@ -158,7 +159,7 @@ all_prerequisites := \
$(imported_PREREQUISITES) $(imported_PREREQUISITES)
# All autoconf files are prerequisites # All autoconf files are prerequisites
all_prerequisites += $(all_autoconf) all_prerequisites += $(has_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)
@ -222,19 +223,6 @@ ifneq ("$(all_prerequisites)","")
$(all_objects): $(all_prerequisites) $(all_objects): $(all_prerequisites)
endif 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. ## Precompiled headers.
############################################################################### ###############################################################################