From 4658a88584dc043aa411bf75c70142359e72b2cb Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 20 Feb 2015 14:48:05 -0600 Subject: [PATCH 1/5] Allow compiler flags from command line The following variables are reserved for use from the GNUmake command line: CMD_INCLUDES CMD_CPPFLAGS CMD_CFLAGS CMD_CXXFLAGS CMD_LDFLAGS CMD_DBFLAGS CMD_DBDFLAGS CMD_ARFLAGS For example: make CMD_INCLUDES=/opt/local/include CMD_LDFLAGS=-L/opt/local/lib --- configure/CONFIG_COMMON | 47 ++++++++++++++++--------- configure/RULES.Db | 4 +-- configure/os/CONFIG.Common.RTEMS | 37 +++++++++---------- configure/os/CONFIG.win32-x86.win32-x86 | 3 +- 4 files changed, 53 insertions(+), 38 deletions(-) diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index 6b31eea37..839c94283 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -209,6 +209,16 @@ USR_CPPFLAGS = USR_DBDFLAGS = USR_ARFLAGS = +# Variables to be set only on the command-line: +# CMD_INCLUDES = +# CMD_CFLAGS = +# CMD_CXXFLAGS = +# CMD_LDFLAGS = +# CMD_CPPFLAGS = +# CMD_DBFLAGS = +# CMD_DBDFLAGS = +# CMD_ARFLAGS = + # Debug specific options DEBUG_CPPFLAGS = DEBUG_CFLAGS = @@ -267,32 +277,35 @@ RUNTIME_LDFLAGS += $(RUNTIME_LDFLAGS_$(COMMANDLINE_LIBRARY)) # Flags INCLUDES = -I. $(SRC_INCLUDES) $(INSTALL_INCLUDES) $(RELEASE_INCLUDES)\ - $(TARGET_INCLUDES) $(USR_INCLUDES) $(OP_SYS_INCLUDES) $($(BUILD_CLASS)_INCLUDES) + $(TARGET_INCLUDES) $(USR_INCLUDES) $(CMD_INCLUDES) $(OP_SYS_INCLUDES)\ + $($(BUILD_CLASS)_INCLUDES) -CFLAGS = $($(BUILD_CLASS)_CFLAGS) $(POSIX_CFLAGS) $(OPT_CFLAGS) $(DEBUG_CFLAGS)\ - $(PIPE_CFLAGS) $(WARN_CFLAGS) $(TARGET_CFLAGS) $(USR_CFLAGS) $(ARCH_DEP_CFLAGS)\ - $(CODE_CFLAGS) $(STATIC_CFLAGS) $(OP_SYS_CFLAGS) $(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS) +CFLAGS = $($(BUILD_CLASS)_CFLAGS) $(POSIX_CFLAGS) $(OPT_CFLAGS)\ + $(DEBUG_CFLAGS) $(PIPE_CFLAGS) $(WARN_CFLAGS) $(TARGET_CFLAGS)\ + $(USR_CFLAGS) $(CMD_CFLAGS) $(ARCH_DEP_CFLAGS) $(CODE_CFLAGS)\ + $(STATIC_CFLAGS) $(OP_SYS_CFLAGS) $(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS) -CXXFLAGS = $($(BUILD_CLASS)_CXXFLAGS) $(POSIX_CXXFLAGS) $(OPT_CXXFLAGS) $(DEBUG_CXXFLAGS)\ - $(PIPE_CFLAGS) $(WARN_CXXFLAGS) $(TARGET_CXXFLAGS) $(USR_CXXFLAGS) $(ARCH_DEP_CXXFLAGS)\ - $(CODE_CXXFLAGS) $(STATIC_CXXCFLAGS) $(OP_SYS_CXXFLAGS) $(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS) +CXXFLAGS = $($(BUILD_CLASS)_CXXFLAGS) $(POSIX_CXXFLAGS) $(OPT_CXXFLAGS)\ + $(DEBUG_CXXFLAGS) $(PIPE_CFLAGS) $(WARN_CXXFLAGS) $(TARGET_CXXFLAGS)\ + $(USR_CXXFLAGS) $(CMD_CXXFLAGS) $(ARCH_DEP_CXXFLAGS) $(CODE_CXXFLAGS)\ + $(STATIC_CXXCFLAGS) $(OP_SYS_CXXFLAGS) $(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS) -LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) $(POSIX_LDFLAGS) \ - $(ARCH_DEP_LDFLAGS) $(DEBUG_LDFLAGS) $(OP_SYS_LDFLAGS) $($(BUILD_CLASS)_LDFLAGS)\ - $(RUNTIME_LDFLAGS) $(CODE_LDFLAGS) +LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) $(CMD_LDFLAGS)\ + $(POSIX_LDFLAGS) $(ARCH_DEP_LDFLAGS) $(DEBUG_LDFLAGS) $(OP_SYS_LDFLAGS)\ + $($(BUILD_CLASS)_LDFLAGS) $(RUNTIME_LDFLAGS) $(CODE_LDFLAGS) -LDLIBS = \ - $(POSIX_LDLIBS) $(ARCH_DEP_LDLIBS) $(DEBUG_LDLIBS) $(OP_SYS_LDLIBS) $(GNU_LDLIBS_$(GNU)) +LDLIBS = $(POSIX_LDLIBS) $(ARCH_DEP_LDLIBS) $(DEBUG_LDLIBS) $(OP_SYS_LDLIBS)\ + $(GNU_LDLIBS_$(GNU)) -CPPFLAGS += $($(BUILD_CLASS)_CPPFLAGS) $(POSIX_CPPFLAGS)\ - $(OPT_CPPFLAGS) $(DEBUG_CPPFLAGS) $(WARN_CPPFLAGS)\ - $(BASE_CPPFLAGS) $(TARGET_CPPFLAGS) $(USR_CPPFLAGS) $(ARCH_DEP_CPPFLAGS)\ - $(OP_SYS_CPPFLAGS) $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) +CPPFLAGS = $($(BUILD_CLASS)_CPPFLAGS) $(POSIX_CPPFLAGS) $(OPT_CPPFLAGS)\ + $(DEBUG_CPPFLAGS) $(WARN_CPPFLAGS) $(BASE_CPPFLAGS) $(TARGET_CPPFLAGS)\ + $(USR_CPPFLAGS) $(CMD_CPPFLAGS) $(ARCH_DEP_CPPFLAGS) $(OP_SYS_CPPFLAGS)\ + $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) #-------------------------------------------------- # ar definition default ARFLAGS = -ARCMD = $(AR) $(ARFLAGS) $(USR_ARFLAGS) $@ $(LIBRARY_LD_OBJS) +ARCMD = $(AR) $(ARFLAGS) $(USR_ARFLAGS) $(CMD_ARFLAGS) $@ $(LIBRARY_LD_OBJS) #-------------------------------------------------- # 'Munch' link-edit diff --git a/configure/RULES.Db b/configure/RULES.Db index 45acff5da..f0a4f6868 100644 --- a/configure/RULES.Db +++ b/configure/RULES.Db @@ -24,8 +24,8 @@ vpath %.acs $(USR_VPATH) $(GENERIC_SRC_DIRS) $(COMMON_DIR) DBD_SEARCH_DIRS = . .. $(COMMON_DIR) $(SRC_DIRS) $(INSTALL_DBD) $(RELEASE_DBD_DIRS) DB_SEARCH_DIRS = . .. $(COMMON_DIR) $(SRC_DIRS) $(INSTALL_DB) $(RELEASE_DB_DIRS) -DBDFLAGS = $(USR_DBDFLAGS) $(addprefix -I,$(DBD_SEARCH_DIRS)) -DBFLAGS = $($*_DBFLAGS) $(USR_DBFLAGS) $(addprefix -I,$(DB_SEARCH_DIRS)) +DBDFLAGS = $(USR_DBDFLAGS) $(CMD_DBDFLAGS) $(addprefix -I,$(DBD_SEARCH_DIRS)) +DBFLAGS = $($*_DBFLAGS) $(USR_DBFLAGS) $(CMD_DBFLAGS) $(addprefix -I,$(DB_SEARCH_DIRS)) ##################################################### # To allow os specific dbd files AND have the -j option work properly, diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index faf2bd23c..81132cdfd 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -49,28 +49,29 @@ RANLIB := $(RTEMS_TOOLS)/bin/$(RANLIB) VALID_BUILDS = Ioc #-------------------------------------------------- -# The RTEMS Makefiles redefine several macros, so we have to go -# through the following contortions to get the EPICS flags back. -CFLAGS = $(CROSS_CFLAGS) $(OPT_CFLAGS) $(DEBUG_CFLAGS)\ - $(WARN_CFLAGS) $(TARGET_CFLAGS) $(USR_CFLAGS) $(ARCH_DEP_CFLAGS)\ - $(CODE_CFLAGS) $(STATIC_CFLAGS) $(OP_SYS_CFLAGS) $(LIBRARY_SRC_CFLAGS)\ - $(HDEPENDS_CFLAGS) +# The RTEMS Makefiles redefine several macros, so we have to +# reset them to the proper EPICS values, from CONFIG_COMMON +CFLAGS = $($(BUILD_CLASS)_CFLAGS) $(POSIX_CFLAGS) $(OPT_CFLAGS)\ + $(DEBUG_CFLAGS) $(PIPE_CFLAGS) $(WARN_CFLAGS) $(TARGET_CFLAGS)\ + $(USR_CFLAGS) $(CMD_CFLAGS) $(ARCH_DEP_CFLAGS) $(CODE_CFLAGS)\ + $(STATIC_CFLAGS) $(OP_SYS_CFLAGS) $(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS) -CXXFLAGS = $(CROSS_CXXFLAGS) $(OPT_CXXFLAGS)\ - $(DEBUG_CXXFLAGS) $(WARN_CXXFLAGS) $(TARGET_CXXFLAGS) $(USR_CXXFLAGS)\ - $(ARCH_DEP_CXXFLAGS) $(CODE_CXXFLAGS) $(STATIC_CXXCFLAGS) $(OP_SYS_CXXFLAGS)\ - $(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS) +CXXFLAGS = $($(BUILD_CLASS)_CXXFLAGS) $(POSIX_CXXFLAGS) $(OPT_CXXFLAGS)\ + $(DEBUG_CXXFLAGS) $(PIPE_CFLAGS) $(WARN_CXXFLAGS) $(TARGET_CXXFLAGS)\ + $(USR_CXXFLAGS) $(CMD_CXXFLAGS) $(ARCH_DEP_CXXFLAGS) $(CODE_CXXFLAGS)\ + $(STATIC_CXXCFLAGS) $(OP_SYS_CXXFLAGS) $(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS) -LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) \ - $(ARCH_DEP_LDFLAGS) $(DEBUG_LDFLAGS) $(OP_SYS_LDFLAGS) $(CROSS_LDFLAGS)\ - $(RUNTIME_LDFLAGS) $(CODE_LDFLAGS) +LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) $(CMD_LDFLAGS)\ + $(POSIX_LDFLAGS) $(ARCH_DEP_LDFLAGS) $(DEBUG_LDFLAGS) $(OP_SYS_LDFLAGS)\ + $($(BUILD_CLASS)_LDFLAGS) $(RUNTIME_LDFLAGS) $(CODE_LDFLAGS) -LDLIBS = \ - $(POSIX_LDLIBS) $(ARCH_DEP_LDLIBS) $(DEBUG_LDLIBS) $(OP_SYS_LDLIBS) +LDLIBS = $(POSIX_LDLIBS) $(ARCH_DEP_LDLIBS) $(DEBUG_LDLIBS) $(OP_SYS_LDLIBS)\ + $(GNU_LDLIBS_$(GNU)) -CPPFLAGS += $(CROSS_CPPFLAGS) $(POSIX_CPPFLAGS)\ -$(BASE_CPPFLAGS) $(TARGET_CPPFLAGS) $(USR_CPPFLAGS) $(ARCH_DEP_CPPFLAGS)\ - $(OP_SYS_CPPFLAGS) $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) +CPPFLAGS += $($(BUILD_CLASS)_CPPFLAGS) $(POSIX_CPPFLAGS) $(OPT_CPPFLAGS)\ + $(DEBUG_CPPFLAGS) $(WARN_CPPFLAGS) $(BASE_CPPFLAGS) $(TARGET_CPPFLAGS)\ + $(USR_CPPFLAGS) $(CMD_CPPFLAGS) $(ARCH_DEP_CPPFLAGS) $(OP_SYS_CPPFLAGS)\ + $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) #-------------------------------------------------- # Although RTEMS uses gcc, it wants to use gcc its own way diff --git a/configure/os/CONFIG.win32-x86.win32-x86 b/configure/os/CONFIG.win32-x86.win32-x86 index a9fa77ca8..ed6839de7 100644 --- a/configure/os/CONFIG.win32-x86.win32-x86 +++ b/configure/os/CONFIG.win32-x86.win32-x86 @@ -189,7 +189,8 @@ OP_SYS_CXXFLAGS = $(COMPILER_CXXFLAGS) # '-entry:_DllMainCRTStartup$(DLLENTRY)' DLLENTRY = @12 -WIN32_DLLFLAGS = /subsystem:windows /dll $(OPT_LDFLAGS) $(USR_LDFLAGS) $(TARGET_LDFLAGS) $(LIB_LDFLAGS) +WIN32_DLLFLAGS = /subsystem:windows /dll $(OPT_LDFLAGS) \ + $(USR_LDFLAGS) $(CMD_LDFLAGS) $(TARGET_LDFLAGS) $(LIB_LDFLAGS) # # specify dll .def file only if it exists From 88314d0374b163261b2d04cb07b73a35b259fc84 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 20 Feb 2015 15:24:29 -0600 Subject: [PATCH 2/5] Release notes for CMD_ variables --- documentation/RELEASE_NOTES.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index bec510c5c..ef8612194 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -13,6 +13,29 @@ +

Added Make variables for command-line use

+ +

The following variables are now used during the build process, reserved for +setting on the command-line only (Makefiles should continue to use the +USR_ equivalents):

+ + + +

For example:

+ +
+make CMD_INCLUDES=/opt/local/include CMD_LDFLAGS=-L/opt/local/lib
+
+

Back-ported dbLoadRecordsHook from the 3.15 branch

See the Release Notes from the Base 3.15.1 release for details.

From 0f2d6eac9b1450157a4ca140fb460c231cdfc414 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 20 Feb 2015 15:34:57 -0600 Subject: [PATCH 3/5] Applied rtems-build-gesys-loadable-objects.patch --- configure/RULES_BUILD | 6 +++++ configure/os/CONFIG.Common.RTEMS | 38 +++++++++++++++++++++++++++ configure/os/CONFIG_SITE.Common.RTEMS | 6 +++++ documentation/RELEASE_NOTES.html | 6 +++++ 4 files changed, 56 insertions(+) diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD index bba3cdc73..c0e1ffbe7 100644 --- a/configure/RULES_BUILD +++ b/configure/RULES_BUILD @@ -331,6 +331,12 @@ $(OBJLIB_MUNCHNAME):%.munch : %_ctdt$(OBJ) %$(OBJ) @$(RM) $@ $(MUNCH_CMD) +# GeSys modules for RTEMS +$(MODNAME): %$(MODEXT): %$(EXE) + @echo "Building module $@" + @$(RM) $@ + $(LINK.mod) + runtests: $(TESTSCRIPTS) -$(PERL) -MTest::Harness -e 'runtests @ARGV if @ARGV;' $^ diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 81132cdfd..2e3b73ac8 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -83,6 +83,8 @@ OPT_CXXFLAGS_YES = $(CFLAGS_OPTIMIZE_V) OPT_CFLAGS_NO = $(CFLAGS_DEBUG_V) OPT_CXXFLAGS_NO = $(CFLAGS_DEBUG_V) +MODEXT=.obj + #-------------------------------------------------- # operating system class (include/os/) OS_CLASS = RTEMS @@ -97,6 +99,42 @@ OP_SYS_LDFLAGS += $(CPU_CFLAGS) -u Init \ $(PROJECT_RELEASE)/lib/no-signal.rel \ $(PROJECT_RELEASE)/lib/no-rtmon.rel +MOD_SYS_LDFLAGS += $(CPU_CFLAGS) -Wl,-r -nostdlib + +# Do not link against libraries which are part of the Generic Image +GESYS_LIBS += -lgcc +GESYS_LIBS += -lc -lm -lrtemscpu -lrtemsbsp -lrtems++ -lbspExt +GESYS_LIBS += -lcexp -ltecla_r -lspencer_regexp -lpmelf -lpmbfd +GESYS_LIBS += -lnfs -ltelnetd -lrtems-gdb-stub + +# While not part of the Generic Image it provides symbols which +# would conflict. +GESYS_LIBS += -lrtemsCom + +#-------------------------------------------------- +# Options for building GeSys loadable objects + +MODNAME_YES = $(PRODNAME:%$(EXE)=%$(MODEXT)) +MODNAME += $(MODNAME_$(USE_GESYS)) +PRODTARGETS += $(MODNAME) +BIN_INSTALLS += $(MODNAME) + +# changes to LDFLAGS in CONFIG_COMMON and LINK.cpp in CONFIG.Common.UnixCommon +# should be reflected here with the following exceptions +# +# replace OP_SYS_LDFLAGS with MOD_SYS_LDFLAGS +# replace PROD_LDLIBS with MOD_LDLIBS +# remove STATIC_LDFLAGS + +MOD_LDLIBS = $(filter-out $(GESYS_LIBS),$(PROD_LDLIBS)) + +MOD_LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) $(POSIX_LDFLAGS) \ + $(ARCH_DEP_LDFLAGS) $(DEBUG_LDFLAGS) $(MOD_SYS_LDFLAGS) $($(BUILD_CLASS)_LDFLAGS)\ + $(RUNTIME_LDFLAGS) $(CODE_LDFLAGS) + +LINK.mod = $(CCC) -o $@ $(PRODDIR_LDFLAGS) $(MOD_LDFLAGS) +LINK.mod += $(PROD_LDFLAGS) $(PROD_LD_OBJS) $(PROD_LD_RESS) $(MOD_LDLIBS) + #-------------------------------------------------- # RTEMS has neither shared libraries nor dynamic loading STATIC_BUILD=YES diff --git a/configure/os/CONFIG_SITE.Common.RTEMS b/configure/os/CONFIG_SITE.Common.RTEMS index d8b700b8c..a276bfa47 100644 --- a/configure/os/CONFIG_SITE.Common.RTEMS +++ b/configure/os/CONFIG_SITE.Common.RTEMS @@ -12,6 +12,12 @@ RTEMS_BASE = /usr/local/rtems/rtems-$(RTEMS_VERSION) # RTEMS_TOOLS = $(RTEMS_BASE) +# Link Generic System loadable objects instead of full executable. +# +# A GeSys object is similar to a shared library. It can be (un)loaded +# at runtime by the Generic System loader which is available as a +# patch against RTEMS. +USE_GESYS=NO # If you're using neither BOOTP/DHCP nor FLASH to pick up your IOC # network configuration you must uncomment and specify your Internet diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index ef8612194..c022df09f 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -13,6 +13,12 @@ +

Build rules for RTEMS GESYS modules

+ +

RTEMS target builds can now be configured to make GESYS modules by changing +the USE_GESYS=NO setting in the file +configure/os/CONFIG_SITE.Common.RTEMS to YES.

+

Added Make variables for command-line use

The following variables are now used during the build process, reserved for From 335cba0049a708a1fd7a577af44cc878c7de1ce7 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 20 Feb 2015 15:35:59 -0600 Subject: [PATCH 4/5] Applied rtems-mvme5500-needs-libbspExt.patch --- configure/os/CONFIG.Common.RTEMS-mvme5500 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure/os/CONFIG.Common.RTEMS-mvme5500 b/configure/os/CONFIG.Common.RTEMS-mvme5500 index 082e46b38..39be35635 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme5500 +++ b/configure/os/CONFIG.Common.RTEMS-mvme5500 @@ -22,4 +22,6 @@ define MUNCH_CMD $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary $< $@ endef +OP_SYS_LDLIBS += -lbspExt + include $(CONFIG)/os/CONFIG.Common.RTEMS From 3601a73b77500e379a34520909b15b9c9918be0c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 20 Feb 2015 15:42:14 -0600 Subject: [PATCH 5/5] Applied rtems-use-macro-for-BIN2BOOT.patch --- configure/os/CONFIG.Common.RTEMS-pc386 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure/os/CONFIG.Common.RTEMS-pc386 b/configure/os/CONFIG.Common.RTEMS-pc386 index 0c6088783..2b20b974a 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386 +++ b/configure/os/CONFIG.Common.RTEMS-pc386 @@ -12,7 +12,7 @@ MUNCH_SUFFIX = .boot MUNCHNAME = $(PRODNAME:%$(EXE)=%$(MUNCH_SUFFIX)) define MUNCH_CMD $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary -R .comment -S $< temp.bin - $(PROJECT_RELEASE)/build-tools/bin2boot $@ 0x00097E00 \ + $(BIN2BOOT) $@ 0x00097E00 \ $(PROJECT_RELEASE)/lib/start16.bin 0x00097C00 0 temp.bin 0x00100000 0 rm -f temp.bin endef