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 are different, but it doesn't. Why?

Mike Freisinger

ifneqCannot be indented. The way you've written it, it's run via a shell command, which means it's $(error)first evaluated by the make command.

I'm guessing you want to actually run the two commands make checkonly when make checkcalled , and compare their output. you can do:

.PHONY: check
check:
    if [ "`echo 123`" != "`echo 123`" ]; then \
        echo "Not equal"; \
        exit 1; \
    fi

Related


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 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 values in shell?

rr currentDNS=$(networksetup -getdnsservers Wi-Fi) GOOGLE="8.8.8.8 8.8.4.4" echo '+'$currentDNS'+' echo '+'$GOOGLE'+' It appears that GOOGLE == currentDNS. if [ "$currentDNS" = "$GOOGLE" ];then echo OKK fi but it returns false Gilles Quenot Try this with

How to compare two values in shell?

rr currentDNS=$(networksetup -getdnsservers Wi-Fi) GOOGLE="8.8.8.8 8.8.4.4" echo '+'$currentDNS'+' echo '+'$GOOGLE'+' It appears that GOOGLE == currentDNS. if [ "$currentDNS" = "$GOOGLE" ];then echo OKK fi but it returns false Gilles Quenot Try this with

How to compare two string variables in Makefile

Cpp learner I have the following code: LOCAL_VERSION := $(shell some_binary -v | head -n 1) REMOTE_VERSION := $(shell curl -s https://example.com/key) all: ifeq($(REMOTE_VERSION), $(LOCAL_VERSION)) @echo yes endfi But I get this: user:tmp use

How to compare two string variables in Makefile

Cpp learner I have the following code: LOCAL_VERSION := $(shell some_binary -v | head -n 1) REMOTE_VERSION := $(shell curl -s https://example.com/key) all: ifeq($(REMOTE_VERSION), $(LOCAL_VERSION)) @echo yes endfi But I get this: user:tmp use

Use Makefile to create two outputs

Phoenix I want to create a makefile that runs a program in C++ once, with "CXXFLAGS=-std=c++11 -g -O3 -DTEST -fopenmp", and once with: "CXXFLAGS=-std=c++11 -g - O3 -fopenmp" finally outputs two different files like P1-Test and P1. How can I edit this file? CXX

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 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 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

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 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

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

How to compare command output to string in shell script

Deroca I've been struggling to figure out how to compare the output of a command stored in a variable with the contents of another variable (also a string) in Shell Script. I know this looks like a basic RTFM case, but I've done it, but I really can't figure i

How to compare strings of two files in shell script?

Henrik Bree The first field is the username, the second field is the password, and the last field indicates the action (login/register) File 1: User Input hello,world,register File 2: Plain Text Database admin,123 user,321 foo,bar How to compare user input w