I have a directory structure as follows:
.
├── one
│ ├── one_one
│ │ └── one_one_one
│ │ ├── Makefile
│ │ └── one_one_oneTest.cpp
│ └── one_two
│ ├── Makefile
│ └── one_twoTest.cpp
├── three
│ ├── Makefile
│ └── threeTest.cpp
└── two
└── two_one
├── Makefile
└── two_oneTest.cpp
I want to run the make command where ever I find the Makefile. So, I have written a shell script as follows.
#!/bin/bash
find . -type f -name Makefile -exec make \;
But it gives error saying make: *** No targets specified and no makefile found. Stop.
If I just run find . -type f -name Makefile, I get
./two/two_one/Makefile
./three/Makefile
./one/one_two/Makefile
./one/one_one/one_one_one/Makefile
which is the correct output I expected.
If I run the Makefile using make command, it runs properly, so I think the Makefile is correct. What can be wrong with the shell script?
Just for reference, one of my Makefiles is as follows:
all: TestTwoOne
TestTwoOne: two_oneTest.cpp
g++ two_oneTest.cpp -o TestTwoOne