how to change directories from makefile and execute subdirectories make file? -
suppose has 2 sub directories b , c each subdirectories has own make file.the parent has own make file.to call child directories have use below command in parent makefile :
subb: cd b && make subc: cd c && make
is there generalized way of calling child directories makefile single statement.beacause in future more 50 60 folders may added.what generalized way of writing it
i use combination of make -c
, find
.
make -c <directory>
runs make usual, except temporarily changes <directory>
before running command.
find
command traverses directory tree. default prints paths of files, directories, symlinks, etc. contained within current working directory. can tell find
run particular command on each of paths instead of printing them, using -exec
option. in command passed -exec
, {}
stands path of current file/directory, , ;
necessary mark end of command (these special characters in shell syntax need quote them).
if wanted, example, run makefile in of directories in current working directory, this:
sub: find -maxdepth 1 -type d -exec make -c '{}' ';'
-type d
tells find
run on directories. -maxdepth 1
means directories directly beneath current directory checked; sub-directories within them not.
Comments
Post a Comment