Makefile and subdirectories
Hi there,
I would like to write down a simple Makefile at the root of my source directory in order to go in each directory to do a make all there. I'm developping some javacode and a my own library called py. In py, I've got different subfoler in order to keep my source more or less organised: ./py/util (general purpose class, like extra math functions) ./py/images (class which open images, process them) ./py/gui (class of the gui to my program) ./py/io etc... In each folder, I've got some .java files and a Makefile. Usually, I go in each directory and perform a make all there and it works. Now, I would like to be smart. I stay in ./ and I type make all. I would like it goes in each subdirectory and perform a make all. I tried so far and unsuccessfully: ------------------------------------------------- SHELL = /bin/sh CC = javac SUBDIRS = images gui io util #--------------------------------------------------------------------- # Rules #--------------------------------------------------------------------- all: for dir in ${SUBDIRS} ; do ( cd py/$dir ; ${MAKE} all ) ; done ------------------------------------------------------- It says everything is up to date :( How can I do? Thanks for your help, PY |
Try this in your Makefile:
Code:
DIRS = src doc man etc |
Great! It works very well !
The only point is to give the rule to follow otherwise it takes the first by default ! Code:
all: |
It tells it not to exit if the result code is non-zero. This means in practice that it will continue trying to make all the subdirectories even if it encounters errors doing so.
So if you've got Code:
SUBDIRS = images gui io util |
don't forget to read this:
http://www.canb.auug.org.au/~millerp...cons-harm.html recursive make considered harmful ;) |
All times are GMT -5. The time now is 10:19 PM. |