]> rtime.felk.cvut.cz Git - rtems-devel.git/commitdiff
RTEMS template for OMK build system conforming application.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Mon, 28 Nov 2005 18:26:47 +0000 (19:26 +0100)
committerPavel Pisa <pi@thor.(none)>
Sat, 28 Nov 2009 23:29:46 +0000 (00:29 +0100)
To utilize automatic OMK build system GNU make program
of version 3.81beta1 or higher is required.

The config.target has to exist in the top level directory
containing Makefile.rules file. The convenient way is to
create config.target as the symbolic link to selected file
in the config subdirectory.
The config.target file defines RTEMS_MAKEFILE_PATH variable
pointing to RTEMS target board specific installation directory.

Issue next command to build project
  make default-config
  make

The more help about OMK style Makefiles can be found
in the README.makerules file.

darcs-hash:20051128182647-ff715-2d2d773193de26aebbab4fb2919363c5377c68ec.gz

19 files changed:
rtems-omk-template/Makefile [new file with mode: 0644]
rtems-omk-template/Makefile.omk [new file with mode: 0644]
rtems-omk-template/Makefile.rules [new file with mode: 0644]
rtems-omk-template/README.makerules [new file with mode: 0644]
rtems-omk-template/appfoo/Makefile [new file with mode: 0644]
rtems-omk-template/appfoo/Makefile.omk [new file with mode: 0644]
rtems-omk-template/appfoo/app_def.h [new file with mode: 0644]
rtems-omk-template/appfoo/init.c [new file with mode: 0644]
rtems-omk-template/appfoo/system.h [new file with mode: 0644]
rtems-omk-template/appfoo/task_1.c [new file with mode: 0644]
rtems-omk-template/config/config.ec555 [new file with mode: 0644]
rtems-omk-template/libbar/Makefile [new file with mode: 0644]
rtems-omk-template/libbar/Makefile.omk [new file with mode: 0644]
rtems-omk-template/libbar/bar.h [new file with mode: 0644]
rtems-omk-template/libbar/function1.c [new file with mode: 0644]
rtems-omk-template/libbar/function2.c [new file with mode: 0644]
rtems-omk-template/system_opt/Makefile [new file with mode: 0644]
rtems-omk-template/system_opt/Makefile.omk [new file with mode: 0644]
rtems-omk-template/system_opt/system_def.h [new file with mode: 0644]

diff --git a/rtems-omk-template/Makefile b/rtems-omk-template/Makefile
new file mode 100644 (file)
index 0000000..142cc88
--- /dev/null
@@ -0,0 +1,14 @@
+# 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
+
diff --git a/rtems-omk-template/Makefile.omk b/rtems-omk-template/Makefile.omk
new file mode 100644 (file)
index 0000000..98ad3fc
--- /dev/null
@@ -0,0 +1,2 @@
+SUBDIRS = system_opt libbar appfoo 
+
diff --git a/rtems-omk-template/Makefile.rules b/rtems-omk-template/Makefile.rules
new file mode 100644 (file)
index 0000000..8cf8734
--- /dev/null
@@ -0,0 +1,494 @@
+#  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: $(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),\
+               $(cmetrh:%=$(USER_INCLUDE_DIR)/%))))
+
+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)/%) \
+              $(cmetric_include_HEADERS:%=$(USER_INCLUDE_DIR)/%) \
+              $(tar_EMBEDFILES:%=$(USER_OBJS_DIR)/%_tarfile)
+              
+
diff --git a/rtems-omk-template/README.makerules b/rtems-omk-template/README.makerules
new file mode 100644 (file)
index 0000000..bb16443
--- /dev/null
@@ -0,0 +1,248 @@
+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.
+
diff --git a/rtems-omk-template/appfoo/Makefile b/rtems-omk-template/appfoo/Makefile
new file mode 100644 (file)
index 0000000..142cc88
--- /dev/null
@@ -0,0 +1,14 @@
+# 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
+
diff --git a/rtems-omk-template/appfoo/Makefile.omk b/rtems-omk-template/appfoo/Makefile.omk
new file mode 100644 (file)
index 0000000..135b758
--- /dev/null
@@ -0,0 +1,15 @@
+default_CONFIG += CONFIG_OC_BUILD4RTEMS=y
+default_CONFIG += CONFIG_OC_GDBSTUB=n
+
+bin_PROGRAMS = appfoo
+
+#lib_LIBRARIES = 
+
+#include_HEADERS = 
+
+appfoo_SOURCES += init.c task_1.c
+
+#appfoo_EMBEDTARFILES = rootfs
+
+lib_LOADLIBES += bar
+
diff --git a/rtems-omk-template/appfoo/app_def.h b/rtems-omk-template/appfoo/app_def.h
new file mode 100644 (file)
index 0000000..6527316
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef _APP_DEF_H
+#define _APP_DEF_H
+
+#ifndef COND_EXTERN
+  #ifdef CONFIGURE_INIT
+    #define COND_EXTERN
+  #else
+    #define COND_EXTERN extern
+  #endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+COND_EXTERN rtems_id   Task_1_id;           /* Task 1 id */
+COND_EXTERN rtems_name Task_1_name;         /* Task 1 name */
+
+rtems_task Task_1(
+  rtems_task_argument argument
+);
+
+void bad_rtems_status(rtems_status_code status, int fail_level, const char *text);
+
+static inline
+void check_rtems_status(rtems_status_code status, int fail_level, const char *text)
+{
+   if(!rtems_is_status_successful(status))
+     bad_rtems_status(status, fail_level, text);
+}
+
+#define TASK_1_PRIORITY     30
+#define SHELL_TASK_PRIORITY 50
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_APP_DEF_H*/
diff --git a/rtems-omk-template/appfoo/init.c b/rtems-omk-template/appfoo/init.c
new file mode 100644 (file)
index 0000000..06f57dc
--- /dev/null
@@ -0,0 +1,99 @@
+/*  Init
+ *
+ *  This routine is the initialization task for this test program.
+ *  It is called from init_exec and has the responsibility for creating
+ *  and starting the tasks that make up the test.  If the time of day
+ *  clock is required for the test, it should also be set to a known
+ *  value by this function.
+ *
+ *  Input parameters:  NONE
+ *
+ *  Output parameters:  NONE
+ *
+ *  COPYRIGHT (c) 1989-1999.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id: init.c,v 1.12.4.1 2003/09/04 18:46:30 joel Exp $
+ */
+
+#define CONFIGURE_INIT
+#include <system_def.h>
+#include "system.h"
+#include "app_def.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <rtems/error.h>
+#include <rtems/monitor.h>
+#include <rtems/shell.h>
+
+#define BUILD_VERSION_STRING(major,minor,patch) \
+        __XSTRING(major) "." __XSTRING(minor) "." __XSTRING(patch)
+
+void 
+bad_rtems_status(rtems_status_code status, int fail_level, const char *text)
+{
+  printf("ERROR: %s status %s", text, rtems_status_text(status));
+  status = rtems_task_delete( RTEMS_SELF );
+}
+
+int testcmd_forshell(int argc, char **argv)
+{
+  int i;
+  printf("Command %s called\n",argv[0]);
+  for(i=1;i<argc;i++)
+    if(argv[i])
+      printf("%s",argv[i]);
+  printf("\n");
+  return 0;
+}
+
+rtems_task Init(
+  rtems_task_argument ignored
+)
+{
+  rtems_status_code status;
+
+  printf( "\n\nRTEMS v "
+          BUILD_VERSION_STRING(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
+         "\n");
+  
+  rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL);
+  /*rtems_capture_cli_init (0);*/
+  
+  printf( "Starting application " SW_VER_ID " v "
+          BUILD_VERSION_STRING(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
+         "\n" );
+
+  Task_1_name = rtems_build_name( 'T', 'S', 'K', '1' );
+    
+  status = rtems_task_create(
+     Task_1_name,
+     TASK_1_PRIORITY,
+     RTEMS_MINIMUM_STACK_SIZE+0x10000,
+     RTEMS_DEFAULT_MODES /*& ~(RTEMS_TIMESLICE_MASK) | RTEMS_TIMESLICE*/,
+     RTEMS_DEFAULT_ATTRIBUTES,
+     &Task_1_id
+  );
+  check_rtems_status(status, 0, "rtems_task_create of Task_1");
+
+  status = rtems_task_start( Task_1_id, Task_1, 0 );
+  check_rtems_status(status, 0, "rtems_task_start of Task_1\n");
+
+  shell_init("SHLL",RTEMS_MINIMUM_STACK_SIZE+0x1000,
+              SHELL_TASK_PRIORITY,"/dev/console",B19200 | CS8, 0);
+
+  shell_add_cmd("testcmd", "app",
+                "test command for shell",
+                testcmd_forshell);
+
+  //rtems_monitor_wakeup();
+
+  status = rtems_task_delete( RTEMS_SELF );
+  
+  printf( "*** END OF TEST2 ***\n" );
+  exit( 0 );
+}
diff --git a/rtems-omk-template/appfoo/system.h b/rtems-omk-template/appfoo/system.h
new file mode 100644 (file)
index 0000000..5ce9d4a
--- /dev/null
@@ -0,0 +1,57 @@
+/*  system.h
+ *
+ *  This include file contains information that is included in every
+ *  function in the test set.
+ *
+ *  COPYRIGHT (c) 1989-1999.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id: system.h,v 1.13.6.1 2003/09/04 18:46:30 joel Exp $
+ */
+
+#include <rtems.h>
+
+/* functions */
+
+rtems_task Init(
+  rtems_task_argument argument
+);
+
+/* configuration information */
+
+#include <bsp.h> /* for device driver prototypes */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
+
+#define TICKS_PER_SECOND 1000
+
+#define CONFIGURE_MAXIMUM_TIMERS                 32
+#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES         32
+#define CONFIGURE_MAXIMUM_SEMAPHORES             32
+#define CONFIGURE_MAXIMUM_TASKS                  32
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
+#define CONFIGURE_MAXIMUM_DRIVERS (CONFIGURE_NUMBER_OF_DRIVERS+10)
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+/*#define CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM*/
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 1000
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE  (10*1024)
+#define CONFIGURE_INIT_TASK_PRIORITY    120
+#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
+                                           RTEMS_NO_TIMESLICE | \
+                                           RTEMS_NO_ASR | \
+                                           RTEMS_INTERRUPT_LEVEL(0))
+
+#include <rtems/confdefs.h>
+
+/* end of include file */
diff --git a/rtems-omk-template/appfoo/task_1.c b/rtems-omk-template/appfoo/task_1.c
new file mode 100644 (file)
index 0000000..ffd6fa2
--- /dev/null
@@ -0,0 +1,25 @@
+#include <system_def.h>
+#include "system.h"
+#include "app_def.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <rtems/untar.h>
+#include <rtems/error.h>
+#include <rtems/mw_uid.h>
+#include <errno.h>
+
+
+rtems_task Task_1(
+  rtems_task_argument argument
+)
+{
+  rtems_status_code status;
+  printf("*** Starting up Task_1 ***\n");
+
+  while(1){
+    printf("Task_1 woken\n");
+    status = rtems_task_wake_after( TICKS_PER_SECOND );
+    check_rtems_status( status, 0, "rtems_task_wake_after" );
+  }
+}
+
diff --git a/rtems-omk-template/config/config.ec555 b/rtems-omk-template/config/config.ec555
new file mode 100644 (file)
index 0000000..ebbb6a2
--- /dev/null
@@ -0,0 +1,4 @@
+# EC555 BSP for Wuerz-elektronik EC555 board
+# This file should be symlinked as config.target into project
+# Makefile.rules directory
+RTEMS_MAKEFILE_PATH=/opt/rtems/powerpc-rtems/ec555
diff --git a/rtems-omk-template/libbar/Makefile b/rtems-omk-template/libbar/Makefile
new file mode 100644 (file)
index 0000000..142cc88
--- /dev/null
@@ -0,0 +1,14 @@
+# 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
+
diff --git a/rtems-omk-template/libbar/Makefile.omk b/rtems-omk-template/libbar/Makefile.omk
new file mode 100644 (file)
index 0000000..b3403f4
--- /dev/null
@@ -0,0 +1,5 @@
+lib_LIBRARIES = bar
+
+include_HEADERS = bar.h
+
+bar_SOURCES = function1.c function2.c
diff --git a/rtems-omk-template/libbar/bar.h b/rtems-omk-template/libbar/bar.h
new file mode 100644 (file)
index 0000000..8093b51
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef _BAR_H_
+#define _BAR_H_
+
+int function1(int);
+int function2(char *);
+
+#endif /*_BAR_H_*/
diff --git a/rtems-omk-template/libbar/function1.c b/rtems-omk-template/libbar/function1.c
new file mode 100644 (file)
index 0000000..56ba44a
--- /dev/null
@@ -0,0 +1,6 @@
+#include <bar.h>
+
+int function1(int a)
+{
+  return a*a;
+}
diff --git a/rtems-omk-template/libbar/function2.c b/rtems-omk-template/libbar/function2.c
new file mode 100644 (file)
index 0000000..4a1db33
--- /dev/null
@@ -0,0 +1,7 @@
+#include <string.h>
+#include <bar.h>
+
+int function2(char *s)
+{
+  return strlen(s);
+}
diff --git a/rtems-omk-template/system_opt/Makefile b/rtems-omk-template/system_opt/Makefile
new file mode 100644 (file)
index 0000000..142cc88
--- /dev/null
@@ -0,0 +1,14 @@
+# 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
+
diff --git a/rtems-omk-template/system_opt/Makefile.omk b/rtems-omk-template/system_opt/Makefile.omk
new file mode 100644 (file)
index 0000000..ab511ae
--- /dev/null
@@ -0,0 +1,3 @@
+#SUBDIRS = 
+
+include_HEADERS = system_def.h
diff --git a/rtems-omk-template/system_opt/system_def.h b/rtems-omk-template/system_opt/system_def.h
new file mode 100644 (file)
index 0000000..78e8f6a
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef _SYSTEM_DEF_H_
+#define _SYSTEM_DEF_H_
+
+#include <inttypes.h>
+
+#define VER_CODE(major,minor,patch) (major*0x10000+minor*0x100+patch)
+/* Software version */
+#define SW_VER_ID      "APPFOO"
+#define SW_VER_MAJOR   0
+#define SW_VER_MINOR   1
+#define SW_VER_PATCH   0
+#define SW_VER_CODE    VER_CODE(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
+/* Hardware version */
+#define HW_VER_ID      "SOMEBOARD"
+#define HW_VER_MAJOR   0
+#define HW_VER_MINOR   1
+#define HW_VER_PATCH   0
+#define HW_VER_CODE    VER_CODE(HW_VER_MAJOR,HW_VER_MINOR,HW_VER_PATCH)
+/* Version of mechanical  */
+#define MECH_VER_ID     "SOMESTUFF"
+#define MECH_VER_MAJOR  0
+#define MECH_VER_MINOR  1
+#define MECH_VER_PATCH  0
+#define MECH_VER_CODE  VER_CODE(MECH_VER_MAJOR,MECH_VER_MINOR,MECH_VER_PATCH)
+
+#endif /* _SYSTEM_DEF_H_ */