]> rtime.felk.cvut.cz Git - rtems-devel.git/commitdiff
Makefile.rules updated to actual OMK project version.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 27 Sep 2012 19:14:39 +0000 (21:14 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 27 Sep 2012 19:14:39 +0000 (21:14 +0200)
  git://rtime.felk.cvut.cz/omk.git
  http://rtime.felk.cvut.cz/omk/

Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
rtems-omk-template/Makefile.rules

index 97409ce148dd8bc9d54e091913a963fbb8b9a957..5638119f80ae5727913c7b1fb4ed7b14c6575bb1 100644 (file)
@@ -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 by Michal Sojka - Czech Technical University, FEE, DCE
+#  (C) Copyright 2006, 2007, 2008, 2009, 2010, 2011 by Michal Sojka - Czech Technical University, FEE, DCE
 #
 #  Homepage: http://rtime.felk.cvut.cz/omk/
-#  Version:  0.1-95-g0919d5c
+#  Version:  0.2-97-g532aeb1
 #
 # The OMK build system is distributed under the GNU General Public
 # License.  See file COPYING for details.
 #                    variables.
 OMK_RULES_TYPE=rtems                                                             #OMK:Makefile.rules.rtems@
                                                                                  #OMK:base.omk@Makefile.rules.rtems
-# We need to ensure definition of sources directory first
-ifndef SOURCES_DIR
-# Only shell built-in pwd understands -L
-SOURCES_DIR := $(shell ( pwd -L ) )
-endif
-
 # If we are not called by OMK leaf Makefile...
 ifndef MAKERULES_DIR
 MAKERULES_DIR := $(abspath $(dir $(filter %Makefile.rules,$(MAKEFILE_LIST))))
 endif
 
+# The $(SED4OMK) command for BSD based systems requires -E option to allow
+# extended regular expressions
+
+SED4OMK ?= sed
+ifneq ($(shell ( echo A | $(SED4OMK) -n -e 's/A\|B/y/p' )),y)
+  SED4OMK := $(SED4OMK) -E
+  ifneq ($(shell ( echo A | $(SED4OMK) -n -e 's/A\|B/y/p' )),y)
+    SED4OMK := gsed
+  endif
+  ifneq ($(shell ( echo A | $(SED4OMK) -n -e 's/A\|B/y/p' )),y)
+    SED4OMK := gsed -E
+  endif
+  ifneq ($(shell ( echo A | $(SED4OMK) -n -e 's/A\|B/y/p' )),y)
+    $(error No SED program suitable for OMK found)
+  endif
+endif
+
 # OUTPUT_DIR is the place where _compiled, _build and possible other
 # files/directories are created. By default is the same as
 # $(MAKERULES_DIR).
@@ -60,7 +71,16 @@ ifndef OUTPUT_DIR
 OUTPUT_DIR := $(MAKERULES_DIR)
 endif
 
-.PHONY: all default check-make-ver omkize
+# We need to ensure definition of sources directory first
+ifndef SOURCES_DIR
+# Only shell built-in pwd understands -L
+SOURCES_DIR := $(shell ( pwd -L ) )
+INVOCATION_DIR := $(SOURCES_DIR:$(OUTPUT_DIR)%=%)
+INVOCATION_DIR := $(INVOCATION_DIR:/%=%)
+INVOCATION_DIR := $(INVOCATION_DIR:\\%=%)
+endif
+
+.PHONY: all default check-make-ver print-hints omkize
 
 ifdef W
   ifeq ("$(origin W)", "command line")
@@ -72,7 +92,7 @@ ifndef OMK_WHOLE_TREE
 endif
 
 ifneq ($(OMK_WHOLE_TREE),1)
-all: check-make-ver default
+all: check-make-ver print-hints default
        @echo "Compilation finished"
 else
 # Run make in the top-level directory
@@ -80,48 +100,41 @@ all:
        @$(MAKE) -C $(MAKERULES_DIR) OMK_SERIALIZE_INCLUDED=n SOURCES_DIR=$(MAKERULES_DIR) RELATIVE_DIR="" $(MAKECMDGOALS) W=0
 endif
 
-ifdef OMK_TESTSROOT
-# Usage: $(call canttest,<error message>)
-define canttest
-       ( echo "$(1)" > $(OUTPUT_DIR)/_canttest; echo "$(1)"; exit 1 )
-endef
-else
-define canttest
-       echo "$(1)"
-endef
-endif
+# omk-get-var target allows external scripts/programs to determine the
+# values of OMK variables such as RELATIVE_DIR etc.
+.PHONY: omk-get-var
+omk-get-var:
+       @$(foreach var,$(VAR),echo $(var)=$($(var));)
 
 #=========================
 # Include the config file
 
-# FIXME: I think CONFIG_FILE_OK variable is useless. We have three
-# config files and it is not clearly defined to which file is this
-# variable related.
-ifneq ($(CONFIG_FILE_OK),y)
 ifndef CONFIG_FILE
 CONFIG_FILE      := $(OUTPUT_DIR)/config.omk
 endif
-ifneq ($(wildcard $(CONFIG_FILE)-default),)
--include $(CONFIG_FILE)-default
-else
-ifneq ($(MAKECMDGOALS),default-config)
-$(warning Please, run "make default-config" first)
+
+$(CONFIG_FILE)-default:
+       $(MAKE) default-config 
+
+ifeq ($(MAKECMDGOALS),default-config)
+export DEFAULT_CONFIG_PASS=1
 endif
+
+ifneq ($(DEFAULT_CONFIG_PASS),1)
+include $(CONFIG_FILE)-default
 endif
 
 -include $(OUTPUT_DIR)/config.target
 
 ifneq ($(wildcard $(CONFIG_FILE)),)
 -include $(CONFIG_FILE)
-CONFIG_FILE_OK = y
 endif
-endif #$(CONFIG_FILE_OK)
 
 
 CONFIG_FILES ?= $(wildcard $(CONFIG_FILE)-default) $(wildcard $(OUTPUT_DIR)/config.target) $(wildcard $(CONFIG_FILE))
 
 
-export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR
+export SED4OMK SOURCES_DIR MAKERULES_DIR RELATIVE_DIR INVOCATION_DIR
 export CONFIG_FILE CONFIG_FILES OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT
 # OMK_SERIALIZE_INCLUDED has to be exported to submakes because passes
 # must to be serialized only in the toplevel make.
@@ -133,7 +146,7 @@ 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_/$$__')
+#override BACK2TOP_DIR := $(shell echo $(RELATIVE_DIR)/ | $(SED4OMK) -e 's_//_/_g' -e 's_/\./_/_g' -e 's_^\./__g'  -e 's_\([^/][^/]*\)_.._g' -e 's_/$$__')
 #$(warning  BACK2TOP_DIR = "$(BACK2TOP_DIR)")
 
 #$(warning SOURCES_DIR = "$(SOURCES_DIR)")
@@ -188,10 +201,13 @@ endif
 OMK_INCLUDED := 1
 endif
 
+print-hints:
+       @echo 'Use "make V=1" to see the verbose compile lines.'
+
 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'` ; \
+       @GOOD_MAKE_VERSION=`echo $(MAKE_VERSION) | $(SED4OMK) -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 "Your make program version ($(MAKE_VERSION)) is too old and does not support OMK system." ; \
                echo "Please update to make program 3.81beta1 or newer." ; exit 1 ; \
        fi
 
@@ -222,14 +238,17 @@ endif
 
 pass = $(strip $(1))
 
+unexport SUBDIRS
+
 # Call a pass in a subdirectory
 # Usage: $(call omk_pass_subdir_template,<pass name>,<build dir>,<subdir>)
 define omk_pass_subdir_template
 .PHONY: $(pass)-$(3)-subdir
 $(pass)-submakes: $(pass)-$(3)-subdir
+$(pass)-$(3)-subdir: MAKEOVERRIDES:=$(filter-out SUBDIRS=%,$(MAKEOVERRIDES))
 $(pass)-$(3)-subdir:
        @$(call mkdir_def,$(2)/$(3))
-       +@$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(3) $(NO_PRINT_DIRECTORY) \
+       +@$(MAKE) --no-builtin-rules SOURCES_DIR=$(SOURCES_DIR)/$(3) $(NO_PRINT_DIRECTORY) \
                RELATIVE_DIR=$(RELATIVE_PREFIX)$(3) -C $(2)/$(3) \
                -f $(SUBDIR_MAKEFILE) $(pass)-submakes
 # In subdirectories we can call submakes directly since passes are
@@ -261,7 +280,7 @@ $(foreach subdir,$(SUBDIRS),$(eval $(call omk_pass_subdir_template,$(pass),$(2),
 $(pass):
 # Submakes have to be called this way and not as dependecies for pass
 # serialization to work
-       +@$(MAKE) SOURCES_DIR=$(SOURCES_DIR) $(NO_PRINT_DIRECTORY) \
+       +@$(MAKE) --no-builtin-rules SOURCES_DIR=$(SOURCES_DIR) $(NO_PRINT_DIRECTORY) \
                RELATIVE_DIR=$(RELATIVE_DIR) \
                -f $(SOURCESDIR_MAKEFILE) $(pass)-submakes
 $(pass)-submakes:
@@ -272,7 +291,7 @@ $(pass)-submakes: $(pass)-this-dir
 $(pass)-this-dir: $(foreach subdir,$(SUBDIRS),$(pass)-$(subdir)-subdir)
        +@echo "make[omk]: $(pass) in $(RELATIVE_DIR)"
        @$(call mkdir_def,$(2))
-       +@$(MAKE) $(NO_PRINT_DIRECTORY) SOURCES_DIR=$(SOURCES_DIR) RELATIVE_DIR=$(RELATIVE_DIR) -C $(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)
 $(pass)-local: $($(pass)_HOOKS)
 endif
@@ -296,7 +315,7 @@ 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" ; )
+               $(SED4OMK) -e 's/^[^=]*=x$$/#\0/' >> "$(CONFIG_FILE)-default" ; )
 
 
 omkize:
@@ -317,11 +336,17 @@ endif
 
 ifneq ($(LN_HEADERS),y)
 define cp_cmd
-( echo "  CP      $(1:$(OUTPUT_DIR)/%=%) -> $(2:$(OUTPUT_DIR)/%=%)"; cp $(CPHEADER_FLAGS) $(1) $(2) )
+if ! cmp --quiet $(1) $(2); then \
+    echo "  CP      $(1:$(OUTPUT_DIR)/%=%) -> $(2:$(OUTPUT_DIR)/%=%)"; \
+    install -D $(CPHEADER_FLAGS) $(1) $(2) || exit 1; \
+fi
 endef
 else
 define cp_cmd
-( echo "  LN      $(1:$(OUTPUT_DIR)/%=%) -> $(2:$(OUTPUT_DIR)/%=%)"; [ -f $(1) ] && ln -sf $(LNHEADER_FLAGS) $(1) $(2) )
+if ! cmp --quiet $(1) $(2); then \
+    echo "  LN      $(1:$(OUTPUT_DIR)/%=%) -> $(2:$(OUTPUT_DIR)/%=%)"; \
+    if [ -f $(1) ]; then d=$(2); mkdir -p $${d%/*} && ln -sf $(LNHEADER_FLAGS) $(1) $(2) || exit 1; else exit 1; fi; \
+fi
 endef
 endif
 
@@ -331,29 +356,21 @@ endif
 # Syntax: $(call include-pass-template,<include dir>,<keyword>)
 define include-pass-template
 include-pass-local: include-pass-local-$(2)
-include-pass-local-$(2): $$($(2)_GEN_HEADERS) $$(foreach f,$$(renamed_$(2)_GEN_HEADERS),$$(shell echo '$$(f)' | sed -e 's/^\(.*\)->.*$$$$/\1/'))
-       @$$(foreach f, $$($(2)_HEADERS), cmp --quiet $$(SOURCES_DIR)/$$(f) $(1)/$$(notdir $$(f)) \
-          || $$(call cp_cmd,$$(SOURCES_DIR)/$$(f),$(1)/$$(notdir $$(f))) || exit 1 ; )
-       @$$(foreach f, $$($(2)_GEN_HEADERS), cmp --quiet $$(f) $(1)/$$(notdir $$(f)) \
-          || $$(call cp_cmd,$$(LOCAL_BUILD_DIR)/$$(f),$(1)/$$(notdir $$(f))) || exit 1 ; ) # FIXME: Use correct build dir, then document it
-       @$$(foreach f, $$(nobase_$(2)_HEADERS), cmp --quiet $$(SOURCES_DIR)/$$(f) $(1)/$$(f) \
-          || ( mkdir -p $(1)/$$(dir $$(f)) && $$(call cp_cmd,$$(SOURCES_DIR)/$$(f),$(1)/$$(f)) ) || exit 1 ; )
+include-pass-local-$(2): $$($(2)_GEN_HEADERS) $$(foreach f,$$(renamed_$(2)_GEN_HEADERS),$$(shell f='$$(f)'; echo $$$${f%->*}))
+       @$$(foreach f, $$($(2)_HEADERS),$$(call cp_cmd,$$(SOURCES_DIR)/$$(f),$(1)/$$(notdir $$(f))); )
+# FIXME: Use correct build dir, then document it (in the line bellow)
+       @$$(foreach f, $$($(2)_GEN_HEADERS),$$(call cp_cmd,$$(LOCAL_BUILD_DIR)/$$(f),$(1)/$$(notdir $$(f))); )
+       @$$(foreach f, $$(nobase_$(2)_HEADERS), $$(call cp_cmd,$$(SOURCES_DIR)/$$(f),$(1)/$$(f)); )
        @$$(foreach f, $$(renamed_$(2)_HEADERS), \
-          srcfname=`echo '$$(f)' | sed -e 's/^\(.*\)->.*$$$$/\1/'` ; destfname=`echo '$$(f)' | sed -e 's/^.*->\(.*\)$$$$/\1/'` ; \
-          cmp --quiet $$(SOURCES_DIR)/$$$${srcfname} $(1)/$$$${destfname} \
-          || ( mkdir -p `dirname $(1)/$$$${destfname}` && $$(call cp_cmd,$$(SOURCES_DIR)/$$$${srcfname},$(1)/$$$${destfname}) ) || exit 1 ; )
+          f='$$(f)'; srcfname=$$$${f%->*}; destfname=$$$${f#*->}; \
+          $$(call cp_cmd,$$(SOURCES_DIR)/$$$${srcfname},$(1)/$$$${destfname}); )
        @$$(foreach f, $$(renamed_$(2)_GEN_HEADERS), \
-          srcfname=`echo '$$(f)' | sed -e 's/^\(.*\)->.*$$$$/\1/'` ; destfname=`echo '$$(f)' | sed -e 's/^.*->\(.*\)$$$$/\1/'` ; \
-          cmp --quiet $$$${srcfname} $(1)/$$$${destfname} \
-          || ( mkdir -p `dirname $(1)/$$$${destfname}` && $$(call cp_cmd,$$(LOCAL_BUILD_DIR)/$$$${srcfname},$(1)/$$$${destfname}) ) || exit 1 ; )
+          f='$$(f)'; srcfname=$$$${f%->*}; destfname=$$$${f#*->}; \
+          $$(call cp_cmd,$$(LOCAL_BUILD_DIR)/$$$${srcfname},$(1)/$$$${destfname}); )
+# Suppress "Nothing to be done for `include-pass-local'" message if no headers are defined in Makefile.omk
+       @$$(if $$($(2)_HEADERS)$$($(2)_GEN_HEADERS)$$(nobase_$(2)_HEADERS)$$(renamed_$(2)_HEADERS)$$(renamed_$(2)_GEN_HEADERS),,true)
 endef
                                                                                  #OMK:rtems.omk@Makefile.rules.rtems
-ifdef OMK_TESTSROOT
-ifeq ($(RTEMS_MAKEFILE_PATH),)
-$(error $(shell $(call canttest,RTEMS_MAKEFILE_PATH not defined)))
-endif
-endif
-
 include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
 include $(RTEMS_CUSTOM)
 include $(CONFIG.CC)
@@ -459,7 +476,7 @@ S_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 
 # Check GCC version for user build
 ifndef CC_MAJOR_VERSION
-CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | $(SED4OMK) -e 's/\([^.]\)\..*/\1/')
 endif
 # Prepare suitable define for dependency building
 ifeq ($(CC_MAJOR_VERSION),2)
@@ -508,23 +525,46 @@ $(2): $(1)
        $(Q)if [ -n `dirname $$@` ] ; then \
              if [ ! -e `dirname $$@` ] ; then \
                mkdir -p `dirname $$@` ; fi ; fi
-       $(Q)echo >$$@ '/* Automatically generated from $$< */'
-       $(Q)echo >>$$@ '/* Conditionals to control compilation */'
-       $(Q)set -o pipefail ; $(NM) $$< \
-               | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
-               | sort >>$$@
-       $(Q)echo >>$$@ '/* Defines from the values defined to symbols */'
-       $(Q)set -o pipefail ; $(NM) $$< \
-               | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
-               | sort >>$$@
+       $(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
 
-# Syntax: $(call PROGRAM_template,<dir>,<executable-name>,<link-variant>)
+idl_COMPILE = $(IDL_COMPILER)
+
+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)
+endef
+
+# Syntax: $(call PROGRAM_template,<executable-name>,<dir>,<link-variant>)
 define PROGRAM_template
-$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.c=%.o))
-$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cc=%.o))
-$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cxx=%.o))
-$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.S=%.o))
+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)
+
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.c=%.o) $$($(1)_GEN_SOURCES:%.c=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cc=%.o) $$($(1)_GEN_SOURCES:%.c=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cxx=%.o) $$($(1)_GEN_SOURCES:%.c=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.S=%.o) $$($(1)_GEN_SOURCES:%.c=%.o))
 $(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
 $(1)_OBJS := $$(sort $$($(1)_OBJS))
 
@@ -533,7 +573,6 @@ USER_SOURCES += $$($(1)_SOURCES)
 USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES)
 
 $(2)/$(1): $(USER_LIB_DIR)/timestamp
-
 $(2)/$(1): $$($(1)_OBJS)
        @$(QUIET_CMD_ECHO) "  LINK    $$@"
        $(Q) $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES))" ] ; \
@@ -542,7 +581,7 @@ $(2)/$(1): $$($(1)_OBJS)
          $$(AM_LDFLAGS) $$(LDFLAGS) $$($(1)_OBJS) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) \
          -o $(2)/$(1)
 #@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
+#@$(SED4OMK) -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
 # FIXME: Why the map file was commented out?
@@ -552,10 +591,18 @@ endef
 
 # Syntax: $(call LIBRARY_template,<library-name>)
 define LIBRARY_template
-$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.c=%.o))
-$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cc=%.o))
-$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cxx=%.o))
-$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.S=%.o))
+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)
+
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.c=%.o) $$($(1)_GEN_SOURCES:%.c=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cc=%.o) $$($(1)_GEN_SOURCES:%.c=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cxx=%.o) $$($(1)_GEN_SOURCES:%.c=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.S=%.o) $$($(1)_GEN_SOURCES:%.c=%.o))
 $(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
 $(1)_OBJS := $$(sort $$($(1)_OBJS))
 
@@ -569,14 +616,23 @@ $(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
        @touch $(USER_LIB_DIR)/timestamp
 endef
 
-
+$(USER_LIB_DIR)/timestamp:
+       $(Q)touch $@
 
 # Syntax: $(call SOLIB_template,<library-name>)
 define SOLIB_template
-$(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.c=%.lo))
-$(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.cc=%.lo))
-$(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.cxx=%.lo))
-$(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.S=%.lo))
+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)
+
+$(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.c=%.lo) $$($(1)_GEN_SOURCES:%.c=%.lo))
+$(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.cc=%.lo) $$($(1)_GEN_SOURCES:%.c=%.lo))
+$(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.cxx=%.lo) $$($(1)_GEN_SOURCES:%.c=%.lo))
+$(1)_OBJSLO += $$(filter %.lo,$$($(1)_SOURCES:%.S=%.lo) $$($(1)_GEN_SOURCES:%.c=%.lo))
 $(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
 $(1)_OBJSLO := $$(sort $$($(1)_OBJSLO))
 
@@ -594,7 +650,7 @@ endef
 library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS)) \
                    $(lib_LIBRARIES:%=$(USER_LIB_DIR)/lib%.a) $(shared_LIBRARIES:%=$(USER_LIB_DIR)/lib%.so)
 
-binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%) $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/% $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%)
+binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%) $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%)
 
 # Special rules for CMETRIC generated headers
 
@@ -606,6 +662,7 @@ $(foreach cmetrh,$(cmetric_include_HEADERS),$(eval $(call CMETRIC_o_h_template,\
                $(addprefix $(USER_INCLUDE_DIR)/,$(cmetrh)))))
 
 GEN_HEADERS+=$(cmetric_include_HEADERS:%=$(USER_INCLUDE_DIR)/%)
+GEN_HEADERS+=$(filter %.h,$(USER_IDLS:%.idl=%.h))
 
 # Generate rules for compilation of programs and libraries
 
@@ -619,6 +676,11 @@ $(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
 
 $(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))
 
+# IDL compilation
+USER_IDLS := $(sort $(USER_IDLS))
+$(foreach src,$(filter %.idl,$(USER_IDLS)),$(eval $(call COMPILE_idl_template,$(SOURCES_DIR)/$(src),$(src:%.idl=%))))
+
+
 -include $(USER_OBJS_DIR)/*.d
 
 endif
@@ -626,7 +688,7 @@ endif
 #=====================================================================
 
 
-$(eval $(call omk_pass_template, include-pass,$(USER_OBJS_DIR),,$(include_HEADERS)$(nobase_include_HEADERS)$(renamed_include_HEADERS)$(config_include_HEADERS)$(LOCAL_CONFIG_H)))
+$(eval $(call omk_pass_template, include-pass,$(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(include_HEADERS)$(nobase_include_HEADERS)$(renamed_include_HEADERS)$(config_include_HEADERS)$(LOCAL_CONFIG_H)))
 $(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)))
 
@@ -646,6 +708,7 @@ 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))
 
@@ -657,6 +720,8 @@ $(foreach src,$(filter %.cxx,$(USER_SOURCES)),$(eval $(call COMPILE_cc_o_templat
 
 $(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))
@@ -686,6 +751,13 @@ clean-local:
 
 
 default: include-pass library-pass binary-pass
+
+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
                                                                                  #OMK:config_h.omk@Makefile.rules.rtems
 # Syntax: $(call BUILD_CONFIG_H_template,<stamp_dir>,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
 define BUILD_CONFIG_H_template
@@ -699,10 +771,10 @@ $(addprefix $(1)/,$(notdir $(addsuffix .stamp,$(2)))) : $(CONFIG_FILES)
        $(if $(DOXYGEN),@echo "/** @file */" >> "$(2).tmp")
        @echo "#ifndef $(4)" >> "$(2).tmp"
        @echo "#define $(4)" >> "$(2).tmp"
-       @( $(foreach x, $(shell echo '$($(3))' | tr 'x\t ' 'x\n\n' | sed -e 's/^\([^ =]*\)\(=[^ ]\+\|\)$$/\1/' ), \
+       @( $(foreach x, $(shell echo '$($(3))' | tr 'x\t ' 'x\n\n' | $(SED4OMK) -e 's/^\([^ =]*\)\(=[^ ]\+\|\)$$/\1/' ), \
                echo '$(x).$($(x))' ; ) echo ; ) | \
-               sed -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \
-               sed -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \
+               $(SED4OMK) -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \
+               $(SED4OMK) -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \
                  >> "$(2).tmp"
        @echo "#endif /*$(4)*/" >> "$(2).tmp"
        @touch "$$@"
@@ -789,7 +861,7 @@ $(SOURCES_LIST): $(CONFIG_FILES) $(shell find -name $(MAKEFILE_OMK))
        @mv "$(SOURCES_LIST).tmp2" "$(SOURCES_LIST)"
        @echo "$(SOURCES_LIST): \\" > "$(SOURCES_LIST_D).tmp2"
        @cat "$(SOURCES_LIST_D).tmp"|grep -v "$(SOURCES_LIST_D).tmp"|sort|uniq|\
-               sed -e 's/$$/\\/' >> "$(SOURCES_LIST_D).tmp2"
+               $(SED4OMK) -e 's/$$/\\/' >> "$(SOURCES_LIST_D).tmp2"
        @rm "$(SOURCES_LIST_D).tmp"
        @mv "$(SOURCES_LIST_D).tmp2" "$(SOURCES_LIST_D)"
 endif
@@ -802,7 +874,7 @@ sources-list-pass-local:
          echo "$(addsuffix /,$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%))$(h)" >> "$(SOURCES_LIST).tmp";)
        @$(foreach ch,$(config_include_HEADERS), \
          echo "$(USER_INCLUDE_DIR:$(OUTPUT_DIR)/$(addsuffix /,$(SOURCES_LIST_DIR))%=%)/$(ch)" >> "$(SOURCES_LIST).tmp";)
-       @$(foreach h,$(renamed_include_HEADERS),echo '$(h)'|sed -e 's|\(.*\)->.*|$(addsuffix /,$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%))\1|' >> "$(SOURCES_LIST).tmp";)
+       @$(foreach h,$(renamed_include_HEADERS),echo '$(h)'|$(SED4OMK) -e 's|\(.*\)->.*|$(addsuffix /,$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%))\1|' >> "$(SOURCES_LIST).tmp";)
        @$(foreach bin,$(lib_LIBRARIES) $(shared_LIBRARIES) $(bin_PROGRAMS) $(test_PROGRAMS) $(utils_PROGRAMS) \
          $(kernel_LIBRARIES) $(rtlinux_LIBRARIES) $(kernel_MODULES),\
          $(foreach src,$(filter-out %.o,$($(bin)_SOURCES)),echo "$(addsuffix /,$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%))$(src)" >> "$(SOURCES_LIST).tmp";))
@@ -825,7 +897,7 @@ export TAGS_CMD
 
 ifeq ($(MAKECMDGOALS),do-tags)
 .PHONY: do-tags
-do-tags: $(shell sed -e '/^\#/d' $(SOURCES_LIST))
+do-tags: $(shell $(SED4OMK) -e '/^\#/d' $(SOURCES_LIST))
        @$(QUIET_CMD_ECHO) "  TAGS    $(SOURCES_LIST_FN)"
        $(Q)$(TAGS_CMD) $^
 endif
@@ -834,6 +906,6 @@ endif
 
 cscope: $(SOURCES_LIST)
        @$(QUIET_CMD_ECHO) "  CSCOPE  < $(SOURCES_LIST_FN)"
-       $(Q)sed -e '/^#/d' $(SOURCES_LIST) > cscope.files
+       $(Q)$(SED4OMK) -e '/^#/d' $(SOURCES_LIST) > cscope.files
        $(Q)cscope -b -icscope.files
 #FIXME: see doc to -i in cscope(1)