ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm looking for a Makefile to compile a tree of source files to a destination tree. I'm only familiar with the basics of make, and a few auto-magic targets, but that's now enough to compile a folder resursively. How can I do that?
(I don't intent to use automake for this project, it concerns my website. it's written in xml, and converted to html with an xslt sheet using sablotron)
do:
for i in `find . -type d`; do make e "D=$$i"; done
e:
cd "$(D)"; echo "making: $(D)##"
...replace the "making:" part with whatever you want to do in those directorys.
But if you want actual dependancies checking in all those directories you'll have to put a Makefile inside each directory.
maybe use "include ../Makefile" so you don't have to rewrite stuff.
niknah,
Thanks for your Makefile help. The 'find' trick was definitely a nice pointer.
I did came up with something completely different in my next version, having read some more online Make books/tutorials.
Code:
# Build list of files
DIRS = $(shell find . -type d)
FILES = $(subst .xml,.html,$(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.xml)))
# default target, build all dependencies
all: $(FILES)
# other target, remove all files
clean:
rm -f $(FILES)
# automatic target using pattern matching
%.html: %.xml
@#echo "Compile $< to $@"
sabcmd "resources/xslt/codingdomain.xsl" $< $@
# explicitly declare a target phony,
# so it still works if a file called "all" is created
.PHONY: all clean
There is one thing I'm wondering about.. is it possible to support a different "build" directory? (or know what the "source" and "destination" folders are?)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.