X-Git-Url: http://rtime.felk.cvut.cz/gitweb/omk.git/blobdiff_plain/75a9abff74dfbdd3103e115c19f4a5f0cc9cb0af..ca54517a66460ac64138e7a8944209f5c6b62ced:/snippets/rtems.omk diff --git a/snippets/rtems.omk b/snippets/rtems.omk index 8ba457c..83c78eb 100644 --- a/snippets/rtems.omk +++ b/snippets/rtems.omk @@ -12,9 +12,15 @@ # xxx_SOURCES .. list of specific target sources # xxx_LIBS .. list of specific target libraries # INCLUDES .. additional include directories and defines for user-space -# tar_EMBEDFILES .. list of tars with embedded files +# xxx_EMBEDTARFILES .. list of source subdirectories which are embedded as tar files to the application # xxx_EXPORTSYMBOLS .. if "y" then include symbol table in the application for dlopen functionality +# Output variables: +# OBJ_EXT - extension of object files +# LIB_EXT - extension of library files +# LIB_PREF - prefix for library files +# ASM_EXT - extension of assembler sources + include $(RTEMS_MAKEFILE_PATH)/Makefile.inc include $(RTEMS_CUSTOM) include $(CONFIG.CC) @@ -33,7 +39,6 @@ USER_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/user LOCAL_BUILD_DIR = $(USER_OBJS_DIR) - DEFAULT_INCLUDES = -I $(PROJECT_INCLUDE) CPPFLAGS += -I $(USER_INCLUDE_DIR) @@ -51,6 +56,11 @@ LOADLIBES += $(lib_LOADLIBES:%=-l%) SOLIB_PICFLAGS += -shared -fpic +OBJ_EXT = .o +LIB_EXT = .a +LIB_PREF = lib +ASM_EXT = .S + ifndef RELATIVE_DIR RELATIVE_DIR := $(SOURCES_DIR:$(MAKERULES_DIR)%=%) endif @@ -204,10 +214,10 @@ $(2)/$(1): $(USER_LIB_DIR)/timestamp $(2)/$(1): $$($(1)_OBJS) @$(QUIET_CMD_ECHO) " LINK $$@" $(Q) if [ -z "$$($(1)_EXPORTSYMBOLS)" ] ; then \ - $$($(1)_LDCOMMAND) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) -o $(2)/$(1) || exit 1; \ + $$($(1)_LDCOMMAND) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $(2)/$(1) || exit 1; \ else \ rm -f $(1).prelink ; \ - $$($(1)_LDCOMMAND) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) -o $(1).prelink || exit 1 ; \ + $$($(1)_LDCOMMAND) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $(1).prelink || exit 1 ; \ $(RTEMS_SYSM) -e -c "$$(CC) $$(CPPFLAGS) $$(OMK_CPPFLAGS) $$(OMK_CFLAGS) $$(CFLAGS)" \ -S $(1)-symbol-table.c -o $(1)-symbol-table.o $(1).prelink || exit 1 ; \ $$($(1)_LDCOMMAND) $(1)-symbol-table.o $$(LOADLIBES) $$($(1)_LIBS:%=-l%) -o $(2)/$(1) || exit 1 ; \ @@ -220,7 +230,18 @@ $(2)/$(1): $$($(1)_OBJS) # FIXME: Why the map file was commented out? 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,) define LIBRARY_template @@ -282,7 +303,8 @@ 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_PROGRAMS:%=$(USER_UTILS_DIR)/%) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%) +binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%) $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%) \ + $(foreach of,$(OUTPUT_FORMATS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%.$(of)) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%.$(of))) GEN_HEADERS+=$(filter %.h,$(USER_IDLS:%.idl=%.h)) @@ -298,6 +320,12 @@ $(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib)))) $(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib)))) +# Create _build directories for sources in subdirectories i.e. *_SOURCES=dir/file.c +_dirs_to_create=$(filter-out ./,$(sort $(dir $(USER_SOURCES) $(SOLIB_SOURCES)))) +ifneq ($(_dirs_to_create),) +$(shell mkdir -p $(addprefix $(LOCAL_BUILD_DIR)/,$(_dirs_to_create))) +endif + # IDL compilation USER_IDLS := $(sort $(USER_IDLS)) $(foreach src,$(filter %.idl,$(USER_IDLS)),$(eval $(call COMPILE_idl_template,$(SOURCES_DIR)/$(src),$(src:%.idl=%)))) @@ -369,7 +397,9 @@ clean-local:: $(USER_OBJS_DIR)/*.d \ $(USER_OBJS_DIR)/*.map \ $(LOCAL_CONFIG_H:%=$(USER_OBJS_DIR)/%) \ - $(tar_EMBEDFILES:%=$(USER_OBJS_DIR)/%_tarfile) + $(USER_OBJS_DIR)/*_tarfile \ + $(USER_OBJS_DIR)/*.prelink \ + $(USER_OBJS_DIR)/*.tmp default: include-pass library-pass binary-pass