commit 30084776e0fc7c273d4b09d58c70cbe612888999 Author: Edouard Dupin Date: Tue Jul 17 10:00:54 2012 +0200 Extract ewol element to create subModule diff --git a/Makefile.Android.mk b/Makefile.Android.mk new file mode 100644 index 0000000..8894168 --- /dev/null +++ b/Makefile.Android.mk @@ -0,0 +1,66 @@ + + +PROJECT_PACKAGE=$(PROJECT_NAME)package +JAVA_FOLDER=src/com/$(PROJECT_VENDOR)/$(PROJECT_NAME) +EWOL_JAVA_FOLDER=src/org/ewol + + +all: + @echo "------------------------------------------------------------------------" + @echo ' Project name : $(PROJECT_NAME)' + @echo ' Project Vendor : $(PROJECT_VENDOR)' + @echo ' Build date : $(BUILD_TIME) ' + @echo ' Tag : $(PROJECT_VERSION_TAG) ' + @echo "------------------------------------------------------------------------" + + @rm -rf bin + + @echo " (sh) Clear previous sources " + @rm -rf src jni/ewolAndroidAbstraction.cpp + @echo " (sh) Create folder : $(JAVA_FOLDER)/ & $(EWOL_JAVA_FOLDER)" + @mkdir -p $(JAVA_FOLDER)/ + @mkdir -p $(EWOL_JAVA_FOLDER)/ + + @echo " (sh) copy the java Files & Replace __XXX__ element with project properties" + @cp $(EWOL_FOLDER)/Java/PROJECT_NAME.java $(JAVA_FOLDER)/$(PROJECT_NAME).java + @sed -i "s|__PROJECT_VENDOR__|$(PROJECT_VENDOR)|" $(JAVA_FOLDER)/$(PROJECT_NAME).java + @sed -i "s|__PROJECT_NAME__|$(PROJECT_NAME)|" $(JAVA_FOLDER)/$(PROJECT_NAME).java + @sed -i "s|__PROJECT_PACKAGE__|$(PROJECT_PACKAGE)|" $(JAVA_FOLDER)/$(PROJECT_NAME).java + # copy the Ewol java files : + @cp $(EWOL_FOLDER)/Java/interfaceJNI.java $(EWOL_JAVA_FOLDER)/ + @cp $(EWOL_FOLDER)/Java/interfaceOpenGL.java $(EWOL_JAVA_FOLDER)/ + @cp $(EWOL_FOLDER)/Java/interfaceSurfaceView.java $(EWOL_JAVA_FOLDER)/ + @cp $(EWOL_FOLDER)/Java/interfaceAudio.java $(EWOL_JAVA_FOLDER)/ + + @echo " (sh) copy the cpp for jni File : $(EWOL_FOLDER)/SourcesJava/ewolAndroidAbstraction.cpp" + @cp $(EWOL_FOLDER)/Java/ewolAndroidAbstraction.cpp jni/ + @sed -i "s|__PROJECT_VENDOR__|$(PROJECT_VENDOR)|" jni/ewolAndroidAbstraction.cpp + @sed -i "s|__PROJECT_NAME__|$(PROJECT_NAME)|" jni/ewolAndroidAbstraction.cpp + @sed -i "s|__PROJECT_PACKAGE__|$(PROJECT_PACKAGE)|" jni/ewolAndroidAbstraction.cpp + + @echo " (ndk-build) build native code" + cd $(PROJECT_NDK) ; NDK_PROJECT_PATH=$(PROJECT_PATH) NDK_MODULE_PATH=$(PROJECT_MODULE) ./ndk-build + @echo " (ant) build java code" + PATH=$(PROJECT_SDK)/tools/:$(PROJECT_SDK)/platform-tools/:$(PATH) ant -Dsdk.dir=$(PROJECT_SDK) debug + @echo " (sh) Clear previous sources " + @rm -rf src jni/ewolAndroidAbstraction.cpp + +install: all + @echo "------------------------------------------------------------------------" + @echo ' INSTALL : ./bin/$(PROJECT_NAME)-debug.apk' + @echo "------------------------------------------------------------------------" + @# $(PROJECT_SDK)/platform-tools/adb kill-server + @# install application + sudo $(PROJECT_SDK)/platform-tools/adb install -r ./bin/$(PROJECT_NAME)-debug.apk + +clean: + @echo "------------------------------------------------------------------------" + @echo ' CLEANING : bin libs gen obj' + @echo "------------------------------------------------------------------------" + cd $(PROJECT_NDK) ; NDK_PROJECT_PATH=$(PROJECT_PATH) NDK_MODULE_PATH=$(PROJECT_MODULE) ./ndk-build clean + +localclean: + @echo "------------------------------------------------------------------------" + @echo ' Remove : bin libs gen obj' + @echo "------------------------------------------------------------------------" + rm -rf bin libs gen obj diff --git a/Makefile.Linux.mk b/Makefile.Linux.mk new file mode 100644 index 0000000..6d59f3d --- /dev/null +++ b/Makefile.Linux.mk @@ -0,0 +1,37 @@ + +USER_PACKAGES += $(EWOL_FOLDER)/Sources/ + +include $(EWOL_FOLDER)/Build/coreLinux/main.mk + + +# http://alp.developpez.com/tutoriels/debian/creer-paquet/ +#package: .encadrer +# @echo 'Create Folders ...' +# @mkdir -p package/$(PROJECT_NAME)/DEBIAN/ +# @mkdir -p package/$(PROJECT_NAME)/usr/bin/ +# @mkdir -p package/$(PROJECT_NAME)/usr/share/doc/ +# @mkdir -p package/$(PROJECT_NAME)/usr/share/edn/ +# # Create the control file +# @echo "Package: "$(PROJECT_NAME) > package/$(PROJECT_NAME)/DEBIAN/control +# @echo "Version: "$(VERSION_TAG_SHORT) >> package/$(PROJECT_NAME)/DEBIAN/control +# @echo "Section: Development,Editors" >> package/$(PROJECT_NAME)/DEBIAN/control +# @echo "Priority: optional" >>package/$(PROJECT_NAME)/DEBIAN/control +# @echo "Architecture: all" >> package/$(PROJECT_NAME)/DEBIAN/control +# @echo "Depends: bash" >> package/$(PROJECT_NAME)/DEBIAN/control +# @echo "Maintainer: Mr DUPIN Edouard " >> package/$(PROJECT_NAME)/DEBIAN/control +# @echo "Description: Text editor for sources code with ctags management" >> package/$(PROJECT_NAME)/DEBIAN/control +# @echo "" >> package/$(PROJECT_NAME)/DEBIAN/control +# # Create the PostRm +# @echo "#!/bin/bash" > package/$(PROJECT_NAME)/DEBIAN/postrm +# @echo "rm ~/."$(PROJECT_NAME) >> package/$(PROJECT_NAME)/DEBIAN/postrm +# @echo "" >> package/$(PROJECT_NAME)/DEBIAN/postrm +# # Enable Execution in script +# @chmod 755 package/$(PROJECT_NAME)/DEBIAN/post* +# @#chmod 755 package/$(PROJECT_NAME)/DEBIAN/pre* +# # copy licence and information : +# @cp README package/$(PROJECT_NAME)/usr/share/doc/README +# @cp licence.txt package/$(PROJECT_NAME)/usr/share/doc/copyright +# @echo "First generation in progress" >> package/$(PROJECT_NAME)/usr/share/doc/changelog +# @cp -vf $(PROJECT_NAME) package/$(PROJECT_NAME)/usr/bin/ +# @cp -vf data/*.xml package/$(PROJECT_NAME)/usr/share/edn/ +# @cd package; dpkg-deb --build $(PROJECT_NAME) diff --git a/Makefile.mk b/Makefile.mk new file mode 100644 index 0000000..66557ec --- /dev/null +++ b/Makefile.mk @@ -0,0 +1,35 @@ + +############################################################################### +### Platform specificity : ### +############################################################################### +SUPPORTED_PLATFORM=Linux CygWin MacOS IOS Android +DEFAULT_PLATFORM=Linux + +# default platform can be overridden +PLATFORM?=$(DEFAULT_PLATFORM) + +PROJECT_PATH=$(shell pwd) + +PROJECT_MODULE=$(PROJECT_PATH)/../ + +ifeq ($(PLATFORM), Linux) + PROJECT_NDK?=$(realpath $(PROJECT_MODULE)/ewol/) +else ifeq ($(PLATFORM), MacOS) + +else ifeq ($(PLATFORM), IOS) + +else ifeq ($(PLATFORM), CygWin) + +else ifeq ($(PLATFORM), Android) + PROJECT_NDK:=$(PROJECT_MODULE)/android/ndk/ + PROJECT_SDK:=$(PROJECT_MODULE)/android/sdk/ +else + $(error you must specify a corect platform : make PLATFORM=$(SUPPORTED_PLATFORM)) +endif + +# get the compilation date and time : +BUILD_TIME=$(shell date) + +EWOL_FOLDER?=$(realpath $(PROJECT_MODULE)/ewol) + +include $(EWOL_FOLDER)/Build/Makefile.$(PLATFORM).mk diff --git a/coreLinux/clearvars.mk b/coreLinux/clearvars.mk new file mode 100644 index 0000000..12738a3 --- /dev/null +++ b/coreLinux/clearvars.mk @@ -0,0 +1,17 @@ +############################################################################### +## @file clearvars.mk +## @author Y.M. Morgan +## @date 2011/05/14 +## +## Clear out values of all variables used by rule templates. +############################################################################### + +# Do NOT clear LOCAL_PATH, it is set BEFORE including this makefile + +$(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)) diff --git a/coreLinux/conf b/coreLinux/conf new file mode 100755 index 0000000..fbb9373 Binary files /dev/null and b/coreLinux/conf differ diff --git a/coreLinux/config.mk b/coreLinux/config.mk new file mode 100644 index 0000000..fc7aa79 --- /dev/null +++ b/coreLinux/config.mk @@ -0,0 +1,330 @@ +############################################################################### +## @file config.mk +## @author Y.M. Morgan +## @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 + +############################################################################### +## 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. +############################################################################### + +# 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 + +############################################################################### +## Load configuration of a module. +## Simply evaluate a call to simplify job of caller. +############################################################################### +load-config = $(eval $(call __load-config-internal,$(LOCAL_MODULE))) + +############################################################################### +## Rules. +############################################################################### + +# 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 + +# 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}; \ + ) + +# 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; \ + ) + diff --git a/coreLinux/defs.mk b/coreLinux/defs.mk new file mode 100644 index 0000000..7890cbf --- /dev/null +++ b/coreLinux/defs.mk @@ -0,0 +1,553 @@ +############################################################################### +## @file defs.mk +## @author Y.M. Morgan +## @date 2011/05/14 +## +## This file contains macros used by other makefiles. +############################################################################### + +############################################################################### +## 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. 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 +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 +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. +############################################################################### + +# 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 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 $@) +$(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) \ + $(TARGET_PCH_FLAGS) -MMD -MP -o $@ \ + $(call path-from-top,$<) +endef + +############################################################################### +## Commands for running gcc to compile a C++ file. +############################################################################### + +define transform-cpp-to-o +@mkdir -p $(dir $@) +$(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 $@ \ + $(call path-from-top,$<) +endef + +############################################################################### +## Commands for running gcc to compile a C file. +############################################################################### + +define transform-c-to-o +$(call print-banner1,"$(PRIVATE_ARM_MODE) C",$(PRIVATE_MODULE),$(call path-from-top,$<)) +$(call check-pwd-is-top-dir) +@mkdir -p $(dir $@) +$(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 + +############################################################################### +## Commands for running gcc to compile a S file. +############################################################################### + +define transform-s-to-o +$(call print-banner1,"ASM",$(PRIVATE_MODULE),$(call path-from-top,$<)) +$(call check-pwd-is-top-dir) +@mkdir -p $(dir $@) +$(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 + +############################################################################### +## Commands for running ar. +############################################################################### + +# Explicitly delete the archive first so that ar doesn't +# try to add to an existing archive. +define transform-o-to-static-lib +@mkdir -p $(dir $@) +$(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) $@ $(PRIVATE_ALL_OBJECTS) +endef + +############################################################################### +## Commands for running gcc to link a shared library. +############################################################################### + +define transform-o-to-shared-lib +@mkdir -p $(dir $@) +$(call print-banner2,"SharedLib",$(PRIVATE_MODULE),$(call path-from-top,$@)) +$(call check-pwd-is-top-dir) +$(Q)$(GXX) \ + $(TARGET_GLOBAL_LDFLAGS_SHARED) \ + -Wl,-Map -Wl,$(basename $@).map \ + -shared \ + -Wl,-soname -Wl,$(notdir $@) \ + -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) \ + $(TARGET_GLOBAL_LDLIBS_SHARED) +endef + +############################################################################### +## Commands for running gcc to link an executable. +############################################################################### + +define transform-o-to-executable +@mkdir -p $(dir $@) +$(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) \ + -o $@ \ + $(PRIVATE_LDLIBS) \ + $(TARGET_GLOBAL_LDLIBS) +endef + +############################################################################### +## Commands for copying files. +############################################################################### + +# Copy a single file from one place to another, preserving permissions and +# overwriting any existing file. +define copy-file-to-target +@mkdir -p $(dir $@) +$(Q)cp -fp $< $@ +endef + +# Define a rule to copy a file. For use via $(eval). +# $(1) : source file +# $(2) : destination file +define copy-one-file +$(2): $(1) + @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 callable from user makefiles. +############################################################################### + +# 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))) \ No newline at end of file diff --git a/coreLinux/executable.mk b/coreLinux/executable.mk new file mode 100644 index 0000000..8e9825b --- /dev/null +++ b/coreLinux/executable.mk @@ -0,0 +1,16 @@ +############################################################################### +## @file executable.mk +## @author Y.M. Morgan +## @date 2011/05/14 +## +## Build an executable. +############################################################################### + +LOCAL_MODULE_CLASS := EXECUTABLE +LOCAL_DESTDIR := usr/bin + +ifndef LOCAL_MODULE_FILENAME +LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_EXE_SUFFIX) +endif + +$(call module-add,$(LOCAL_MODULE)) diff --git a/coreLinux/main.mk b/coreLinux/main.mk new file mode 100644 index 0000000..dad8cdc --- /dev/null +++ b/coreLinux/main.mk @@ -0,0 +1,220 @@ +############################################################################### +## @file main.mk +## @author Y.M. Morgan +## @date 2011/05/14 +## +## Main Makefile. +############################################################################### + +############################################################################### +## General setup. +############################################################################### + +# Make sure SHELL is correctly set +SHELL := /bin/bash + +# Turns off suffix rules built into make +.SUFFIXES: + +# Tools for target +GCC ?= $(CROSS)gcc +GXX ?= $(CROSS)g++ +AR ?= $(CROSS)ar +LD ?= $(CROSS)ld +NM ?= $(CROSS)nm +STRIP ?= $(CROSS)strip + +# 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 +USE_CLANG := 0 +USE_CCACHE := 0 + +# Quiet command if V is 0 +ifeq ("$(V)","0") + Q := @ +endif + +# This is the default target. It must be the first declared target. +all: + +# 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 +## only after. +############################################################################### + +# 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 warnings flags +include $(BUILD_SYSTEM)/warnings.mk + +# Load configuration +include $(BUILD_SYSTEM)/config.mk + +# 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 +BUILD_EXECUTABLE := $(BUILD_SYSTEM)/executable.mk +RULES := $(BUILD_SYSTEM)/rules.mk + +############################################################################### +## Makefile scan and includes. +############################################################################### +ifeq ("$(DEBUG)","1") + BUILD_DIRECTORY_MODE := debug +else + BUILD_DIRECTORY_MODE := release +endif + +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 + +# 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 + +# 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. +############################################################################### + +# 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 + +############################################################################### +# Main rules. +############################################################################### + +.PHONY: all +all: $(foreach __mod,$(__modules),$(__mod)) $(AUTOCONF_MERGE_FILE) + +.PHONY: clean +clean: $(foreach __mod,$(__modules),clean-$(__mod)) + @rm -f $(AUTOCONF_MERGE_FILE) + @rm -f $(USER_MAKEFILES) + +# 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" + +# 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 ----------------------------------------------------------------------) +$(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 ----------------------------------------------------------------------) diff --git a/coreLinux/make-autoconf.sh b/coreLinux/make-autoconf.sh new file mode 100755 index 0000000..462a555 --- /dev/null +++ b/coreLinux/make-autoconf.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ "$#" != "2" ]; then + echo "Usage : $0 " + 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 + + diff --git a/coreLinux/make-final.py b/coreLinux/make-final.py new file mode 100755 index 0000000..965ad15 --- /dev/null +++ b/coreLinux/make-final.py @@ -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] " + 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() + diff --git a/coreLinux/module.mk b/coreLinux/module.mk new file mode 100644 index 0000000..d0d2b35 --- /dev/null +++ b/coreLinux/module.mk @@ -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 + diff --git a/coreLinux/qconf b/coreLinux/qconf new file mode 100755 index 0000000..9309ef4 Binary files /dev/null and b/coreLinux/qconf differ diff --git a/coreLinux/rules.mk b/coreLinux/rules.mk new file mode 100644 index 0000000..2a5d1b8 --- /dev/null +++ b/coreLinux/rules.mk @@ -0,0 +1,307 @@ +############################################################################### +## @file rules.mk +## @author Y.M. Morgan +## @date 2011/05/14 +## +## 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 +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 +LOCAL_C_INCLUDES := -I$(build_dir) -I$(LOCAL_PATH) $(LOCAL_C_INCLUDES) + +############################################################################### +## 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 $(build_dir)/,$(cpp_sources:.cpp=.o)) + +cxx_sources := $(filter %.cxx,$(LOCAL_SRC_FILES)) +cxx_objects := $(addprefix $(build_dir)/,$(cxx_sources:.cxx=.o)) + +c_sources := $(filter %.c,$(LOCAL_SRC_FILES)) +c_objects := $(addprefix $(build_dir)/,$(c_sources:.c=.o)) + +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) \ + $(s_objects) \ + $(S_objects) \ + +# 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) + +# 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), \ + $(call module-get-staging-filename,$(lib))) +all_static_libraries := \ + $(foreach lib,$(LOCAL_STATIC_LIBRARIES), \ + $(call module-get-staging-filename,$(lib))) +all_whole_static_libraries := \ + $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \ + $(call module-get-staging-filename,$(lib))) + +all_external_libraries := \ + $(foreach lib,$(LOCAL_EXTERNAL_LIBRARIES), \ + $(TARGET_OUT_BUILD)/$(lib)/$(lib).done) + +# all_libraries is used for the dependencies. +all_libraries := \ + $(all_shared_libraries) \ + $(all_static_libraries) \ + $(all_whole_static_libraries) \ + $(all_external_libraries) \ + +############################################################################### +## Import of dependencies. +############################################################################### + +# Get all modules we depend on +all_depends := $(call module-get-all-dependencies,$(LOCAL_MODULE)) +all_depends := $(filter-out $(LOCAL_MODULE),$(all_depends)) + +# 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) + +# 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)) + +# 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 -----) + +# 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)) + +# 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)) + +# Force their inclusion (space after -include and before comma is important) +LOCAL_CFLAGS += $(addprefix -include ,$(all_autoconf)) + +# 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. +############################################################################### + +# cpp files +ifneq ("$(strip $(cpp_objects))","") +$(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): $(build_dir)/%.o: $(LOCAL_PATH)/%.cxx + $(transform-cpp-to-o) +-include $(cxx_objects:%.o=%.d) +endif + +# c files +ifneq ("$(strip $(c_objects))","") +$(c_objects): $(build_dir)/%.o: $(LOCAL_PATH)/%.c + $(transform-c-to-o) +-include $(c_objects:%.o=%.d) +endif + +# 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 + +# 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 := \ + $(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. +.PHONY: $(LOCAL_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. +############################################################################### + +LOCAL_PRECOMPILED_FILE := $(strip $(LOCAL_PRECOMPILED_FILE)) +ifneq ("$(LOCAL_PRECOMPILED_FILE)","") + +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): $(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_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) + diff --git a/coreLinux/setup.mk b/coreLinux/setup.mk new file mode 100644 index 0000000..4abf7a0 --- /dev/null +++ b/coreLinux/setup.mk @@ -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 diff --git a/coreLinux/shared.mk b/coreLinux/shared.mk new file mode 100644 index 0000000..5a315e5 --- /dev/null +++ b/coreLinux/shared.mk @@ -0,0 +1,16 @@ +############################################################################### +## @file shared.mk +## @author Y.M. Morgan +## @date 2011/05/14 +## +## Build a shared library. +############################################################################### + +LOCAL_MODULE_CLASS := SHARED_LIBRARY +LOCAL_DESTDIR := usr/lib + +ifndef LOCAL_MODULE_FILENAME +LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_SHARED_LIB_SUFFIX) +endif + +$(call module-add,$(LOCAL_MODULE)) diff --git a/coreLinux/static.mk b/coreLinux/static.mk new file mode 100644 index 0000000..7f28206 --- /dev/null +++ b/coreLinux/static.mk @@ -0,0 +1,16 @@ +############################################################################### +## @file static.mk +## @author Y.M. Morgan +## @date 2011/05/14 +## +## Build a static library. +############################################################################### + +LOCAL_MODULE_CLASS := STATIC_LIBRARY +LOCAL_DESTDIR := usr/lib + +ifndef LOCAL_MODULE_FILENAME +LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)$(TARGET_STATIC_LIB_SUFFIX) +endif + +$(call module-add,$(LOCAL_MODULE)) diff --git a/coreLinux/warnings.mk b/coreLinux/warnings.mk new file mode 100644 index 0000000..69af9d0 --- /dev/null +++ b/coreLinux/warnings.mk @@ -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) +