From: Michal Sojka Date: Wed, 11 Mar 2015 18:07:03 +0000 (+0100) Subject: Update Makefile.rules the the latest version X-Git-Url: https://rtime.felk.cvut.cz/gitweb/orte.git/commitdiff_plain/0fd07f4e283c49b0a3f54345d96351523cd9b263?hp=098ecfdc87d8f42d1d591c78e1be608e8b94ea43 Update Makefile.rules the the latest version --- diff --git a/Makefile.rules b/Makefile.rules index 6c3095e..59d1de6 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -1,10 +1,10 @@ # Makefile.rules - OCERA make framework common project rules -*- makefile-gmake -*- #OMK:base.omk # # (C) Copyright 2003, 2006, 2007, 2008, 2009 by Pavel Pisa - OCERA team member -# (C) Copyright 2006, 2007, 2008, 2009, 2010, 2011 by Michal Sojka - Czech Technical University, FEE, DCE +# (C) Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2015 by Michal Sojka - Czech Technical University, FEE, DCE # # Homepage: http://rtime.felk.cvut.cz/omk/ -# Version: 0.2-111-g8f9236e +# Version: 0.2-170-g3a5eb29 # # The OMK build system is distributed under the GNU General Public # License. See file COPYING for details. @@ -24,34 +24,37 @@ # input variables #OMK:linux.omk # lib_LIBRARIES .. list of the user-space libraries # shared_LIBRARIES .. list of the user-space shared libraries -# kernel_LIBRARIES .. list of the kernel-space libraries -# rtlinux_LIBRARIES.. list of the RT-Linux kernel-space 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 -# kernel_HEADERS .. list of the kernel-space public header files -# rtlinux_HEADERS .. list of the RT-Linux kernel-space public header files # bin_PROGRAMS .. list of the require binary programs # utils_PROGRAMS .. list of the development utility programs # test_PROGRAMS .. list of the testing programs # bin_SCRIPTS .. list of scripts to be copied to _compiled/bin -# kernel_MODULES .. list of the kernel side modules/applications -# rtlinux_MODULES .. list of RT-Linux the kernel side modules/applications # xxx_SOURCES .. list of specific target sources +# xxx_GEN_SOURCES .. list of specific target sources that are generated in the build directory # xxx_LIBS .. list of specific target libraries (-l prefix is automatically added) # xxx_LDFLAGS .. list of specific target LDFLAGS # lib_LOADLIBES .. list of libraries linked to each executable # INCLUDES .. additional include directories and defines for user-space +# +# OMK_CFLAGS .. C compiler flags +# OMK_CXXFLAGS .. C++ compiler flags +# OMK_CPPFLAGS .. C preprocessor flags +# LDFLAGS .. linker flags for programs linking +# kernel_LIBRARIES .. list of the kernel-space libraries #OMK:linux-kernel.omk +# rtlinux_LIBRARIES.. list of the RT-Linux kernel-space libraries +# kernel_HEADERS .. list of the kernel-space public header files +# rtlinux_HEADERS .. list of the RT-Linux kernel-space public header files +# kernel_MODULES .. list of the kernel side modules/applications +# rtlinux_MODULES .. list of RT-Linux the kernel side modules/applications # kernel_INCLUDES .. additional include directories and defines for kernel-space # rtlinux_INCLUDES .. additional include directories and defines for RT-Linux # OMIT_KERNEL_PASSES if defined, all kernel passes are omited -# # LINUX_DIR .. location of Linux kernel sources # RTL_DIR .. location of RT-Linux sources -# CFLAGS .. C compiler flags -# CXXFLAGS .. C++ compiler flags -# CPPFLAGS .. C preprocessor flags -# LDFLAGS .. linker flags for programs linking +# cmetric_include_HEADERS .. generate header file with offsets and sizes of structure fields #OMK:cmetric.omk +# xxx_CMETRIC_SOURCES .. the source cmetric generation # LOCAL_CONFIG_H .. name of local config.h file generated from values #OMK:config_h.omk # of options defined in the current directory # config_include_HEADERS .. names of global config files (possibly @@ -317,8 +320,10 @@ $(pass)-this-dir: $(foreach subdir,$(SUBDIRS),$(pass)-$(subdir)-subdir) @$(call mkdir_def,$(2)) +@$(MAKE) --no-builtin-rules $(NO_PRINT_DIRECTORY) SOURCES_DIR=$(SOURCES_DIR) RELATIVE_DIR=$(RELATIVE_DIR) -C $(2) \ -f $(SOURCESDIR_MAKEFILE) $(3) $(check-target) $(1:%=%-local) +ifneq ($(pass),clean) $(pass)-local: $($(pass)_HOOKS) endif +endif endef # ======================= @@ -348,7 +353,7 @@ omkize: fi $(Q)for i in `find -L . -name Makefile.omk` ; do \ d=`dirname $${i}`; \ - if ! test -f "$${d}/Makefile.rules" && ( test -f "$${d}/Makefile" && ! cmp -s Makefile "$${d}/Makefile" ); then \ + if ! test -f "$${d}/Makefile.rules" && ! cmp -s Makefile "$${d}/Makefile"; then \ rm -f "$${d}/Makefile"; \ cp -v Makefile "$${d}/Makefile"; \ fi \ @@ -438,50 +443,12 @@ include-pass-local-$(2): $$($(2)_GEN_HEADERS) $$(foreach f,$$(renamed_$(2)_GEN_H @$$(if $$($(2)_HEADERS)$$($(2)_GEN_HEADERS)$$(nobase_$(2)_HEADERS)$$(renamed_$(2)_HEADERS)$$(renamed_$(2)_GEN_HEADERS),,true) endef #OMK:linux.omk@Makefile.rules.linux -# Hack to check RT-Linux rules -#LINUX_DIR := /home/cvs/ocera/ocera-build/kernel/linux -#RTL_DIR := /home/cvs/ocera/ocera-build/kernel/rtlinux -#CONFIG_RTLINUX = y -#OCERA_DIR := $(shell ( cd -L $(OUTPUT_DIR)/../../.. ; pwd -L ) ) - --include $(OUTPUT_DIR)/OCERA_TOP_DIR - BUILD_DIR_NAME = _build COMPILED_DIR_NAME = _compiled ifndef GROUP_DIR_NAME GROUP_DIR_NAME = nogroup endif -ifdef OCERA_DIR -ifeq ($(wildcard $(OCERA_DIR)/ocera.mk),) -$(warning "ocera.mk" file does not exist. Adapt Makefile.rules for standalone compilation) -$(warning (comment out definition of OCERA_DIR line and optionally select RTL_DIR) ) -$(error or go to the ocera/ directory and do 'make' to generate the "ocera.mk" file first, please) -endif -include $(OCERA_DIR)/ocera.mk -KERN_INCLUDE_DIR := $(OCERA_KERNEL_INCLUDES_DIR) -KERN_LIB_DIR := $(OCERA_KERNEL_LIBRARIES_DIR) -KERN_MODULES_DIR := $(OCERA_MODULES_DIR) -KERN_BUILD_DIR := $(BUILD_DIR)/kern/$(GROUP_DIR_NAME) -KERN_MODPOST_DIR := $(BUILD_DIR)/kern-modpost -USER_INCLUDE_DIR := $(OCERA_USER_INCLUDES_DIR) -USER_LIB_DIR := $(OCERA_USER_LIBRARIES_DIR) -USER_UTILS_DIR := $(TARGET_DIR)/usr/bin -USER_TESTS_DIR := $(TARGET_DIR)/usr/bin -USER_BIN_DIR := $(TARGET_DIR)/usr/bin -USER_BUILD_DIR := $(BUILD_DIR)/user/$(GROUP_DIR_NAME) -#LINUX_DIR := $(OCERA_DIR)/kernel/linux -#RTL_DIR := $(OCERA_DIR)/kernel/rtlinux -#CONFIG_FILE := $(OCERA_DIR)/emdebsys/.config -ifneq ($(wildcard $(CONFIG_FILE)),) -CONFIG_FILE_OK = y -endif -else # OCERA_DIR -KERN_INCLUDE_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/include-kern -KERN_LIB_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/lib-kern -KERN_MODULES_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/modules -KERN_BUILD_DIR := $(OUTPUT_DIR)/$(BUILD_DIR_NAME)/kern -KERN_MODPOST_DIR := $(OUTPUT_DIR)/$(BUILD_DIR_NAME)/kern-modpost USER_INCLUDE_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/include USER_LIB_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/lib USER_UTILS_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/bin-utils @@ -489,14 +456,6 @@ USER_TESTS_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/bin-tests USER_BIN_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/bin USER_BUILD_DIR := $(OUTPUT_DIR)/$(BUILD_DIR_NAME)/user -ifndef LINUX_VERSION -LINUX_VERSION=$(shell uname -r) -endif -ifndef LINUX_DIR -LINUX_DIR=/lib/modules/$(LINUX_VERSION)/build -endif -endif # OCERA_DIR - ifeq ($(BUILD_OS),) # Check for target ifeq ($(OS),Windows_NT) @@ -516,21 +475,18 @@ export BUILD_OS LOCAL_BUILD_DIR = $(USER_OBJS_DIR) -# Assign default values to CFLAGS variable. If the variable is defined +# Assign default values to OMK_CFLAGS variable. If the variable is defined # earlier (i.g. in config.omk), it is not overriden here. -CFLAGS ?= -O2 -Wall -CXXFLAGS ?= -O2 -Wall +OMK_CFLAGS ?= -O2 -Wall +OMK_CXXFLAGS ?= -O2 -Wall -CPPFLAGS += -I $(USER_INCLUDE_DIR) +INCLUDES += -I $(USER_INCLUDE_DIR) LOADLIBES += -L$(USER_LIB_DIR) LOADLIBES += $(lib_LOADLIBES:%=-l%) -LIB_CPPFLAGS += $(CPPFLAGS) -LIB_CFLAGS += $(CFLAGS) - ifeq ($(TARGET_OS),win32) EXE_SUFFIX = .exe SOLIB_EXT = dll @@ -544,7 +500,6 @@ endif #vpath %.cxx $(SOURCES_DIR) USER_OBJS_DIR = $(USER_BUILD_DIR)/$(RELATIVE_DIR) -KERN_OBJS_DIR = $(KERN_BUILD_DIR)/$(RELATIVE_DIR) OMK_WORK_DIR = $(USER_OBJS_DIR) .PHONY: dep subdirs clean clean-custom cleandepend check-dir @@ -555,10 +510,6 @@ include-pass: check-dir library-pass: include-pass link-pseudo-pass: library-pass binary-pass: link-pseudo-pass -kernel-lib-pass: include-pass -kernel-mod-pass: kernel-lib-pass -kernel-modpost-pass: kernel-mod-pass -kernel-pass: kernel-mod-pass kernel-modpost-pass override OMK_SERIALIZE_INCLUDED = y MAKEOVERRIDES := $(filter-out OMK_SERIALIZE_INCLUDED=n,$(MAKEOVERRIDES)) @@ -569,21 +520,14 @@ endif ifdef USER_RULE_TEMPLATES -USER_SOURCES2OBJS = .o/.c .o/.cc .o/.cxx .o/.cpp .o/.S .o/.o - -USER_SOURCES2OBJSLO = .lo/.c .lo/.cc .lo/.cxx .lo/.cpp .lo/.S .lo/.lo - -#%.lo: %.c -# $(CC) -o $@ $(LCFLAGS) -c $< +c_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(OMK_CPPFLAGS) \ + $(CPPFLAGS) $(OMK_CFLAGS) $(CFLAGS) -DOMK_FOR_USER -c_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_USER +cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(OMK_CPPFLAGS) \ + $(CPPFLAGS) $(OMK_CFLAGS) $(CFLAGS) $(OMK_CXXFLAGS) $(CXXFLAGS) -DOMK_FOR_USER -cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CXXFLAGS) -DOMK_FOR_USER - -S_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ASFLAGS) -DOMK_FOR_USER +S_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(OMK_CPPFLAGS) \ + $(CPPFLAGS) $(OMK_CFLAGS) $(CFLAGS) $(ASFLAGS) -DOMK_FOR_USER idl_COMPILE = $(IDL_COMPILER) @@ -601,100 +545,117 @@ endif # Syntax: $(call COMPILE_c_o_template,,,) define COMPILE_c_o_template +ifeq ($$($(2)_C_TARGET),) +$(2)_C_TARGET=1 $(2): $(1) $$(GEN_HEADERS) @$(QUIET_CMD_ECHO) " CC $$@" $(Q) if $$(c_o_COMPILE) $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \ then mv -f "$$@.d.tmp" "$$@.d" ; \ else rm -f "$$@.d.tmp" ; exit 1; \ fi +endif endef # Syntax: $(call COMPILE_cc_o_template,,,) define COMPILE_cc_o_template +ifeq ($$($(2)_CC_TARGET),) +$(2)_CC_TARGET=1 $(2): $(1) $$(GEN_HEADERS) @$(QUIET_CMD_ECHO) " CXX $$@" $(Q) if $$(cc_o_COMPILE) $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \ then mv -f "$$@.d.tmp" "$$@.d" ; \ else rm -f "$$@.d.tmp" ; exit 1; \ fi +endif endef # Syntax: $(call COMPILE_S_o_template,,,) define COMPILE_S_o_template +ifeq ($$($(2)_S_TARGET),) +$(2)_S_TARGET=1 $(2): $(1) $$(GEN_HEADERS) @$(QUIET_CMD_ECHO) " AS $$@" $(Q) if $$(S_o_COMPILE) -D__ASSEMBLY__ $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \ then mv -f "$$@.d.tmp" "$$@.d" ; \ else rm -f "$$@.d.tmp" ; exit 1; \ fi +endif endef -NM ?= nm - -# Syntax: $(call CMETRIC_o_h_template,,) -define CMETRIC_o_h_template -$(2): $(1) - @$(QUIET_CMD_ECHO) " CMETRIC $$@" - $(Q)if [ -n `dirname $$@` ] ; then \ - if [ ! -e `dirname $$@` ] ; then \ - mkdir -p `dirname $$@` ; fi ; fi - $(Q)echo >$$@.tmp '/* Automatically generated from $$< */' - $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */' -# Bellow, the tricks with redirection are for shells without set -o pipefail -# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html) - $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ - | $(SED4OMK) -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ - | sort >>$$@.tmp` && exit $$$$status - $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */' - $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ - | $(SED4OMK) -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ - | sort >>$$@.tmp` && exit $$$$status - $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */' - $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\ - | $(SED4OMK) -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \ - | sort >>$$@.tmp` && exit $$$$status - $(Q)mv $$@.tmp $$@ +# Syntax: $(call COMPILE_s_o_template,,,) +define COMPILE_s_o_template +ifeq ($$($(2)_s_TARGET),) +$(2)_s_TARGET=1 +$(2): $(1) $$(GEN_HEADERS) + @$(QUIET_CMD_ECHO) " AS $$@" + $(Q)$$(S_o_COMPILE) $(3) -o $$@ -c $$< +endif endef +# Syntax: $(call COMPILE_idl_template,,) +define COMPILE_idl_template +ifeq ($$($(2)_IDL_TARGET),) +$(2)_IDL_TARGET=1 +GEN_HEADERS+=$(filter %.h,$(notdir $(1:%.idl=%.h))) # Do we need this global variable? -define COMPILE_idl_template $(2).c $(2)-stubs.c $(2)-skels.c $(2)-common.c $(2).h: $(1) $$(wildcard $$(firstword $$(idl_COMPILE))) @$(QUIET_CMD_ECHO) " IDL $$@" $(Q) $$(idl_COMPILE) $$($(2)_IDLFLAGS) $(1) +endif endef +# GCC recognizes files matching this pattern as C++ +CXX_PATTERN = %.cc %.cp %.cxx %.cpp %.CPP %.c++ %.C -# Syntax: $(call PROGRAM_template,,,,) -# FIXME: ???????? asi je tu blbej komentar -define PROGRAM_template - -USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c)) -USER_GEN_SOURCES += $$($(1)_GEN_SOURCES) - -$(foreach x, $(USER_SOURCES2OBJS), -$(1)_OBJS += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\ - $$($(1)_SOURCES) $$($(1)_GEN_SOURCES))) +# Syntax: $(call COMPILE_templates,,,) +# Note: The newlines after $(call ) are IMPORTANT!!! +define COMPILE_templates +$(foreach src,$(filter %.c,$(1)),$(call COMPILE_c_o_template,$(src),$(3)$(notdir $(src:%.c=%$(2))),) +) +$(foreach src,$(filter $(CXX_PATTERN),$(1)),$(call COMPILE_cc_o_template,$(src),$(3)$(notdir $(basename $(src))$(2)),) +) +$(foreach src,$(filter %.S,$(1)),$(call COMPILE_S_o_template,$(src),$(3)$(notdir $(basename $(src))$(2)),) ) -$(1)_OBJS := $$(sort $$($(1)_OBJS:%/=%)) +$(foreach src,$(filter %.s,$(1)),$(call COMPILE_s_o_template,$(src),$(3)$(notdir $(basename $(src))$(2)),) +) +endef + +TARGET_IDL_SOURCES = $(filter %.c,$($(1)_SERVER_IDL:%.idl=%-skels.c)) \ + $(filter %.c,$($(1)_SERVER_IDL:%.idl=%-common.c)) \ + $(filter %.c,$($(1)_CLIENT_IDL:%.idl=%-stubs.c)) \ + $(filter %.c,$($(1)_CLIENT_IDL:%.idl=%-common.c)) \ + $(filter %.c,$($(1)_IDL:%.idl=%.c)) +TARGET_SOURCES = $($(1)_SOURCES) $($(1)_GEN_SOURCES) $(TARGET_IDL_SOURCES) +TARGET_SOURCES_ABS = $($(1)_SOURCES:%=$(SOURCES_DIR)/%) $($(1)_GEN_SOURCES) $(TARGET_IDL_SOURCES) +TARGET_OBJ_PREFIX = $(if $($(1)_CFLAGS)$($(1)_CXXFLAGS)$($(1)_CPPFLAGS),$(1)-,) +TARGET_OBJS = $(sort $(addprefix $(TARGET_OBJ_PREFIX),$(addsuffix .o,$(basename $(notdir $(TARGET_SOURCES)))))) +TARGET_LOBJS = $(sort $(addprefix $(TARGET_OBJ_PREFIX),$(addsuffix .lo,$(basename $(notdir $(TARGET_SOURCES)))))) +TARGET_IDLS = $($(1)_SERVER_IDL) $($(1)_CLIENT_IDL) $($(1)_IDL) +TARGET_CFLAGS = $(if $($(1)_CFLAGS),$($(1)_CFLAGS),$(OMK_CFLAGS)) +TARGET_CXXFLAGS = $(if $($(1)_CXXFLAGS),$($(1)_CXXFLAGS),$(OMK_CXXFLAGS)) +TARGET_CPPFLAGS = $(if $($(1)_CPPFLAGS),$($(1)_CPPFLAGS),$(OMK_CPPFLAGS)) + +# Syntax: $(call PROGRAM_template,,,,) +define PROGRAM_template +$(foreach idl,$(TARGET_IDLS),$(call COMPILE_idl_template,$(SOURCES_DIR)/$(idl),$(idl:%.idl=%))) -USER_OBJS += $$($(1)_OBJS) -USER_SOURCES += $$($(1)_SOURCES) +$(call COMPILE_templates,$(TARGET_SOURCES_ABS),.o,$(TARGET_OBJ_PREFIX)) -$(2)/$(1)$(3): $$($(1)_OBJS) +$(2)/$(1)$(3): OMK_CFLAGS=$(TARGET_CFLAGS) +$(2)/$(1)$(3): OMK_CXXFLAGS=$(TARGET_CXXFLAGS) +$(2)/$(1)$(3): OMK_CPPFLAGS=$(TARGET_CPPFLAGS) +$(2)/$(1)$(3): $(TARGET_OBJS) @$(QUIET_CMD_ECHO) " LINK $$@" - $(Q) $$(if $$(filter %.cc,$$($(1)_SOURCES))$$(filter %.cxx,$$($(1)_SOURCES))$$(filter %.cpp,$$($(1)_SOURCES)),$$(CXX),$$(CC)) \ - $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) $$(LOADLIBES) $$(LDFLAGS) $$($(1)_LDFLAGS) -Wl,-rpath-link,$(USER_LIB_DIR) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $$@ + $(Q) $(if $(filter $(CXX_PATTERN),$(TARGET_SOURCES)),$$(CXX),$$(CC)) \ + $(TARGET_OBJS) $$($(1)_LIBS:%=-l%) $$(LOADLIBES) $$(OMK_LDFLAGS) $$(LDFLAGS) $$($(1)_LDFLAGS) -Wl,-rpath-link,$(USER_LIB_DIR) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $$@ @echo "$(2)/$(1)$(3): \\" >$(USER_OBJS_DIR)/$(1).exe.d @$(SED4OMK) -n -e 's|^LOAD \(.*\)$$$$| \1 \&|p' $(USER_OBJS_DIR)/$(1).exe.map|tr '&' '\134' >>$(USER_OBJS_DIR)/$(1).exe.d @echo >>$(USER_OBJS_DIR)/$(1).exe.d + +binary-pass-local: $(2)/$(1)$(3) endef # Usage: $(call SCRIPT_template,,) @@ -702,84 +663,52 @@ define SCRIPT_template $(2)/$(1): $$(SOURCES_DIR)/$(1) @$(QUIET_CMD_ECHO) " CP $$@" $(Q)cp $$^ $$@ + +binary-pass-local: $(2)/$(1) endef # Syntax: $(call LIBRARY_template,) define LIBRARY_template -USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c)) -USER_GEN_SOURCES += $$($(1)_GEN_SOURCES) - -$(foreach x, $(USER_SOURCES2OBJS), -$(1)_OBJS += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\ - $$($(1)_SOURCES) $$($(1)_GEN_SOURCES))) -) -$(1)_OBJS := $$(sort $$($(1)_OBJS:%/=%)) +$(foreach idl,$(TARGET_IDLS),$(call COMPILE_idl_template,$(SOURCES_DIR)/$(idl),$(idl:%.idl=%))) -USER_OBJS += $$($(1)_OBJS) -USER_SOURCES += $$($(1)_SOURCES) +$(call COMPILE_templates,$(TARGET_SOURCES_ABS),.o,$(TARGET_OBJ_PREFIX)) -$(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS) +$(USER_LIB_DIR)/lib$(1).a: OMK_CFLAGS=$(TARGET_CFLAGS) +$(USER_LIB_DIR)/lib$(1).a: OMK_CXXFLAGS=$(TARGET_CXXFLAGS) +$(USER_LIB_DIR)/lib$(1).a: OMK_CPPFLAGS=$(TARGET_CPPFLAGS) +$(USER_LIB_DIR)/lib$(1).a: $(TARGET_OBJS) @$(QUIET_CMD_ECHO) " AR $$@" $(Q) $(AR) rcs $$@ $$^ + +library-pass-local: $(USER_LIB_DIR)/lib$(1).a endef -.PHONY: FORCE # Syntax: $(call SOLIB_template,) define SOLIB_template -USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c)) -$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c)) -SOLIB_GEN_SOURCES += $$($(1)_GEN_SOURCES) - -$(foreach x, $(USER_SOURCES2OBJSLO), -$(1)_OBJSLO += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\ - $$($(1)_SOURCES) $$($(1)_GEN_SOURCES))) -) -$(1)_OBJSLO := $$(sort $$($(1)_OBJSLO:%/=%)) +$(foreach idl,$(TARGET_IDLS),$(call COMPILE_idl_template,$(SOURCES_DIR)/$(idl),$(idl:%.idl=%))) -SOLIB_OBJS += $$($(1)_OBJSLO) -SOLIB_SOURCES += $$($(1)_SOURCES) +$(call COMPILE_templates,$(TARGET_SOURCES_ABS),.lo,$(TARGET_OBJ_PREFIX)) -$(OMK_WORK_DIR)/lib$(1).$(SOLIB_EXT).omkvar: $$($(1)_OBJSLO) FORCE - $(Q)echo '$(1)_objslo += $$$$(addprefix $(USER_OBJS_DIR)/,$$($(1)_OBJSLO))' > $$@.tmp; \ +.PHONY: $(OMK_WORK_DIR)/lib$(1).$(SOLIB_EXT).omkvar +$(2)/$(1)$(3): OMK_CFLAGS=$(TARGET_CFLAGS) +$(2)/$(1)$(3): OMK_CXXFLAGS=$(TARGET_CXXFLAGS) +$(2)/$(1)$(3): OMK_CPPFLAGS=$(TARGET_CPPFLAGS) +$(OMK_WORK_DIR)/lib$(1).$(SOLIB_EXT).omkvar: OMK_CFLAGS = $(TARGET_CFLAGS) $(SOLIB_PICFLAGS) +$(OMK_WORK_DIR)/lib$(1).$(SOLIB_EXT).omkvar: OMK_CXXFLAGS = $(TARGET_CXXFLAGS) $(SOLIB_PICFLAGS) +$(OMK_WORK_DIR)/lib$(1).$(SOLIB_EXT).omkvar: OMK_CPPFLAGS = $(TARGET_CPPFLAGS) +$(OMK_WORK_DIR)/lib$(1).$(SOLIB_EXT).omkvar: $(TARGET_LOBJS) + $(Q)echo '$(1)_objslo += $$$$(addprefix $(USER_OBJS_DIR)/,$$^)' > $$@.tmp; \ echo '$(1)_libs += $$($(1)_LIBS) $$(lib_LOADLIBES)' >> $$@.tmp; \ echo '$(1)_ldflags += $$($(1)_LDFLAGS) $$(lib_LDFLAGS)' >> $$@.tmp; \ echo 'shared_libs := $$$$(sort $(1) $$$$(shared_libs))' >> $$@.tmp; \ if cmp -s $$@.tmp $$@; then rm $$@.tmp; else mv $$@.tmp $$@; fi -endef - -library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS)) \ - $(lib_LIBRARIES:%=$(USER_LIB_DIR)/lib%.a) $(shared_LIBRARIES:%=$(OMK_WORK_DIR)/lib%.$(SOLIB_EXT).omkvar) - -binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%$(EXE_SUFFIX)) \ - $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%$(EXE_SUFFIX)) \ - $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%$(EXE_SUFFIX)) \ - $(bin_SCRIPTS:%=$(USER_BIN_DIR)/%) -# Special rules for CMETRIC generated headers - -$(foreach cmetrh,$(cmetric_include_HEADERS),$(eval $(call COMPILE_c_o_template,\ - $(SOURCES_DIR)/$($(basename $(notdir $(cmetrh)))_CMETRIC_SOURCES),\ - $($(basename $(notdir $(cmetrh)))_CMETRIC_SOURCES:%.c=%.o),))) -$(foreach cmetrh,$(cmetric_include_HEADERS),$(eval $(call CMETRIC_o_h_template,\ - $($(basename $(notdir $(cmetrh)))_CMETRIC_SOURCES:%.c=%.o),\ - $(addprefix $(USER_INCLUDE_DIR)/,$(cmetrh))))) - -GEN_HEADERS+=$(cmetric_include_HEADERS:%=$(USER_INCLUDE_DIR)/%) - -GEN_HEADERS+=$(filter %.h,$(USER_IDLS:%.idl=%.h)) +library-pass-local: $(OMK_WORK_DIR)/lib$(1).$(SOLIB_EXT).omkvar +endef # Generate rules for compilation of programs and libraries @@ -792,6 +721,7 @@ $(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN $(foreach script,$(bin_SCRIPTS),$(eval $(call SCRIPT_template,$(script),$(USER_BIN_DIR)))) +# $(foreach lib,$(lib_LIBRARIES),$(info $(call LIBRARY_template,$(lib)))) $(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib)))) $(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib)))) @@ -809,6 +739,8 @@ link-pseudo-pass: ifeq ($(MAKECMDGOALS),link-shared-libs) + + # Syntax: $(call solib_link_template,) define solib_link_template $(1)_shared_libs = $$(patsubst %,$(USER_LIB_DIR)/lib%.$(SOLIB_EXT),$$(filter $$(shared_libs),$$($(1)_libs))) @@ -826,6 +758,62 @@ $(foreach lib,$(shared_libs),$(eval $(call solib_link_template,$(lib)))) link-shared-libs: $(shared_libs:%=$(USER_LIB_DIR)/lib%.$(SOLIB_EXT)) endif # link-shared-libs +$(eval $(call omk_pass_template, library-pass,$(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(lib_LIBRARIES)$(shared_LIBRARIES)$(cmetric_include_HEADERS))) +$(eval $(call omk_pass_template, binary-pass, $(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(bin_PROGRAMS)$(utils_PROGRAMS)$(test_PROGRAMS)$(bin_SCRIPTS))) + +$(eval $(call omk_pass_template,clean,$(USER_OBJS_DIR),,always)) +$(eval $(call omk_pass_template,install,$(USER_OBJS_DIR),,always)) +$(eval $(call omk_pass_template,include-pass,$(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,always)) + +check-dir:: + @$(call mkdir_def,$(USER_BUILD_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)) + @$(call mkdir_def,$(USER_TESTS_DIR)) + +install-local: # TODO + +$(eval $(call include-pass-template,$(USER_INCLUDE_DIR),include)) + +clean-local:: + @echo Cleaning in $(USER_OBJS_DIR) + @rm -f $(USER_OBJS_DIR)/*.[och] \ + $(USER_OBJS_DIR)/*.lo \ + $(USER_OBJS_DIR)/*.d \ + $(USER_OBJS_DIR)/*.map \ + $(LOCAL_CONFIG_H:%=$(USER_OBJS_DIR)/%) + +include-pass-submakes: extra-rules-subdirs + +# We must go to EXTRA_RULES_SUBDIRS before going to any other +# directory, since the executables compiled in EXTRA_RULES_SUBDIRS +# might be needed there. +include-pass-this-dir $(foreach subdir,$(SUBDIRS),include-pass-$(subdir)-subdir): extra-rules-subdirs + +default: include-pass library-pass binary-pass + #OMK:linux-kernel.omk@Makefile.rules.linux +KERN_INCLUDE_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/include-kern +KERN_LIB_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/lib-kern +KERN_MODULES_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/modules +KERN_BUILD_DIR := $(OUTPUT_DIR)/$(BUILD_DIR_NAME)/kern +KERN_MODPOST_DIR := $(OUTPUT_DIR)/$(BUILD_DIR_NAME)/kern-modpost + +ifndef LINUX_VERSION +LINUX_VERSION=$(shell uname -r) +endif +ifndef LINUX_DIR +LINUX_DIR=/lib/modules/$(LINUX_VERSION)/build +endif + +KERN_OBJS_DIR = $(KERN_BUILD_DIR)/$(RELATIVE_DIR) + +kernel-lib-pass: include-pass +kernel-mod-pass: kernel-lib-pass +kernel-modpost-pass: kernel-mod-pass +kernel-pass: kernel-mod-pass kernel-modpost-pass + #===================================================================== # Kernel-space rules and templates to compile modules, libraries etc. @@ -890,7 +878,7 @@ KERN_KBUILD_MODNAME=-D"KBUILD_MODNAME=((THIS_MODULE)!=NULL?(THIS_MODULE)->name:N endif endif # CONFIG_RTLINUX -KERN_LOADLIBES += -L$(KERN_LIB_DIR) +KERN_LOADLIBES += -L$(KERN_LIB_DIR) KERN_LOADLIBES += $(rtlinux_LOADLIBES:%=-l%) KERN_LOADLIBES += $(kernel_LOADLIBES:%=-l%) @@ -1024,7 +1012,7 @@ KERN_SOURCES += $$($(1)_SOURCES) # #endif@\ # };@\ # #endif@\ -# " | tr @ \\n >$$@ +# " | tr @ \\n >$$@ #$(eval $(call COMPILE_c_o_kern_template,$(1).mod.c,$(1).mod.o,-DKBUILD_MODNAME=$(1))) @@ -1135,92 +1123,18 @@ kernel-modpost-pass: -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y KERN_MODPOST_PASS=y $(@:%=%-local) ; \ fi -$(eval $(call omk_pass_template, library-pass,$(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(lib_LIBRARIES)$(shared_LIBRARIES))) -$(eval $(call omk_pass_template, binary-pass, $(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(bin_PROGRAMS)$(utils_PROGRAMS)$(test_PROGRAMS)$(bin_SCRIPTS))) - -$(eval $(call omk_pass_template,clean,$(USER_OBJS_DIR),,always)) -$(eval $(call omk_pass_template,install,$(USER_OBJS_DIR),,always)) -$(eval $(call omk_pass_template,include-pass,$(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,always)) - check-dir:: - @$(call mkdir_def,$(USER_BUILD_DIR)) @$(call mkdir_def,$(KERN_BUILD_DIR)) - @$(call mkdir_def,$(USER_INCLUDE_DIR)) @$(call mkdir_def,$(KERN_INCLUDE_DIR)) - @$(call mkdir_def,$(USER_LIB_DIR)) @$(call mkdir_def,$(KERN_LIB_DIR)) - @$(call mkdir_def,$(USER_BIN_DIR)) - @$(call mkdir_def,$(USER_UTILS_DIR)) - @$(call mkdir_def,$(USER_TESTS_DIR)) @$(call mkdir_def,$(KERN_MODULES_DIR)) @$(call mkdir_def,$(KERN_MODPOST_DIR)) -install-local: # TODO - -$(eval $(call include-pass-template,$(USER_INCLUDE_DIR),include)) $(eval $(call include-pass-template,$(KERN_INCLUDE_DIR),kernel)) ifeq ($(CONFIG_RTLINUX),y) $(eval $(call include-pass-template,$(KERN_INCLUDE_DIR),rtlinux)) endif - -ifdef USER_RULE_TEMPLATES - -# User-space static libraries and applications object files - -USER_SOURCES := $(sort $(USER_SOURCES)) - -USER_GEN_SOURCES := $(sort $(USER_GEN_SOURCES)) - -#$(warning USER_SOURCES = $(USER_SOURCES)) - -$(foreach src,$(filter %.c,$(USER_SOURCES)),$(eval $(call COMPILE_c_o_template,$(SOURCES_DIR)/$(src),$(src:%.c=%.o),))) - -$(foreach src,$(filter %.cc,$(USER_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%.o),))) - -$(foreach src,$(filter %.cxx,$(USER_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.o),))) - -$(foreach src,$(filter %.cpp,$(USER_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cpp=%.o),))) - -$(foreach src,$(filter %.S,$(USER_SOURCES)),$(eval $(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.o),))) - -$(foreach src,$(filter %.c,$(USER_GEN_SOURCES)),$(eval $(call COMPILE_c_o_template,$(src),$(src:%.c=%.o),))) - -# User-space shared libraries object files - -SOLIB_SOURCES := $(sort $(SOLIB_SOURCES)) - -SOLIB_GEN_SOURCES := $(sort $(SOLIB_GEN_SOURCES)) - -#$(warning SOLIB_SOURCES = $(SOLIB_SOURCES)) -#$(warning SOLIB_GEN_SOURCES = $(SOLIB_GEN_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 %.cxx,$(SOLIB_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.lo),$(SOLIB_PICFLAGS)))) - -$(foreach src,$(filter %.cpp,$(SOLIB_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cpp=%.lo),$(SOLIB_PICFLAGS)))) - -$(foreach src,$(filter %.S,$(SOLIB_SOURCES)),$(eval $(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.lo),$(SOLIB_PICFLAGS)))) - -$(foreach src,$(filter %.c,$(SOLIB_GEN_SOURCES)),$(eval $(call COMPILE_c_o_template,$(src),$(src:%.c=%.lo),$(SOLIB_PICFLAGS)))) - -# Create _build directories for sources in subdirectories i.e. *_SOURCES=dir/file.c -_dirs_to_create=$(filter-out ./,$(sort $(dir $(USER_SOURCES) $(SOLIB_SOURCES)))) -ifneq ($(_dirs_to_create),) -$(shell mkdir -p $(addprefix $(LOCAL_BUILD_DIR)/,$(_dirs_to_create))) -endif - -# IDL compilation - -USER_IDLS := $(sort $(USER_IDLS)) - -$(foreach src,$(filter %.idl,$(USER_IDLS)),$(eval $(call COMPILE_idl_template,$(SOURCES_DIR)/$(src),$(src:%.idl=%)))) - -endif - ifdef KERN_RULE_TEMPLATES KERN_SOURCES := $(sort $(KERN_SOURCES)) @@ -1238,31 +1152,62 @@ $(foreach src,$(filter %.cpp,$(KERN_SOURCES)),$(eval $(call COMPILE_cc_o_kern_te $(foreach src,$(filter %.S,$(USER_SOURCES)),$(eval $(call COMPILE_S_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.o),))) endif -clean-local: clean-custom - @echo Cleaning in $(KERN_OBJS_DIR) and $(USER_OBJS_DIR) - @rm -f $(KERN_OBJS_DIR)/*.o $(USER_OBJS_DIR)/*.[och] $(USER_OBJS_DIR)/*.lo\ - $(KERN_OBJS_DIR)/*.d $(USER_OBJS_DIR)/*.d \ - $(KERN_OBJS_DIR)/*.map $(USER_OBJS_DIR)/*.map \ +clean-local:: + @echo Cleaning in $(KERN_OBJS_DIR) + @rm -f $(KERN_OBJS_DIR)/*.o \ + $(KERN_OBJS_DIR)/*.d \ + $(KERN_OBJS_DIR)/*.map \ $(KERN_OBJS_DIR)/*.mod.c \ $(kernel_MODULES:%=$(KERN_MODPOST_DIR)/%.*) \ - $(LOCAL_CONFIG_H:%=$(KERN_OBJS_DIR)/%) \ - $(LOCAL_CONFIG_H:%=$(USER_OBJS_DIR)/%) + $(LOCAL_CONFIG_H:%=$(KERN_OBJS_DIR)/%) @if [ -e $(KERN_LIB_DIR)/kernel.mk ] ; then \ touch -t 200001010101 $(KERN_LIB_DIR)/kernel.mk ; \ fi -include-pass-submakes: extra-rules-subdirs - -# We must go to EXTRA_RULES_SUBDIRS before going to any other -# directory, since the executables compiled in EXTRA_RULES_SUBDIRS -# might be needed there. -include-pass-this-dir $(foreach subdir,$(SUBDIRS),include-pass-$(subdir)-subdir): extra-rules-subdirs - -default: include-pass library-pass binary-pass ifndef OMIT_KERNEL_PASSES # Also make kernel passes if not disabled default: kernel-lib-pass kernel-pass endif + #OMK:cmetric.omk@Makefile.rules.linux +NM ?= nm + +# Syntax: $(call CMETRIC_o_h_template,,) +define CMETRIC_o_h_template +$(2): $(1) + @$(QUIET_CMD_ECHO) " CMETRIC $$@" + $(Q)if [ -n `dirname $$@` ] ; then \ + if [ ! -e `dirname $$@` ] ; then \ + mkdir -p `dirname $$@` ; fi ; fi + $(Q)echo >$$@.tmp '/* Automatically generated from $$< */' + $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */' +# Bellow, the tricks with redirection are for shells without set -o pipefail +# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html) + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ + | $(SED4OMK) -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */' + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ + | $(SED4OMK) -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */' + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\ + | $(SED4OMK) -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)mv $$@.tmp $$@ +endef + +library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS)) + +# Special rules for CMETRIC generated headers + +$(foreach cmetrh,$(cmetric_include_HEADERS),$(eval $(call COMPILE_c_o_template,\ + $(SOURCES_DIR)/$($(basename $(notdir $(cmetrh)))_CMETRIC_SOURCES),\ + $($(basename $(notdir $(cmetrh)))_CMETRIC_SOURCES:%.c=%.o),))) +$(foreach cmetrh,$(cmetric_include_HEADERS),$(eval $(call CMETRIC_o_h_template,\ + $($(basename $(notdir $(cmetrh)))_CMETRIC_SOURCES:%.c=%.o),\ + $(addprefix $(USER_INCLUDE_DIR)/,$(cmetrh))))) + +GEN_HEADERS+=$(cmetric_include_HEADERS:%=$(USER_INCLUDE_DIR)/%) #OMK:config_h.omk@Makefile.rules.linux # Syntax: $(call BUILD_CONFIG_H_template,,,,) define BUILD_CONFIG_H_template @@ -1328,9 +1273,7 @@ include-pass-local: $(kern_config_h_stamp_files) endif -clean-local: clean-local-config-h - -clean-local-config-h: +clean-local:: @$(foreach confh,$(config_h_stamp_files) $(kern_config_h_stamp_files),\ if [ -e $(confh) ] ; then rm $(confh) ; fi ; \ ) @@ -1367,8 +1310,7 @@ qt-subpass-$(1): $(LOCAL_BUILD_DIR)/$(dir $(1))Makefile RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir $(1)) -C $(LOCAL_BUILD_DIR)/$(dir $(1)) || exit 1 ; # Hook to clean pass -clean-local: clean-qt-$(dir $(1)) -clean-qt-$(dir $(1)): $(LOCAL_BUILD_DIR)/$(dir $(1))Makefile +clean-local:: $(LOCAL_BUILD_DIR)/$(dir $(1))Makefile @$(QUIET_CMD_ECHO) " QT CLEAN $(dir $(1))" $(Q)$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir $(1)) \ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir $(1)) \ @@ -1377,7 +1319,7 @@ clean-qt-$(dir $(1)): $(LOCAL_BUILD_DIR)/$(dir $(1))Makefile endef $(foreach pro,$(QT_PROJECTS), $(eval $(call qt_project_template,$(pro)))) -$(foreach pro,$(foreach dir,$(QT_SUBDIRS), $(wildcard $(dir)/*.pro)), $(eval $(call qt_project_template,$(pro)))) +$(foreach pro,$(foreach dir,$(QT_SUBDIRS), $(wildcard $(SOURCES_DIR)/$(dir)/*.pro)), $(eval $(call qt_project_template,$(pro:$(SOURCES_DIR)/%=%)))) endif #OMK:sources-list.omk@Makefile.rules.linux