4

I'm new to Linux, more so for Makefile.

In Linux, is 'make folder/path/clean' same as running 'make clean' command in folder/path/?

(folder/path/ refers to an arbitrary directory.)

Apart from this question, is there a generalization one can make about this syntax (of command and argument) in Linux?

Update based on comments and suggested answers: Thanks, I learned some new things. I also found that Makefile that I am using (openwrt) is different from the normal GNU Makefile in that it has more features.

A summary is that that the two commands in the main question are not the same.

  • 1
    Linux, is the OS kernel found in a number of Operating systems like Debian, Ubuntu, ArchLinux... Is your question about building Linux in those OSes, or about using make when building any particular software in any particular Operating System built around a Linux kernel? – Stéphane Chazelas Aug 26 '13 at 10:15
10

To execute make clean in folder/path, you want

make -C folder/path clean

The -C switch is not POSIX, though (see the comments). It works, at least, for GNU make, which is the make you have if you're running Linux.

| improve this answer | |
5

No it is not. Your syntax would not work unless you have a rule for folder/path/clean in the directory that you execute the make folder/path/clean in.

You can, for example, make a recursive clean rule in your make file to (maybe?) achieve what you want. For example:

recursive-clean:
  (cd folder/path; make clean)
  ...

For each directory that you have or just do a for loop over all the directories etc.

| improve this answer | |
  • I am not sure if this is what you are looking for. If not, let me know and I can update my answer). – mtahmed Aug 26 '13 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.