From: Pavel Pisa Date: Sat, 5 Sep 2015 09:43:05 +0000 (+0200) Subject: OMK Makefile.rules updated to actual mainline version. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/commitdiff_plain/23c6af9c614e0d42ab109f9e833a2e82ea8bd4e7 OMK Makefile.rules updated to actual mainline version. The main change is support for exporting symbol table from build application. Signed-off-by: Pavel Pisa --- diff --git a/rtems-omk-template/Makefile.rules b/rtems-omk-template/Makefile.rules index 58d6288..5160614 100644 --- a/rtems-omk-template/Makefile.rules +++ b/rtems-omk-template/Makefile.rules @@ -1,10 +1,10 @@ # Makefile.rules - OCERA make framework common project rules -*- makefile-gmake -*- #OMK:base.omk # # (C) Copyright 2003, 2006, 2007, 2008, 2009 by Pavel Pisa - OCERA team member -# (C) Copyright 2006, 2007, 2008, 2009, 2010, 2011 by Michal Sojka - Czech Technical University, FEE, DCE +# (C) Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2015 by Michal Sojka - Czech Technical University, FEE, DCE # # Homepage: http://rtime.felk.cvut.cz/omk/ -# Version: 0.2-114-g1b1fb1a +# Version: 0.2-173-g6a298fc # # The OMK build system is distributed under the GNU General Public # License. See file COPYING for details. @@ -30,7 +30,10 @@ # 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 +# cmetric_include_HEADERS .. generate header file with offsets and sizes of structure fields #OMK:cmetric.omk +# xxx_CMETRIC_SOURCES .. the source cmetric generation # LOCAL_CONFIG_H .. name of local config.h file generated from values #OMK:config_h.omk # of options defined in the current directory # config_include_HEADERS .. names of global config files (possibly @@ -293,8 +296,10 @@ $(pass)-this-dir: $(foreach subdir,$(SUBDIRS),$(pass)-$(subdir)-subdir) @$(call mkdir_def,$(2)) +@$(MAKE) --no-builtin-rules $(NO_PRINT_DIRECTORY) SOURCES_DIR=$(SOURCES_DIR) RELATIVE_DIR=$(RELATIVE_DIR) -C $(2) \ -f $(SOURCESDIR_MAKEFILE) $(3) $(check-target) $(1:%=%-local) +ifneq ($(pass),clean) $(pass)-local: $($(pass)_HOOKS) endif +endif endef # ======================= @@ -324,7 +329,7 @@ omkize: fi $(Q)for i in `find -L . -name Makefile.omk` ; do \ d=`dirname $${i}`; \ - if ! test -f "$${d}/Makefile.rules" && ( test -f "$${d}/Makefile" && ! cmp -s Makefile "$${d}/Makefile" ); then \ + if ! test -f "$${d}/Makefile.rules" && ! cmp -s Makefile "$${d}/Makefile"; then \ rm -f "$${d}/Makefile"; \ cp -v Makefile "$${d}/Makefile"; \ fi \ @@ -397,10 +402,10 @@ 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%) +#CPPFLAGS += $(OMK_CPPFLAGS) +#CFLAGS += $(OMK_CFLAGS) +#CXXFLAGS += $(OMK_CXXFLAGS) +#LDFLAGS += $(CFLAGS) $(OMK_CFLAGS) $(LD_PATHS:%=-L%) LOADLIBES += -L$(USER_LIB_DIR) @@ -466,14 +471,14 @@ 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 +c_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(OMK_CPPFLAGS) \ + $(CPPFLAGS) $(OMK_CFLAGS) $(CFLAGS) $(INCLUDES) -DOMK_FOR_USER -cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CXXFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) -DOMK_FOR_USER +cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(OMK_CPPFLAGS) \ + $(CPPFLAGS) $(OMK_CXXFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) -DOMK_FOR_USER -S_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ASFLAGS) -DOMK_FOR_USER +S_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(OMK_CPPFLAGS) \ + $(CPPFLAGS) $(OMK_CFLAGS) $(CFLAGS) $(ASFLAGS) -DOMK_FOR_USER # Check GCC version for user build ifndef CC_MAJOR_VERSION @@ -519,31 +524,6 @@ $(2): $(1) $$(GEN_HEADERS) fi endef -# Syntax: $(call CMETRIC_o_h_template,,) -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 >$$@.tmp '/* Automatically generated from $$< */' - $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */' -# Bellow, the tricks with redirection are for shells without set -o pipefail -# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html) - $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ - | $(SED4OMK) -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ - | sort >>$$@.tmp` && exit $$$$status - $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */' - $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ - | $(SED4OMK) -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ - | sort >>$$@.tmp` && exit $$$$status - $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */' - $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\ - | $(SED4OMK) -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \ - | sort >>$$@.tmp` && exit $$$$status - $(Q)mv $$@.tmp $$@ -endef - idl_COMPILE = $(IDL_COMPILER) define COMPILE_idl_template @@ -552,6 +532,8 @@ $(2).c $(2)-stubs.c $(2)-skels.c $(2)-common.c $(2).h: $(1) $$(wildcard $$(first $(Q) $$(idl_COMPILE) $$($(2)_IDLFLAGS) $(1) endef +RTEMS_SYSM?=rtems-syms + # Syntax: $(call PROGRAM_template,,,) define PROGRAM_template USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL) @@ -573,14 +555,26 @@ USER_OBJS += $$($(1)_OBJS) USER_SOURCES += $$($(1)_SOURCES) USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES) +$(1)_LDFLAGS += $$(if $$(filter COMPLETE,$$($(1)_EXPORTSYMBOLS)),-Xlinker --whole-archive,) + +$(1)_LDCOMMAND += $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES))" ] ; \ + then echo $$(CC) $$(CPPFLAGS) $$(OMK_CPPFLAGS) $$(OMK_CFLAGS) $$(CFLAGS) ; \ + else echo $$(CXX) $$(CPPFLAGS) $$(OMK_CPPFLAGS) $$(OMK_CXXFLAGS) $$(CXXFLAGS) ; fi) \ + $$($(1)_LDFLAGS) $$(OMK_LDFLAGS) $$(LDFLAGS) $$($(1)_OBJS) + $(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) + $(Q) if [ -z "$$($(1)_EXPORTSYMBOLS)" ] ; then \ + $$($(1)_LDCOMMAND) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) -o $(2)/$(1) || exit 1; \ + else \ + rm -f $(1).prelink ; \ + $$($(1)_LDCOMMAND) $$(LOADLIBES) $$($(1)_LIBS:%=-l%) -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 ; \ + fi + #@echo "$(2)/$(1): \\" >$(USER_OBJS_DIR)/$(1).exe.d #@$(SED4OMK) -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(USER_OBJS_DIR)/$(1).exe.map >>$(USER_OBJS_DIR)/$(1).exe.d #@echo >>$(USER_OBJS_DIR)/$(1).exe.d @@ -648,21 +642,10 @@ 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) +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)/%) -# 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)/%) GEN_HEADERS+=$(filter %.h,$(USER_IDLS:%.idl=%.h)) # Generate rules for compilation of programs and libraries @@ -742,13 +725,15 @@ $(foreach tarfile,$(USER_EMBEDTARFILES),$(eval $(call TARFILE_template,$(tarfile endif -clean-local: +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) + $(USER_OBJS_DIR)/*_tarfile \ + $(USER_OBJS_DIR)/*.prelink \ + $(USER_OBJS_DIR)/*.tmp default: include-pass library-pass binary-pass @@ -759,6 +744,46 @@ include-pass-submakes: extra-rules-subdirs # directory, since the executables compiled in EXTRA_RULES_SUBDIRS # might be needed there. include-pass-this-dir $(foreach subdir,$(SUBDIRS),include-pass-$(subdir)-subdir): extra-rules-subdirs + #OMK:cmetric.omk@Makefile.rules.rtems +NM ?= nm + +# Syntax: $(call CMETRIC_o_h_template,,) +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 >$$@.tmp '/* Automatically generated from $$< */' + $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */' +# Bellow, the tricks with redirection are for shells without set -o pipefail +# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html) + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ + | $(SED4OMK) -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */' + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ + | $(SED4OMK) -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */' + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\ + | $(SED4OMK) -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)mv $$@.tmp $$@ +endef + +library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS)) + +# 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)/%) #OMK:config_h.omk@Makefile.rules.rtems # Syntax: $(call BUILD_CONFIG_H_template,,,,) define BUILD_CONFIG_H_template @@ -824,9 +849,7 @@ include-pass-local: $(kern_config_h_stamp_files) endif -clean-local: clean-local-config-h - -clean-local-config-h: +clean-local:: @$(foreach confh,$(config_h_stamp_files) $(kern_config_h_stamp_files),\ if [ -e $(confh) ] ; then rm $(confh) ; fi ; \ )