Skip to content

Commit

Permalink
Fix #2423, avoid use of abspath make function
Browse files Browse the repository at this point in the history
The abspath function does not work in GNU make v3.80, which is still
used as it is packaged with the Wind River tools as part of VxWorks 6.x.

The $(abspath ...) function was used in two places related to generating
tables - first for extraction of the ELF file from an intermediate
lib, second for conversion of that ELF file to a table file.  In the
first case, the path should already be absolute, as it comes from CMake.
In the second case, the path should always be relative, because it is
intended to match another pattern rule starting with "elf/%".  For the
second rule, prefixing with $(CURDIR) should achieve the same effect.
  • Loading branch information
jphickey committed Aug 10, 2023
1 parent 8852743 commit 0cdb4e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions cmake/tables/elf2cfetbl_rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Rule for traditional CFE table generation via elf2cfetbl

# The dependency of this target should always be an absolute pathname to
# the intermediate library file as it is generated by a CMake script via
# the TARGET_FILE property. Therefore, the same path should still work
# after the "cd" command. The "cd" is so the ar tool writes the object file
# into a separate dir, in case of similarly-named files on different cpus.
elf/%:
@mkdir -pv $(dir $(@))
cd $(dir $(@)) && $(AR) x $(abspath $(<)) $(notdir $(@))
@mkdir -pv "$(dir $(@))"
cd "$(dir $(@))" && $(AR) x "$(<)" "$(notdir $(@))"
11 changes: 8 additions & 3 deletions cmake/tables/tabletool_rule.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
cfetables:
@echo "Table build completed"

#%.tbl: $(TBLTOOL)
# The dependency of this rule should always be a relative path starting with elf/,
# at least with the current rule generator script, so it matches the elf/% pattern rule.
# But because elf2cfetbl only writes its output to the current working dir, it has to be run
# after changing dirs into the staging area. Thus the path to the elf file needs to be adjusted.
# Ideally this chould be done with the $(abspath f...) function but this doesn't exist in older versions.
# As a workaround, $CURDIR is used.
staging/%.tbl:
@mkdir -pv $(dir $(@))
cd $(dir $(@)) && $(TBLTOOL) $(TBLTOOL_FLAGS) $(abspath $(^))
@mkdir -pv "$(dir $(@))"
cd "$(dir $(@))" && $(TBLTOOL) $(TBLTOOL_FLAGS) "$(CURDIR)/$(<)"

0 comments on commit 0cdb4e4

Please sign in to comment.