# Makefile.rules - OCERA make framework common project rules # This version is adapted for SDCC build # # (C) Copyright 2003-2005 by Pavel Pisa - OCERA team member # # The uLan driver is distributed under the Gnu General Public License. # See file COPYING for details. # # # input variables # V .. if set to 1, full command text is shown else short form is used # SUBDIRS .. list of subdirectories intended for make from actual directory # lib_LIBRARIES .. list of the user-space libraries # lib_LDSCRIPTS .. list of LD scripts that should be copied to the lib direcotry # shared_LIBRARIES .. list of the user-space shared libraries # include_HEADERS .. list of the user-space public header files # nobase_include_HEADERS .. public headers copied even with directory part # renamed_include_HEADERS .. public headers copied to the different target name # asm_build_HEADERS .. list of files copied to the build object directory # bin_PROGRAMS .. list of the require binary programs # utils_PROGRAMS .. list of the development utility programs # xxx_SOURCES .. list of specific target sources # INCLUDES .. additional include directories and defines for user-space # default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ... # tar_EMBEDFILES .. list of tars with embedded files # link_VARIANTS .. list of ld script suffixes (after hypen `-') that # should be used for linking (e.g. ram flash). If this is not # specified, then the value of DEFAULT_LD_SCRIPT_VARIANT from config.target is used. # BUILD_DIR_NAME = _build COMPILED_DIR_NAME = _compiled GROUP_DIR_NAME = CC = sdcc OBJ_EXT = .rel LIB_EXT = .lib LIB_PREF = AR = sdcclib AS = asx8051 HC = packihx TOHIT = ul_sendhex ARFLAGS = -a A51TOASX = $(MAKERULES_DIR)/a51toasx.sh # We need to ensure definition of sources directory first ifndef SOURCES_DIR SOURCES_DIR := $(shell ( pwd -L ) ) endif all: default USER_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include USER_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib USER_UTILS_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin-utils USER_BIN_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin USER_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/user ifndef CONFIG_FILE CONFIG_FILE := $(MAKERULES_DIR)/config.omk endif ifneq ($(wildcard $(CONFIG_FILE)-default),) -include $(CONFIG_FILE)-default else $(warning Please, run "make default-config" first) endif ifneq ($(wildcard $(CONFIG_FILE)),) include $(CONFIG_FILE) CONFIG_FILE_OK = y endif # Check and include real OCERA style Makefile.omk now ifndef OMK_INCLUDED include $(SOURCES_DIR)/Makefile.omk OMK_INCLUDED := 1 endif export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR export CONFIG_FILE OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT export MOD #CFLAGS += -ggdb #CFLAGS += -O2 #CFLAGS += -Wall #CXXFLAGS += -ggdb #CXXFLAGS += -O2 #CXXFLAGS += -Wall #DEFAULT_INCLUDES = -I $(PROJECT_INCLUDE) CPPFLAGS += -I $(USER_INCLUDE_DIR) CPPFLAGS += $(CONFIG_OMK_DEFINES) #CPPFLAGS += $(AM_CPPFLAGS) #CFLAGS += $(AM_CFLAGS) #CXXFLAGS += $(AM_CXXFLAGS) #LDFLAGS += $(CFLAGS) $(AM_CFLAGS) $(LD_PATHS:%=-L%) CFLAGS += $(TARGET_ARCH) LDFLAGS += $(TARGET_ARCH) LOADLIBES += -L$(USER_LIB_DIR) LOADLIBES += $(lib_LOADLIBES:%=-l%) SOLIB_PICFLAGS += -shared -fpic ifndef RELATIVE_DIR RELATIVE_DIR := $(SOURCES_DIR:$(MAKERULES_DIR)%=%) endif override RELATIVE_DIR := $(RELATIVE_DIR:/%=%) override RELATIVE_DIR := $(RELATIVE_DIR:\\%=%) #$(warning RELATIVE_DIR $(RELATIVE_DIR)) override BACK2TOP_DIR := $(shell echo $(RELATIVE_DIR)/ | sed -e 's_//_/_g' -e 's_/\./_/_g' -e 's_^\./__g' -e 's_\([^/][^/]*\)_.._g' -e 's_/$$__') #$(warning BACK2TOP_DIR $(BACK2TOP_DIR)) #$(warning SOURCES_DIR = $(SOURCES_DIR)) #$(warning MAKERULES_DIR = $(MAKERULES_DIR)) #$(warning RELATIVE_DIR = $(RELATIVE_DIR)) override RELATIVE_PREFIX := $(RELATIVE_DIR)/ override RELATIVE_PREFIX := $(RELATIVE_PREFIX:/%=%) #vpath %.c $(SOURCES_DIR) #vpath %.cc $(SOURCES_DIR) VPATH = $(SOURCES_DIR) srcdir = $(SOURCES_DIR) USER_OBJS_DIR = $(USER_BUILD_DIR)/$(RELATIVE_DIR) .PHONY: default dep subdirs clean cleandepend default-config .PHONY: check-make-ver check-dir include-pass library-pass binary-pass utils-pass .PHONY: default-config-pass .PHONY: check-dir-local include-pass-local library-pass-local binary-pass-local .PHONY: utils-pass-local default-config-pass-local # Some support to serialize some targets for parallel make ifneq ($(OMK_SERIALIZE_INCLUDED),y) include-pass: check-dir library-pass: include-pass binary-pass utils-pass: library-pass OMK_SERIALIZE_INCLUDED = y endif # Defines for quiet compilation ifdef V ifeq ("$(origin V)", "command line") OMK_VERBOSE = $(V) endif endif ifndef OMK_VERBOSE OMK_VERBOSE = 0 endif ifeq ($(OMK_VERBOSE),1) Q = else Q = @ endif ifneq ($(findstring s,$(MAKEFLAGS)),) QUIET_CMD_ECHO = true OMK_SILENT = 1 else QUIET_CMD_ECHO = echo CPHEADER_FLAGS += -v endif default: check-make-ver check-dir include-pass library-pass binary-pass utils-pass #===================================================================== # Common utility rules define mkdir_def [ -d $(1) ] || mkdir -p $(1) || exit 1 endef # Syntax: $(call BUILD_CONFIG_H_template,,,) define BUILD_CONFIG_H_template $(1) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default) @$(QUIET_CMD_ECHO) " CONFGEN $$@ in `pwd`" @if [ ! -d `dirname $(1).tmp` ] ; then \ mkdir `dirname $(1).tmp` ; fi @echo "/* Automatically generated from */" > "$(1).tmp" @echo "/* config file : $< */" >> "$(1).tmp" @echo "#ifndef $(3)" >> "$(1).tmp" @echo "#define $(3)" >> "$(1).tmp" @( $(foreach x, $(shell echo '$($(2))' | sed -e 's/\<\([^ =]*\)\(=[^ ]\+\|\)\>/\1/g' ), \ echo '$(x).$($(x))' ; ) echo ; ) | \ sed -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \ sed -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \ >> "$(1).tmp" @echo "#endif /*$(3)*/" >> "$(1).tmp" @if cmp --quiet "$(1).tmp" "$(1)" ; then \ echo rm "$(1).tmp" ; \ else mv "$(1).tmp" "$(1)" ; \ echo Updated configuration "$(1)" ; fi endef ifdef LOCAL_CONFIG_H $(eval $(call BUILD_CONFIG_H_template,$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) ) endif check-make-ver: @GOOD_MAKE_VERSION=`echo $(MAKE_VERSION) | sed -n -e 's/^[4-9]\..*\|^3\.9[0-9].*\|^3\.8[1-9].*/y/p'` ; \ if [ x$$GOOD_MAKE_VERSION != xy ] ; then \ echo "Your make program version is too old and does not support OMK system." ; \ echo "Please update to make program 3.81beta1 or newer." ; exit 1 ; \ fi link_VARIANTS ?= $(DEFAULT_LD_SCRIPT_VARIANT) #===================================================================== # Special rules for target filesystem and data preparation define TARFILE_template .PHONY: $(2) $(2): $(Q) ABSOLUTETARFILE=`cd $$(dir $$@) ; pwd`/$$@ ; \ ( test -e $$$$ABSOLUTETARFILE && ( cd $(3) && tar -df $$$$ABSOLUTETARFILE ) ) || \ ( cd $(3) && tar -cf $$$$ABSOLUTETARFILE . ) $(2)$(OBJ_EXT): $(2) @$(QUIET_CMD_ECHO) " TARFILE $$@" $(Q) $(OBJCOPY) -I binary -O elf32-littlearm $$^ $$@ endef #===================================================================== # User-space rules and templates to compile programs, libraries etc. ifdef USER_RULE_TEMPLATES #%.lo: %.c # $(CC) -o $@ $(LCFLAGS) -c $< c_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(INCLUDES) -DOMK_FOR_USER cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CXXFLAGS) $(CFLAGS) $(INCLUDES) -DOMK_FOR_USER # Check GCC version for user build ifndef CC_MAJOR_VERSION CC_MAJOR_VERSION := sdcc endif # Prepare suitable define for dependency building #CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp" # Syntax: $(call COMPILE_c_o_template,,,) define COMPILE_c_o_template $(2): $(1) $(LOCAL_CONFIG_H) @$(QUIET_CMD_ECHO) " CC $$@" $(Q) if $$(c_o_COMPILE) $(3) -o "$$@" -c $$< ; \ then $$(c_o_COMPILE) $(3) -M $$< > "$$@.d" ; \ else exit 1; \ fi endef # Syntax: $(call COMPILE_cc_o_template,,,) define COMPILE_cc_o_template $(2): $(1) $(LOCAL_CONFIG_H) @$(QUIET_CMD_ECHO) " CXX $$@" $(Q) echo "C++ compilation not suported for this compiler" endef # Syntax: $(call COMPILE_S_o_template,,,) define COMPILE_asm_o_template $(2): $(1) $(LOCAL_CONFIG_H) @$(QUIET_CMD_ECHO) " ASM $$@" $(Q) $$(A51TOASX) $(1) $(2:%$(OBJ_EXT)=%.s) $(Q) $$(AS) -l -o $(2:%$(OBJ_EXT)=%.s) endef # Syntax: $(call PROGRAM_template,,,,) define PROGRAM_template $(1)_OBJS += $$(filter %$(OBJ_EXT),$$($(1)_SOURCES:%.c=%$(OBJ_EXT))) $(1)_OBJS += $$(filter %$(OBJ_EXT),$$($(1)_SOURCES:%.cc=%$(OBJ_EXT))) $(1)_OBJS += $$(filter %$(OBJ_EXT),$$($(1)_SOURCES:%.asm=%$(OBJ_EXT))) $(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile$(OBJ_EXT)) $(1)_OBJS := $$(sort $$($(1)_OBJS)) USER_OBJS += $$($(1)_OBJS) USER_SOURCES += $$($(1)_SOURCES) USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES) -include $(USER_LIB_DIR)/$(LD_SCRIPT).ld$$(addprefix -,$(3)) $(2)/$(1)$(addprefix -,$(3)): $(USER_LIB_DIR)/timestamp $(2)/$(1)$(addprefix -,$(3)): $$($(1)_OBJS) @$(QUIET_CMD_ECHO) " LINK $$@" $(Q) $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES))" ] ; \ then echo $$(CC) $$(CPPFLAGS) $$(AM_CPPFLAGS) $$(AM_CFLAGS) $$(CFLAGS) ; \ else echo $$(CXX) $$(CPPFLAGS) $$(AM_CPPFLAGS) $$(AM_CXXFLAGS) $$(CXXFLAGS) ; fi) \ $$(AM_LDFLAGS) $$(LDFLAGS) $$($(1)_OBJS) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) \ -o $(2)/$(1)$(addprefix -,$(3)) $(HC) $(2)/$(1)$(addprefix -,$(3)) >$(2)/$(1)$(addprefix -,$(3)).hex hex2bin $(2)/$(1)$(addprefix -,$(3)).hex #@echo "$(2)/$(1): \\" >$(USER_OBJS_DIR)/$(1).exe.d #@sed -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(USER_OBJS_DIR)/$(1).exe.map >>$(USER_OBJS_DIR)/$(1).exe.d #@echo >>$(USER_OBJS_DIR)/$(1).exe.d #-Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map endef # Syntax: $(call LIBRARY_template,) define LIBRARY_template $(1)_OBJS += $$(filter %$(OBJ_EXT),$$($(1)_SOURCES:%.c=%$(OBJ_EXT))) $(1)_OBJS += $$(filter %$(OBJ_EXT),$$($(1)_SOURCES:%.cc=%$(OBJ_EXT))) $(1)_OBJS += $$(filter %$(OBJ_EXT),$$($(1)_SOURCES:%.asm=%$(OBJ_EXT))) $(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile$(OBJ_EXT)) $(1)_OBJS := $$(sort $$($(1)_OBJS)) USER_OBJS += $$($(1)_OBJS) USER_SOURCES += $$($(1)_SOURCES) USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES) $(USER_LIB_DIR)/$(LIB_PREF)$(1)$(LIB_EXT): $$($(1)_OBJS) @$(QUIET_CMD_ECHO) " AR $$@" $(Q) for i in $$^ ; do $(AR) $(ARFLAGS) $$@ $$$$i ; done @touch $(USER_LIB_DIR)/timestamp endef # Syntax: $(call SOLIB_template,) define SOLIB_template $(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.c=%.lo)) $(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.cc=%.lo)) $(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile$(OBJ_EXT)) $(1)_OBJSLO := $$(sort $$($(1)_OBJSLO)) SOLIB_OBJS += $$($(1)_OBJSLO) SOLIB_SOURCES += $$($(1)_SOURCES) USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES) $(USER_LIB_DIR)/lib$(1).so: $$($(1)_OBJSLO) @$(QUIET_CMD_ECHO) " LINK $$@" $(Q) $(LD) --shared --soname=lib$(1).so -o $$@ $$^ endef library-pass-local: $(lib_LIBRARIES:%=$(USER_LIB_DIR)/$(LIB_PREF)%$(LIB_EXT)) $(shared_LIBRARIES:%=$(USER_LIB_DIR)/$(LIB_PREF)%.so) binary-pass-local: $(foreach link,$(link_VARIANTS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%-$(link)) $(foreach of,$(OUTPUT_FORMATS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%-$(link).$(of)))) utils-pass-local: $(foreach link,$(link_VARIANTS),$(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%-$(link)) $(foreach of,$(OUTPUT_FORMATS),$(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%-$(link).$(of)))) $(foreach prog,$(utils_PROGRAMS),$(foreach link,$(link_VARIANTS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR),$(link))))) $(foreach prog,$(bin_PROGRAMS),$(foreach link,$(link_VARIANTS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR),$(link))))) $(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib)))) $(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib)))) -include $(USER_OBJS_DIR)/*.d endif #===================================================================== library-pass binary-pass utils-pass: +@$(foreach dir, $(SUBDIRS), $(call mkdir_def,$(USER_OBJS_DIR)/$(dir)) ; \ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(USER_OBJS_DIR)/$(dir) \ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;) +@$(call mkdir_def,$(USER_OBJS_DIR)) @$(MAKE) --no-print-directory -C $(USER_OBJS_DIR) \ -f $(SOURCES_DIR)/Makefile USER_RULE_TEMPLATES=y $(@:%=%-local) dep clean install check-dir include-pass default-config-pass: +@$(foreach dir, $(SUBDIRS), $(call mkdir_def,$(USER_OBJS_DIR)/$(dir)) ; \ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(USER_OBJS_DIR)/$(dir) \ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;) +@$(call mkdir_def,$(USER_OBJS_DIR)) @$(MAKE) --no-print-directory -C $(USER_OBJS_DIR) \ -f $(SOURCES_DIR)/Makefile $(@:%=%-local) dep-local: check-dir-local: @$(call mkdir_def,$(USER_OBJS_DIR)) @$(call mkdir_def,$(USER_INCLUDE_DIR)) @$(call mkdir_def,$(USER_LIB_DIR)) @$(call mkdir_def,$(USER_BIN_DIR)) @$(call mkdir_def,$(USER_UTILS_DIR)) install-local: default-config: @echo "# Start of OMK config file" > "$(CONFIG_FILE)-default" @echo "# This file should not be altered manually" >> "$(CONFIG_FILE)-default" @echo "# Overrides should be stored in file $(notdir $(CONFIG_FILE))" >> "$(CONFIG_FILE)-default" @echo >> "$(CONFIG_FILE)-default" @$(MAKE) --no-print-directory -C $(MAKERULES_DIR) \ RELATIVE_DIR="" SOURCES_DIR=$(MAKERULES_DIR) \ -f $(MAKERULES_DIR)/Makefile default-config-pass default-config-pass-local: @echo Default config for $(RELATIVE_DIR) @echo "# Config for $(RELATIVE_DIR)" >> "$(CONFIG_FILE)-default" @$(foreach x, $(default_CONFIG), echo '$(x)' | \ sed -e 's/^[^=]*=x$$/#\0/' >> "$(CONFIG_FILE)-default" ; ) include-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)) @$(call mkdir_def,$(USER_INCLUDE_DIR)) @$(foreach f, $(include_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(USER_INCLUDE_DIR)/$(notdir $(f)) \ || cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$(f) $(USER_INCLUDE_DIR)/$(notdir $(f)) || exit 1 ; ) @$(foreach f, $(nobase_include_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(USER_INCLUDE_DIR)/$(f) \ || ( mkdir -p $(USER_INCLUDE_DIR)/$(dir $(f)) && cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$(f) $(USER_INCLUDE_DIR)/$(f) ) || exit 1 ; ) @$(foreach f, $(renamed_include_HEADERS), \ srcfname=`echo '$(f)' | sed -e 's/^\(.*\)->.*$$/\1/'` ; destfname=`echo '$(f)' | sed -e 's/^.*->\(.*\)$$/\1/'` ; \ cmp --quiet $(SOURCES_DIR)/$${srcfname} $(USER_INCLUDE_DIR)/$${destfname} \ || ( mkdir -p `dirname $(USER_INCLUDE_DIR)/$${destfname}` && cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$${srcfname} $(USER_INCLUDE_DIR)/$${destfname} ) || exit 1 ; ) @$(foreach f, $(asm_build_HEADERS), \ srcfname=`echo '$(f)' | sed -e 's/^\(.*\)->.*$$/\1/'` ; destfname=`echo '$(f)' | sed -e 's/^.*->\(.*\)$$/\1/'` ; \ cmp --quiet $(SOURCES_DIR)/$${srcfname} $(USER_OBJS_DIR)/$${destfname} \ || ( mkdir -p `dirname $(USER_OBJS_DIR)/$${destfname}` && \ $(A51TOASX) $(SOURCES_DIR)/$${srcfname} $(USER_OBJS_DIR)/$${destfname} ) || exit 1 ; ) $(foreach f, $(lib_LDSCRIPTS), cmp --quiet $(SOURCES_DIR)/$(f) $(USER_LIB_DIR)/$(notdir $(f)) \ || cp $(CP_FLAGS) $(SOURCES_DIR)/$(f) $(USER_LIB_DIR)/$(notdir $(f)) || exit 1 ; ) ifdef USER_RULE_TEMPLATES # User-space static libraries and applications object files USER_SOURCES := $(sort $(USER_SOURCES)) #$(warning USER_SOURCES = $(USER_SOURCES)) $(foreach src,$(filter %.c,$(USER_SOURCES)),$(eval $(call COMPILE_c_o_template,$(SOURCES_DIR)/$(src),$(src:%.c=%$(OBJ_EXT)),))) $(foreach src,$(filter %.cc,$(USER_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%$(OBJ_EXT)),))) $(foreach src,$(filter %.asm,$(USER_SOURCES)),$(eval $(call COMPILE_asm_o_template,$(SOURCES_DIR)/$(src),$(src:%.asm=%$(OBJ_EXT)),))) # User-space shared libraries object files SOLIB_SOURCES := $(sort $(SOLIB_SOURCES)) #$(warning SOLIB_SOURCES = $(SOLIB_SOURCES)) $(foreach src,$(filter %.c,$(SOLIB_SOURCES)),$(eval $(call COMPILE_c_o_template,$(SOURCES_DIR)/$(src),$(src:%.c=%.lo),$(SOLIB_PICFLAGS)))) $(foreach src,$(filter %.cc,$(SOLIB_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%.lo),$(SOLIB_PICFLAGS)))) $(foreach src,$(filter %.asm,$(SOLIB_SOURCES)),$(eval $(call COMPILE_asm_o_template,$(SOURCES_DIR)/$(src),$(src:%.asm=%$(OBJ_EXT)),$(SOLIB_PICFLAGS)))) $(foreach tarfile,$(USER_EMBEDTARFILES),$(eval $(call TARFILE_template,$(tarfile),$(tarfile)_tarfile,$(SOURCES_DIR)/$(tarfile)))) endif #===================================================================== # Automatic loading of compiled program by issuing "make load" ifneq ($(OUTPUT_FORMATS),) # Select a file extension (e.g. .bin) for "make load" command to load. LOAD_EXTENSION = .$(firstword $(OUTPUT_FORMATS)) endif # Syntax: $(call LOAD_PROGRAM_template,,,) # Used to load program to the target hardware define LOAD_PROGRAM_template .PHONY: load-$(1)$(addprefix -,$(3)) -include $(USER_LIB_DIR)/$(LD_SCRIPT).ld$$(addprefix -,$(3)) load-$(1)$(addprefix -,$(3)): $(2)/$(1)$(addprefix -,$(3))$(LOAD_EXTENSION) @$(QUIET_CMD_ECHO) " LOAD $$<" @if [ -z "$$(LOAD_CMD$(addprefix -,$(3)))" ]; then echo "No command for loading applications to '$(3)' is specified."; exit 1; fi $(Q) $$(LOAD_CMD$(addprefix -,$(3))) $$< endef # Syntax: $(call LOAD__RUN_VARIANT_template,) # Used to load and/or run non-default variant of the default program define LOAD_RUN_VARIANT_template .PHONY: load-$(1) run-$(1) -include $(USER_LIB_DIR)/$(LD_SCRIPT).ld$$(addprefix -,$(3)) load-$(1): load-$(firstword $(bin_PROGRAMS))-$(1) run-$(1): @$(QUIET_CMD_ECHO) " RUN $(1)" @if [ -z "$(RUN_CMD-$(1))" ]; then echo "No command for running '$(1)' variant is specified."; exit 1; fi $(Q) $(RUN_CMD-$(1)) endef $(foreach link,$(link_VARIANTS),$(foreach prog,$(bin_PROGRAMS),$(eval $(call LOAD_PROGRAM_template,$(prog),$(USER_BIN_DIR),$(link))))) $(foreach link,$(link_VARIANTS),$(eval $(call LOAD_RUN_VARIANT_template,$(link)))) .PHONY: load run load: $(addprefix load-,$(firstword $(bin_PROGRAMS))-$(firstword $(link_VARIANTS))) run: run-$(firstword $(link_VARIANTS)) # Special rules for configuration exported headers $(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\ _$(basename $(notdir $(confh)))_H \ ))) #===================================================================== clean-local: @echo Cleaning in $(USER_OBJS_DIR) @rm -f $(USER_OBJS_DIR)/*$(OBJ_EXT) $(USER_OBJS_DIR)/*.lo \ $(USER_OBJS_DIR)/*.d \ $(USER_OBJS_DIR)/*.map \ $(LOCAL_CONFIG_H:%=$(USER_OBJS_DIR)/%) \ $(tar_EMBEDFILES:%=$(USER_OBJS_DIR)/%_tarfile) @$(foreach confh,$(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)),\ if [ -e $(confh) ] ; then touch -t 200001010101 $(confh) ; fi ; \ )