1

I have a script that calls to a linter and I want to implement it into my makefile and call to it with the command make lint. A simple call to the script (linter) either with it's path or without does not work, eg:

.PHONY: lint 

lint:
         ./$(ROOT)/tools/Manage/linter

Even though that command works fine in the terminal. However I did get this command to work:

.PHONY: lint

lint:
        cd /$(ROOT)/tools/Manage/ ; ./linter

However I've been informed that cd'ing to run script is improper makefile practice. Any help on cleaning this up would be greatly appreciated.

miken32
  • 42,008
  • 16
  • 111
  • 154
Dev_Seb
  • 11
  • 2
  • 3
    `$(ROOT)` and `./$(ROOT)` are not the same. – Beta Jun 14 '22 at 17:21
  • 1
    "cd'int to run a script" is a perfectly reasonable practice, where it's needed. There's no particular reason it should be needed here though. As @Beta says, look very carefully at your paths and compare the one that works (on the command line) with the one that doesn't. I'm sure you'll find they're different. – MadScientist Jun 14 '22 at 18:31
  • My answer to [Difference between `./` and `~/`](https://stackoverflow.com/questions/31435921/difference-between-and/55342466) also contains a brief discussion about the differences between `/path` and `./path`. [What exactly is current working directory?](https://stackoverflow.com/questions/45591428/what-exactly-is-current-working-directory) has some notes on why you might or might not avoid `cd` – tripleee Jun 15 '22 at 05:29

0 Answers0