0

I would like to check if Linux system is ubuntu inside Makefile. What I do is:

copy_files:
    if [ "$(head -n 1 /etc/lsb-release | cut -d '=' -f2)" = "Ubuntu" ]; then \
        echo "ubuntu"; \
    else \
        echo "not ubuntu"; \
    fi

But the above condition fails always, i.e. it always prints "not ubuntu" on an ubuntu machine. So What am I doing wrong?

6
  • 1
    Please edit your question and explain what "does not work" mean. Is there an error message? Does the test run but return the wrong value? Does it not run? Does it crash the build process?
    – terdon
    Commented Jul 3 at 11:10
  • Thanks. I just did so.
    – ellat
    Commented Jul 3 at 11:36
  • 1
    Related: Makefile command substitution Commented Jul 3 at 11:47
  • 1
    Related or a bona fide dupe, @steeldriver? Looks like the OP just needs to use $$(head -n 1 ...) for the reasons explained in that answer, right?
    – terdon
    Commented Jul 3 at 11:54
  • 1
    @terdon yes I think that's it - but there may be something I'm missing Commented Jul 3 at 12:06

0

Browse other questions tagged .