Please always CC the mailing list. On Mon, 2007-09-10 at 19:13 +0530, Jeenu V wrote: > > Your problem is here: > DIRS = $(shell ls) > > Thanks for this too. Actually I tried to get the list of directories > with this command: > > $(shell for i in $(ls -d */); do echo $i | sed 's#/$$##'; done) > > but was failing and had to resort to what was there in the Makefile. > I could work it around by > > COMMAND := ls -d */ | sed s#/$$# > $(shell $(COMMAND))
All of these are too complicated. All you have to do is something like this: DIRS = $(patsubst %/.,%,$(wildcard */.)) Not only is this significantly simpler BUT it's a LOT more efficient than forking a new shell, plus a bunch of other programs like ls, sed, etc. However, IMO you should not do this. A common thing people want to do when they first start using make is to have it intuit everything about their build environment, by using $(wildcard ...) etc. to have make find all the things it needs to build. In my opinion this is usually a mistake. It's too easy to get something wrong; someone makes a temporary file or directory that you didn't expect and all of a sudden your build is failing, maybe for reasons that aren't immediately obvious. I understand the attraction of not having to change your makefile but (again IMO) it's not worth it. Source files should be explicitly stated in the makefile, and if you create new ones you want to build you should modify the makefile to add them. In this case (subdirectories) it's a bit less clear-cut (I've created build systems where it would automatically try to build in each subdirectory without being explicitly told to do so, and it does work), but still probably a useful rule to follow. > I'm wondering why it executed the commands even with "make -n". As I said, check out the section of the GNU make manual "How Makefiles are Remade" in the chapter "Writing Makefiles". That happens even if you specify -n, because otherwise how can make know if the makefile is correct? If you don't understand it, let us know. -- ------------------------------------------------------------------------------- Paul D. Smith <[EMAIL PROTECTED]> Find some GNU make tips at: http://www.gnu.org http://make.mad-scientist.us "Please remain calm...I may be mad, but I am a professional." --Mad Scientist _______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make