--- /dev/null
+# -*- makefile -*-
+
+# Rules for compilation of C, C++ and assembler sources using FNU
+# toolchain. These rules are meant to be used with GNU toolchain and
+# are included from OMK when it is necessary to compile something for
+# target.
+
+-include $(USER_OBJS_DIR)/*.d
+
+#%.lo: %.c
+# $(CC) -o $@ $(LCFLAGS) -c $<
+
+c_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(USER_CFLAGS) $(INCLUDES)
+
+cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CXXFLAGS) $(CFLAGS) $(USER_CXXFLAGS) $(INCLUDES)
+
+S_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ASFLAGS) $(USER_AFLAGS) $(INCLUDES)
+
+# Check GCC version for user build
+ifndef CC_MAJOR_VERSION
+CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(CC_MAJOR_VERSION),2)
+CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+
+# Syntax: $(call COMPILE_c_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_c_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(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
+endef
+
+
+# Syntax: $(call COMPILE_cc_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(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
+endef
+
+
+# Syntax: $(call COMPILE_S_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_S_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+ @$(QUIET_CMD_ECHO) " AS $$@"
+ $(Q) if $$(S_o_COMPILE) -D__ASSEMBLY__ $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
+ then if [ -e "$$@.d.tmp" ] ; then mv -f "$$@.d.tmp" "$$@.d" ; fi ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+# Syntax: $(call CMETRIC_o_h_template,<object_file>,<target_header>)
+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 >$$@ '/* 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 >>$$@
+endef
+
+# Syntax: $(call PROGRAM_template,<dir>,<executable-name>,<executable-suffix>,<linker-sript>)
+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))
+$(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
+$(1)_OBJS += $$(filter %.o,$(1)_SOURCES)
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES)
+
+# Required for broken binutils
+#$(2)/$(1)$(3): $(USER_LIB_DIR)/timestamp
+
+$(2)/$(1)$(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)_LDFLAGS) $(4:%=-Wl,-T,%) -Wl,-Map,$(1)$(3).map \
+ $$($(1)_OBJS) $$(LOADLIBES) $$($(1)_MOREOBJS) $$($(1)_LIBS:%=-l%) \
+ -o $$@
+ @echo "$(2)/$(1)$(3): \\" >$(USER_OBJS_DIR)/$(1)$(3).x.d
+ @if [ -n "$(4)" ]; then \
+ echo " $(USER_LIB_DIR)/$(4) \\" >>$(USER_OBJS_DIR)/$(1)$(3).x.d; fi
+ @sed -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(USER_OBJS_DIR)/$(1)$(3).map >>$(USER_OBJS_DIR)/$(1)$(3).x.d
+ @echo >>$(USER_OBJS_DIR)/$(1).x.d
+
+# RTEMS
+# $$(AM_LDFLAGS) $$(LDFLAGS) $$($(1)_OBJS) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) \
+# -o $(2)/$(1)
+#@echo "$(2)/$(1): \\" >$(USER_OBJS_DIR)/$(1).x.d
+#@sed -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(USER_OBJS_DIR)/$(1).x.map >>$(USER_OBJS_DIR)/$(1).x.d
+#@echo >>$(USER_OBJS_DIR)/$(1).x.d
+#-Wl,-Map,$(USER_OBJS_DIR)/$(1).x.map
+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))
+$(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES)
+
+$(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR $$@"
+ $(Q) $(AR) rcs $$@ $$^
+# RTEMS
+# @touch $(USER_LIB_DIR)/timestamp
+endef
+
+
+
+# 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))
+$(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
+$(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
+
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
--- /dev/null
+SUBDIRS = utils canvca candev lincan canmon
--- /dev/null
+# Makefile.rules - OCERA make framework common project rules -*- makefile -*-
+#
+# (C) Copyright 2003 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
+# 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
+# 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
+# INCLUDES .. additional include directories and defines for user-space
+# kernel_INCLUDES .. additional include directories and defines for kernel-space
+# rtlinux_INCLUDES .. additional include directories and defines for RT-Linux
+# default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ...
+#
+# LINUX_DIR .. location of Linux kernel sources
+# RTL_DIR .. location of RT-Linux sources
+
+# 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 $(MAKERULES_DIR)/../../.. ; pwd -L ) )
+-include $(MAKERULES_DIR)/OCERA_TOP_DIR
+
+BUILD_DIR_NAME = _build
+COMPILED_DIR_NAME = _compiled
+ifndef GROUP_DIR_NAME
+GROUP_DIR_NAME = nogroup
+endif
+
+# We need to ensure definition of sources directory first
+ifndef SOURCES_DIR
+SOURCES_DIR := $(shell ( pwd -L ) )
+endif
+
+all: default
+
+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_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)),)
+#include $(CONFIG_FILE)
+CONFIG_FILE_OK = y
+endif
+else # OCERA_DIR
+KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
+KERN_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
+KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
+KERN_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
+KERN_MODPOST_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern-modpost
+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
+ifndef LINUX_VERSION
+LINUX_VERSION=$(shell uname -r)
+endif
+ifndef LINUX_DIR
+LINUX_DIR=/lib/modules/$(LINUX_VERSION)/build
+endif
+endif # OCERA_DIR
+
+# 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 LINUX_DIR LINUX_VERSION RTL_DIR
+export CONFIG_FILE OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT
+
+#CFLAGS += -ggdb
+CFLAGS += -O2
+CFLAGS += -Wall
+#CXXFLAGS += -ggdb
+CXXFLAGS += -O2
+CXXFLAGS += -Wall
+
+
+CPPFLAGS += -I $(USER_INCLUDE_DIR)
+
+LOADLIBES += -L$(USER_LIB_DIR)
+
+LOADLIBES += $(lib_LOADLIBES:%=-l%)
+
+LIB_CPPFLAGS += $(CPPFLAGS)
+LIB_CFLAGS += $(CFLAGS)
+
+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))
+
+#vpath %.c $(SOURCES_DIR)
+#vpath %.cc $(SOURCES_DIR)
+#vpath %.cxx $(SOURCES_DIR)
+
+VPATH = $(SOURCES_DIR)
+srcdir = $(SOURCES_DIR)
+
+USER_OBJS_DIR = $(USER_BUILD_DIR)/$(RELATIVE_DIR)
+KERN_OBJS_DIR = $(KERN_BUILD_DIR)/$(RELATIVE_DIR)
+
+.PHONY: default dep subdirs clean clean-custom cleandepend default-config
+.PHONY: check-make-ver check-dir include-pass library-pass binary-pass utils-pass
+.PHONY: kernel-lib-pass kernel-pass kernel-mod-pass kernel-modpost-pass default-config-pass
+.PHONY: check-dir-local include-pass-local library-pass-local binary-pass-local
+.PHONY: utils-pass-local kernel-lib-pass-local kernel-mod-pass-local kernel-modpost-pass-local
+.PHONY: 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
+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
+
+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 kernel-lib-pass kernel-pass
+
+#=====================================================================
+# Common utility rules
+
+define mkdir_def
+ [ -d $(1) ] || mkdir -p $(1) || exit 1
+endef
+
+ifdef LOCAL_CONFIG_H
+
+$(LOCAL_CONFIG_H) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+ @echo LOCAL_CONFIG_H=`pwd`/$(LOCAL_CONFIG_H)
+ @echo "/* Automatically generated from */" > "$(LOCAL_CONFIG_H).tmp"
+ @echo "/* config file : $< */" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#ifndef _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#define _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @( $(foreach x, $(shell echo $(default_CONFIG) | sed -e 's/\<\([^ ]*\)=[^ ]\>/\1/g' ), \
+ echo $(x).$($(x)) ; ) echo ; ) | \
+ sed -n -e 's/^\(.*\)\.[ym]$$/#define \1 1/p' \
+ >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#endif /*_LOCAL_CONFIG_H*/" >> "$(LOCAL_CONFIG_H).tmp"
+ @if cmp --quiet "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; then \
+ echo rm "$(LOCAL_CONFIG_H).tmp" ; \
+ else mv "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; \
+ echo Updated configuration "$(LOCAL_CONFIG_H)" ; fi
+
+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
+
+#=====================================================================
+# 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) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_USER
+
+cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_USER
+
+
+# Check GCC version for user build
+ifndef CC_MAJOR_VERSION
+CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(CC_MAJOR_VERSION),2)
+CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+
+
+
+define COMPILE_c_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(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
+endef
+
+
+
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(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
+endef
+
+
+
+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 := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+
+$(2)/$(1): $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " LINK $$@"
+ $(Q) $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES:%.cxx=%.cc))" ] ; then echo $$(CC) ; else echo $$(CXX) ; fi) \
+ $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) $$(LOADLIBES) $$(LDFLAGS) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -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
+ @echo >>$(USER_OBJS_DIR)/$(1).exe.d
+endef
+
+
+
+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 := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+
+$(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR $$@"
+ $(Q) $(AR) rcs $$@ $$^
+endef
+
+
+
+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 := $$(sort $$($(1)_OBJSLO))
+
+SOLIB_OBJS += $$($(1)_OBJSLO)
+SOLIB_SOURCES += $$($(1)_SOURCES)
+
+$(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%.a) $(shared_LIBRARIES:%=$(USER_LIB_DIR)/lib%.so)
+
+binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%)
+
+utils-pass-local: $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%)
+
+$(foreach prog,$(utils_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR))))
+
+$(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR))))
+
+$(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
+
+$(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))
+
+-include $(USER_OBJS_DIR)/*.d
+
+endif
+
+#=====================================================================
+# Kernel-space rules and templates to compile modules, libraries etc.
+
+ifdef KERN_RULE_TEMPLATES
+
+$(KERN_LIB_DIR)/kernel.mk: $(LINUX_DIR)/.config $(MAKERULES_DIR)/kernelcfg2mk
+ @$(QUIET_CMD_ECHO) " KCFG2MK $$@"
+ $(Q) $(MAKERULES_DIR)/kernelcfg2mk $(LINUX_DIR) $(KERN_LIB_DIR)
+
+ifeq ($(CONFIG_RTLINUX),y)
+include $(RTL_DIR)/rtl.mk
+
+KERN_CC = $(CC)
+kern_GCCLIB_DIR=$(shell LANG=C LC_ALL=C LC_MESSAGES=C $(CC) -print-search-dirs | sed -n -e 's/^install: \(.*\)$$/\1/p' )
+INCLUDES := -I $(KERN_INCLUDE_DIR) $(INCLUDE) $(rtlinux_INCLUDES) $(kernel_INCLUDES)
+#-DEXPORT_NO_SYMBOLS
+c_o_kern_COMPILE = $(KERN_CC) -idirafter $(kern_GCCLIB_DIR)/include $(INCLUDES) $(CFLAGS) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB -nostdinc
+cc_o_kern_COMPILE = $(CXX) $(INCLUDES) $(CXXFLAGS) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB
+KERN_EXE_SUFFIX := .o
+KERN_ARCH = $(ARCH)
+KERN_LD = $(LD)
+KERN_AR = $(AR)
+
+else # CONFIG_RTLINUX
+
+include $(KERN_LIB_DIR)/kernel.mk
+
+ifeq ($(LINUX_SRC),)
+LINUX_SRC = $(LINUX_DIR)
+endif
+kernel_INCLUDES += -I $(LINUX_DIR) -idirafter $(LINUX_SRC)/include/linux
+
+ifdef LINUX_CC
+KERN_CC = $(LINUX_CC)
+kern_GCCLIB_DIR=$(shell LANG=C LC_ALL=C LC_MESSAGES=C $(LINUX_CC) -print-search-dirs | sed -n -e 's/^install: \(.*\)$$/\1/p' )
+else
+KERN_CC = echo KERN_CC not defined - compilation skipped
+endif
+c_o_kern_COMPILE = $(KERN_CC) $(kernel_INCLUDES) -idirafter $(kern_GCCLIB_DIR)/include $(LINUX_CPPFLAGS) $(LINUX_CFLAGS) $(LINUX_CFLAGS_MODULE) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB -nostdinc
+cc_o_kern_COMPILE = $(KERN_CC) $(kernel_INCLUDES) -idirafter $(kern_GCCLIB_DIR)/include $(LINUX_CPPFLAGS) $(LINUX_CFLAGS) $(LINUX_CFLAGS_MODULE) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB
+KERN_EXE_SUFFIX := $(LINUX_MODULE_EXT)
+KERN_LDFLAGS = $(LINUX_LDFLAGS)
+ifdef LINUX_ARCH
+KERN_ARCH = $(LINUX_ARCH)
+else
+KERN_ARCH = echo KERN_ARCH not defined - skipped
+endif
+ifdef LINUX_LD
+KERN_LD = $(LINUX_LD)
+else
+KERN_LD = echo KERN_LD not defined - skipped
+endif
+ifneq ($(LINUX_AR),)
+KERN_AR = $(LINUX_AR)
+else
+KERN_AR = $(AR)
+endif
+endif # CONFIG_RTLINUX
+
+KERN_LOADLIBES += -L$(KERN_LIB_DIR)
+
+KERN_LOADLIBES += $(rtlinux_LOADLIBES:%=-l%)
+KERN_LOADLIBES += $(kernel_LOADLIBES:%=-l%)
+
+
+
+# Check GCC version for kernel part of build
+ifndef kern_CC_MAJOR_VERSION
+kern_CC_MAJOR_VERSION := $(shell $(KERN_CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(kern_CC_MAJOR_VERSION),2)
+kern_CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+kern_CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+ifeq ($(KERN_EXE_SUFFIX),.ko)
+ifeq ($(wildcard $(LINUX_DIR)/scripts/mod/modpost),)
+KERN_MODPOST = $(LINUX_DIR)/scripts/modpost
+else
+KERN_MODPOST = $(LINUX_DIR)/scripts/mod/modpost
+endif
+KERN_MODULES_LINK_DIR = $(KERN_MODPOST_DIR)
+KERN_LINK_SUFFIX = .o
+else
+KERN_MODULES_LINK_DIR = $(KERN_MODULES_DIR)
+KERN_LINK_SUFFIX = $(KERN_EXE_SUFFIX)
+endif
+
+define COMPILE_c_o_kern_template
+
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CC [K] $$@"
+ $(Q) if $$(c_o_kern_COMPILE) $$(kern_CC_DEPFLAGS) $(3) -DKBUILD_BASENAME=$(notdir $(basename $(1))) \
+ -o $$@ -c $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+
+define COMPILE_cc_o_kern_template
+
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CXX [K] $$@"
+ $(Q) if $$(cc_o_kern_COMPILE) $$(kern_CC_DEPFLAGS) $(3) -DKBUILD_BASENAME=$(notdir $(basename $(1))) \
+ -o $$@ -c $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+
+define MODULE_kern_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 := $$(sort $$($(1)_OBJS))
+
+KERN_OBJS += $$($(1)_OBJS)
+KERN_SOURCES += $$($(1)_SOURCES)
+
+# this is hack to build "__this_module" structure for 2.6.x kernels
+# modpost is used for that purpose now
+
+#$(1).mod.c:
+# echo "\
+# #include <linux/version.h>@\
+# #include <linux/module.h>@\
+# #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,5))@\
+# #include <linux/vermagic.h>@\
+# #include <linux/compiler.h>@\
+# @\
+# MODULE_INFO(vermagic, VERMAGIC_STRING);@\
+# @\
+# #undef unix@\
+# struct module __this_module@\
+# __attribute__((section(\".gnu.linkonce.this_module\"))) = {@\
+# .name = __stringify(KBUILD_MODNAME),@\
+# .init = init_module,@\
+# #ifdef CONFIG_MODULE_UNLOAD@\
+# .exit = cleanup_module,@\
+# #endif@\
+# };@\
+# #endif@\
+# " | tr @ \\n >$$@
+
+
+#$(eval $(call COMPILE_c_o_kern_template,$(1).mod.c,$(1).mod.o,-DKBUILD_MODNAME=$(1)))
+
+$(2)/$(1)$(KERN_LINK_SUFFIX): $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " LD [K] $$@"
+ $(Q) $$(KERN_LD) $$(KERN_LDFLAGS) -r $$($(1)_OBJS) -L$$(kern_GCCLIB_DIR) $$($(1)_LIBS:%=-l%) $$(KERN_LOADLIBES) -Map $(KERN_OBJS_DIR)/$(1).mod.map -o $$@
+ @echo "$(2)/$(1)$(KERN_LINK_SUFFIX): \\" >$(KERN_OBJS_DIR)/$(1).mod.d
+ @sed -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(KERN_OBJS_DIR)/$(1).mod.map >>$(KERN_OBJS_DIR)/$(1).mod.d
+ @echo >>$(KERN_OBJS_DIR)/$(1).mod.d
+ @if [ "$(KERN_EXE_SUFFIX)" == ".ko" ] ; then \
+ echo $(1) >>$(KERN_MODPOST_DIR)/module-changes ; \
+ echo $(1) >>$(KERN_MODPOST_DIR)/$(1).mod.stamp ; \
+ fi
+
+endef
+
+
+
+define LIBRARY_kern_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 := $$(sort $$($(1)_OBJS))
+
+KERN_OBJS += $$($(1)_OBJS)
+KERN_SOURCES += $$($(1)_SOURCES)
+
+$(KERN_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR [K] $$@"
+ $(Q) $(KERN_AR) rcs $$@ $$^
+endef
+
+
+ifdef LINUX_DIR
+
+kernel-lib-pass-local: $(kernel_LIBRARIES:%=$(KERN_LIB_DIR)/lib%.a)
+
+kernel-mod-pass-local: $(kernel_MODULES:%=$(KERN_MODULES_LINK_DIR)/%$(KERN_LINK_SUFFIX))
+
+$(foreach module,$(kernel_MODULES),$(eval $(call MODULE_kern_template,$(module),$(KERN_MODULES_LINK_DIR))))
+
+$(foreach lib,$(kernel_LIBRARIES),$(eval $(call LIBRARY_kern_template,$(lib))))
+
+endif
+
+
+ifeq ($(CONFIG_RTLINUX),y)
+
+kernel-mod-pass-local: $(rtlinux_MODULES:%=$(KERN_MODULES_LINK_DIR)/%$(KERN_LINK_SUFFIX))
+
+kernel-lib-pass-local: $(rtlinux_LIBRARIES:%=$(KERN_LIB_DIR)/lib%.a)
+
+$(foreach module,$(rtlinux_MODULES),$(eval $(call MODULE_kern_template,$(module),$(KERN_MODULES_LINK_DIR))))
+
+$(foreach lib,$(rtlinux_LIBRARIES),$(eval $(call LIBRARY_kern_template,$(lib))))
+
+endif
+
+ifeq ($(KERN_MODPOST_PASS),y)
+
+MODULES_LIST := $(wildcard *.mod.stamp)
+MODULES_LIST := $(MODULES_LIST:%.mod.stamp=%)
+
+define MODPOST_kern_template
+$(2) : $(1)$(KERN_LINK_SUFFIX) $(1).mod.c
+ @$(QUIET_CMD_ECHO) " LD [M] $$@"
+ $(Q) $$(cc_o_kern_COMPILE) -DKBUILD_BASENAME=$(1) -DKBUILD_MODNAME=$(1) -o $(1).mod.o -c $(1).mod.c
+ $(Q) $$(KERN_LD) $$(KERN_LDFLAGS) $(1)$(KERN_LINK_SUFFIX) $(1).mod.o -r -o $$@
+endef
+
+kernel-modpost-versions: $(wildcard $(LINUX_DIR)/Module.symvers)
+ @$(QUIET_CMD_ECHO) " MODPOST $(KERN_MODPOST_DIR)"
+ @echo >$(KERN_MODPOST_DIR)/modpost-running
+ @rm -f $(KERN_MODPOST_DIR)/module-changes
+ $(Q) $(KERN_MODPOST) $(MODULES_LIST:%=%$(KERN_LINK_SUFFIX)) $(^:%=-i %)
+
+$(MODULES_LIST:%=%.mod.c) : kernel-modpost-versions
+
+kernel-modpost-pass-local: $(MODULES_LIST:%=$(KERN_MODULES_DIR)/%$(KERN_EXE_SUFFIX))
+ @rm -f $(KERN_MODPOST_DIR)/modpost-running
+
+$(foreach module,$(MODULES_LIST),$(eval $(call MODPOST_kern_template,$(module),$(module:%=$(KERN_MODULES_DIR)/%$(KERN_EXE_SUFFIX)))))
+
+endif
+
+-include $(KERN_OBJS_DIR)/*.d
+
+endif
+
+#=====================================================================
+
+
+kernel-lib-pass:
+ +@$(foreach dir, $(SUBDIRS), $(call mkdir_def,$(KERN_OBJS_DIR)/$(dir)) ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) -C $(KERN_OBJS_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;)
+ +@$(call mkdir_def,$(KERN_OBJS_DIR))
+ +@if [ -n "$(kernel_LIBRARIES)$(rtlinux_LIBRARIES)" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_OBJS_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y $(@:%=%-local) ; \
+ fi
+
+kernel-mod-pass:
+ +@$(foreach dir, $(SUBDIRS), $(call mkdir_def,$(KERN_OBJS_DIR)/$(dir)) ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) -C $(KERN_OBJS_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;)
+ +@$(call mkdir_def,$(KERN_OBJS_DIR))
+ +@if [ -n "$(kernel_MODULES)$(rtlinux_MODULES)" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_OBJS_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y $(@:%=%-local) ; \
+ fi
+
+kernel-modpost-pass:
+ +@if [ -e "$(KERN_MODPOST_DIR)/module-changes" -o -e "$(KERN_MODPOST_DIR)/modpost-running" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_MODPOST_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y KERN_MODPOST_PASS=y $(@:%=%-local) ; \
+ fi
+
+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_DIR)/$(dir) -C $(USER_OBJS_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;)
+ +@$(foreach dir, $(QT_SUBDIRS), $(call mkdir_def,$(USER_OBJS_DIR)/$(dir)) ; \
+ if [ "$@" != "binary-pass" ] ; then exit 0 ; fi ; \
+ if [ ! -e $(SOURCES_DIR)/$(dir)/Makefile ] ; then \
+ ( cd $(SOURCES_DIR)/$(dir) ; $$QTDIR/bin/qmake TOP_DIR=$(MAKERULES_DIR) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) QTDIR=$(QTDIR) CC=$(CC) \
+ CXX=$(CXX) || exit 1 ;) ; fi ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) -C $(SOURCES_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_DIR)/$(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,$(KERN_OBJS_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,$(KERN_MODULES_DIR))
+ @$(call mkdir_def,$(KERN_MODPOST_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:
+ @$(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 ; )
+# Kernel and RT-Linux stuff
+ @$(call mkdir_def,$(KERN_INCLUDE_DIR))
+ @$(foreach f, $(kernel_HEADERS) $(rtlinux_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(notdir $(f)) \
+ || cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(notdir $(f)) || exit 1 ; )
+ @$(foreach f, $(nobase_kernel_HEADERS) $(nobase_rtlinux_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(f) \
+ || ( mkdir -p $(KERN_INCLUDE_DIR)/$(dir $(f)) && cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(f) ) || exit 1 ; )
+ @$(foreach f, $(renamed_kernel_HEADERS) $(renamed_rtlinux_HEADERS), \
+ srcfname=`echo '$(f)' | sed -e 's/^\(.*\)->.*$$/\1/'` ; destfname=`echo '$(f)' | sed -e 's/^.*->\(.*\)$$/\1/'` ; \
+ cmp --quiet $(SOURCES_DIR)/$${srcfname} $(KERN_INCLUDE_DIR)/$${destfname} \
+ || ( mkdir -p `dirname $(KERN_INCLUDE_DIR)/$${destfname}` && cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$${srcfname} $(KERN_INCLUDE_DIR)/$${destfname} ) || 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=%.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),)))
+
+# 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 %.cxx,$(SOLIB_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.lo),$(SOLIB_PICFLAGS))))
+
+endif
+
+ifdef KERN_RULE_TEMPLATES
+
+KERN_SOURCES := $(sort $(KERN_SOURCES))
+
+#$(warning KERN_SOURCES = $(KERN_SOURCES))
+
+$(foreach src,$(filter %.c,$(KERN_SOURCES)),$(eval $(call COMPILE_c_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.c=%.o),)))
+
+$(foreach src,$(filter %.cc,$(KERN_SOURCES)),$(eval $(call COMPILE_cc_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%.o),)))
+
+$(foreach src,$(filter %.cxx,$(KERN_SOURCES)),$(eval $(call COMPILE_cc_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.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)/*.o $(USER_OBJS_DIR)/*.lo \
+ $(KERN_OBJS_DIR)/*.d $(USER_OBJS_DIR)/*.d \
+ $(KERN_OBJS_DIR)/*.map $(USER_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)/%)
+ @if [ -e $(KERN_LIB_DIR)/kernel.mk ] ; then \
+ touch -t 200001010101 $(KERN_LIB_DIR)/kernel.mk ; \
+ fi
+
+
--- /dev/null
+Description of OCERA Make System for CAN Components (OMK)
+=========================================================
+
+Important notice:
+This make system uses features found in recent versions of GNU Make
+program. If you encounter problems with package building,
+check, that you use correct version of Make program.
+The Make older than version 3.80, could not be used.
+Even Make version 3.80 has annoying bug which causes
+building fail with misleading message "virtual memory exhausted".
+Please, upgrade to last version of Make (3.81beta1).
+You can take it from GNU CVS, Paul D. Smith's site or from our local copy
+ http://paulandlesley.org/make/make-3.81beta1.tar.bz2
+ http://cmp.felk.cvut.cz/~pisa/can/make-3.81beta1.tar.gz
+
+
+There is list of features which we want to solve with our makesystem:
+ - central Makefile.rules for most of subcomponents and components
+ (our CAN framework includes more libraries common with our other projects,
+ we need to separate some utility libraries etc.)
+ - the rules in more spread Makefiles are way to the hell,
+ (update for different kernel, RT-Linux etc would be nightmare in other case)
+ - make system should allow to freely move with cross-dependant components
+ without need to update users of moved component
+ (I hate somethink like -I../../sched/rtlshwq/include in CAN makefiles
+ for example. Component could be renamed to different name or version
+ could be added to name and all Makefiles in CAN would require to
+ be updated)
+ - make system should be able to compile mutually cross-dependant libraries
+ and should ensure, that change in one component sources or headers
+ would result in relink or rebuild in components linked against that library
+ or including modified header file
+ - make system has to enable compilation out of OCERA full source tree
+ (we would lost many users of particular components in other case)
+ - compile should be able to do all above work without need to install
+ any files before successful finish of build.
+ - because we use some libraries for RT-Linux build and userspace
+ build, we need to solve how to compile from same sources to both targets.
+ - the build system should allow to call make for particular source
+ subdirectory. Time of recursive make through all subdirectories is
+ unacceptable.
+ - make system should enable to build out of sources tree
+ (else clean or working with CVS sandbox gets fussy and simultaneous
+ multiple targets gets problematic)
+ - it would be good, if there would be possibility to make from read-only
+ media sources
+ - make system should store results of build in some separate directory
+ structure to simple install and testing
+ - Makefiles in sources directories should be simple
+
+There is probably only one alternative fully supporting above requirements
+and it is GNU Autoheader...Automake...Autoconf... system.
+But it is complicated and requires big amount of support files.
+It would be acceptable if it could be easily used for OCERA framework.
+But there are important show stopper for that system:
+ - it would require deep revision of all OCERA CVS contents and agreement
+ on this would be problematic
+ - this system is not well prepared for dual compilation for Linux
+ and RT-Linux sub-targets. It would mean many changes in default
+ autoconf setup to support this. Probably simplest way would be
+ to rebuild GCC tool chain for something like i586-elf-rtlinux.
+ This would require even more space for OCERA development.
+
+The problem calls for same solution, which would have minimal impact
+on other components and would be elegant and would be maintainable
+and small, because our main goal is components development and not
+make systems development.
+
+There is result of our trial. It is OMK make system.
+The Makefile and Makefile.omk files should be in all source
+directories. Common Makefile.rules file is required in the toplevel
+sources directory. Alternatively this file could be moved
+to link tree pointing into readonly media or can be anywhere
+else if MAKERULES_DIR and SOURCES_DIR are specified.
+
+Syntax of Makefile.omk files is for usual cases compatible
+to Automake's Makefile.am descriptions. There are specific targets
+for RT-Linux and Linux kernel related stuff
+
+Makefile.omk user defined variables
+# SUBDIRS .. list of subdirectories intended for make from actual directory
+# 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 header files
+# nobase_include_HEADERS .. headers copied even with directory part
+# kernel_HEADERS .. list of the kernel-space header files
+# rtlinux_HEADERS .. list of the RT-Linux kernel-space header files
+# bin_PROGRAMS .. list of the require binary programs
+# utils_PROGRAMS .. list of the development utility programs
+# 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
+# INCLUDES .. additional include directories and defines for user-space
+# kernel_INCLUDES .. additional include directories and defines for kernel-space
+# rtlinux_INCLUDES .. additional include directories and defines for RT-Linux
+# default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ...
+
+The Makefile is same for all sources directories and is only 14 lines long.
+It is there only for convenience reasons to enable call "make" from
+local directory. It contains code which locates Makefile.rules in actual
+or any parent directory. With standard BASH environment it works such way,
+that if you get into sources directory over symbolic links, it is able to
+unwind yours steps back => you can make links to readonly media component
+directories, copy Makefile.rules, Makefile and toplevel Makefile.omk,
+adjust Makefile.omk to contain only required components and then call
+make in top or even directories after crossing from your tree
+to readonly media.
+
+The system compiles all files out of source directories.
+The actual version of system is adapted even for OCERA tree mode
+if OCERA_DIR variable is defined in Makefile.rules
+
+There are next predefined directory name components,
+which can be adapted if required
+
+BUILD_DIR_NAME = _build
+ prefix of directory, where temporary build files are stored
+COMPILED_DIR_NAME = _compiled
+ prefix of directory, where final compilation results are stored
+GROUP_DIR_NAME = yyy
+ this is used for separation of build sub-trees in OCERA environment
+ where more Makefile.rules is spread in the tree
+
+Next directories are used:
+
+KERN_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
+ directory to store intermediate files for kernel-space targets
+USER_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/user
+ directory to store intermediate files for user-space targets
+
+USER_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include
+ directory to store exported include files which should be installed later
+ on user-space include path
+USER_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib
+ same for user-pace libraries
+USER_UTILS_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin-utils
+ utilities for testing, which would not probably be installed
+USER_BIN_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin
+ binaries, which should go into directory on standard system PATH
+ (/usr/local/bin, /usr/bin or $(prefix)/bin)
+
+KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
+ directory to store exported include files which should be installed later
+ on kernel-space include path
+KERN_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
+ same for kernel-pace libraries
+KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
+ builded modules for Linux kernel or RT-Linux system
+
+There is more recursive passes through directories to enable
+mutual dependant libraries and binaries to compile.
+Next passes are defined
+
+default-config .. generates config.omk-default or xxx-default configuration file
+check-dir .. checks and creates required build directories
+include-pass .. copyes header files to USER_INCLUDE_DIR and KERN_INCLUDE_DIR
+library-pass .. builds objects in USER_BUILD_DIR/<relative path> and creates
+ libraries in USER_LIB_DIR
+binary-pass and utils-pass .. links respective binaries
+ in USER_{BIN,UTILS}_DIR directory. If some object file is missing
+ it compiles it in USER_BUILD_DIR/<relative path>
+kernel-lib-pass .. builds libraries for kernel space targets
+kernel-pass .. builds kernel modules
+
+The amount of passes is relatively high and consumes some time.
+But only other way to support all required features is to assemble
+one big toplevel Makefile, which would contain all components
+and targets cross-dependencies.
+
+Drawbacks of designed make system
+ - the system is not as fast as we would like
+ - it lacks Autoconf and configure extensive support for many systems
+ from UNIX to DOS and WINDOWS
+ - it does not contain support for checking existence of target libraries
+ and functionalities as GNU Autoconf
+ - it is heavily dependant on GNU MAKE program. But it would not be big
+ problem, because even many commercial applications distribute GNU
+ MAKE with them to be able to work in non-friendly systems
+ - the key drawback is dependence on recent MAKE version 3.80 and better
+ and even version 3.80 of MAKE has important bug, which has been
+ corrected in newer sources
+
+The last point is critical. I have not noticed it first, because
+I use Slackware-9.2 and it contains latest released version
+of MAKE (version 3.80).
+The problem appears when I have tried to build bigger libraries.
+There is bug in version 3.80, which results in misleading
+error "Virtual memory exhausted". It is known bug with ID 1517
+
+ * long prerequisite inside eval(call()) => vm exhausted, Paul D. Smith
+
+I have optimized some rules to not push memory to the edge,
+but there could be still issues with 3.80 version.
+
+I have downloaded latest MAKE CVS sources. The compilation required
+separate lookup and download for .po files and full Autoheader... cycle.
+I have put together package similar to release. Only ./configure --prefix=...
+and make is required. CVS sources contains version 3.81beta1.
+You can download prepared sources archive from
+ http://paulandlesley.org/make/make-3.81beta1.tar.bz2
+Or you can get our local copy from
+ http://cmp.felk.cvut.cz/~pisa/can/make-3.81beta1.tar.gz
+
+The archive contains even "make" binary build by me, which should work
+on other Linux distributions as well.
+Older version of MAKE (3.79.x released about year 2000) found
+on Mandrake and RedHat are not sufficient and do not support eval feature.
+I do not expect, that Debian would be more up-to-date or contain fixes
+to MAKE vm exhausted bug.
+
+The local CTU archive with our CAN components prepared for inclusion
+into OCERA SF CVS could be found in my "can" directory
+
+ http://cmp.felk.cvut.cz/~pisa/can/ocera-can-031212.tar.gz
+
+The code should build for user-space with new make on most of Linux distros
+when make is updated.
+
+If you want to test compile for RT-Linux targets, line
+
+#RTL_DIR := /home/cvs/ocera/ocera-build/kernel/rtlinux
+
+in "Makefile.rules" has to be activated and updated
+to point RT-Linux directory containing "rtl.mk".
+There is only one library ("ulutrtl") and test utility compiled for RT-Linux
+("can/utils/ulut/ul_rtlchk.c").
+
+The next line ,if enabled, controls compilation in OCERA project tree
+
+#OCERA_DIR := $(shell ( cd -L $(MAKERULES_DIR)/../../.. ; pwd -L ) )
+
+The LinCAN driver has been updated to compile out of source directories.
+
+Please, check, if you could compile CAN package and help us with integration
+into OCERA SF CVS. Send your comments and objections.
+
+The OMK system has been adapted to support actual OCERA configuration process.
+I am not happy with ocera.mk mix of defines and poor two or three rules,
+but OMK is able to overcome that.
+
+The OMK system has integrated rules (default-config) to build default configuration
+file. The file is named "config.omk-default" for the stand-alone compilation.
+The name corresponds to OCERA config + "-default" if OCERA_DIR is defined.
+This file contains statements from all default_CONFIG lines in all Makefile.omk.
+The file should be used for building of own "config.omk" file, or as list
+for all options if Kconfig is used.
+
--- /dev/null
+#!/bin/bash
+
+if [ $# -lt 1 ] ; then
+ echo "kernelcfg2mk: requires linux kernel directory as the first argument"
+ exit 2
+fi
+
+LINUX_DIR="$1"
+
+if [ $# -gt 1 ] ; then
+ KERN_MODULES_DIR="$2"
+fi
+
+if [ ! -e $LINUX_DIR/.config ] ; then
+ echo "kernelcfg2mk: the provided locations doesnot point to configured kernel sources"
+ echo " check directory $LINUX_DIR"
+ exit 2
+fi
+
+if [ ! -e $LINUX_DIR/.config ] ; then
+ echo "kernelcfg2mk: the provided locations doesnot point to configured kernel sources"
+ echo " check directory $LINUX_DIR"
+ exit 2
+fi
+
+if [ -z "$KERN_BUILD_DIR" ] ; then
+ KERN_BUILD_DIR=`pwd`
+fi
+
+if [ -z "$KERN_MODULES_DIR" ] ; then
+ KERN_MODULES_DIR=`pwd`
+fi
+
+
+if [ -z "$MAKE" ] ; then
+ MAKE="make"
+fi
+
+
+KERN_TEST_DIR="$KERN_BUILD_DIR/kern-test-mk"
+
+mkdir -p $KERN_TEST_DIR
+
+#echo MAKERULES_DIR $MAKERULES_DIR
+#echo LINUX_DIR $LINUX_DIR
+#echo KERN_BUILD_DIR $KERN_BUILD_DIR
+#echo KERN_MODULES_DIR $KERN_MODULES_DIR
+
+RETVAL="0"
+
+LINUX_VERSION=$(grep UTS_RELEASE ${LINUX_DIR}/include/linux/version.h | \
+ sed 's/[^"]*"\(.*\)\{1\}"/\1/')
+
+LINUX_VERSION_MAJOR=$(echo ${LINUX_VERSION} | cut -d. -f1)
+LINUX_VERSION_MINOR=$(echo ${LINUX_VERSION} | cut -d. -f2)
+
+#echo $LINUX_VERSION
+#echo $LINUX_VERSION_MAJOR
+#echo $LINUX_VERSION_MINOR
+
+
+case $LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR in
+
+
+#=====================================================================
+# test for 2.4.x kernels
+ 2.[01234])
+
+ rm -f ${KERN_BUILD_DIR}/kernel.mk
+ rm -rf ${KERN_TEST_DIR}
+ mkdir ${KERN_TEST_DIR}
+ cd ${KERN_TEST_DIR}
+
+ cat >${KERN_TEST_DIR}/Makefile <<EOF
+
+.PHONY: modules
+modules:
+ @echo LINUX_ARCH="\$(ARCH)" >>flags
+ @echo LINUX_LDFLAGS="" >>flags
+ @echo LINUX_ARFLAGS="\$(ARFLAGS)" >>flags
+ @echo LINUX_CROSS_COMPILE="\$(CROSS_COMPILE)" >>flags
+ @echo LINUX_KERNELRELEASE="\$(KERNELRELEASE)" >>flags
+ @echo LINUX_AFLAGS="\$(AFLAGS)" | sed 's#Iinclude#I"\$(LINUXDIR)/include"#g'>>flags
+ @echo LINUX_CFLAGS="\$(CFLAGS)" | sed 's#Iinclude#I"\$(LINUXDIR)/include"#g'>>flags
+ @echo LINUX_MODFLAGS="\$(MODFLAGS)"
+ @echo LINUX_CC="\$(CC)" >>flags
+ @echo LINUX_LD="\$(LD) \$(LDFLAGS)" >>flags
+ @echo LINUX_AS="\$(AS)" >>flags
+ @echo LINUX_AR="\$(AR)" >>flags
+ @echo LINUX_MODULE_EXT=".o" >>flags
+
+EOF
+
+ #echo ${MAKE} -C ${LINUX_DIR} SUBDIRS=${KERN_TEST_DIR} modules
+ ${MAKE} -C ${LINUX_DIR} SUBDIRS=${KERN_TEST_DIR} modules
+ if [ $? == 0 ] ; then
+ cp -v flags ${KERN_MODULES_DIR}/kernel.mk
+ if [ ! $? == 0 ] ; then
+ RETVAL="2"
+ fi
+ else
+ RETVAL="1"
+ fi
+
+ cd ${KERN_BUILD_DIR}
+ rm -rf ${KERN_TEST_DIR}
+ ;;
+
+#=====================================================================
+# test for 2.6.x kernels
+
+ 2.6)
+
+ rm -f ${KERN_BUILD_DIR}/kernel.mk
+ rm -rf ${KERN_TEST_DIR}
+ mkdir ${KERN_TEST_DIR}
+ cd ${KERN_TEST_DIR}
+
+ cat >${KERN_TEST_DIR}/Makefile <<EOF
+obj-m += fake.o
+
+\$(obj)/fake.c: flags
+ touch \$(obj)/fake.c
+
+ifeq (\$(KBUILD_SRC),)
+OMK_LINUX_SRC = \$(LINUXDIR)
+else
+OMK_LINUX_SRC = \$(KBUILD_SRC)
+endif
+#\$(warning Test \$OMK_LINUX_SRC)
+
+.PHONY: flags
+flags:
+ @echo LINUX_SRC="\$(OMK_LINUX_SRC)" >>\$(obj)/flags
+ @echo LINUX_ARCH="\$(ARCH)" >>\$(obj)/flags
+ @echo LINUX_LDFLAGS="" >>\$(obj)/flags
+ @echo LINUX_ARFLAGS="\$(ARFLAGS)" >>\$(obj)/flags
+ @echo LINUX_CROSS_COMPILE="\$(CROSS_COMPILE)" >>\$(obj)/flags
+ @echo LINUX_KERNELRELEASE="\$(KERNELRELEASE)" >>\$(obj)/flags
+ @echo LINUX_CPPFLAGS="\$(CPPFLAGS)" | sed 's#Iinclude#I"\$(LINUXDIR)/include"#g'>>\$(obj)/flags
+ @echo LINUX_AFLAGS="\$(AFLAGS)" | sed 's#Iinclude#I"\$(OMK_LINUX_SRC)/include"#g'>>\$(obj)/flags
+ @echo LINUX_CFLAGS="\$(CFLAGS)" | sed 's#Iinclude#I"\$(OMK_LINUX_SRC)/include"#g'>>\$(obj)/flags
+ @echo LINUX_CFLAGS_MODULE="\$(CFLAGS_MODULE)" >>\$(obj)/flags
+ @echo LINUX_CC="\$(CC)" >>\$(obj)/flags
+ @echo LINUX_LD="\$(LD) \$(LDFLAGS) \$(LDFLAGS_MODULE)" >>\$(obj)/flags
+ @echo LINUX_AS="\$(AS)" >>\$(obj)/flags
+ @echo LINUX_AR="\$(AR)" >>\$(obj)/flags
+ @echo LINUX_MODULE_EXT=".ko" >>\$(obj)/flags
+EOF
+
+ # V=1
+ #echo ${MAKE} -C ${LINUX_DIR} SUBDIRS=${KERN_TEST_DIR} LINUXDIR=${LINUX_DIR} MODVERDIR=${KERN_TEST_DIR} modules
+ ${MAKE} -C ${LINUX_DIR} SUBDIRS=${KERN_TEST_DIR} LINUXDIR=${LINUX_DIR} MODVERDIR=${KERN_TEST_DIR} modules
+ #if [ $? == 0 ] ; then
+ cp -v flags ${KERN_MODULES_DIR}/kernel.mk
+ if [ ! $? == 0 ] ; then
+ RETVAL="2"
+ fi
+ #else
+ # RETVAL="1"
+ #fi
+
+ cd ${KERN_BUILD_DIR}
+ rm -rf ${KERN_TEST_DIR}
+ ;;
+
+#=====================================================================
+
+ *)
+ echo "Unsupported Linux version $LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR"
+ ;;
+esac
+
+
+exit ${RETVAL}
--- /dev/null
+#!/bin/bash
+
+# Script to modify Makefile.rules for standalone build
+# without OCERA framework
+
+if [ ! -e Makefile.rules-ocera ] ; then
+ cp Makefile.rules Makefile.rules-ocera
+fi
+
+if [ -e OCERA_TOP_DIR ] ; then
+ mv -f OCERA_TOP_DIR OCERA_TOP_DIR-ocera
+fi
+
+# Commentout definition of OCERA location
+#sed -e 's/^OCERA_DIR := /#OCERA_DIR := /' <Makefile.rules-ocera >Makefile.rules
+
+# Prepare "config.omk-default" file, user overrides should go into "config.omk"
+make default-config
+
+echo
+echo 'To modify required configuration options, create "config.omk" file'
+echo 'and add modified lines from "config.omk-default" file into it'
+echo
+echo 'To build project, call simple "make"'
+echo
+echo 'GNU make program version 3.81beta1 or newer is required to build project'
+echo 'check by "make --version" command'
+echo
--- /dev/null
+#!/bin/sh
+# Script to test native build of LinCAN in the KDE konsole window
+# This script uses command DCOP scripting capabilities of konsole
+# and if it is started from already running console, scripting has to be enabled.
+# Parameter "--script" is required when konsole has been started.
+# konsole --script
+
+#CAN_SRC_DIR=~/ocera/ocera-pc104/components/comm/can
+#CAN_BIN_DIR=~/ocera/ocera-pc104/target-i386/usr/bin
+#CAN_UTILS_DIR=~/ocera/ocera-pc104/target-i386/usr/bin
+
+if [ -z "$CAN_BIN_DIR" ] ; then
+ MAKERULES_DIR=$( cd `dirname $0` ; old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$old_pwd" == `pwd` ] ; \
+ then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd )
+ CAN_BIN_DIR="$MAKERULES_DIR/_compiled/bin"
+ CAN_UTILS_DIR="$MAKERULES_DIR/_compiled/bin-utils"
+ CAN_MODULES_DIR="$MAKERULES_DIR/_compiled/modules"
+fi
+
+if [ -z "$CAN_SRC_DIR" ] ; then
+ CAN_SRC_DIR=$(cd `dirname $0` ; pwd)
+fi
+
+if [ -z "$(lsmod | grep '^lincan' )" ] ; then
+ echo Inserting LinCAN module
+ echo insmod $CAN_MODULES_DIR/lincan.*o hw=virtual io=0
+ insmod $CAN_MODULES_DIR/lincan.*o hw=virtual io=0
+ if [ $? -ne 0 ] ; then
+ echo "Trying to insert LinCAN in the supervisor/root mode"
+ su -c "insmod $CAN_MODULES_DIR/lincan.*o hw=virtual io=0"
+ if [ $? -ne 0 ] ; then
+ echo LinCAN has not been inserted and attempt to insert it failed
+ exit 1
+ fi
+ fi
+fi
+
+if [ -n "$KONSOLE_DCOP" ] ; then
+ #DCOPRef(konsole-9272,konsole)
+ konsole=$(echo "$KONSOLE_DCOP" | sed -n 's/DCOPRef(\([^,]*\),konsole)/\1/p')
+else
+ konsole=$(dcopstart konsole-script)
+fi
+
+echo "INVOKING: cd $CAN_SRC_DIR"
+session=$(dcop $konsole konsole newSession)
+dcop $konsole $session renameSession Compile
+dcop $konsole $session sendSession "cd $CAN_SRC_DIR"
+
+echo "INVOKING: cd $CAN_BIN_DIR ; ./canblaster -g 15"
+session=$(dcop $konsole konsole newSession)
+dcop $konsole $session renameSession canblaster
+dcop $konsole $session sendSession "cd $CAN_BIN_DIR ; ./canblaster -g 15"
+
+echo "INVOKING: cd $CAN_BIN_DIR ; ./canslave -g 15 -e $CAN_SRC_DIR/nascan.eds -s $CAN_SRC_DIR/nascan.hds"
+session=$(dcop $konsole konsole newSession)
+dcop $konsole $session renameSession canslave
+dcop $konsole $session sendSession "cd $CAN_BIN_DIR ; ./canslave -g 15 -e $CAN_SRC_DIR/candev/nascan.eds -s $CAN_SRC_DIR/candev/nascan.hds"
+
+echo "INVOKING: cd $CAN_BIN_DIR ; ./canmonitor"
+session=$(dcop $konsole konsole newSession)
+dcop $konsole $session renameSession canmonitor
+dcop $konsole $session sendSession "cd $CAN_BIN_DIR ; ./canmonitor"
+
+echo "INVOKING: cd $CAN_UTILS_DIR ; ./readburst"
+session=$(dcop $konsole konsole newSession)
+dcop $konsole $session renameSession readburst
+dcop $konsole $session sendSession "cd $CAN_UTILS_DIR ; ./readburst"
--- /dev/null
+# Makefile.rules - OCERA make framework common project rules -*- makefile -*-
+#
+# (C) Copyright 2003 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
+# 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
+# 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
+# INCLUDES .. additional include directories and defines for user-space
+# kernel_INCLUDES .. additional include directories and defines for kernel-space
+# rtlinux_INCLUDES .. additional include directories and defines for RT-Linux
+# default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ...
+#
+# LINUX_DIR .. location of Linux kernel sources
+# RTL_DIR .. location of RT-Linux sources
+
+# 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 $(MAKERULES_DIR)/../../../.. ; pwd -L ) )
+-include $(MAKERULES_DIR)/OCERA_TOP_DIR
+
+BUILD_DIR_NAME = _build
+COMPILED_DIR_NAME = _compiled
+ifndef GROUP_DIR_NAME
+GROUP_DIR_NAME = nogroup
+endif
+
+# We need to ensure definition of sources directory first
+ifndef SOURCES_DIR
+SOURCES_DIR := $(shell ( pwd -L ) )
+endif
+
+all: default
+
+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_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)),)
+#include $(CONFIG_FILE)
+CONFIG_FILE_OK = y
+endif
+else # OCERA_DIR
+KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
+KERN_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
+KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
+KERN_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
+KERN_MODPOST_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern-modpost
+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
+ifndef LINUX_VERSION
+LINUX_VERSION=$(shell uname -r)
+endif
+ifndef LINUX_DIR
+LINUX_DIR=/lib/modules/$(LINUX_VERSION)/build
+endif
+endif # OCERA_DIR
+
+# Check and include real OCERA style Makefile.omk now
+ifndef OMK_INCLUDED
+include $(SOURCES_DIR)/Makefile.omk
+OMK_INCLUDED := 1
+endif
+
+# Check for target
+OS_TARGET = linux
+ifeq ($(OS),Windows_NT)
+ OS_TARGET = win32
+endif
+
+export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR LINUX_DIR LINUX_VERSION RTL_DIR
+export CONFIG_FILE OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT
+export OS_TARGET
+
+#CFLAGS += -ggdb
+CFLAGS += -O2
+CFLAGS += -Wall
+#CXXFLAGS += -ggdb
+CXXFLAGS += -O2
+CXXFLAGS += -Wall
+
+
+CPPFLAGS += -I $(USER_INCLUDE_DIR)
+
+LOADLIBES += -L$(USER_LIB_DIR)
+
+LOADLIBES += $(lib_LOADLIBES:%=-l%)
+
+LIB_CPPFLAGS += $(CPPFLAGS)
+LIB_CFLAGS += $(CFLAGS)
+
+SOLIB_PICFLAGS += -shared
+ifeq ($(OS_TARGET),linux)
+ SOLIB_PICFLAGS += -fpic
+endif
+
+SOLIB_EXT = so
+ifeq ($(OS_TARGET),win32)
+ SOLIB_EXT = dll
+endif
+
+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:/%=%)
+
+#$(warning RELATIVE_PREFIX = $(RELATIVE_PREFIX))
+
+#vpath %.c $(SOURCES_DIR)
+#vpath %.cc $(SOURCES_DIR)
+#vpath %.cxx $(SOURCES_DIR)
+
+VPATH = $(SOURCES_DIR)
+srcdir = $(SOURCES_DIR)
+
+USER_OBJS_DIR = $(USER_BUILD_DIR)/$(RELATIVE_DIR)
+KERN_OBJS_DIR = $(KERN_BUILD_DIR)/$(RELATIVE_DIR)
+
+.PHONY: default dep subdirs clean clean-custom cleandepend default-config
+.PHONY: check-make-ver check-dir include-pass library-pass binary-pass utils-pass
+.PHONY: kernel-lib-pass kernel-pass kernel-mod-pass kernel-modpost-pass default-config-pass
+.PHONY: check-dir-local include-pass-local library-pass-local binary-pass-local
+.PHONY: utils-pass-local kernel-lib-pass-local kernel-mod-pass-local kernel-modpost-pass-local
+.PHONY: 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
+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
+
+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 kernel-lib-pass kernel-pass
+
+#=====================================================================
+# Common utility rules
+
+define mkdir_def
+ [ -d $(1) ] || mkdir -p $(1) || exit 1
+endef
+
+ifdef LOCAL_CONFIG_H
+
+$(LOCAL_CONFIG_H) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+ @echo LOCAL_CONFIG_H=`pwd`/$(LOCAL_CONFIG_H)
+ @echo "/* Automatically generated from */" > "$(LOCAL_CONFIG_H).tmp"
+ @echo "/* config file : $< */" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#ifndef _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#define _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @( $(foreach x, $(shell echo $(default_CONFIG) | sed -e 's/\<\([^ ]*\)=[^ ]\>/\1/g' ), \
+ echo $(x).$($(x)) ; ) echo ; ) | \
+ sed -n -e 's/^\(.*\)\.[ym]$$/#define \1 1/p' \
+ >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#endif /*_LOCAL_CONFIG_H*/" >> "$(LOCAL_CONFIG_H).tmp"
+ @if cmp --quiet "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; then \
+ echo rm "$(LOCAL_CONFIG_H).tmp" ; \
+ else mv "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; \
+ echo Updated configuration "$(LOCAL_CONFIG_H)" ; fi
+
+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
+
+#=====================================================================
+# 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) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_USER
+
+cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_USER
+
+idl_COMPILE = $(IDL_COMPILER)
+
+# Check GCC version for user build
+ifndef CC_MAJOR_VERSION
+CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(CC_MAJOR_VERSION),2)
+CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+
+
+
+define COMPILE_c_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(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
+endef
+
+
+
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(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
+endef
+
+define COMPILE_idl_template
+$(2).c $(2).h: $(1)
+ @$(QUIET_CMD_ECHO) " IDL $$@"
+ $(Q) $$(idl_COMPILE) $(1)
+endef
+
+
+define PROGRAM_template
+
+USER_IDLS += $$($(1)_IDL)
+$(1)_OBJS += $$(filter %.o,$$($(1)_IDL:%.idl=%.o))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c))
+
+$(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 := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+
+$(2)/$(1): $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " LINK $$@"
+ $(Q) $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES:%.cxx=%.cc))" ] ; then echo $$(CC) ; else echo $$(CXX) ; fi) \
+ $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) $$(LOADLIBES) $$(LDFLAGS) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -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
+ @echo >>$(USER_OBJS_DIR)/$(1).exe.d
+endef
+
+
+
+define LIBRARY_template
+
+USER_IDLS += $$($(1)_IDL)
+$(1)_OBJS += $$(filter %.o,$$($(1)_IDL:%.idl=%.o))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c))
+
+$(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 := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+
+$(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR $$@"
+ $(Q) $(AR) rcs $$@ $$^
+endef
+
+
+
+define SOLIB_template
+
+USER_IDLS += $$($(1)_IDL)
+$(1)_OBJSLO += $$(filter %.lo,$$($(1)_IDL:%.idl=%.lo))
+SOLIB_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c))
+
+$(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 := $$(sort $$($(1)_OBJSLO))
+
+SOLIB_OBJS += $$($(1)_OBJSLO)
+SOLIB_SOURCES += $$($(1)_SOURCES)
+
+$(USER_LIB_DIR)/lib$(1).$(SOLIB_EXT): $$($(1)_OBJSLO)
+ @$(QUIET_CMD_ECHO) " LINK $$@"
+ $(Q) $(LD) --shared --soname=lib$(1).$(SOLIB_EXT) -o $$@ $$^ $(LOADLIBES)
+endef
+
+
+
+library-pass-local: $(lib_LIBRARIES:%=$(USER_LIB_DIR)/lib%.a) $(shared_LIBRARIES:%=$(USER_LIB_DIR)/lib%.$(SOLIB_EXT))
+
+binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%)
+
+utils-pass-local: $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%)
+
+$(foreach prog,$(utils_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR))))
+
+$(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR))))
+
+$(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
+
+$(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))
+
+-include $(USER_OBJS_DIR)/*.d
+
+endif
+
+#=====================================================================
+# Kernel-space rules and templates to compile modules, libraries etc.
+
+ifdef KERN_RULE_TEMPLATES
+
+$(KERN_LIB_DIR)/kernel.mk: $(LINUX_DIR)/.config $(MAKERULES_DIR)/kernelcfg2mk
+ @$(QUIET_CMD_ECHO) " KCFG2MK $$@"
+ $(Q) $(MAKERULES_DIR)/kernelcfg2mk $(LINUX_DIR) $(KERN_LIB_DIR)
+
+ifeq ($(CONFIG_RTLINUX),y)
+include $(RTL_DIR)/rtl.mk
+
+KERN_CC = $(CC)
+kern_GCCLIB_DIR=$(shell LANG=C LC_ALL=C LC_MESSAGES=C $(CC) -print-search-dirs | sed -n -e 's/^install: \(.*\)$$/\1/p' )
+INCLUDES := -I $(KERN_INCLUDE_DIR) $(INCLUDE) $(rtlinux_INCLUDES) $(kernel_INCLUDES)
+#-DEXPORT_NO_SYMBOLS
+c_o_kern_COMPILE = $(KERN_CC) -idirafter $(kern_GCCLIB_DIR)/include $(INCLUDES) $(CFLAGS) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB -nostdinc
+cc_o_kern_COMPILE = $(CXX) $(INCLUDES) $(CXXFLAGS) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB
+KERN_EXE_SUFFIX := .o
+KERN_ARCH = $(ARCH)
+KERN_LD = $(LD)
+KERN_AR = $(AR)
+
+else # CONFIG_RTLINUX
+
+include $(KERN_LIB_DIR)/kernel.mk
+
+ifeq ($(LINUX_SRC),)
+LINUX_SRC = $(LINUX_DIR)
+endif
+kernel_INCLUDES += -idirafter $(LINUX_SRC)/include/linux
+
+ifdef LINUX_CC
+KERN_CC = $(LINUX_CC)
+kern_GCCLIB_DIR=$(shell LANG=C LC_ALL=C LC_MESSAGES=C $(LINUX_CC) -print-search-dirs | sed -n -e 's/^install: \(.*\)$$/\1/p' )
+else
+KERN_CC = echo KERN_CC not defined - compilation skipped
+endif
+c_o_kern_COMPILE = $(KERN_CC) $(kernel_INCLUDES) -idirafter $(kern_GCCLIB_DIR)/include $(LINUX_CPPFLAGS) $(LINUX_CFLAGS) $(LINUX_CFLAGS_MODULE) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB -nostdinc
+cc_o_kern_COMPILE = $(KERN_CC) $(kernel_INCLUDES) -idirafter $(kern_GCCLIB_DIR)/include $(LINUX_CPPFLAGS) $(LINUX_CFLAGS) $(LINUX_CFLAGS_MODULE) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB
+KERN_EXE_SUFFIX := $(LINUX_MODULE_EXT)
+KERN_LDFLAGS = $(LINUX_LDFLAGS)
+ifdef LINUX_ARCH
+KERN_ARCH = $(LINUX_ARCH)
+else
+KERN_ARCH = echo KERN_ARCH not defined - skipped
+endif
+ifdef LINUX_LD
+KERN_LD = $(LINUX_LD)
+else
+KERN_LD = echo KERN_LD not defined - skipped
+endif
+ifneq ($(LINUX_AR),)
+KERN_AR = $(LINUX_AR)
+else
+KERN_AR = $(AR)
+endif
+endif # CONFIG_RTLINUX
+
+KERN_LOADLIBES += -L$(KERN_LIB_DIR)
+
+KERN_LOADLIBES += $(rtlinux_LOADLIBES:%=-l%)
+KERN_LOADLIBES += $(kernel_LOADLIBES:%=-l%)
+
+
+
+# Check GCC version for kernel part of build
+ifndef kern_CC_MAJOR_VERSION
+kern_CC_MAJOR_VERSION := $(shell $(KERN_CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(kern_CC_MAJOR_VERSION),2)
+kern_CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+kern_CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+ifeq ($(KERN_EXE_SUFFIX),.ko)
+ifeq ($(wildcard $(LINUX_DIR)/scripts/mod/modpost),)
+KERN_MODPOST = $(LINUX_DIR)/scripts/modpost
+else
+KERN_MODPOST = $(LINUX_DIR)/scripts/mod/modpost
+endif
+KERN_MODULES_LINK_DIR = $(KERN_MODPOST_DIR)
+KERN_LINK_SUFFIX = .o
+else
+KERN_MODULES_LINK_DIR = $(KERN_MODULES_DIR)
+KERN_LINK_SUFFIX = $(KERN_EXE_SUFFIX)
+endif
+
+define COMPILE_c_o_kern_template
+
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CC [K] $$@"
+ $(Q) if $$(c_o_kern_COMPILE) $$(kern_CC_DEPFLAGS) $(3) -DKBUILD_BASENAME=$(notdir $(basename $(1))) \
+ -o $$@ -c $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+
+define COMPILE_cc_o_kern_template
+
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CXX [K] $$@"
+ $(Q) if $$(cc_o_kern_COMPILE) $$(kern_CC_DEPFLAGS) $(3) -DKBUILD_BASENAME=$(notdir $(basename $(1))) \
+ -o $$@ -c $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+
+define MODULE_kern_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 := $$(sort $$($(1)_OBJS))
+
+KERN_OBJS += $$($(1)_OBJS)
+KERN_SOURCES += $$($(1)_SOURCES)
+
+# this is hack to build "__this_module" structure for 2.6.x kernels
+# modpost is used for that purpose now
+
+#$(1).mod.c:
+# echo "\
+# #include <linux/version.h>@\
+# #include <linux/module.h>@\
+# #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,5))@\
+# #include <linux/vermagic.h>@\
+# #include <linux/compiler.h>@\
+# @\
+# MODULE_INFO(vermagic, VERMAGIC_STRING);@\
+# @\
+# #undef unix@\
+# struct module __this_module@\
+# __attribute__((section(\".gnu.linkonce.this_module\"))) = {@\
+# .name = __stringify(KBUILD_MODNAME),@\
+# .init = init_module,@\
+# #ifdef CONFIG_MODULE_UNLOAD@\
+# .exit = cleanup_module,@\
+# #endif@\
+# };@\
+# #endif@\
+# " | tr @ \\n >$$@
+
+
+#$(eval $(call COMPILE_c_o_kern_template,$(1).mod.c,$(1).mod.o,-DKBUILD_MODNAME=$(1)))
+
+$(2)/$(1)$(KERN_LINK_SUFFIX): $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " LD [K] $$@"
+ $(Q) $$(KERN_LD) $$(KERN_LDFLAGS) -r $$($(1)_OBJS) -L$$(kern_GCCLIB_DIR) $$($(1)_LIBS:%=-l%) $$(KERN_LOADLIBES) -Map $(KERN_OBJS_DIR)/$(1).mod.map -o $$@
+ @echo "$(2)/$(1)$(KERN_LINK_SUFFIX): \\" >$(KERN_OBJS_DIR)/$(1).mod.d
+ @sed -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(KERN_OBJS_DIR)/$(1).mod.map >>$(KERN_OBJS_DIR)/$(1).mod.d
+ @echo >>$(KERN_OBJS_DIR)/$(1).mod.d
+ @if [ "$(KERN_EXE_SUFFIX)" == ".ko" ] ; then \
+ echo $(1) >>$(KERN_MODPOST_DIR)/module-changes ; \
+ echo $(1) >>$(KERN_MODPOST_DIR)/$(1).mod.stamp ; \
+ fi
+
+endef
+
+
+
+define LIBRARY_kern_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 := $$(sort $$($(1)_OBJS))
+
+KERN_OBJS += $$($(1)_OBJS)
+KERN_SOURCES += $$($(1)_SOURCES)
+
+$(KERN_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR [K] $$@"
+ $(Q) $(KERN_AR) rcs $$@ $$^
+endef
+
+
+ifdef LINUX_DIR
+
+kernel-lib-pass-local: $(kernel_LIBRARIES:%=$(KERN_LIB_DIR)/lib%.a)
+
+kernel-mod-pass-local: $(kernel_MODULES:%=$(KERN_MODULES_LINK_DIR)/%$(KERN_LINK_SUFFIX))
+
+$(foreach module,$(kernel_MODULES),$(eval $(call MODULE_kern_template,$(module),$(KERN_MODULES_LINK_DIR))))
+
+$(foreach lib,$(kernel_LIBRARIES),$(eval $(call LIBRARY_kern_template,$(lib))))
+
+endif
+
+
+ifeq ($(CONFIG_RTLINUX),y)
+
+kernel-mod-pass-local: $(rtlinux_MODULES:%=$(KERN_MODULES_LINK_DIR)/%$(KERN_LINK_SUFFIX))
+
+kernel-lib-pass-local: $(rtlinux_LIBRARIES:%=$(KERN_LIB_DIR)/lib%.a)
+
+$(foreach module,$(rtlinux_MODULES),$(eval $(call MODULE_kern_template,$(module),$(KERN_MODULES_LINK_DIR))))
+
+$(foreach lib,$(rtlinux_LIBRARIES),$(eval $(call LIBRARY_kern_template,$(lib))))
+
+endif
+
+ifeq ($(KERN_MODPOST_PASS),y)
+
+MODULES_LIST := $(wildcard *.mod.stamp)
+MODULES_LIST := $(MODULES_LIST:%.mod.stamp=%)
+
+define MODPOST_kern_template
+$(2) : $(1)$(KERN_LINK_SUFFIX) $(1).mod.c
+ @$(QUIET_CMD_ECHO) " LD [M] $$@"
+ $(Q) $$(cc_o_kern_COMPILE) -DKBUILD_BASENAME=$(1) -DKBUILD_MODNAME=$(1) -o $(1).mod.o -c $(1).mod.c
+ $(Q) $$(KERN_LD) $$(KERN_LDFLAGS) $(1)$(KERN_LINK_SUFFIX) $(1).mod.o -r -o $$@
+endef
+
+kernel-modpost-versions: $(wildcard $(LINUX_DIR)/Module.symvers)
+ @$(QUIET_CMD_ECHO) " MODPOST $(KERN_MODPOST_DIR)"
+ @echo >$(KERN_MODPOST_DIR)/modpost-running
+ @rm -f $(KERN_MODPOST_DIR)/module-changes
+ $(Q) $(KERN_MODPOST) $(MODULES_LIST:%=%$(KERN_LINK_SUFFIX)) $(^:%=-i %)
+
+$(MODULES_LIST:%=%.mod.c) : kernel-modpost-versions
+
+kernel-modpost-pass-local: $(MODULES_LIST:%=$(KERN_MODULES_DIR)/%$(KERN_EXE_SUFFIX))
+ @rm -f $(KERN_MODPOST_DIR)/modpost-running
+
+$(foreach module,$(MODULES_LIST),$(eval $(call MODPOST_kern_template,$(module),$(module:%=$(KERN_MODULES_DIR)/%$(KERN_EXE_SUFFIX)))))
+
+endif
+
+-include $(KERN_OBJS_DIR)/*.d
+
+endif
+
+#=====================================================================
+
+
+kernel-lib-pass:
+ +@$(foreach dir, $(SUBDIRS), $(call mkdir_def,$(KERN_OBJS_DIR)/$(dir)) ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(KERN_OBJS_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;)
+ +@$(call mkdir_def,$(KERN_OBJS_DIR))
+ +@if [ -n "$(kernel_LIBRARIES)$(rtlinux_LIBRARIES)" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_OBJS_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y $(@:%=%-local) ; \
+ fi
+
+kernel-mod-pass:
+ +@$(foreach dir, $(SUBDIRS), $(call mkdir_def,$(KERN_OBJS_DIR)/$(dir)) ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(KERN_OBJS_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;)
+ +@$(call mkdir_def,$(KERN_OBJS_DIR))
+ +@if [ -n "$(kernel_MODULES)$(rtlinux_MODULES)" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_OBJS_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y $(@:%=%-local) ; \
+ fi
+
+kernel-modpost-pass:
+ +@if [ -e "$(KERN_MODPOST_DIR)/module-changes" -o -e "$(KERN_MODPOST_DIR)/modpost-running" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_MODPOST_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y KERN_MODPOST_PASS=y $(@:%=%-local) ; \
+ fi
+
+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 ;)
+ +@$(foreach dir, $(QT_SUBDIRS), $(call mkdir_def,$(USER_OBJS_DIR)/$(dir)) ; \
+ if [ "$@" != "binary-pass" ] ; then exit 0 ; fi ; \
+ if [ ! -e $(SOURCES_DIR)/$(dir)/Makefile ] ; then \
+ ( cd $(SOURCES_DIR)/$(dir) ; $$QTDIR/bin/qmake TOP_DIR=$(MAKERULES_DIR) \
+ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) || exit 1 ;) ; fi ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(SOURCES_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,$(KERN_OBJS_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,$(KERN_MODULES_DIR))
+ @$(call mkdir_def,$(KERN_MODPOST_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:
+ @$(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 ; )
+# Kernel and RT-Linux stuff
+ @$(call mkdir_def,$(KERN_INCLUDE_DIR))
+ @$(foreach f, $(kernel_HEADERS) $(rtlinux_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(notdir $(f)) \
+ || cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(notdir $(f)) || exit 1 ; )
+ @$(foreach f, $(nobase_kernel_HEADERS) $(nobase_rtlinux_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(f) \
+ || ( mkdir -p $(KERN_INCLUDE_DIR)/$(dir $(f)) && cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(f) ) || exit 1 ; )
+ @$(foreach f, $(renamed_kernel_HEADERS) $(renamed_rtlinux_HEADERS), \
+ srcfname=`echo '$(f)' | sed -e 's/^\(.*\)->.*$$/\1/'` ; destfname=`echo '$(f)' | sed -e 's/^.*->\(.*\)$$/\1/'` ; \
+ cmp --quiet $(SOURCES_DIR)/$${srcfname} $(KERN_INCLUDE_DIR)/$${destfname} \
+ || ( mkdir -p `dirname $(KERN_INCLUDE_DIR)/$${destfname}` && cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$${srcfname} $(KERN_INCLUDE_DIR)/$${destfname} ) || exit 1 ; )
+
+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 %.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 %.c,$(SOLIB_GEN_SOURCES)),$(eval $(call COMPILE_c_o_template,$(src),$(src:%.c=%.lo),$(SOLIB_PICFLAGS))))
+
+# IDL compilation
+
+USER_IDLS := $(sort $(USER_IDLS))
+
+#$(warning USER_IDLS = $(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))
+
+#$(warning KERN_SOURCES = $(KERN_SOURCES))
+
+$(foreach src,$(filter %.c,$(KERN_SOURCES)),$(eval $(call COMPILE_c_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.c=%.o),)))
+
+$(foreach src,$(filter %.cc,$(KERN_SOURCES)),$(eval $(call COMPILE_cc_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%.o),)))
+
+$(foreach src,$(filter %.cxx,$(KERN_SOURCES)),$(eval $(call COMPILE_cc_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.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)/*.o $(USER_OBJS_DIR)/*.lo \
+ $(KERN_OBJS_DIR)/*.d $(USER_OBJS_DIR)/*.d \
+ $(KERN_OBJS_DIR)/*.map $(USER_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)/%)
+ @if [ -e $(KERN_LIB_DIR)/kernel.mk ] ; then \
+ touch -t 200001010101 $(KERN_LIB_DIR)/kernel.mk ; \
+ fi
+
+
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
--- /dev/null
+SUBDIRS = system_opt libbar appfoo
+
--- /dev/null
+# Makefile.rules - OCERA make framework common project rules
+# This version is adapted for RTEMS build
+#
+# (C) Copyright 2003 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
+# 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
+# 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
+#
+
+# Include RTEMS target configuration defining RTEMS_MAKEFILE_PATH
+include $(MAKERULES_DIR)/config.target
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(CONFIG.CC)
+
+BUILD_DIR_NAME = _build/$(RTEMS_BSP)
+COMPILED_DIR_NAME = _compiled/$(RTEMS_BSP)
+GROUP_DIR_NAME =
+
+
+# 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
+
+#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%)
+
+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))
+
+#$(warning SOURCES_DIR = $(SOURCES_DIR))
+#$(warning MAKERULES_DIR = $(MAKERULES_DIR))
+#$(warning RELATIVE_DIR = $(RELATIVE_DIR))
+
+#vpath %.c $(SOURCES_DIR)
+#vpath %.cc $(SOURCES_DIR)
+#vpath %.cxx $(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
+
+ifdef LOCAL_CONFIG_H
+
+$(LOCAL_CONFIG_H) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+ @echo LOCAL_CONFIG_H=`pwd`/$(LOCAL_CONFIG_H)
+ @echo "/* Automatically generated from */" > "$(LOCAL_CONFIG_H).tmp"
+ @echo "/* config file : $< */" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#ifndef _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#define _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @( $(foreach x, $(shell echo $(default_CONFIG) | sed -e 's/\<\([^ ]*\)=[^ ]\>/\1/g' ), \
+ echo $(x).$($(x)) ; ) echo ; ) | \
+ sed -n -e 's/^\(.*\)\.[ym]$$/#define \1 1/p' \
+ >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#endif /*_LOCAL_CONFIG_H*/" >> "$(LOCAL_CONFIG_H).tmp"
+ @if cmp --quiet "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; then \
+ echo rm "$(LOCAL_CONFIG_H).tmp" ; \
+ else mv "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; \
+ echo Updated configuration "$(LOCAL_CONFIG_H)" ; fi
+
+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
+
+#=====================================================================
+# 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).o: $(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
+
+include $(MAKERULES_DIR)/Makefile.rules.gcc
+
+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-pass-local: $(utils_PROGRAMS:%=$(USER_UTILS_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)/%)
+
+# Generate rules for compilation of programs and libraries
+
+$(foreach prog,$(utils_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR))))
+
+$(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR))))
+
+$(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_DIR)/$(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_DIR)/$(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:
+ @$(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 ; )
+
+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=%.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 %.S,$(USER_SOURCES)),$(eval $(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.o),)))
+
+# 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 %.cxx,$(SOLIB_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.lo),$(SOLIB_PICFLAGS))))
+
+$(foreach src,$(filter %.S,$(SOLIB_SOURCES)),$(eval $(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.lo),$(SOLIB_PICFLAGS))))
+
+$(foreach tarfile,$(USER_EMBEDTARFILES),$(eval $(call TARFILE_template,$(tarfile),$(tarfile)_tarfile,$(SOURCES_DIR)/$(tarfile))))
+
+endif
+
+
+clean-local:
+ @echo Cleaning in $(USER_OBJS_DIR)
+ @rm -f $(USER_OBJS_DIR)/*.o $(USER_OBJS_DIR)/*.lo \
+ $(USER_OBJS_DIR)/*.d \
+ $(USER_OBJS_DIR)/*.map \
+ $(LOCAL_CONFIG_H:%=$(USER_OBJS_DIR)/%) \
+ $(tar_EMBEDFILES:%=$(USER_OBJS_DIR)/%_tarfile)
+
+
--- /dev/null
+#=====================================================================
+# 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
+
+S_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ASFLAGS) -DOMK_FOR_USER
+
+# Check GCC version for user build
+ifndef CC_MAJOR_VERSION
+CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(CC_MAJOR_VERSION),2)
+CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+
+# Syntax: $(call COMPILE_c_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_c_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(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
+endef
+
+
+# Syntax: $(call COMPILE_cc_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(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
+endef
+
+
+# Syntax: $(call COMPILE_S_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_S_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+ @$(QUIET_CMD_ECHO) " AS $$@"
+ $(Q) if $$(S_o_COMPILE) -D__ASSEMBLY__ $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
+ then if [ -e "$$@.d.tmp" ] ; then mv -f "$$@.d.tmp" "$$@.d" ; fi ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+# Syntax: $(call CMETRIC_o_h_template,<object_file>,<target_header>)
+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 >$$@ '/* 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 >>$$@
+endef
+
+# Syntax: $(call PROGRAM_template,<dir>,<executable-name>,<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))
+$(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+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))" ] ; \
+ 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)
+#@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,<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))
+$(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES)
+
+$(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR $$@"
+ $(Q) $(AR) rcs $$@ $$^
+ @touch $(USER_LIB_DIR)/timestamp
+endef
+
+
+
+# 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))
+$(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
+$(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
+
--- /dev/null
+# Makefile.rules - OCERA make framework common project rules
+# This version is adapted for RTEMS build
+#
+# (C) Copyright 2003 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
+# 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
+# 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
+#
+
+# Include RTEMS target configuration defining RTEMS_MAKEFILE_PATH
+include $(MAKERULES_DIR)/config.target
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(CONFIG.CC)
+
+BUILD_DIR_NAME = _build/$(RTEMS_BSP)
+COMPILED_DIR_NAME = _compiled/$(RTEMS_BSP)
+GROUP_DIR_NAME =
+
+
+# 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
+
+#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%)
+
+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))
+
+#$(warning SOURCES_DIR = $(SOURCES_DIR))
+#$(warning MAKERULES_DIR = $(MAKERULES_DIR))
+#$(warning RELATIVE_DIR = $(RELATIVE_DIR))
+
+#vpath %.c $(SOURCES_DIR)
+#vpath %.cc $(SOURCES_DIR)
+#vpath %.cxx $(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
+
+ifdef LOCAL_CONFIG_H
+
+$(LOCAL_CONFIG_H) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+ @echo LOCAL_CONFIG_H=`pwd`/$(LOCAL_CONFIG_H)
+ @echo "/* Automatically generated from */" > "$(LOCAL_CONFIG_H).tmp"
+ @echo "/* config file : $< */" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#ifndef _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#define _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @( $(foreach x, $(shell echo $(default_CONFIG) | sed -e 's/\<\([^ ]*\)=[^ ]\>/\1/g' ), \
+ echo $(x).$($(x)) ; ) echo ; ) | \
+ sed -n -e 's/^\(.*\)\.[ym]$$/#define \1 1/p' \
+ >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#endif /*_LOCAL_CONFIG_H*/" >> "$(LOCAL_CONFIG_H).tmp"
+ @if cmp --quiet "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; then \
+ echo rm "$(LOCAL_CONFIG_H).tmp" ; \
+ else mv "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; \
+ echo Updated configuration "$(LOCAL_CONFIG_H)" ; fi
+
+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
+
+#=====================================================================
+# 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).o: $(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
+
+S_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ASFLAGS) -DOMK_FOR_USER
+
+# Check GCC version for user build
+ifndef CC_MAJOR_VERSION
+CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(CC_MAJOR_VERSION),2)
+CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+
+# Syntax: $(call COMPILE_c_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_c_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(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
+endef
+
+
+# Syntax: $(call COMPILE_cc_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(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
+endef
+
+
+# Syntax: $(call COMPILE_S_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_S_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+ @$(QUIET_CMD_ECHO) " AS $$@"
+ $(Q) if $$(S_o_COMPILE) -D__ASSEMBLY__ $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
+ then if [ -e "$$@.d.tmp" ] ; then mv -f "$$@.d.tmp" "$$@.d" ; fi ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+# Syntax: $(call CMETRIC_o_h_template,<object_file>,<target_header>)
+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 >$$@ '/* 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 >>$$@
+endef
+
+# Syntax: $(call PROGRAM_template,<dir>,<executable-name>,<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))
+$(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+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))" ] ; \
+ 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)
+#@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,<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))
+$(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES)
+
+$(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR $$@"
+ $(Q) $(AR) rcs $$@ $$^
+ @touch $(USER_LIB_DIR)/timestamp
+endef
+
+
+
+# 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))
+$(1)_OBJS += $$($(1)_EMBEDTARFILES:%=%_tarfile.o)
+$(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: $(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-pass-local: $(utils_PROGRAMS:%=$(USER_UTILS_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)/%)
+
+# Generate rules for compilation of programs and libraries
+
+$(foreach prog,$(utils_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR))))
+
+$(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR))))
+
+$(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_DIR)/$(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_DIR)/$(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:
+ @$(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 ; )
+
+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=%.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 %.S,$(USER_SOURCES)),$(eval $(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.o),)))
+
+# 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 %.cxx,$(SOLIB_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.lo),$(SOLIB_PICFLAGS))))
+
+$(foreach src,$(filter %.S,$(SOLIB_SOURCES)),$(eval $(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.lo),$(SOLIB_PICFLAGS))))
+
+$(foreach tarfile,$(USER_EMBEDTARFILES),$(eval $(call TARFILE_template,$(tarfile),$(tarfile)_tarfile,$(SOURCES_DIR)/$(tarfile))))
+
+endif
+
+
+clean-local:
+ @echo Cleaning in $(USER_OBJS_DIR)
+ @rm -f $(USER_OBJS_DIR)/*.o $(USER_OBJS_DIR)/*.lo \
+ $(USER_OBJS_DIR)/*.d \
+ $(USER_OBJS_DIR)/*.map \
+ $(LOCAL_CONFIG_H:%=$(USER_OBJS_DIR)/%) \
+ $(tar_EMBEDFILES:%=$(USER_OBJS_DIR)/%_tarfile)
+
+
--- /dev/null
+Description of OCERA Make System for CAN Components (OMK)
+=========================================================
+
+Important notice:
+This make system uses features found in recent versions of GNU Make
+program. If you encounter problems with package building,
+check, that you use correct version of Make program.
+The Make older than version 3.80, could not be used.
+Even Make version 3.80 has annoying bug which causes
+building fail with misleading message "virtual memory exhausted".
+Please, upgrade to last version of Make (3.81beta1).
+You can take it from GNU CVS or from our local copy
+
+http://cmp.felk.cvut.cz/~pisa/can/make-3.81beta1.tar.gz
+
+
+There is list of features which we want to solve with our makesystem:
+ - central Makefile.rules for most of subcomponents and components
+ (our CAN framework includes more libraries common with our other projects,
+ we need to separate some utility libraries etc.)
+ - the rules in more spread Makefiles are way to the hell,
+ (update for different kernel, RT-Linux etc would be nightmare in other case)
+ - make system should allow to freely move with cross-dependant components
+ without need to update users of moved component
+ (I hate somethink like -I../../sched/rtlshwq/include in CAN makefiles
+ for example. Component could be renamed to different name or version
+ could be added to name and all Makefiles in CAN would require to
+ be updated)
+ - make system should be able to compile mutually cross-dependant libraries
+ and should ensure, that change in one component sources or headers
+ would result in relink or rebuild in components linked against that library
+ or including modified header file
+ - make system has to enable compilation out of OCERA full source tree
+ (we would lost many users of particular components in other case)
+ - compile should be able to do all above work without need to install
+ any files before successful finish of build.
+ - because we use some libraries for RT-Linux build and userspace
+ build, we need to solve how to compile from same sources to both targets.
+ - the build system should allow to call make for particular source
+ subdirectory. Time of recursive make through all subdirectories is
+ unacceptable.
+ - make system should enable to build out of sources tree
+ (else clean or working with CVS sandbox gets fussy and simultaneous
+ multiple targets gets problematic)
+ - it would be good, if there would be possibility to make from read-only
+ media sources
+ - make system should store results of build in some separate directory
+ structure to simple install and testing
+ - Makefiles in sources directories should be simple
+
+There is probably only one alternative fully supporting above requirements
+and it is GNU Autoheader...Automake...Autoconf... system.
+But it is complicated and requires big amount of support files.
+It would be acceptable if it could be easily used for OCERA framework.
+But there are important show stopper for that system:
+ - it would require deep revision of all OCERA CVS contents and agreement
+ on this would be problematic
+ - this system is not well prepared for dual compilation for Linux
+ and RT-Linux sub-targets. It would mean many changes in default
+ autoconf setup to support this. Probably simplest way would be
+ to rebuild GCC tool chain for something like i586-elf-rtlinux.
+ This would require even more space for OCERA development.
+
+The problem calls for same solution, which would have minimal impact
+on other components and would be elegant and would be maintainable
+and small, because our main goal is components development and not
+make systems development.
+
+There is result of our trial. It is OMK make system.
+The Makefile and Makefile.omk files should be in all source
+directories. Common Makefile.rules file is required in the toplevel
+sources directory. Alternatively this file could be moved
+to link tree pointing into readonly media or can be anywhere
+else if MAKERULES_DIR and SOURCES_DIR are specified.
+
+Syntax of Makefile.omk files is for usual cases compatible
+to Automake's Makefile.am descriptions. There are specific targets
+for RT-Linux and Linux kernel related stuff
+
+Makefile.omk user defined variables
+# SUBDIRS .. list of subdirectories intended for make from actual directory
+# 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 header files
+# nobase_include_HEADERS .. headers copied even with directory part
+# kernel_HEADERS .. list of the kernel-space header files
+# rtlinux_HEADERS .. list of the RT-Linux kernel-space header files
+# bin_PROGRAMS .. list of the require binary programs
+# utils_PROGRAMS .. list of the development utility programs
+# 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
+# INCLUDES .. additional include directories and defines for user-space
+# kernel_INCLUDES .. additional include directories and defines for kernel-space
+# rtlinux_INCLUDES .. additional include directories and defines for RT-Linux
+# default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ...
+
+The Makefile is same for all sources directories and is only 14 lines long.
+It is there only for convenience reasons to enable call "make" from
+local directory. It contains code which locates Makefile.rules in actual
+or any parent directory. With standard BASH environment it works such way,
+that if you get into sources directory over symbolic links, it is able to
+unwind yours steps back => you can make links to readonly media component
+directories, copy Makefile.rules, Makefile and toplevel Makefile.omk,
+adjust Makefile.omk to contain only required components and then call
+make in top or even directories after crossing from your tree
+to readonly media.
+
+The system compiles all files out of source directories.
+The actual version of system is adapted even for OCERA tree mode
+if OCERA_DIR variable is defined in Makefile.rules
+
+There are next predefined directory name components,
+which can be adapted if required
+
+BUILD_DIR_NAME = _build
+ prefix of directory, where temporary build files are stored
+COMPILED_DIR_NAME = _compiled
+ prefix of directory, where final compilation results are stored
+GROUP_DIR_NAME = yyy
+ this is used for separation of build sub-trees in OCERA environment
+ where more Makefile.rules is spread in the tree
+
+Next directories are used:
+
+KERN_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
+ directory to store intermediate files for kernel-space targets
+USER_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/user
+ directory to store intermediate files for user-space targets
+
+USER_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include
+ directory to store exported include files which should be installed later
+ on user-space include path
+USER_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib
+ same for user-pace libraries
+USER_UTILS_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin-utils
+ utilities for testing, which would not probably be installed
+USER_BIN_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin
+ binaries, which should go into directory on standard system PATH
+ (/usr/local/bin, /usr/bin or $(prefix)/bin)
+
+KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
+ directory to store exported include files which should be installed later
+ on kernel-space include path
+KERN_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
+ same for kernel-pace libraries
+KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
+ builded modules for Linux kernel or RT-Linux system
+
+There is more recursive passes through directories to enable
+mutual dependant libraries and binaries to compile.
+Next passes are defined
+
+default-config .. generates config.omk-default or xxx-default configuration file
+check-dir .. checks and creates required build directories
+include-pass .. copyes header files to USER_INCLUDE_DIR and KERN_INCLUDE_DIR
+library-pass .. builds objects in USER_BUILD_DIR/<relative path> and creates
+ libraries in USER_LIB_DIR
+binary-pass and utils-pass .. links respective binaries
+ in USER_{BIN,UTILS}_DIR directory. If some object file is missing
+ it compiles it in USER_BUILD_DIR/<relative path>
+kernel-lib-pass .. builds libraries for kernel space targets
+kernel-pass .. builds kernel modules
+
+The amount of passes is relatively high and consumes some time.
+But only other way to support all required features is to assemble
+one big toplevel Makefile, which would contain all components
+and targets cross-dependencies.
+
+Drawbacks of designed make system
+ - the system is not as fast as we would like
+ - it lacks Autoconf and configure extensive support for many systems
+ from UNIX to DOS and WINDOWS
+ - it does not contain support for checking existence of target libraries
+ and functionalities as GNU Autoconf
+ - it is heavily dependant on GNU MAKE program. But it would not be big
+ problem, because even many commercial applications distribute GNU
+ MAKE with them to be able to work in non-friendly systems
+ - the key drawback is dependence on recent MAKE version 3.80 and better
+ and even version 3.80 of MAKE has important bug, which has been
+ corrected in newer sources
+
+The last point is critical. I have not noticed it first, because
+I use Slackware-9.2 and it contains latest released version
+of MAKE (version 3.80).
+The problem appears when I have tried to build bigger libraries.
+There is bug in version 3.80, which results in misleading
+error "Virtual memory exhausted". It is known bug with ID 1517
+
+ * long prerequisite inside eval(call()) => vm exhausted, Paul D. Smith
+
+I have optimized some rules to not push memory to the edge,
+but there could be still issues with 3.80 version.
+
+I have downloaded latest MAKE CVS sources. The compilation required
+separate lookup and download for .po files and full Autoheader... cycle.
+I have put together package similar to release. Only ./configure --prefix=...
+and make is required. CVS sources contains version 3.81beta1.
+You can download prepared sources archive from
+
+ http://cmp.felk.cvut.cz/~pisa/can/make-3.81beta1.tar.gz
+
+The archive contains even "make" binary build by me, which should work
+on other Linux distributions as well.
+Older version of MAKE (3.79.x released about year 2000) found
+on Mandrake and RedHat are not sufficient and do not support eval feature.
+I do not expect, that Debian would be more up-to-date or contain fixes
+to MAKE vm exhausted bug.
+
+The local CTU archive with our CAN components prepared for inclusion
+into OCERA SF CVS could be found in my "can" directory
+
+ http://cmp.felk.cvut.cz/~pisa/can/ocera-can-031212.tar.gz
+
+The code should build for user-space with new make on most of Linux distros
+when make is updated.
+
+If you want to test compile for RT-Linux targets, line
+
+#RTL_DIR := /home/cvs/ocera/ocera-build/kernel/rtlinux
+
+in "Makefile.rules" has to be activated and updated
+to point RT-Linux directory containing "rtl.mk".
+There is only one library ("ulutrtl") and test utility compiled for RT-Linux
+("can/utils/ulut/ul_rtlchk.c").
+
+The next line ,if enabled, controls compilation in OCERA project tree
+
+#OCERA_DIR := $(shell ( cd -L $(MAKERULES_DIR)/../../.. ; pwd -L ) )
+
+The LinCAN driver has been updated to compile out of source directories.
+
+Please, check, if you could compile CAN package and help us with integration
+into OCERA SF CVS. Send your comments and objections.
+
+The OMK system has been adapted to support actual OCERA configuration process.
+I am not happy with ocera.mk mix of defines and poor two or three rules,
+but OMK is able to overcome that.
+
+The OMK system has integrated rules (default-config) to build default configuration
+file. The file is named "config.omk-default" for the stand-alone compilation.
+The name corresponds to OCERA config + "-default" if OCERA_DIR is defined.
+This file contains statements from all default_CONFIG lines in all Makefile.omk.
+The file should be used for building of own "config.omk" file, or as list
+for all options if Kconfig is used.
+
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
--- /dev/null
+# -*- makefile -*-
+
+SUBDIRS = arch board drivers libs4c app
--- /dev/null
+# Makefile.rules - OCERA make framework common project rules -*- makefile -*-
+#
+# (C) Copyright 2003 by Pavel Pisa - OCERA team member
+#
+# 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
+# default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ...
+# local_EVALUATE .. commands to be evaluated at the end of the Makefile
+
+# We need to ensure definition of sources directory first
+ifndef SOURCES_DIR
+SOURCES_DIR := $(shell ( pwd -L ) )
+endif
+
+.PHONY: all default check-make-ver
+
+all: check-make-ver default
+
+#=========================
+# Include the config file
+
+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
+
+ifeq ($(wildcard $(MAKERULES_DIR)/config.target),$(MAKERULES_DIR)/config.target)
+$(error Please, rename $(MAKERULES_DIR)/config.target to config.omk!)
+endif
+
+BUILD_DIR_NAME = _build$(addprefix /,$(PREFIX_DIR))
+COMPILED_DIR_NAME = _compiled$(addprefix /,$(PREFIX_DIR))
+ifndef GROUP_DIR_NAME
+GROUP_DIR_NAME = nogroup
+endif
+
+
+export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR
+export CONFIG_FILE OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT
+
+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))
+
+LOCAL_BUILD_DIR=$(MAKERULES_DIR)/$(BUILD_DIR_NAME)/$(RELATIVE_DIR)
+#$(warning LOCAL_BUILD_DIR = $(LOCAL_BUILD_DIR))
+
+#vpath %.c $(SOURCES_DIR)
+#vpath %.cc $(SOURCES_DIR)
+#vpath %.cxx $(SOURCES_DIR)
+
+VPATH = $(SOURCES_DIR)
+srcdir = $(SOURCES_DIR)
+
+# 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
+ CP_FLAGS += -v
+endif
+
+# ===================================================================
+# We have set up all important variables, so we can check and include
+# real OCERA style Makefile.omk now
+ifndef OMK_INCLUDED
+include $(SOURCES_DIR)/Makefile.omk
+OMK_INCLUDED := 1
+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
+
+distclean dist-clean:
+ @$(QUIET_CMD_ECHO) " RM $(COMPILED_DIR_NAME) $(BUILD_DIR_NAME)"
+ @rm -fr $(MAKERULES_DIR)/$(COMPILED_DIR_NAME) $(MAKERULES_DIR)/$(BUILD_DIR_NAME)
+
+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
+
+# Common OMK templates
+# ====================
+
+# Syntax: $(call mkdir,<pass name(s)>,<local make flags>)
+define mkdir_def
+ [ -d $(1) ] || mkdir -p $(1) || exit 1
+endef
+
+# Syntax: $(call omk_pass_template,<pass name>,<local make flags>)
+define omk_pass_template
+.PHNOY: $(1) $(1)-local
+$(1):
+ +@$(foreach dir,$(SUBDIRS),$(call mkdir_def,$(LOCAL_BUILD_DIR)/$(dir)) ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) -C $(LOCAL_BUILD_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $$@ || exit 1 ;)
+ +@$(call mkdir_def,$(LOCAL_BUILD_DIR))
+ @$(MAKE) --no-print-directory -C $(LOCAL_BUILD_DIR) \
+ -f $(SOURCES_DIR)/Makefile $(2) $$(@:%=%-local)
+endef
+
+# =======================
+# DEFAULT CONFIG PASS
+
+$(eval $(call omk_pass_template,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" ; )
+
+
+# =======================
+
+
+# TODO: Put rules specific to C language to a separate file
+#include $(MAKERULES_DIR)/Makefile.rules.c-lang
+
+include $(MAKERULES_DIR)/Makefile.rules.systemless
+
+ifneq ($(local_EVALUATE),)
+#$(warning $(local_EVALUATE))
+$(eval $(local_EVALUATE))
+endif
+
--- /dev/null
+# -*- makefile -*-
+
+# Rules for compilation of C, C++ and assembler sources using FNU
+# toolchain. These rules are meant to be used with GNU toolchain and
+# are included from OMK when it is necessary to compile something for
+# target.
+
+-include $(USER_OBJS_DIR)/*.d
+
+#%.lo: %.c
+# $(CC) -o $@ $(LCFLAGS) -c $<
+
+c_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+
+cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+
+S_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ASFLAGS)
+
+
+# Check GCC version for user build
+ifndef CC_MAJOR_VERSION
+CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(CC_MAJOR_VERSION),2)
+CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+
+
+# Syntax: $(call COMPILE_c_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_c_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(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
+endef
+
+
+
+# Syntax: $(call COMPILE_cc_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(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
+endef
+
+# Syntax: $(call COMPILE_S_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_S_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+ @$(QUIET_CMD_ECHO) " AS $$@"
+ $(Q) if $$(S_o_COMPILE) -D__ASSEMBLY__ $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
+ then if [ -e "$$@.d.tmp" ] ; then mv -f "$$@.d.tmp" "$$@.d" ; fi ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+# Syntax: $(call CMETRIC_o_h_template,<object_file>,<target_header>)
+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 >$$@ '/* 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 >>$$@
+endef
+
+# Syntax: $(call PROGRAM_template,<dir>,<executable-name>,<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))
+$(1)_OBJS += $$(filter %.o,$(1)_SOURCES)
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+SOURCES += $$($(1)_SOURCES)
+
+ifneq ($$(LD_SCRIPT),)
+$(1)$$(addprefix -,$(3))_LDFLAGS = -Wl,-T,$$(LD_SCRIPT).ld$$(addprefix -,$(3))
+endif
+
+
+$(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)$$(addprefix -,$(3))_LDFLAGS) -Wl,-Map,$(1)$$(addprefix -,$(3)).map \
+ $$($(1)_OBJS) $$(LOADLIBES) $$($(1)_MOREOBJS) $$($(1)_LIBS:%=-l%) \
+ -o $$@
+ @echo "$(2)/$(1)$(addprefix -,$(3)): \\" >$(USER_OBJS_DIR)/$(1)$(addprefix -,$(3)).exe.d
+ @if [ -n "$(LD_SCRIPT)" ]; then \
+ echo " $(USER_LIB_DIR)/$(LD_SCRIPT).ld$(addprefix -,$(3)) \\" >>$(USER_OBJS_DIR)/$(1)$(addprefix -,$(3)).exe.d; fi
+ @sed -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(USER_OBJS_DIR)/$(1)$(addprefix -,$(3)).map >>$(USER_OBJS_DIR)/$(1)$(addprefix -,$(3)).exe.d
+ @echo >>$(USER_OBJS_DIR)/$(1).exe.d
+endef
+
+# Rules for other output formats (can be specified by OUTPUT_FORMATS)
+%.bin: %
+ @$(QUIET_CMD_ECHO) " OBJCOPY $@"
+ $(Q) $(OBJCOPY) --output-target=binary -S $< $@
+
+%.hex: %
+ @$(QUIET_CMD_ECHO) " OBJCOPY $@"
+ $(Q) $(OBJCOPY) --output-target=ihex -S $< $@
+
+%.srec: %
+ @$(QUIET_CMD_ECHO) " OBJCOPY $@"
+ $(Q) $(OBJCOPY) --output-target=srec -S $< $@
+
+# 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))
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+SOURCES += $$($(1)_SOURCES)
+
+$(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR $$@"
+ $(Q) $(AR) rcs $$@ $$^
+endef
+
+
+# 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))
+$(1)_OBJSLO := $$(sort $$($(1)_OBJSLO))
+
+SOLIB_OBJS += $$($(1)_OBJSLO)
+SOLIB_SOURCES += $$($(1)_SOURCES)
+
+$(USER_LIB_DIR)/lib$(1).so: $$($(1)_OBJSLO)
+ @$(QUIET_CMD_ECHO) " LINK $$@"
+ $(Q) $(LD) --shared --soname=lib$(1).so -o $$@ $$^
+endef
+
+
+# lib_obj_SOURCES handling
+lib_OBJS = $(addsuffix .o,$(basename $(lib_obj_SOURCES)))
+SOURCES += $(filter-out %.o,$(lib_obj_SOURCES))
+#$(warning lib_OBJS = $(lib_OBJS))
+
+# # Syntax: $(call LIBOBJ_template,<object-name>)
+# define LIBOBJ_template
+# $(USER_LIB_DIR)/$(1): $(1)
+# @cp $(CP_FLAGS) $$< $$@
+# endef
+$(USER_LIB_DIR)/%.o: %.o
+ @cp $(CP_FLAGS) $< $@
+
--- /dev/null
+# -*- makefile -*-
+
+# This Makefile is included from Makefile.rules and contains rules
+# specific to the h8300-boot project.
+
+# input variables
+
+# bin_PROGRAMS .. list of the require binary programs
+# include_HEADERS .. list of the user-space public header files
+# lib_LIBRARIES .. list of the user-space libraries
+# lib_LDSCRIPTS .. list of LD scripts that should be copied to the lib direcotry
+# lib_obj_SOURCES .. list of source files which should be compiled and
+# the produced object file placed to the lib directory (e.g. crt0.S)
+# shared_LIBRARIES .. list of the user-space shared libraries
+# nobase_include_HEADERS .. public headers copied even with directory part
+# renamed_include_HEADERS .. public headers copied to the different target name (xxx.h->yyy.h)
+# utils_PROGRAMS .. list of the development utility programs (compiled for host computer) - does not work yet
+# xxx_SOURCES .. list of specific target sources
+# xxx_LIBS .. list of specific target libraries
+# INCLUDES .. additional include directories and defines for user-space
+# lib_LOADLIBES .. list of libraries linked to each executable
+# 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.
+
+# 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
+
+#=====================================================================
+# Common utility rules
+
+ifdef LOCAL_CONFIG_H
+
+$(LOCAL_CONFIG_H) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+ @echo LOCAL_CONFIG_H=`pwd`/$(LOCAL_CONFIG_H)
+ @echo "/* Automatically generated from */" > "$(LOCAL_CONFIG_H).tmp"
+ @echo "/* config file : $< */" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#ifndef _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#define _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @( $(foreach x, $(shell echo $(default_CONFIG) | sed -e 's/\<\([^ ]*\)=[^ ]\>/\1/g' ), \
+ echo $(x).$($(x)) ; ) echo ; ) | \
+ sed -n -e 's/^\(.*\)\.[ym]$$/#define \1 1/p' \
+ >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#endif /*_LOCAL_CONFIG_H*/" >> "$(LOCAL_CONFIG_H).tmp"
+ @if cmp --quiet "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; then \
+ echo rm "$(LOCAL_CONFIG_H).tmp" ; \
+ else mv "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; \
+ echo Updated configuration "$(LOCAL_CONFIG_H)" ; fi
+
+endif
+
+link_VARIANTS ?= $(DEFAULT_LD_SCRIPT_VARIANT)
+
+
+#=====================================================================
+# Include correct rules for just running pass
+
+USER_COMPILED_DIR_NAME=$(MAKERULES_DIR)/$(COMPILED_DIR_NAME)
+
+USER_INCLUDE_DIR := $(USER_COMPILED_DIR_NAME)/include
+USER_LIB_DIR := $(USER_COMPILED_DIR_NAME)/lib
+USER_UTILS_DIR := $(USER_COMPILED_DIR_NAME)/bin-utils
+USER_BIN_DIR := $(USER_COMPILED_DIR_NAME)/bin
+USER_OBJS_DIR := $(LOCAL_BUILD_DIR)
+
+
+# -------------------------------------
+# Rules for compilation for target
+ifdef TARGET_RULE_TEMPLATES
+CC = $(CROSS_COMPILE)gcc
+LINK = $(CROSS_COMPILE)ld
+AR = $(CROSS_COMPILE)ar
+OBJCOPY = $(CROSS_COMPILE)objcopy
+NM = $(CROSS_COMPILE)nm
+
+CFLAGS += $(TARGET_ARCH) $(DEBUG) $(OPTIMIZE)
+CFLAGS += -Wall
+CFLAGS += -I$(SOURCES_DIR)
+CFLAGS += -I$(USER_INCLUDE_DIR) -DOMK_FOR_TARGET
+
+LOADLIBES += -L$(USER_LIB_DIR)
+LOADLIBES += $(lib_LOADLIBES:%=-l%)
+
+LDFLAGS += -nostartfiles
+
+LIB_CPPFLAGS += $(CPPFLAGS)
+LIB_CFLAGS += $(CFLAGS)
+
+SOLIB_PICFLAGS += -shared -fpic
+
+INCLUDE_DIR := $(USER_INCLUDE_DIR)
+LIB_DIR := $(USER_LIB_DIR)
+OBJS_DIR := $(USER_OBJS_DIR)
+
+include $(MAKERULES_DIR)/Makefile.rules.gcc
+
+# 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)/%)
+
+# Generate rules for compilation of programs and libraries
+$(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 src,$(lib_obj_SOURCES),$(eval $(call LIBOBJ_template,$(addsuffix .o,$(basename $(src))))))
+$(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))
+
+# User-space static libraries and applications object files
+SOURCES := $(sort $(SOURCES))
+#$(warning SOURCES = $(SOURCES))
+
+# User-space shared libraries object files
+SOLIB_SOURCES := $(sort $(SOLIB_SOURCES))
+#$(warning SOLIB_SOURCES = $(SOLIB_SOURCES))
+
+
+# The above generated rules produced $(SOURCES) and $(SOLIB_SOURCES)
+# variables. Now generate rules for compilation of theese sources
+$(foreach src,$(filter %.c,$(SOURCES)),$(eval $(call COMPILE_c_o_template,$(SOURCES_DIR)/$(src),$(src:%.c=%.o),)))
+$(foreach src,$(filter %.cc,$(SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%.o),)))
+$(foreach src,$(filter %.cxx,$(SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.o),)))
+$(foreach src,$(filter %.S,$(SOURCES)),$(eval $(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.o),)))
+
+$(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 %.S,$(SOLIB_SOURCES)),$(eval $(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.lo),$(SOLIB_PICFLAGS))))
+
+library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS)) \
+ $(lib_LIBRARIES:%=$(LIB_DIR)/lib%.a) $(shared_LIBRARIES:%=$(LIB_DIR)/lib%.so) \
+ $(addprefix $(LIB_DIR)/,$(lib_OBJS))
+
+binary-pass-local: $(foreach link,$(link_VARIANTS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%-$(link)) \
+ $(foreach of,$(OUTPUT_FORMATS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%-$(link).$(of))))
+
+endif # TARGET_RULE_TEMPLATES
+
+
+# -------------------------------------
+# Rules for compilation utilities for host (user space)
+ifdef HOST_RULE_TEMPLATES
+
+CFLAGS += $(DEBUG) $(OPTIMIZE)
+CFLAGS += -Wall
+CFLAGS += -I$(SOURCES_DIR)
+CFLAGS += -I$(USER_INCLUDE_DIR) -DOMK_FOR_USER
+
+LOADLIBES += -L$(USER_LIB_DIR)
+LOADLIBES += $(lib_LOADLIBES:%=-l%)
+
+LIB_CPPFLAGS += $(CPPFLAGS)
+LIB_CFLAGS += $(CFLAGS)
+
+SOLIB_PICFLAGS += -shared -fpic
+
+# For host compilation, we don't use a specfic ld script
+LD_SCRIPT =
+
+# TODO: It is probably better to use different directories for host
+# includes, libraries and objects
+INCLUDE_DIR := $(USER_INCLUDE_DIR)
+LIB_DIR := $(USER_LIB_DIR)
+OBJS_DIR := $(USER_OBJS_DIR)
+
+include $(MAKERULES_DIR)/Makefile.rules.gcc
+
+ #User-space static libraries and applications object files
+#SOURCES := $(sort $(SOURCES))
+#$(warning SOURCES = $(SOURCES))
+
+# Generate rules for compilation of utility programs
+$(foreach prog,$(utils_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR),)))
+
+# The above generated rule produced $(SOURCES) variable. Now generate
+# rules for compilation of theese sources
+$(foreach src,$(filter %.c,$(SOURCES)),$(eval $(call COMPILE_c_o_template,$(SOURCES_DIR)/$(src),$(src:%.c=%.o),)))
+$(foreach src,$(filter %.cc,$(SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%.o),)))
+$(foreach src,$(filter %.cxx,$(SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.o),)))
+$(foreach src,$(filter %.S,$(SOURCES)),$(eval $(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%.o),)))
+
+utils-pass-local: $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%)
+
+endif # HOST_RULE_TEMPLATES
+
+
+#=====================================================================
+# 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,<executable-name>,<dir>,<link-variant>)
+# Used to load program to the target hardware
+define LOAD_PROGRAM_template
+.PHONY: load-$(1)$(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,<link-variant>)
+# Used to load and/or run non-default variant of the default program
+define LOAD_RUN_VARIANT_template
+.PHONY: load-$(1) run-$(1)
+
+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))
+
+
+
+#=====================================================================
+# Generate pass rules from generic templates
+TARGET_PASSES = library-pass binary-pass
+OTHER_PASSES = dep clean install check-dir include-pass
+
+$(eval $(call omk_pass_template,$(TARGET_PASSES),TARGET_RULE_TEMPLATES=y))
+$(eval $(call omk_pass_template, utils-pass,HOST_RULE_TEMPLATES=y))
+
+$(eval $(call omk_pass_template,$(OTHER_PASSES),))
+
+
+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:
+
+# TODO: Check modification date of changed header files. If it is
+# newer that in source dir, show a warning.
+include-pass-local:
+ @$(call mkdir_def,$(USER_INCLUDE_DIR))
+ @$(foreach f, $(include_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(USER_INCLUDE_DIR)/$(notdir $(f)) \
+ || cp $(CP_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 $(CP_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 $(CP_FLAGS) $(SOURCES_DIR)/$${srcfname} $(USER_INCLUDE_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 ; )
+
+
+.PHONY: clean-custom
+clean-local: clean-custom
+ @echo Cleaning in $(USER_OBJS_DIR)
+ @rm -f $(USER_OBJS_DIR)/*.o $(USER_OBJS_DIR)/*.lo \
+ $(USER_OBJS_DIR)/*.d \
+ $(USER_OBJS_DIR)/*.map \
+ $(LOCAL_CONFIG_H:%=$(USER_OBJS_DIR)/%)
+
+# Which passes to pass
+default: check-dir include-pass library-pass binary-pass utils-pass
+
+ETAGS = etags -R -f $(MAKERULES_DIR)/TAGS
+.PHONY: TAGS
+TAGS:
+ $(ETAGS) $(MAKERULES_DIR)/app
+ $(ETAGS) -a $(MAKERULES_DIR)/arch/$(ARCH)/generic
+ $(ETAGS) -a $(MAKERULES_DIR)/arch/$(ARCH)/mach-$(MACH)
+ $(ETAGS) -a $(MAKERULES_DIR)/board/$(BOARD)
+ $(ETAGS) -a $(MAKERULES_DIR)/libs4c
--- /dev/null
+!!! TODO: Modify this to agree with h8300 project
+
+Description of OCERA Make System for CAN Components (OMK)
+=========================================================
+
+Important notice:
+This make system uses features found in recent versions of GNU Make
+program. If you encounter problems with package building,
+check, that you use correct version of Make program.
+The Make older than version 3.80, could not be used.
+Even Make version 3.80 has annoying bug which causes
+building fail with misleading message "virtual memory exhausted".
+Please, upgrade to last version of Make (3.81beta1).
+You can take it from GNU CVS, Paul D. Smith's site or from our local copy
+ http://paulandlesley.org/make/make-3.81beta1.tar.bz2
+ http://cmp.felk.cvut.cz/~pisa/can/make-3.81beta1.tar.gz
+
+
+There is list of features which we want to solve with our makesystem:
+ - central Makefile.rules for most of subcomponents and components
+ (our CAN framework includes more libraries common with our other projects,
+ we need to separate some utility libraries etc.)
+ - the rules in more spread Makefiles are way to the hell,
+ (update for different kernel, RT-Linux etc would be nightmare in other case)
+ - make system should allow to freely move with cross-dependant components
+ without need to update users of moved component
+ (I hate somethink like -I../../sched/rtlshwq/include in CAN makefiles
+ for example. Component could be renamed to different name or version
+ could be added to name and all Makefiles in CAN would require to
+ be updated)
+ - make system should be able to compile mutually cross-dependant libraries
+ and should ensure, that change in one component sources or headers
+ would result in relink or rebuild in components linked against that library
+ or including modified header file
+ - make system has to enable compilation out of OCERA full source tree
+ (we would lost many users of particular components in other case)
+ - compile should be able to do all above work without need to install
+ any files before successful finish of build.
+ - because we use some libraries for RT-Linux build and userspace
+ build, we need to solve how to compile from same sources to both targets.
+ - the build system should allow to call make for particular source
+ subdirectory. Time of recursive make through all subdirectories is
+ unacceptable.
+ - make system should enable to build out of sources tree
+ (else clean or working with CVS sandbox gets fussy and simultaneous
+ multiple targets gets problematic)
+ - it would be good, if there would be possibility to make from read-only
+ media sources
+ - make system should store results of build in some separate directory
+ structure to simple install and testing
+ - Makefiles in sources directories should be simple
+
+There is probably only one alternative fully supporting above requirements
+and it is GNU Autoheader...Automake...Autoconf... system.
+But it is complicated and requires big amount of support files.
+It would be acceptable if it could be easily used for OCERA framework.
+But there are important show stopper for that system:
+ - it would require deep revision of all OCERA CVS contents and agreement
+ on this would be problematic
+ - this system is not well prepared for dual compilation for Linux
+ and RT-Linux sub-targets. It would mean many changes in default
+ autoconf setup to support this. Probably simplest way would be
+ to rebuild GCC tool chain for something like i586-elf-rtlinux.
+ This would require even more space for OCERA development.
+
+The problem calls for same solution, which would have minimal impact
+on other components and would be elegant and would be maintainable
+and small, because our main goal is components development and not
+make systems development.
+
+There is result of our trial. It is OMK make system.
+The Makefile and Makefile.omk files should be in all source
+directories. Common Makefile.rules file is required in the toplevel
+sources directory. Alternatively this file could be moved
+to link tree pointing into readonly media or can be anywhere
+else if MAKERULES_DIR and SOURCES_DIR are specified.
+
+Syntax of Makefile.omk files is for usual cases compatible
+to Automake's Makefile.am descriptions. There are specific targets
+for RT-Linux and Linux kernel related stuff
+
+Makefile.omk user defined variables
+# SUBDIRS .. list of subdirectories intended for make from actual directory
+# 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 header files
+# nobase_include_HEADERS .. headers copied even with directory part
+# kernel_HEADERS .. list of the kernel-space header files
+# rtlinux_HEADERS .. list of the RT-Linux kernel-space header files
+# bin_PROGRAMS .. list of the require binary programs
+# utils_PROGRAMS .. list of the development utility programs
+# 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
+# INCLUDES .. additional include directories and defines for user-space
+# kernel_INCLUDES .. additional include directories and defines for kernel-space
+# rtlinux_INCLUDES .. additional include directories and defines for RT-Linux
+# default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ...
+
+The Makefile is same for all sources directories and is only 14 lines long.
+It is there only for convenience reasons to enable call "make" from
+local directory. It contains code which locates Makefile.rules in actual
+or any parent directory. With standard BASH environment it works such way,
+that if you get into sources directory over symbolic links, it is able to
+unwind yours steps back => you can make links to readonly media component
+directories, copy Makefile.rules, Makefile and toplevel Makefile.omk,
+adjust Makefile.omk to contain only required components and then call
+make in top or even directories after crossing from your tree
+to readonly media.
+
+The system compiles all files out of source directories.
+The actual version of system is adapted even for OCERA tree mode
+if OCERA_DIR variable is defined in Makefile.rules
+
+There are next predefined directory name components,
+which can be adapted if required
+
+BUILD_DIR_NAME = _build
+ prefix of directory, where temporary build files are stored
+COMPILED_DIR_NAME = _compiled
+ prefix of directory, where final compilation results are stored
+GROUP_DIR_NAME = yyy
+ this is used for separation of build sub-trees in OCERA environment
+ where more Makefile.rules is spread in the tree
+
+Next directories are used:
+
+KERN_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
+ directory to store intermediate files for kernel-space targets
+USER_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/user
+ directory to store intermediate files for user-space targets
+
+USER_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include
+ directory to store exported include files which should be installed later
+ on user-space include path
+USER_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib
+ same for user-pace libraries
+USER_UTILS_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin-utils
+ utilities for testing, which would not probably be installed
+USER_BIN_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin
+ binaries, which should go into directory on standard system PATH
+ (/usr/local/bin, /usr/bin or $(prefix)/bin)
+
+KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
+ directory to store exported include files which should be installed later
+ on kernel-space include path
+KERN_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
+ same for kernel-pace libraries
+KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
+ builded modules for Linux kernel or RT-Linux system
+
+There is more recursive passes through directories to enable
+mutual dependant libraries and binaries to compile.
+Next passes are defined
+
+default-config .. generates config.omk-default or xxx-default configuration file
+check-dir .. checks and creates required build directories
+include-pass .. copyes header files to USER_INCLUDE_DIR and KERN_INCLUDE_DIR
+library-pass .. builds objects in USER_BUILD_DIR/<relative path> and creates
+ libraries in USER_LIB_DIR
+binary-pass and utils-pass .. links respective binaries
+ in USER_{BIN,UTILS}_DIR directory. If some object file is missing
+ it compiles it in USER_BUILD_DIR/<relative path>
+kernel-lib-pass .. builds libraries for kernel space targets
+kernel-pass .. builds kernel modules
+
+The amount of passes is relatively high and consumes some time.
+But only other way to support all required features is to assemble
+one big toplevel Makefile, which would contain all components
+and targets cross-dependencies.
+
+Drawbacks of designed make system
+ - the system is not as fast as we would like
+ - it lacks Autoconf and configure extensive support for many systems
+ from UNIX to DOS and WINDOWS
+ - it does not contain support for checking existence of target libraries
+ and functionalities as GNU Autoconf
+ - it is heavily dependant on GNU MAKE program. But it would not be big
+ problem, because even many commercial applications distribute GNU
+ MAKE with them to be able to work in non-friendly systems
+ - the key drawback is dependence on recent MAKE version 3.80 and better
+ and even version 3.80 of MAKE has important bug, which has been
+ corrected in newer sources
+
+The last point is critical. I have not noticed it first, because
+I use Slackware-9.2 and it contains latest released version
+of MAKE (version 3.80).
+The problem appears when I have tried to build bigger libraries.
+There is bug in version 3.80, which results in misleading
+error "Virtual memory exhausted". It is known bug with ID 1517
+
+ * long prerequisite inside eval(call()) => vm exhausted, Paul D. Smith
+
+I have optimized some rules to not push memory to the edge,
+but there could be still issues with 3.80 version.
+
+I have downloaded latest MAKE CVS sources. The compilation required
+separate lookup and download for .po files and full Autoheader... cycle.
+I have put together package similar to release. Only ./configure --prefix=...
+and make is required. CVS sources contains version 3.81beta1.
+You can download prepared sources archive from
+ http://paulandlesley.org/make/make-3.81beta1.tar.bz2
+Or you can get our local copy from
+ http://cmp.felk.cvut.cz/~pisa/can/make-3.81beta1.tar.gz
+
+The archive contains even "make" binary build by me, which should work
+on other Linux distributions as well.
+Older version of MAKE (3.79.x released about year 2000) found
+on Mandrake and RedHat are not sufficient and do not support eval feature.
+I do not expect, that Debian would be more up-to-date or contain fixes
+to MAKE vm exhausted bug.
+
+The local CTU archive with our CAN components prepared for inclusion
+into OCERA SF CVS could be found in my "can" directory
+
+ http://cmp.felk.cvut.cz/~pisa/can/ocera-can-031212.tar.gz
+
+The code should build for user-space with new make on most of Linux distros
+when make is updated.
+
+If you want to test compile for RT-Linux targets, line
+
+#RTL_DIR := /home/cvs/ocera/ocera-build/kernel/rtlinux
+
+in "Makefile.rules" has to be activated and updated
+to point RT-Linux directory containing "rtl.mk".
+There is only one library ("ulutrtl") and test utility compiled for RT-Linux
+("can/utils/ulut/ul_rtlchk.c").
+
+The next line ,if enabled, controls compilation in OCERA project tree
+
+#OCERA_DIR := $(shell ( cd -L $(MAKERULES_DIR)/../../.. ; pwd -L ) )
+
+The LinCAN driver has been updated to compile out of source directories.
+
+Please, check, if you could compile CAN package and help us with integration
+into OCERA SF CVS. Send your comments and objections.
+
+The OMK system has been adapted to support actual OCERA configuration process.
+I am not happy with ocera.mk mix of defines and poor two or three rules,
+but OMK is able to overcome that.
+
+The OMK system has integrated rules (default-config) to build default configuration
+file. The file is named "config.omk-default" for the stand-alone compilation.
+The name corresponds to OCERA config + "-default" if OCERA_DIR is defined.
+This file contains statements from all default_CONFIG lines in all Makefile.omk.
+The file should be used for building of own "config.omk" file, or as list
+for all options if Kconfig is used.
+
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
+# DO NOT DELETE
--- /dev/null
+# -*- makefile -*-
+
+SUBDIRS = app arch board libs4c
+
+-include $(SOURCES_DIR)/Makefile.omk-additional
+
--- /dev/null
+# 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
+# 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
+# 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
+#
+
+BUILD_DIR_NAME = _build
+COMPILED_DIR_NAME = _compile
+GROUP_DIR_NAME =
+
+CC = c51
+OBJ_EXT = .obj
+LIB_EXT = .lib
+LIB_PREF =
+AR = lib51
+AS = a51intel
+HC = oh51
+LI = l51
+
+# We need to ensure definition of sources directory first
+ifndef SOURCES_DIR
+SOURCES_DIR := $(shell ( pwd -W ) )
+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
+
+#CFLAGS += -ggdb
+#CFLAGS += -O2
+#CFLAGS += -Wall
+#CXXFLAGS += -ggdb
+#CXXFLAGS += -O2
+#CXXFLAGS += -Wall
+
+ifndef DEFAULT_INCLUDES
+override DEFAULT_INCLUDES = $(INCLUDES) -I $(USER_INCLUDE_DIR) -I $(SOURCES_DIR) \
+ $(shell echo $${C51INC} | sed -e 's/;/ -I /g' -e 's/^\(.\)/-I \1/')
+endif
+#$(warning DEFAULT_INCLUDES = $(DEFAULT_INCLUDES))
+
+#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%)
+
+#LOADLIBES += -L$(USER_LIB_DIR)
+
+#LOADLIBES += $(lib_LOADLIBES:%=-l%)
+
+SOLIB_PICFLAGS += -shared -fpic
+
+ifndef RELATIVE_DIR
+override RELATIVE_DIR := $(SOURCES_DIR:$(MAKERULES_DIR)%=%)
+endif
+ifeq ("$(RELATIVE_DIR)","")
+override RELATIVE_DIR := .
+endif
+override RELATIVE_DIR := $(RELATIVE_DIR:/%=%)
+override RELATIVE_DIR := $(RELATIVE_DIR:\\%=%)
+
+#$(warning SOURCES_DIR = $(SOURCES_DIR))
+#$(warning MAKERULES_DIR = $(MAKERULES_DIR))
+#$(warning RELATIVE_DIR = $(RELATIVE_DIR))
+
+#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
+
+ifdef LOCAL_CONFIG_H
+
+$(LOCAL_CONFIG_H) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+ @echo LOCAL_CONFIG_H=`pwd -W`/$(LOCAL_CONFIG_H)
+ @echo "/* Automatically generated from */" > "$(LOCAL_CONFIG_H).tmp"
+ @echo "/* config file : $< */" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#ifndef _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#define _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @( $(foreach x, $(shell echo $(default_CONFIG) | sed -e 's/\<\([^ ]*\)=[^ ]\>/\1/g' ), \
+ echo $(x).$($(x)) ; ) echo ; ) | \
+ sed -n -e 's/^\(.*\)\.[ym]$$/#define \1 1/p' \
+ >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#endif /*_LOCAL_CONFIG_H*/" >> "$(LOCAL_CONFIG_H).tmp"
+ @if cmp --quiet "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; then \
+ echo rm "$(LOCAL_CONFIG_H).tmp" ; \
+ else mv "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; \
+ echo Updated configuration "$(LOCAL_CONFIG_H)" ; fi
+
+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
+
+#=====================================================================
+# Special rules for target filesystem and data preparation
+
+
+define TARFILE_template
+
+.PHONY: $(2)
+
+$(2):
+ $(Q) ABSOLUTETARFILE=`cd $$(dir $$@) ; pwd -W`/$$@ ; \
+ ( 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) $(AM_CPPFLAGS)
+
+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"
+
+
+#"OBJECT($$@)"
+# export C51INC="${C51INC};$$(USER_INCLUDE_DIR);$$(SOURCES_DIR)" ; \
+# echo fastdep "$$(DEFAULT_INCLUDES)" <$$< >"$$@.d"; \
+
+define COMPILE_c_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CC $$@"
+ $(Q) cp $$< .;\
+ export C51INC=`echo "$$(DEFAULT_INCLUDES)" | sed -e 's/-I//' -e 's/-I/;/g' -e 's/ //g'`;\
+ $$(c_o_COMPILE) $(3) `basename $$< ` SRC ; \
+ if [ $$$$? -le 1 ] ; \
+ then if a51 `basename $$< .c`.src ; \
+ then \
+ touch "$$@.d" ; \
+ else echo ERRORLEVEL $$$$? ; exit 1; \
+ fi \
+ else echo ERRORLEVEL $$$$? ; exit 1; \
+ fi
+endef
+
+
+
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CXX $$@"
+ $(Q) echo "C++ compilation not suported for this compiler"
+endef
+
+define COMPILE_asm_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " ASM $$@"
+ $(Q) \
+ cp $$< .; \
+ if [ -f $(SOURCES_DIR)/reg1210.inc ] ; then \
+ cp $(SOURCES_DIR)/reg1210.inc .; \
+ fi;\
+ $$(AS) $(2:%$(OBJ_EXT)=%.asm)
+endef
+
+
+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)
+
+$(2)/$(1): $(USER_LIB_DIR)/timestamp
+
+
+# $(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)
+# $(HC) $(2)/$(1) >$(2)/$(1).hex
+
+# $$(LI) $$($(1)_OBJS) $$(LOADLIBES)
+
+$(2)/$(1): $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " LINK $$@"
+ $(Q) \
+ export C51LIB="$${C51LIB};$(USER_LIB_DIR)"; \
+ export LI_FILES="$$($(1)_OBJS) $$(lib_LOADLIBES:%=%$$(LIB_EXT))"; \
+ export LI_FILES="`echo "$$$${LI_FILES}" | sed -e 's/\(.\) \(.\)/\1,\2/g'`";\
+ $$(LI) $$$${LI_FILES}
+endef
+
+
+
+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) \
+ rm -f $$@; \
+ $(AR) CREATE $$@; \
+ for i in $$^ ; do $(AR) ADD $$$$i TO $$@ ; done
+ @touch $(USER_LIB_DIR)/timestamp
+endef
+
+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: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%)
+
+utils-pass-local: $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%)
+
+$(foreach prog,$(utils_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR))))
+
+$(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR))))
+
+$(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_DIR)/$(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_DIR)/$(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:
+ @$(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 ; )
+
+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
+
+
+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)
+
+
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
+# DO NOT DELETE
--- /dev/null
+# -*- makefile -*-
+
+SUBDIRS = app arch board libs4c
+
+-include $(SOURCES_DIR)/Makefile.omk-additional
+
--- /dev/null
+# 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))
+
+#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
+
+ifdef LOCAL_CONFIG_H
+
+$(LOCAL_CONFIG_H) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+ @echo LOCAL_CONFIG_H=`pwd`/$(LOCAL_CONFIG_H)
+ @echo "/* Automatically generated from */" > "$(LOCAL_CONFIG_H).tmp"
+ @echo "/* config file : $< */" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#ifndef _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#define _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @( $(foreach x, $(shell echo $(default_CONFIG) | sed -e 's/\<\([^ ]*\)=[^ ]\>/\1/g' ), \
+ echo $(x).$($(x)) ; ) echo ; ) | \
+ sed -n -e 's/^\(.*\)\.[ym]$$/#define \1 1/p' \
+ >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#endif /*_LOCAL_CONFIG_H*/" >> "$(LOCAL_CONFIG_H).tmp"
+ @if cmp --quiet "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; then \
+ echo rm "$(LOCAL_CONFIG_H).tmp" ; \
+ else mv "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; \
+ echo Updated configuration "$(LOCAL_CONFIG_H)" ; fi
+
+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"
+
+
+
+
+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
+
+
+
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CXX $$@"
+ $(Q) echo "C++ compilation not suported for this compiler"
+endef
+
+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
+
+
+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
+
+
+
+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
+
+
+
+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_DIR)/$(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_DIR)/$(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:
+ @$(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,<executable-name>,<dir>,<link-variant>)
+# 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,<link-variant>)
+# 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))
+
+
+#=====================================================================
+
+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)
+
+
--- /dev/null
+SUBDIRS = ul_drv libs4c apps
--- /dev/null
+# Makefile.rules - OCERA make framework common project rules -*- makefile -*-
+#
+# (C) Copyright 2003 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
+# 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
+# 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
+# INCLUDES .. additional include directories and defines for user-space
+# kernel_INCLUDES .. additional include directories and defines for kernel-space
+# rtlinux_INCLUDES .. additional include directories and defines for RT-Linux
+# default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ...
+#
+# LINUX_DIR .. location of Linux kernel sources
+# RTL_DIR .. location of RT-Linux sources
+
+# 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 $(MAKERULES_DIR)/../../.. ; pwd -L ) )
+
+BUILD_DIR_NAME = _build
+COMPILED_DIR_NAME = _compiled
+GROUP_DIR_NAME = ulan
+
+
+# We need to ensure definition of sources directory first
+ifndef SOURCES_DIR
+SOURCES_DIR := $(shell ( pwd -L ) )
+endif
+
+all: default
+
+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_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)),)
+#include $(CONFIG_FILE)
+CONFIG_FILE_OK = y
+endif
+else # OCERA_DIR
+KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
+KERN_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
+KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
+KERN_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
+KERN_MODPOST_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern-modpost
+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
+ifndef LINUX_VERSION
+LINUX_VERSION=$(shell uname -r)
+endif
+ifndef LINUX_DIR
+LINUX_DIR=/lib/modules/$(LINUX_VERSION)/build
+endif
+endif # OCERA_DIR
+
+# 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 LINUX_DIR LINUX_VERSION RTL_DIR
+export CONFIG_FILE OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT
+
+#CFLAGS += -ggdb
+CFLAGS += -O2
+CFLAGS += -Wall
+#CXXFLAGS += -ggdb
+CXXFLAGS += -O2
+CXXFLAGS += -Wall
+
+
+CPPFLAGS += -I $(USER_INCLUDE_DIR)
+
+LOADLIBES += -L$(USER_LIB_DIR)
+
+LOADLIBES += $(lib_LOADLIBES:%=-l%)
+
+LIB_CPPFLAGS += $(CPPFLAGS)
+LIB_CFLAGS += $(CFLAGS)
+
+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))
+
+#vpath %.c $(SOURCES_DIR)
+#vpath %.cc $(SOURCES_DIR)
+#vpath %.cxx $(SOURCES_DIR)
+
+VPATH = $(SOURCES_DIR)
+srcdir = $(SOURCES_DIR)
+
+USER_OBJS_DIR = $(USER_BUILD_DIR)/$(RELATIVE_DIR)
+KERN_OBJS_DIR = $(KERN_BUILD_DIR)/$(RELATIVE_DIR)
+
+.PHONY: default dep subdirs clean clean-custom cleandepend default-config
+.PHONY: check-make-ver check-dir include-pass library-pass binary-pass utils-pass
+.PHONY: kernel-lib-pass kernel-pass kernel-mod-pass kernel-modpost-pass default-config-pass
+.PHONY: check-dir-local include-pass-local library-pass-local binary-pass-local
+.PHONY: utils-pass-local kernel-lib-pass-local kernel-mod-pass-local kernel-modpost-pass-local
+.PHONY: 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
+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
+
+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 kernel-lib-pass kernel-pass
+
+#=====================================================================
+# Common utility rules
+
+define mkdir_def
+ [ -d $(1) ] || mkdir -p $(1) || exit 1
+endef
+
+ifdef LOCAL_CONFIG_H
+
+$(LOCAL_CONFIG_H) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+ @echo LOCAL_CONFIG_H=`pwd`/$(LOCAL_CONFIG_H)
+ @echo "/* Automatically generated from */" > "$(LOCAL_CONFIG_H).tmp"
+ @echo "/* config file : $< */" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#ifndef _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#define _LOCAL_CONFIG_H" >> "$(LOCAL_CONFIG_H).tmp"
+ @( $(foreach x, $(shell echo $(default_CONFIG) | sed -e 's/\<\([^ ]*\)=[^ ]\>/\1/g' ), \
+ echo $(x).$($(x)) ; ) echo ; ) | \
+ sed -n -e 's/^\(.*\)\.[ym]$$/#define \1 1/p' \
+ >> "$(LOCAL_CONFIG_H).tmp"
+ @echo "#endif /*_LOCAL_CONFIG_H*/" >> "$(LOCAL_CONFIG_H).tmp"
+ @if cmp --quiet "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; then \
+ echo rm "$(LOCAL_CONFIG_H).tmp" ; \
+ else mv "$(LOCAL_CONFIG_H).tmp" "$(LOCAL_CONFIG_H)" ; \
+ echo Updated configuration "$(LOCAL_CONFIG_H)" ; fi
+
+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
+
+#=====================================================================
+# 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) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_USER
+
+cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_USER
+
+idl_COMPILE = $(IDL_COMPILER)
+
+# Check GCC version for user build
+ifndef CC_MAJOR_VERSION
+CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(CC_MAJOR_VERSION),2)
+CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+
+
+
+define COMPILE_c_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(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
+endef
+
+
+
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(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
+endef
+
+
+
+define COMPILE_idl_template
+$(2)-stubs.c $(2)-skels.c $(2)-common.c $(2).h: $(1)
+ @$(QUIET_CMD_ECHO) " IDL $$@"
+ $(Q) $$(idl_COMPILE) $(1)
+endef
+
+
+
+define PROGRAM_template
+
+USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL)
+$(1)_IDL_OBJS += $$(filter %.o,$$($(1)_SERVER_IDL:%.idl=%-skels.o))
+$(1)_IDL_OBJS += $$(filter %.o,$$($(1)_SERVER_IDL:%.idl=%-common.o))
+$(1)_IDL_OBJS += $$(filter %.o,$$($(1)_CLIENT_IDL:%.idl=%-stubs.o))
+$(1)_IDL_OBJS += $$(filter %.o,$$($(1)_CLIENT_IDL:%.idl=%-common.o))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c))
+
+$(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 := $$(sort $$($(1)_IDL_OBJS)) $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+
+#$$(warning $(1)_OBJS = $$($(1)_OBJS))
+
+$(2)/$(1): $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " LINK $$@"
+ $(Q) $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES:%.cxx=%.cc))" ] ; then echo $$(CC) ; else echo $$(CXX) ; fi) \
+ $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) $$(LOADLIBES) $$(LDFLAGS) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -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
+ @echo >>$(USER_OBJS_DIR)/$(1).exe.d
+endef
+
+
+
+define LIBRARY_template
+
+USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL)
+$(1)_IDL_OBJS += $$(filter %.o,$$($(1)_SERVER_IDL:%.idl=%-skels.o))
+$(1)_IDL_OBJS += $$(filter %.o,$$($(1)_SERVER_IDL:%.idl=%-common.o))
+$(1)_IDL_OBJS += $$(filter %.o,$$($(1)_CLIENT_IDL:%.idl=%-stubs.o))
+$(1)_IDL_OBJS += $$(filter %.o,$$($(1)_CLIENT_IDL:%.idl=%-common.o))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c))
+USER_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c))
+
+$(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 := $$(sort $$($(1)_IDL_OBJS)) $$(sort $$($(1)_OBJS))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+
+$(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR $$@"
+ $(Q) $(AR) rcs $$@ $$^
+endef
+
+
+
+define SOLIB_template
+
+USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL)
+$(1)_IDL_OBJSLO += $$(filter %.lo,$$($(1)_SERVER_IDL:%.idl=%-skels.lo))
+$(1)_IDL_OBJSLO += $$(filter %.lo,$$($(1)_SERVER_IDL:%.idl=%-common.lo))
+$(1)_IDL_OBJSLO += $$(filter %.lo,$$($(1)_CLIENT_IDL:%.idl=%-stubs.lo))
+$(1)_IDL_OBJSLO += $$(filter %.lo,$$($(1)_CLIENT_IDL:%.idl=%-common.lo))
+SOLIB_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c))
+SOLIB_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c))
+SOLIB_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c))
+SOLIB_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c))
+
+$(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 := $$(sort $$($(1)_IDL_OBJSLO)) $$(sort $$($(1)_OBJSLO))
+
+SOLIB_OBJS += $$($(1)_OBJSLO)
+SOLIB_SOURCES += $$($(1)_SOURCES)
+
+$(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%.a) $(shared_LIBRARIES:%=$(USER_LIB_DIR)/lib%.so)
+
+binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%)
+
+utils-pass-local: $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%)
+
+$(foreach prog,$(utils_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR))))
+
+$(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR))))
+
+$(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
+
+$(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))
+
+-include $(USER_OBJS_DIR)/*.d
+
+endif
+
+#=====================================================================
+# Kernel-space rules and templates to compile modules, libraries etc.
+
+ifdef KERN_RULE_TEMPLATES
+
+$(KERN_LIB_DIR)/kernel.mk: $(LINUX_DIR)/.config $(MAKERULES_DIR)/kernelcfg2mk
+ @$(QUIET_CMD_ECHO) " KCFG2MK $$@"
+ $(Q) $(MAKERULES_DIR)/kernelcfg2mk $(LINUX_DIR) $(KERN_LIB_DIR)
+
+ifeq ($(CONFIG_RTLINUX),y)
+include $(RTL_DIR)/rtl.mk
+
+KERN_CC = $(CC)
+kern_GCCLIB_DIR=$(shell LANG=C LC_ALL=C LC_MESSAGES=C $(CC) -print-search-dirs | sed -n -e 's/^install: \(.*\)$$/\1/p' )
+INCLUDES := -I $(KERN_INCLUDE_DIR) $(INCLUDE) $(rtlinux_INCLUDES) $(kernel_INCLUDES)
+#-DEXPORT_NO_SYMBOLS
+c_o_kern_COMPILE = $(KERN_CC) -idirafter $(kern_GCCLIB_DIR)/include $(INCLUDES) $(CFLAGS) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB -nostdinc
+cc_o_kern_COMPILE = $(CXX) $(INCLUDES) $(CXXFLAGS) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB
+KERN_EXE_SUFFIX := .o
+KERN_ARCH = $(ARCH)
+KERN_LD = $(LD)
+KERN_AR = $(AR)
+
+else # CONFIG_RTLINUX
+
+include $(KERN_LIB_DIR)/kernel.mk
+
+ifeq ($(LINUX_SRC),)
+LINUX_SRC = $(LINUX_DIR)
+endif
+kernel_INCLUDES += -I $(LINUX_DIR) -idirafter $(LINUX_SRC)/include/linux
+
+ifdef LINUX_CC
+KERN_CC = $(LINUX_CC)
+kern_GCCLIB_DIR=$(shell LANG=C LC_ALL=C LC_MESSAGES=C $(LINUX_CC) -print-search-dirs | sed -n -e 's/^install: \(.*\)$$/\1/p' )
+else
+KERN_CC = echo KERN_CC not defined - compilation skipped
+endif
+c_o_kern_COMPILE = $(KERN_CC) $(kernel_INCLUDES) -idirafter $(kern_GCCLIB_DIR)/include $(LINUX_CPPFLAGS) $(LINUX_CFLAGS) $(LINUX_CFLAGS_MODULE) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB -nostdinc
+cc_o_kern_COMPILE = $(KERN_CC) $(kernel_INCLUDES) -idirafter $(kern_GCCLIB_DIR)/include $(LINUX_CPPFLAGS) $(LINUX_CFLAGS) $(LINUX_CFLAGS_MODULE) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB
+KERN_EXE_SUFFIX := $(LINUX_MODULE_EXT)
+KERN_LDFLAGS = $(LINUX_LDFLAGS)
+ifdef LINUX_ARCH
+KERN_ARCH = $(LINUX_ARCH)
+else
+KERN_ARCH = echo KERN_ARCH not defined - skipped
+endif
+ifdef LINUX_LD
+KERN_LD = $(LINUX_LD)
+else
+KERN_LD = echo KERN_LD not defined - skipped
+endif
+ifneq ($(LINUX_AR),)
+KERN_AR = $(LINUX_AR)
+else
+KERN_AR = $(AR)
+endif
+endif # CONFIG_RTLINUX
+
+KERN_LOADLIBES += -L$(KERN_LIB_DIR)
+
+KERN_LOADLIBES += $(rtlinux_LOADLIBES:%=-l%)
+KERN_LOADLIBES += $(kernel_LOADLIBES:%=-l%)
+
+
+
+# Check GCC version for kernel part of build
+ifndef kern_CC_MAJOR_VERSION
+kern_CC_MAJOR_VERSION := $(shell $(KERN_CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(kern_CC_MAJOR_VERSION),2)
+kern_CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+kern_CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+ifeq ($(KERN_EXE_SUFFIX),.ko)
+ifeq ($(wildcard $(LINUX_DIR)/scripts/mod/modpost),)
+KERN_MODPOST = $(LINUX_DIR)/scripts/modpost
+else
+KERN_MODPOST = $(LINUX_DIR)/scripts/mod/modpost
+endif
+KERN_MODULES_LINK_DIR = $(KERN_MODPOST_DIR)
+KERN_LINK_SUFFIX = .o
+else
+KERN_MODULES_LINK_DIR = $(KERN_MODULES_DIR)
+KERN_LINK_SUFFIX = $(KERN_EXE_SUFFIX)
+endif
+
+define COMPILE_c_o_kern_template
+
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CC [K] $$@"
+ $(Q) if $$(c_o_kern_COMPILE) $$(kern_CC_DEPFLAGS) $(3) -DKBUILD_BASENAME=$(notdir $(basename $(1))) \
+ -o $$@ -c $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+
+define COMPILE_cc_o_kern_template
+
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CXX [K] $$@"
+ $(Q) if $$(cc_o_kern_COMPILE) $$(kern_CC_DEPFLAGS) $(3) -DKBUILD_BASENAME=$(notdir $(basename $(1))) \
+ -o $$@ -c $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+
+define MODULE_kern_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 := $$(sort $$($(1)_OBJS))
+
+KERN_OBJS += $$($(1)_OBJS)
+KERN_SOURCES += $$($(1)_SOURCES)
+
+# this is hack to build "__this_module" structure for 2.6.x kernels
+# modpost is used for that purpose now
+
+#$(1).mod.c:
+# echo "\
+# #include <linux/version.h>@\
+# #include <linux/module.h>@\
+# #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,5))@\
+# #include <linux/vermagic.h>@\
+# #include <linux/compiler.h>@\
+# @\
+# MODULE_INFO(vermagic, VERMAGIC_STRING);@\
+# @\
+# #undef unix@\
+# struct module __this_module@\
+# __attribute__((section(\".gnu.linkonce.this_module\"))) = {@\
+# .name = __stringify(KBUILD_MODNAME),@\
+# .init = init_module,@\
+# #ifdef CONFIG_MODULE_UNLOAD@\
+# .exit = cleanup_module,@\
+# #endif@\
+# };@\
+# #endif@\
+# " | tr @ \\n >$$@
+
+
+#$(eval $(call COMPILE_c_o_kern_template,$(1).mod.c,$(1).mod.o,-DKBUILD_MODNAME=$(1)))
+
+$(2)/$(1)$(KERN_LINK_SUFFIX): $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " LD [K] $$@"
+ $(Q) $$(KERN_LD) $$(KERN_LDFLAGS) -r $$($(1)_OBJS) -L$$(kern_GCCLIB_DIR) $$($(1)_LIBS:%=-l%) $$(KERN_LOADLIBES) -Map $(KERN_OBJS_DIR)/$(1).mod.map -o $$@
+ @echo "$(2)/$(1)$(KERN_LINK_SUFFIX): \\" >$(KERN_OBJS_DIR)/$(1).mod.d
+ @sed -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(KERN_OBJS_DIR)/$(1).mod.map >>$(KERN_OBJS_DIR)/$(1).mod.d
+ @echo >>$(KERN_OBJS_DIR)/$(1).mod.d
+ @if [ "$(KERN_EXE_SUFFIX)" == ".ko" ] ; then \
+ echo $(1) >>$(KERN_MODPOST_DIR)/module-changes ; \
+ echo $(1) >>$(KERN_MODPOST_DIR)/$(1).mod.stamp ; \
+ fi
+
+endef
+
+
+
+define LIBRARY_kern_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 := $$(sort $$($(1)_OBJS))
+
+KERN_OBJS += $$($(1)_OBJS)
+KERN_SOURCES += $$($(1)_SOURCES)
+
+$(KERN_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR [K] $$@"
+ $(Q) $(KERN_AR) rcs $$@ $$^
+endef
+
+
+ifdef LINUX_DIR
+
+kernel-lib-pass-local: $(kernel_LIBRARIES:%=$(KERN_LIB_DIR)/lib%.a)
+
+kernel-mod-pass-local: $(kernel_MODULES:%=$(KERN_MODULES_LINK_DIR)/%$(KERN_LINK_SUFFIX))
+
+$(foreach module,$(kernel_MODULES),$(eval $(call MODULE_kern_template,$(module),$(KERN_MODULES_LINK_DIR))))
+
+$(foreach lib,$(kernel_LIBRARIES),$(eval $(call LIBRARY_kern_template,$(lib))))
+
+endif
+
+
+ifeq ($(CONFIG_RTLINUX),y)
+
+kernel-mod-pass-local: $(rtlinux_MODULES:%=$(KERN_MODULES_LINK_DIR)/%$(KERN_LINK_SUFFIX))
+
+kernel-lib-pass-local: $(rtlinux_LIBRARIES:%=$(KERN_LIB_DIR)/lib%.a)
+
+$(foreach module,$(rtlinux_MODULES),$(eval $(call MODULE_kern_template,$(module),$(KERN_MODULES_LINK_DIR))))
+
+$(foreach lib,$(rtlinux_LIBRARIES),$(eval $(call LIBRARY_kern_template,$(lib))))
+
+endif
+
+ifeq ($(KERN_MODPOST_PASS),y)
+
+MODULES_LIST := $(wildcard *.mod.stamp)
+MODULES_LIST := $(MODULES_LIST:%.mod.stamp=%)
+
+define MODPOST_kern_template
+$(2) : $(1)$(KERN_LINK_SUFFIX) $(1).mod.c
+ @$(QUIET_CMD_ECHO) " LD [M] $$@"
+ $(Q) $$(cc_o_kern_COMPILE) -DKBUILD_BASENAME=$(1) -DKBUILD_MODNAME=$(1) -o $(1).mod.o -c $(1).mod.c
+ $(Q) $$(KERN_LD) $$(KERN_LDFLAGS) $(1)$(KERN_LINK_SUFFIX) $(1).mod.o -r -o $$@
+endef
+
+kernel-modpost-versions: $(wildcard $(LINUX_DIR)/Module.symvers)
+ @$(QUIET_CMD_ECHO) " MODPOST $(KERN_MODPOST_DIR)"
+ @echo >$(KERN_MODPOST_DIR)/modpost-running
+ @rm -f $(KERN_MODPOST_DIR)/module-changes
+ $(Q) $(KERN_MODPOST) $(MODULES_LIST:%=%$(KERN_LINK_SUFFIX)) $(^:%=-i %)
+
+$(MODULES_LIST:%=%.mod.c) : kernel-modpost-versions
+
+kernel-modpost-pass-local: $(MODULES_LIST:%=$(KERN_MODULES_DIR)/%$(KERN_EXE_SUFFIX))
+ @rm -f $(KERN_MODPOST_DIR)/modpost-running
+
+$(foreach module,$(MODULES_LIST),$(eval $(call MODPOST_kern_template,$(module),$(module:%=$(KERN_MODULES_DIR)/%$(KERN_EXE_SUFFIX)))))
+
+endif
+
+-include $(KERN_OBJS_DIR)/*.d
+
+endif
+
+#=====================================================================
+
+
+kernel-lib-pass:
+ +@$(foreach dir, $(SUBDIRS), $(call mkdir_def,$(KERN_OBJS_DIR)/$(dir)) ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) -C $(KERN_OBJS_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;)
+ +@$(call mkdir_def,$(KERN_OBJS_DIR))
+ +@if [ -n "$(kernel_LIBRARIES)$(rtlinux_LIBRARIES)" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_OBJS_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y $(@:%=%-local) ; \
+ fi
+
+kernel-mod-pass:
+ +@$(foreach dir, $(SUBDIRS), $(call mkdir_def,$(KERN_OBJS_DIR)/$(dir)) ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) -C $(KERN_OBJS_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;)
+ +@$(call mkdir_def,$(KERN_OBJS_DIR))
+ +@if [ -n "$(kernel_MODULES)$(rtlinux_MODULES)" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_OBJS_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y $(@:%=%-local) ; \
+ fi
+
+kernel-modpost-pass:
+ +@if [ -e "$(KERN_MODPOST_DIR)/module-changes" -o -e "$(KERN_MODPOST_DIR)/modpost-running" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_MODPOST_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y KERN_MODPOST_PASS=y $(@:%=%-local) ; \
+ fi
+
+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_DIR)/$(dir) -C $(USER_OBJS_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $@ || exit 1 ;)
+ +@$(foreach dir, $(QT_SUBDIRS), $(call mkdir_def,$(USER_OBJS_DIR)/$(dir)) ; \
+ if [ "$@" != "binary-pass" ] ; then exit 0 ; fi ; \
+ if [ ! -e $(SOURCES_DIR)/$(dir)/Makefile ] ; then \
+ ( cd $(SOURCES_DIR)/$(dir) ; $$QTDIR/bin/qmake TOP_DIR=$(MAKERULES_DIR) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) QTDIR=$(QTDIR) CC=$(CC) \
+ CXX=$(CXX) || exit 1 ;) ; fi ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) -C $(SOURCES_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_DIR)/$(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,$(KERN_OBJS_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,$(KERN_MODULES_DIR))
+ @$(call mkdir_def,$(KERN_MODPOST_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:
+ @$(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 ; )
+# Kernel and RT-Linux stuff
+ @$(call mkdir_def,$(KERN_INCLUDE_DIR))
+ @$(foreach f, $(kernel_HEADERS) $(rtlinux_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(notdir $(f)) \
+ || cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(notdir $(f)) || exit 1 ; )
+ @$(foreach f, $(nobase_kernel_HEADERS) $(nobase_rtlinux_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(f) \
+ || ( mkdir -p $(KERN_INCLUDE_DIR)/$(dir $(f)) && cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$(f) $(KERN_INCLUDE_DIR)/$(f) ) || exit 1 ; )
+ @$(foreach f, $(renamed_kernel_HEADERS) $(renamed_rtlinux_HEADERS), \
+ srcfname=`echo '$(f)' | sed -e 's/^\(.*\)->.*$$/\1/'` ; destfname=`echo '$(f)' | sed -e 's/^.*->\(.*\)$$/\1/'` ; \
+ cmp --quiet $(SOURCES_DIR)/$${srcfname} $(KERN_INCLUDE_DIR)/$${destfname} \
+ || ( mkdir -p `dirname $(KERN_INCLUDE_DIR)/$${destfname}` && cp $(CPHEADER_FLAGS) $(SOURCES_DIR)/$${srcfname} $(KERN_INCLUDE_DIR)/$${destfname} ) || exit 1 ; )
+
+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 %.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))
+
+$(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 %.c,$(SOLIB_GEN_SOURCES)),$(eval $(call COMPILE_c_o_template,$(src),$(src:%.c=%.lo),$(SOLIB_PICFLAGS))))
+
+# IDL compilation
+
+USER_IDLS := $(sort $(USER_IDLS))
+
+#$(warning USER_IDLS = $(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))
+
+#$(warning KERN_SOURCES = $(KERN_SOURCES))
+
+$(foreach src,$(filter %.c,$(KERN_SOURCES)),$(eval $(call COMPILE_c_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.c=%.o),)))
+
+$(foreach src,$(filter %.cc,$(KERN_SOURCES)),$(eval $(call COMPILE_cc_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%.o),)))
+
+$(foreach src,$(filter %.cxx,$(KERN_SOURCES)),$(eval $(call COMPILE_cc_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.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)/*.o $(USER_OBJS_DIR)/*.lo \
+ $(KERN_OBJS_DIR)/*.d $(USER_OBJS_DIR)/*.d \
+ $(KERN_OBJS_DIR)/*.map $(USER_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)/%)
+ @if [ -e $(KERN_LIB_DIR)/kernel.mk ] ; then \
+ touch -t 200001010101 $(KERN_LIB_DIR)/kernel.mk ; \
+ fi
+
+
--- /dev/null
+# enable next for WinNT target
+# export OS=Windows_NT
+
+# enable next for DJGPP target
+# export DJGPP = 1
+
+all: default
+
+.PHONY: default subdirs clean cleandepend
+
+dirs = ul_drv
+
+default clean install:
+ $(foreach dir, $(dirs), $(MAKE) -C $(dir) $@ ;)
+
+
--- /dev/null
+Description of OCERA Make System for CAN Components (OMK)
+=========================================================
+
+Important notice:
+This make system uses features found in recent versions of GNU Make
+program. If you encounter problems with package building,
+check, that you use correct version of Make program.
+The Make older than version 3.80, could not be used.
+Even Make version 3.80 has annoying bug which causes
+building fail with misleading message "virtual memory exhausted".
+Please, upgrade to last version of Make (3.81beta1).
+You can take it from GNU CVS or from our local copy
+
+http://cmp.felk.cvut.cz/~pisa/can/make-3.81beta1.tar.gz
+
+
+There is list of features which we want to solve with our makesystem:
+ - central Makefile.rules for most of subcomponents and components
+ (our CAN framework includes more libraries common with our other projects,
+ we need to separate some utility libraries etc.)
+ - the rules in more spread Makefiles are way to the hell,
+ (update for different kernel, RT-Linux etc would be nightmare in other case)
+ - make system should allow to freely move with cross-dependant components
+ without need to update users of moved component
+ (I hate somethink like -I../../sched/rtlshwq/include in CAN makefiles
+ for example. Component could be renamed to different name or version
+ could be added to name and all Makefiles in CAN would require to
+ be updated)
+ - make system should be able to compile mutually cross-dependant libraries
+ and should ensure, that change in one component sources or headers
+ would result in relink or rebuild in components linked against that library
+ or including modified header file
+ - make system has to enable compilation out of OCERA full source tree
+ (we would lost many users of particular components in other case)
+ - compile should be able to do all above work without need to install
+ any files before successful finish of build.
+ - because we use some libraries for RT-Linux build and userspace
+ build, we need to solve how to compile from same sources to both targets.
+ - the build system should allow to call make for particular source
+ subdirectory. Time of recursive make through all subdirectories is
+ unacceptable.
+ - make system should enable to build out of sources tree
+ (else clean or working with CVS sandbox gets fussy and simultaneous
+ multiple targets gets problematic)
+ - it would be good, if there would be possibility to make from read-only
+ media sources
+ - make system should store results of build in some separate directory
+ structure to simple install and testing
+ - Makefiles in sources directories should be simple
+
+There is probably only one alternative fully supporting above requirements
+and it is GNU Autoheader...Automake...Autoconf... system.
+But it is complicated and requires big amount of support files.
+It would be acceptable if it could be easily used for OCERA framework.
+But there are important show stopper for that system:
+ - it would require deep revision of all OCERA CVS contents and agreement
+ on this would be problematic
+ - this system is not well prepared for dual compilation for Linux
+ and RT-Linux sub-targets. It would mean many changes in default
+ autoconf setup to support this. Probably simplest way would be
+ to rebuild GCC tool chain for something like i586-elf-rtlinux.
+ This would require even more space for OCERA development.
+
+The problem calls for same solution, which would have minimal impact
+on other components and would be elegant and would be maintainable
+and small, because our main goal is components development and not
+make systems development.
+
+There is result of our trial. It is OMK make system.
+The Makefile and Makefile.omk files should be in all source
+directories. Common Makefile.rules file is required in the toplevel
+sources directory. Alternatively this file could be moved
+to link tree pointing into readonly media or can be anywhere
+else if MAKERULES_DIR and SOURCES_DIR are specified.
+
+Syntax of Makefile.omk files is for usual cases compatible
+to Automake's Makefile.am descriptions. There are specific targets
+for RT-Linux and Linux kernel related stuff
+
+Makefile.omk user defined variables
+# SUBDIRS .. list of subdirectories intended for make from actual directory
+# 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 header files
+# nobase_include_HEADERS .. headers copied even with directory part
+# kernel_HEADERS .. list of the kernel-space header files
+# rtlinux_HEADERS .. list of the RT-Linux kernel-space header files
+# bin_PROGRAMS .. list of the require binary programs
+# utils_PROGRAMS .. list of the development utility programs
+# 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
+# INCLUDES .. additional include directories and defines for user-space
+# kernel_INCLUDES .. additional include directories and defines for kernel-space
+# rtlinux_INCLUDES .. additional include directories and defines for RT-Linux
+# default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ...
+
+The Makefile is same for all sources directories and is only 14 lines long.
+It is there only for convenience reasons to enable call "make" from
+local directory. It contains code which locates Makefile.rules in actual
+or any parent directory. With standard BASH environment it works such way,
+that if you get into sources directory over symbolic links, it is able to
+unwind yours steps back => you can make links to readonly media component
+directories, copy Makefile.rules, Makefile and toplevel Makefile.omk,
+adjust Makefile.omk to contain only required components and then call
+make in top or even directories after crossing from your tree
+to readonly media.
+
+The system compiles all files out of source directories.
+The actual version of system is adapted even for OCERA tree mode
+if OCERA_DIR variable is defined in Makefile.rules
+
+There are next predefined directory name components,
+which can be adapted if required
+
+BUILD_DIR_NAME = _build
+ prefix of directory, where temporary build files are stored
+COMPILED_DIR_NAME = _compiled
+ prefix of directory, where final compilation results are stored
+GROUP_DIR_NAME = yyy
+ this is used for separation of build sub-trees in OCERA environment
+ where more Makefile.rules is spread in the tree
+
+Next directories are used:
+
+KERN_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
+ directory to store intermediate files for kernel-space targets
+USER_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/user
+ directory to store intermediate files for user-space targets
+
+USER_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include
+ directory to store exported include files which should be installed later
+ on user-space include path
+USER_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib
+ same for user-pace libraries
+USER_UTILS_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin-utils
+ utilities for testing, which would not probably be installed
+USER_BIN_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin
+ binaries, which should go into directory on standard system PATH
+ (/usr/local/bin, /usr/bin or $(prefix)/bin)
+
+KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
+ directory to store exported include files which should be installed later
+ on kernel-space include path
+KERN_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
+ same for kernel-pace libraries
+KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
+ builded modules for Linux kernel or RT-Linux system
+
+There is more recursive passes through directories to enable
+mutual dependant libraries and binaries to compile.
+Next passes are defined
+
+default-config .. generates config.omk-default or xxx-default configuration file
+check-dir .. checks and creates required build directories
+include-pass .. copyes header files to USER_INCLUDE_DIR and KERN_INCLUDE_DIR
+library-pass .. builds objects in USER_BUILD_DIR/<relative path> and creates
+ libraries in USER_LIB_DIR
+binary-pass and utils-pass .. links respective binaries
+ in USER_{BIN,UTILS}_DIR directory. If some object file is missing
+ it compiles it in USER_BUILD_DIR/<relative path>
+kernel-lib-pass .. builds libraries for kernel space targets
+kernel-pass .. builds kernel modules
+
+The amount of passes is relatively high and consumes some time.
+But only other way to support all required features is to assemble
+one big toplevel Makefile, which would contain all components
+and targets cross-dependencies.
+
+Drawbacks of designed make system
+ - the system is not as fast as we would like
+ - it lacks Autoconf and configure extensive support for many systems
+ from UNIX to DOS and WINDOWS
+ - it does not contain support for checking existence of target libraries
+ and functionalities as GNU Autoconf
+ - it is heavily dependant on GNU MAKE program. But it would not be big
+ problem, because even many commercial applications distribute GNU
+ MAKE with them to be able to work in non-friendly systems
+ - the key drawback is dependence on recent MAKE version 3.80 and better
+ and even version 3.80 of MAKE has important bug, which has been
+ corrected in newer sources
+
+The last point is critical. I have not noticed it first, because
+I use Slackware-9.2 and it contains latest released version
+of MAKE (version 3.80).
+The problem appears when I have tried to build bigger libraries.
+There is bug in version 3.80, which results in misleading
+error "Virtual memory exhausted". It is known bug with ID 1517
+
+ * long prerequisite inside eval(call()) => vm exhausted, Paul D. Smith
+
+I have optimized some rules to not push memory to the edge,
+but there could be still issues with 3.80 version.
+
+I have downloaded latest MAKE CVS sources. The compilation required
+separate lookup and download for .po files and full Autoheader... cycle.
+I have put together package similar to release. Only ./configure --prefix=...
+and make is required. CVS sources contains version 3.81beta1.
+You can download prepared sources archive from
+
+ http://cmp.felk.cvut.cz/~pisa/can/make-3.81beta1.tar.gz
+
+The archive contains even "make" binary build by me, which should work
+on other Linux distributions as well.
+Older version of MAKE (3.79.x released about year 2000) found
+on Mandrake and RedHat are not sufficient and do not support eval feature.
+I do not expect, that Debian would be more up-to-date or contain fixes
+to MAKE vm exhausted bug.
+
+The local CTU archive with our CAN components prepared for inclusion
+into OCERA SF CVS could be found in my "can" directory
+
+ http://cmp.felk.cvut.cz/~pisa/can/ocera-can-031212.tar.gz
+
+The code should build for user-space with new make on most of Linux distros
+when make is updated.
+
+If you want to test compile for RT-Linux targets, line
+
+#RTL_DIR := /home/cvs/ocera/ocera-build/kernel/rtlinux
+
+in "Makefile.rules" has to be activated and updated
+to point RT-Linux directory containing "rtl.mk".
+There is only one library ("ulutrtl") and test utility compiled for RT-Linux
+("can/utils/ulut/ul_rtlchk.c").
+
+The next line ,if enabled, controls compilation in OCERA project tree
+
+#OCERA_DIR := $(shell ( cd -L $(MAKERULES_DIR)/../../.. ; pwd -L ) )
+
+The LinCAN driver has been updated to compile out of source directories.
+
+Please, check, if you could compile CAN package and help us with integration
+into OCERA SF CVS. Send your comments and objections.
+
+The OMK system has been adapted to support actual OCERA configuration process.
+I am not happy with ocera.mk mix of defines and poor two or three rules,
+but OMK is able to overcome that.
+
+The OMK system has integrated rules (default-config) to build default configuration
+file. The file is named "config.omk-default" for the stand-alone compilation.
+The name corresponds to OCERA config + "-default" if OCERA_DIR is defined.
+This file contains statements from all default_CONFIG lines in all Makefile.omk.
+The file should be used for building of own "config.omk" file, or as list
+for all options if Kconfig is used.
+
--- /dev/null
+#!/bin/bash
+
+if [ $# -lt 1 ] ; then
+ echo "kernelcfg2mk: requires linux kernel directory as the first argument"
+ exit 2
+fi
+
+LINUX_DIR="$1"
+
+if [ $# -gt 1 ] ; then
+ KERN_MODULES_DIR="$2"
+fi
+
+if [ ! -e $LINUX_DIR/.config ] ; then
+ echo "kernelcfg2mk: the provided locations doesnot point to configured kernel sources"
+ echo " check directory $LINUX_DIR"
+ exit 2
+fi
+
+if [ ! -e $LINUX_DIR/.config ] ; then
+ echo "kernelcfg2mk: the provided locations doesnot point to configured kernel sources"
+ echo " check directory $LINUX_DIR"
+ exit 2
+fi
+
+if [ -z "$KERN_BUILD_DIR" ] ; then
+ KERN_BUILD_DIR=`pwd`
+fi
+
+if [ -z "$KERN_MODULES_DIR" ] ; then
+ KERN_MODULES_DIR=`pwd`
+fi
+
+
+if [ -z "$MAKE" ] ; then
+ MAKE="make"
+fi
+
+
+KERN_TEST_DIR="$KERN_BUILD_DIR/kern-test-mk"
+
+mkdir -p $KERN_TEST_DIR
+
+#echo MAKERULES_DIR $MAKERULES_DIR
+#echo LINUX_DIR $LINUX_DIR
+#echo KERN_BUILD_DIR $KERN_BUILD_DIR
+#echo KERN_MODULES_DIR $KERN_MODULES_DIR
+
+RETVAL="0"
+
+LINUX_VERSION=$(grep UTS_RELEASE ${LINUX_DIR}/include/linux/version.h | \
+ sed 's/[^"]*"\(.*\)\{1\}"/\1/')
+
+LINUX_VERSION_MAJOR=$(echo ${LINUX_VERSION} | cut -d. -f1)
+LINUX_VERSION_MINOR=$(echo ${LINUX_VERSION} | cut -d. -f2)
+
+#echo $LINUX_VERSION
+#echo $LINUX_VERSION_MAJOR
+#echo $LINUX_VERSION_MINOR
+
+
+case $LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR in
+
+
+#=====================================================================
+# test for 2.4.x kernels
+ 2.[01234])
+
+ rm -f ${KERN_BUILD_DIR}/kernel.mk
+ rm -rf ${KERN_TEST_DIR}
+ mkdir ${KERN_TEST_DIR}
+ cd ${KERN_TEST_DIR}
+
+ cat >${KERN_TEST_DIR}/Makefile <<EOF
+
+.PHONY: modules
+modules:
+ @echo LINUX_ARCH="\$(ARCH)" >>flags
+ @echo LINUX_LDFLAGS="" >>flags
+ @echo LINUX_ARFLAGS="\$(ARFLAGS)" >>flags
+ @echo LINUX_CROSS_COMPILE="\$(CROSS_COMPILE)" >>flags
+ @echo LINUX_KERNELRELEASE="\$(KERNELRELEASE)" >>flags
+ @echo LINUX_AFLAGS="\$(AFLAGS)" | sed 's_Iinclude_I"\$(LINUXDIR)/include"_g'>>flags
+ @echo LINUX_CFLAGS="\$(CFLAGS)" | sed 's_Iinclude_I"\$(LINUXDIR)/include"_g'>>flags
+ @echo LINUX_MODFLAGS="\$(MODFLAGS)"
+ @echo LINUX_CC="\$(CC)" >>flags
+ @echo LINUX_LD="\$(LD) \$(LDFLAGS)" >>flags
+ @echo LINUX_AS="\$(AS)" >>flags
+ @echo LINUX_AR="\$(AR)" >>flags
+ @echo LINUX_MODULE_EXT=".o" >>flags
+
+EOF
+
+ #echo ${MAKE} -C ${LINUX_DIR} SUBDIRS=${KERN_TEST_DIR} modules
+ ${MAKE} -C ${LINUX_DIR} SUBDIRS=${KERN_TEST_DIR} modules
+ if [ $? == 0 ] ; then
+ cp -v flags ${KERN_MODULES_DIR}/kernel.mk
+ if [ ! $? == 0 ] ; then
+ RETVAL="2"
+ fi
+ else
+ RETVAL="1"
+ fi
+
+ cd ${KERN_BUILD_DIR}
+ rm -rf ${KERN_TEST_DIR}
+ ;;
+
+#=====================================================================
+# test for 2.6.x kernels
+
+ 2.6)
+
+ rm -f ${KERN_BUILD_DIR}/kernel.mk
+ rm -rf ${KERN_TEST_DIR}
+ mkdir ${KERN_TEST_DIR}
+ cd ${KERN_TEST_DIR}
+
+ cat >${KERN_TEST_DIR}/Makefile <<EOF
+obj-m += fake.o
+
+\$(obj)/fake.c: flags
+ touch \$(obj)/fake.c
+
+ifeq (\$(KBUILD_SRC),)
+OMK_LINUX_SRC = \$(LINUXDIR)
+else
+OMK_LINUX_SRC = \$(KBUILD_SRC)
+endif
+#\$(warning Test \$OMK_LINUX_SRC)
+
+.PHONY: flags
+flags:
+ @echo LINUX_SRC="\$(OMK_LINUX_SRC)" >>\$(obj)/flags
+ @echo LINUX_ARCH="\$(ARCH)" >>\$(obj)/flags
+ @echo LINUX_LDFLAGS="" >>\$(obj)/flags
+ @echo LINUX_ARFLAGS="\$(ARFLAGS)" >>\$(obj)/flags
+ @echo LINUX_CROSS_COMPILE="\$(CROSS_COMPILE)" >>\$(obj)/flags
+ @echo LINUX_KERNELRELEASE="\$(KERNELRELEASE)" >>\$(obj)/flags
+ @echo LINUX_CPPFLAGS="\$(CPPFLAGS)" | sed 's_Iinclude_I"\$(LINUXDIR)/include"_g'>>\$(obj)/flags
+ @echo LINUX_AFLAGS="\$(AFLAGS)" | sed 's_Iinclude_I"\$(OMK_LINUX_SRC)/include"_g'>>\$(obj)/flags
+ @echo LINUX_CFLAGS="\$(CFLAGS)" | sed 's_Iinclude_I"\$(OMK_LINUX_SRC)/include"_g'>>\$(obj)/flags
+ @echo LINUX_CFLAGS_MODULE="\$(CFLAGS_MODULE)" >>\$(obj)/flags
+ @echo LINUX_CC="\$(CC)" >>\$(obj)/flags
+ @echo LINUX_LD="\$(LD) \$(LDFLAGS) \$(LDFLAGS_MODULE)" >>\$(obj)/flags
+ @echo LINUX_AS="\$(AS)" >>\$(obj)/flags
+ @echo LINUX_AR="\$(AR)" >>\$(obj)/flags
+ @echo LINUX_MODULE_EXT=".ko" >>\$(obj)/flags
+EOF
+
+ # V=1
+ #echo ${MAKE} -C ${LINUX_DIR} SUBDIRS=${KERN_TEST_DIR} LINUXDIR=${LINUX_DIR} MODVERDIR=${KERN_TEST_DIR} modules
+ ${MAKE} -C ${LINUX_DIR} SUBDIRS=${KERN_TEST_DIR} LINUXDIR=${LINUX_DIR} MODVERDIR=${KERN_TEST_DIR} modules
+ #if [ $? == 0 ] ; then
+ cp -v flags ${KERN_MODULES_DIR}/kernel.mk
+ if [ ! $? == 0 ] ; then
+ RETVAL="2"
+ fi
+ #else
+ # RETVAL="1"
+ #fi
+
+ cd ${KERN_BUILD_DIR}
+ rm -rf ${KERN_TEST_DIR}
+ ;;
+
+#=====================================================================
+
+ *)
+ echo "Unsupported Linux version $LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR"
+ ;;
+esac
+
+
+exit ${RETVAL}
--- /dev/null
+#!/bin/bash
+
+MAKEFILES=`find . -name Makefile.omk`
+
+for i in ${MAKEFILES} ; do
+ i=`dirname ${i}`
+ rm -f ${i}/Makefile
+ cp Makefile4omk ${i}/Makefile
+done
+
+make default-config
--- /dev/null
+#!/bin/bash
+
+MAKEFILES=`find . -name Makefile.std`
+
+for i in ${MAKEFILES} ; do
+ ( cd `dirname ${i}` && rm -f Makefile && ln -sf Makefile.std Makefile )
+done