How to use echo in shell command in Makefile?


w

I have a GNU makefile . It runs fine on Linux, Solaris and OS X. However, under Cygwin-32, Cygwin-64 and MinGW it produces:

/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `echo 2.0.4(0.287/5/3) | egrep -i -c "fc22.i686"'

There is no line 0; Fedora 22's test actually happens on line 73:

IS_FEDORA22_i686 = $(shell echo $(RELEASE) | $(EGREP) -i -c "fc22.i686")

What happened to Cygwin and MinGW? More importantly, how can I fix this?


I know this sounds like a stretch, so here's a screenshot. On the top left is MinGW. At the center is Cygwin-32. Bottom right is Cygwin-64.

enter image description here

x

The problem is that the shell sees the parentheses $RELEASEoutside any quotes and tries to interpret them as well. Two things to try: put double quotes around the reference $(RELEASE)and use :=each one . E.g:

SHELL:=/bin/bash.  #at the top of the makefile
IS_FEDORA22_i686 := $(shell echo "$(RELEASE)" | $(EGREP) -i -c "fc22.i686")

EDIT: uname output with something like switches usually doesn't have any shell metacharacters. The same problem can happen with any variable you make. That's why setting it in the makefile is very useful - if the user is running , you'll have a different problem than if the user were running .-mSHELLcshbash

Related


How to use echo in shell command in Makefile?

w I have a GNU makefile . It runs fine on Linux, Solaris and OS X. However, under Cygwin-32, Cygwin-64 and MinGW it produces: /bin/sh: -c: line 0: syntax error near unexpected token `(' /bin/sh: -c: line 0: `echo 2.0.4(0.287/5/3) | egrep -i -c "fc22.i686"' Th

Use echo command with $ in shell script

Ashu Recently, I prefixed the $ with the echo command. To my surprise, it resulted in an error. My order is like this. # !/bin/bash $(echo 'a') The error is.. ./test1.sh: line 3: a: command not found Can anyone explain what's going on here. Thanks in advance

Use echo command with $ in shell script

Ashu Recently, I prefixed the $ with the echo command. To my surprise, it resulted in an error. My order is like this. # !/bin/bash $(echo 'a') The error is.. ./test1.sh: line 3: a: command not found Can anyone explain what's going on here. Thanks in advance

How to use shell or bash to echo #! /

field I'm trying to print #!/via Bash , but instead of printing, it prints the following. parth@parth-ubuntu64:$ echo "#!\/" bash: !\/: event not found Edit: Allow me to make one more update. How do you make the following work? I think I should just use pytho

How to use shell or bash to echo #! /

field I'm trying to print #!/via Bash , but instead of printing, it prints the following. parth@parth-ubuntu64:$ echo "#!\/" bash: !\/: event not found Edit: Allow me to make one more update. How do you make the following work? I think I should just use pytho

How to use shell or bash to echo #! /

field I'm trying to print #!/via Bash , but instead of printing, it prints the following. parth@parth-ubuntu64:$ echo "#!\/" bash: !\/: event not found Edit: Allow me to make one more update. How do you make the following work? I think I should just use pytho

How to use shell builtins in Makefile?

fear I just stumbled upon this question. I am trying to write a very basic Makefiletarget: core: myprogram ulimit -c 10000 ./myprogram ulimit -c 0 The idea is to set the core size limit to an appropriate value, crash the program, then

How to use shell builtins in Makefile?

fear I just stumbled upon this question. I am trying to write a very basic Makefiletarget: core: myprogram ulimit -c 10000 ./myprogram ulimit -c 0 The idea is to set the core size limit to an appropriate value, crash the program, then

How to compare two shell command outputs in Makefile?

Kenorb Mine Makefileare: .PHONY: check check: ifneq $(shell echo 123), $(shell echo 123) $(error Not equal) endif When I run, I get the error: $ make Makefile:3: *** Not equal. Stop. However, this should only happen if they a

How to get variables in $(shell) command in Makefile?

red 888 ❯ make --version GNU Make 3.81 ❯ bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) How can I pass a variable to $(shell) from inside a for loop? I can access the var outside of $(shell), but I don't know how to pass it to A_L

How to compare two shell command outputs in Makefile?

Kenorb Mine Makefileare: .PHONY: check check: ifneq $(shell echo 123), $(shell echo 123) $(error Not equal) endif When I run, I get the error: $ make Makefile:3: *** Not equal. Stop. However, this should only happen if they a

How to compare two shell command outputs in Makefile?

Kenorb Mine Makefileare: .PHONY: check check: ifneq $(shell echo 123), $(shell echo 123) $(error Not equal) endif When I run, I get the error: $ make Makefile:3: *** Not equal. Stop. However, this should only happen if they a

How to change PATH for Makefile $(shell...) command?

user 541686 when i run export PATH := mypath $(error $(shell echo "$${PATH}")) Nothing seems to PATHchange for my call shell. Why is this happening and how do I actually change the PATHfor shellcall? Florian Weimer Is this GNU make? There's a long-standing GN

How to get variables in $(shell) command in Makefile?

red 888 ❯ make --version GNU Make 3.81 ❯ bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) How can I pass a variable to $(shell) from inside a for loop? I can access the var outside of $(shell), but I don't know how to pass it to A_L

How to pass target stemming to shell command in Makefile

dkn37 I'm writing a static pattern rule to generate a list of dependencies for targets matching the pattern. Dependencies are generated via shell commands (file contents provide information about dependencies). Here is an example of an explicit rule: f1.o: $(s

How to pass target stemming to shell command in Makefile

dkn37 I'm writing a static pattern rule to generate a list of dependencies for targets matching the pattern. Dependencies are generated via shell commands (file contents provide information about dependencies). Here is an example of an explicit rule: f1.o: $(s

How to get variables in $(shell) command in Makefile?

red 888 ❯ make --version GNU Make 3.81 ❯ bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) How can I pass a variable to $(shell) from inside a for loop? I can access the var outside of $(shell), but I don't know how to pass it to A_L

How to get variables in $(shell) command in Makefile?

red 888 ❯ make --version GNU Make 3.81 ❯ bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) How can I pass a variable to $(shell) from inside a for loop? I can access the var outside of $(shell), but I don't know how to pass it to A_L

How to get variables in $(shell) command in Makefile?

red 888 ❯ make --version GNU Make 3.81 ❯ bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) How can I pass a variable to $(shell) from inside a for loop? I can access the var outside of $(shell), but I don't know how to pass it to A_L

How to compare two shell command outputs in Makefile?

Kenorb Mine Makefileare: .PHONY: check check: ifneq $(shell echo 123), $(shell echo 123) $(error Not equal) endif When I run, I get the error: $ make Makefile:3: *** Not equal. Stop. However, this should only happen if they a

How to compare two shell command outputs in Makefile?

Kenorb Mine Makefileare: .PHONY: check check: ifneq $(shell echo 123), $(shell echo 123) $(error Not equal) endif When I run, I get the error: $ make Makefile:3: *** Not equal. Stop. However, this should only happen if they a

How to compare two shell command outputs in Makefile?

Kenorb Mine Makefileare: .PHONY: check check: ifneq $(shell echo 123), $(shell echo 123) $(error Not equal) endif When I run, I get the error: $ make Makefile:3: *** Not equal. Stop. However, this should only happen if they a

How to compare two shell command outputs in Makefile?

Kenorb Mine Makefileare: .PHONY: check check: ifneq $(shell echo 123), $(shell echo 123) $(error Not equal) endif When I run, I get the error: $ make Makefile:3: *** Not equal. Stop. However, this should only happen if they a

How to change PATH for Makefile $(shell...) command?

user 541686 when i run export PATH := mypath $(error $(shell echo "$${PATH}")) Nothing seems to PATHchange for my call shell. Why is this happening and how do I actually change the PATHfor shellcall? Florian Weimer Is this GNU make? There's a long-standing GN

How to get variables in $(shell) command in Makefile?

red 888 ❯ make --version GNU Make 3.81 ❯ bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) How can I pass a variable to $(shell) from inside a for loop? I can access the var outside of $(shell), but I don't know how to pass it to A_L

How to get variables in $(shell) command in Makefile?

red 888 ❯ make --version GNU Make 3.81 ❯ bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) How can I pass a variable to $(shell) from inside a for loop? I can access the var outside of $(shell), but I don't know how to pass it to A_L

How to pass target stemming to shell command in Makefile

dkn37 I'm writing a static pattern rule to generate a list of dependencies for targets matching the pattern. Dependencies are generated via shell commands (file contents provide information about dependencies). Here is an example of an explicit rule: f1.o: $(s