]> rtime.felk.cvut.cz Git - omk.git/blobdiff - snippets/nuttx-compile.omk
NuttX: include support for ROM filesystems.
[omk.git] / snippets / nuttx-compile.omk
index f4a1d15509b67008bd87c750831a44c2fa7edcc1..2f223a86cd83a38b9b89959aad78710847e22a68 100644 (file)
@@ -136,9 +136,11 @@ $(foreach x, $(SOURCES2OBJS),
 $(1)_OBJS += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\
                $$($(1)_SOURCES) $$($(1)_GEN_SOURCES)))
 )
+$(1)_OBJS += $$($(1)_EMBEDROMFS:%=%_img.o)
 $(1)_OBJS := $$(sort $$($(1)_OBJS:%/=%))
 
 SOURCES += $$($(1)_SOURCES)
+EMBEDROMFS += $$($(1)_EMBEDROMFS)
 
 ifneq ($$($(1)_PROGBUILTIN),)
 ifneq ($$($(1)_PROGBUILTIN),all)
@@ -162,6 +164,7 @@ else
 $(1)_KMODBUILTIN_LIBS = $$(wildcard $$(KERN_MODULES_DIR)/lib*.ka)
 endif
 
+
 ifneq ($$($(1)_PROGBUILTIN_PDAT),)
 $(1)_BUILTINTABLE = $(OBJS_DIR)/$(1)-builtintab.c
 
@@ -279,9 +282,11 @@ $(foreach x, $(SOURCES2OBJS),
 $(1)_OBJS += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\
                $$($(1)_SOURCES) $$($(1)_GEN_SOURCES)))
 )
+$(1)_OBJS += $$($(1)_EMBEDROMFS:%=%_img.o)
 $(1)_OBJS := $$(sort $$($(1)_OBJS:%/=%))
 
 SOURCES += $$($(1)_SOURCES)
+EMBEDROMFS += $$($(1)_EMBEDROMFS)
 
 $(LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
        @$(QUIET_CMD_ECHO) "  AR      $$@"
@@ -315,3 +320,22 @@ library-pass_HOOKS += force_builtin_library_hook
 force_builtin_library_hook:
 
 endif
+
+# Syntax: $(call ROMFS_template,<filename>,<filename2>,<directory>) FIXME: Is this correct?
+define ROMFS_template
+
+.PHONY: $(2)
+
+$(2):
+       $(Q) genromfs -f $(2).tmp -V $(1) -d $(3)
+       $(Q) if ( [ ! -e $(2) ] || ! cmp $(2).tmp $(2) ) ; then cp $(2).tmp $(2) ; fi
+
+$(2).o: $(2)
+       @$(QUIET_CMD_ECHO) "  ROMFS   $$@"
+       $(Q) $(LD) -r --accept-unknown-input-arch -b binary \
+               --defsym=$(2)_len=_binary_$(2)_size \
+               --defsym=$(2)=_binary_$(2)_start -o $$@.tmp $$^
+       $(Q) $(OBJCOPY) --rename-section .data=.rodata,alloc,load,readonly,data,contents \
+               $$@.tmp $$@
+
+endef