2012-07-17 10:00:54 +02:00
|
|
|
###############################################################################
|
|
|
|
## @file main.mk
|
2012-08-18 21:07:46 +02:00
|
|
|
## @author Edouard DUPIN
|
|
|
|
## @date 17-08-2012
|
|
|
|
## @project EWOL
|
2012-07-17 10:00:54 +02:00
|
|
|
##
|
|
|
|
## Main Makefile.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
## General setup.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Make sure SHELL is correctly set
|
|
|
|
SHELL := /bin/bash
|
|
|
|
|
2012-08-16 18:18:40 +02:00
|
|
|
# This is the default target. It must be the first declared target.
|
|
|
|
all:
|
|
|
|
|
2012-07-17 10:00:54 +02:00
|
|
|
# Turns off suffix rules built into make
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
# Overridable settings
|
|
|
|
V := 0
|
|
|
|
W := 0
|
2012-08-30 18:23:57 +02:00
|
|
|
# debug mode of the software
|
2012-07-17 10:00:54 +02:00
|
|
|
DEBUG := 0
|
2012-08-30 18:23:57 +02:00
|
|
|
# compilation done with Clang system instead of gcc
|
2012-07-23 09:05:16 +02:00
|
|
|
CLANG := 0
|
2012-07-17 10:00:54 +02:00
|
|
|
|
|
|
|
# Quiet command if V is 0
|
|
|
|
ifeq ("$(V)","0")
|
|
|
|
Q := @
|
|
|
|
endif
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
## Build system setup.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Directories (full path)
|
|
|
|
TOP_DIR := $(shell pwd)
|
2012-11-10 16:17:06 +01:00
|
|
|
BUILD_SYSTEM := $(BUILD_SYSTEM)/core
|
2012-07-17 10:00:54 +02:00
|
|
|
|
2012-08-31 16:47:49 +02:00
|
|
|
ifeq ("$(DEBUG)","1")
|
|
|
|
BUILD_DIRECTORY_MODE := debug
|
|
|
|
else
|
|
|
|
BUILD_DIRECTORY_MODE := release
|
|
|
|
endif
|
|
|
|
|
2012-07-17 10:00:54 +02:00
|
|
|
# Setup configuration
|
2012-08-18 21:07:46 +02:00
|
|
|
include $(BUILD_SYSTEM)/setup-host.mk
|
|
|
|
include $(BUILD_SYSTEM)/setup-target.mk
|
2012-07-17 10:00:54 +02:00
|
|
|
include $(BUILD_SYSTEM)/setup.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
|
2012-08-18 21:07:46 +02:00
|
|
|
BUILD_STATIC_LIBRARY := $(BUILD_SYSTEM)/build-static.mk
|
|
|
|
BUILD_SHARED_LIBRARY := $(BUILD_SYSTEM)/build-shared.mk
|
|
|
|
BUILD_EXECUTABLE := $(BUILD_SYSTEM)/build-executable.mk
|
|
|
|
BUILD_PREBUILT := $(BUILD_SYSTEM)/build-prebuilt.mk
|
2012-08-17 18:30:11 +02:00
|
|
|
BUILD_RULES := $(BUILD_SYSTEM)/rules.mk
|
2012-07-17 10:00:54 +02:00
|
|
|
|
2012-11-04 15:42:11 +01:00
|
|
|
|
|
|
|
|
2012-07-17 10:00:54 +02:00
|
|
|
###############################################################################
|
|
|
|
## Makefile scan and includes.
|
|
|
|
###############################################################################
|
2012-08-31 16:47:49 +02:00
|
|
|
|
|
|
|
TARGET_OUT_BUILD ?= $(shell pwd)/out/$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/obj
|
|
|
|
TARGET_OUT_STAGING ?= $(shell pwd)/out/$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/staging
|
|
|
|
TARGET_OUT_FINAL ?= $(shell pwd)/out/$(TARGET_OS)/$(BUILD_DIRECTORY_MODE)/final
|
2012-07-17 10:00:54 +02:00
|
|
|
|
2012-11-04 15:42:11 +01:00
|
|
|
|
2012-11-11 20:39:29 +01:00
|
|
|
# Note : Yhis permit to create a recursive search of all the .mk existed ==> but speed is really slow in Windows
|
|
|
|
ifeq ("$(USE_RECURSIVE_FIND)","1")
|
2012-08-15 20:35:50 +02:00
|
|
|
# Get the list of all makefiles available and include them this find the TARGET_OS.mk and the Generic.mk
|
|
|
|
_moduleFolder = $(shell find $(USER_PACKAGES) -name $(TARGET_OS).mk)
|
|
|
|
_moduleFolder += $(shell find $(USER_PACKAGES) -name Generic.mk)
|
|
|
|
# only keep one folder for each makefile found.
|
|
|
|
_tmpDirectory = $(sort $(dir $(_moduleFolder)))
|
2012-11-11 20:39:29 +01:00
|
|
|
else
|
|
|
|
_tmpDirectory := $(sort $(USER_PACKAGES))
|
|
|
|
endif
|
2012-08-15 20:35:50 +02:00
|
|
|
# this section have all the makefile possible for a specific target,
|
|
|
|
# this isolate the good makefile for every folder where a makefile present
|
|
|
|
# for each folder
|
|
|
|
# check if TARGET_OS.mk is present
|
|
|
|
# add it
|
|
|
|
# otherwise
|
|
|
|
# add generic makefile
|
|
|
|
$(foreach __makefile,$(_tmpDirectory), \
|
2012-11-11 20:39:29 +01:00
|
|
|
$(if $(wildcard $(__makefile)/$(TARGET_OS).mk), \
|
|
|
|
$(eval makefiles += $(__makefile)/$(TARGET_OS).mk) \
|
|
|
|
, \
|
|
|
|
$(if $(wildcard $(__makefile)/Generic.mk), \
|
|
|
|
$(eval makefiles += $(__makefile)/Generic.mk) \
|
|
|
|
) \
|
2012-08-15 20:35:50 +02:00
|
|
|
) \
|
|
|
|
)
|
2012-08-15 23:08:49 +02:00
|
|
|
ifeq ("$(V)","1")
|
2012-08-17 18:30:11 +02:00
|
|
|
$(info makefiles="$(makefiles)")
|
2012-08-15 23:08:49 +02:00
|
|
|
endif
|
2012-08-15 20:35:50 +02:00
|
|
|
# import all the makefiles
|
2012-07-23 10:17:02 +02:00
|
|
|
include $(makefiles)
|
2012-07-17 10:00:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Module dependencies generation.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Recompute all dependencies between modules
|
2012-08-17 18:30:11 +02:00
|
|
|
$(call modules-compute-depends)
|
|
|
|
|
|
|
|
# Check dependencies
|
|
|
|
$(call modules-check-depends)
|
2012-07-17 10:00:54 +02:00
|
|
|
|
2012-08-17 18:30:11 +02:00
|
|
|
# Check variables of modules
|
|
|
|
$(call modules-check-variables)
|
|
|
|
|
2012-07-17 10:00:54 +02:00
|
|
|
###############################################################################
|
|
|
|
# Rule to merge autoconf.h files.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Concatenate all in one
|
2012-08-31 16:47:49 +02:00
|
|
|
AUTOCONF_FILE := $(TARGET_OUT_BUILD)/autoconf.h
|
|
|
|
$(AUTOCONF_FILE): $(CONFIG_GLOBAL_FILE)
|
2012-07-17 10:00:54 +02:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@rm -f $@
|
2012-08-31 16:47:49 +02:00
|
|
|
@$(call generate-autoconf-file,$^,$@)
|
|
|
|
|
|
|
|
|
|
|
|
# Now, really generate rules for modules.
|
|
|
|
# This second pass allows to deal with exported values.
|
|
|
|
$(foreach __mod,$(__modules), \
|
|
|
|
$(eval LOCAL_MODULE := $(__mod)) \
|
|
|
|
$(eval include $(BUILD_SYSTEM)/module.mk) \
|
|
|
|
)
|
2012-07-17 10:00:54 +02:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Main rules.
|
|
|
|
###############################################################################
|
|
|
|
|
2012-08-17 18:30:11 +02:00
|
|
|
# All modules
|
|
|
|
ALL_MODULES := \
|
|
|
|
$(foreach __mod,$(__modules),$(__mod))
|
|
|
|
|
2012-08-31 16:47:49 +02:00
|
|
|
#TODO check this ...
|
|
|
|
|
2012-08-17 18:30:11 +02:00
|
|
|
# All module to actually build
|
|
|
|
ALL_BUILD_MODULES := \
|
|
|
|
$(foreach __mod,$(__modules), \
|
|
|
|
$(if $(call is-module-in-build-config,$(__mod)),$(__mod)))
|
|
|
|
|
2012-11-11 20:39:29 +01:00
|
|
|
ifeq ("$(V)","1")
|
|
|
|
$(info ALL_BUILD_MODULES=$(ALL_BUILD_MODULES))
|
|
|
|
endif
|
2012-10-27 17:44:05 +02:00
|
|
|
|
2012-08-17 18:30:11 +02:00
|
|
|
# TODO : Set ALL_BUILD_MODULES ==> find the end point module (SHARED/BINARY)
|
2012-07-17 10:00:54 +02:00
|
|
|
.PHONY: all
|
2012-09-13 09:52:20 +02:00
|
|
|
all: $(ALL_BUILD_MODULES)
|
2012-07-17 10:00:54 +02:00
|
|
|
|
|
|
|
.PHONY: clean
|
2012-08-17 18:30:11 +02:00
|
|
|
clean: $(foreach __mod,$(ALL_MODULES),clean-$(__mod))
|
2012-07-17 10:00:54 +02:00
|
|
|
@rm -f $(AUTOCONF_MERGE_FILE)
|
|
|
|
|
|
|
|
# Dump the module database for debuging the build system
|
|
|
|
.PHONY: dump
|
|
|
|
dump:
|
|
|
|
$(call modules-dump-database)
|
|
|
|
|
2012-08-17 18:30:11 +02:00
|
|
|
# Dump the module database for debuging the build system
|
|
|
|
.PHONY: dump-depends
|
|
|
|
dump-depends:
|
|
|
|
$(call modules-dump-database-depends)
|
|
|
|
|
|
|
|
# Dummy target to check internal variables
|
|
|
|
.PHONY: check
|
|
|
|
check:
|
|
|
|
|
2012-07-17 10:00:54 +02:00
|
|
|
###############################################################################
|
|
|
|
# Display configuration.
|
|
|
|
###############################################################################
|
|
|
|
$(info ----------------------------------------------------------------------)
|
2012-07-23 09:39:07 +02:00
|
|
|
$(info HOST_OS: $(HOST_OS))
|
|
|
|
$(info TARGET_OS: $(TARGET_OS))
|
|
|
|
$(info TARGET_ARCH: $(TARGET_ARCH))
|
|
|
|
$(info TARGET_OUT_BUILD: $(TARGET_OUT_BUILD))
|
|
|
|
$(info TARGET_OUT_STAGING: $(TARGET_OUT_STAGING))
|
|
|
|
$(info TARGET_OUT_FINAL: $(TARGET_OUT_FINAL))
|
2012-08-17 18:30:11 +02:00
|
|
|
$(info TARGET_CC_PATH: $(TARGET_CC_PATH))
|
|
|
|
$(info TARGET_CC_VERSION: $(TARGET_CC_VERSION))
|
2012-07-17 10:00:54 +02:00
|
|
|
$(info ----------------------------------------------------------------------)
|