Sabersimon
Sabersimon

Reputation: 50

Parsing Makefile list var

Thank You in advance. I have a list where each entry is a word.
For example: Here is the command

'tvc := $(shell jpl-tcs.sh --check_tool_versions --pcf $(PCF))'

Here is the output:
@N: tcs_init_pkg::tcs_build_dirs: Found par directory: /data/home/nbrummel/jpl-tcs/examples/build/cntr/xilinx/par @N: tcs_init_pkg::tcs_build_dirs: Found bit directory: /data/home/nbrummel/jpl-tcs/examples/build/cntr/xilinx/bit @N: tcs_init_pkg::tcs_build_dirs: Found log directory: /data/home/nbrummel/jpl-tcs/examples/build/cntr/xilinx/logs @N: tcs_init_pkg::tcs_build_dirs: Found cores directory: /data/home/nbrummel/jpl-tcs/examples/build/cntr/xilinx/cores @N: tcs_init_pkg::check_xilinx_env_var: XILINX env var is set to: /data/opt/Xilinx/13.2/ISE_DS/ISE @N: jpl-tcs.sh: Checking tool versions @N: tcs_check_versions.py: tool_version.txt found @N: tcs_check_versions.py: Found tool_version.txt in xilinx @N: tcs_check_versions.py: Tool version check : Completed. ---> Local tool versions match tool_version.txt! @N: jpl-tcs.sh: Passed Tool Check @N: jpl-tcs.sh: Using default Xilinx command-line options file: /data/home/nbrummel/jpl-tcs/tcs_defaults/tcs_xcl_tools.sh

I want to format the output to the console or screen like this.

@N: tcs_init_pkg::tcs_build_dirs: Found par directory: /data/home/nbrummel/jpl-tcs/examples/build/cntr/xilinx/par 
@N: tcs_init_pkg::tcs_build_dirs: Found bit directory: /data/home/nbrummel/jpl-tcs/examples/build/cntr/xilinx/bit 
@N: tcs_init_pkg::tcs_build_dirs: Found log directory: /data/home/nbrummel/jpl-tcs/examples/build/cntr/xilinx/logs 
@N: tcs_init_pkg::tcs_build_dirs: Found cores directory: /data/home/nbrummel/jpl-tcs/examples/build/cntr/xilinx/cores 
@N: tcs_init_pkg::check_xilinx_env_var: XILINX env var is set to: /data/opt/Xilinx/13.2/ISE_DS/ISE 
@N: jpl-tcs.sh: Checking tool versions 
@N: tcs_check_versions.py: tool_version.txt found 
@N: tcs_check_versions.py: Found tool_version.txt in xilinx 
@N: tcs_check_versions.py: Tool version check : Completed. ---> Local tool versions match tool_version.txt! 
@N: jpl-tcs.sh: Passed Tool Check 
@N: jpl-tcs.sh: Using default Xilinx command-line options file: /data/home/nbrummel/jpl-tcs/tcs_defaults/tcs_xcl_tools.sh`

Where the new print out would always start with the '@' character. I have gotten it to print out one word on each line but that is not what I want. Any help would be great. Also, this can not be in a recipe.

if I run jpl-tcs.sh ... I get the formatted output above. If i run the same command in Make with tvc:=$(shell jpl-tcs.sh ...) and $(info $(tvc)) then I get the garbed output where the newline characters are omitted. I want it to display like it does in the shell but when I call it in make. How do I do that?

Upvotes: 0

Views: 150

Answers (1)

rici
rici

Reputation: 241731

A simple solution:

sed 's/ @N:/\n@N:/g' file

or, if the list is in a shell variable:

sed 's/ @N:/\n@N:/g' <<< "$list"

If the list is in a make variable, you could use something pretty similar in a recipe:

show_tvc:
    printf "%s\n" "$(tvc)" | sed 's/ @N:/\n@N:/g'

But the simplest solution is probably to send the shell command"s output to the terminal directly:

$(shell jpl-tcs.sh --check_tool_versions --pcf $(PCF) 1>&2)

Upvotes: 1

Related Questions