(no title)
gyepi | 12 years ago
CXX=g++
hello: main.o factorial.o hello.o
clean:
rm -rf *o hello
2. Shameless plug: he didn't mention redo [1], which is simpler than make and more reliable.
The comparable redo scripts to the Makefile would be: cat <<EOF > @all.do
redo hello
EOF
cat <<EOF > hello.do
o='main.o factorial.o hello.o'
redo-ifchange $o
g++ $o -o $3
EOF
cat <<EOF > default.o.do
redo-ifchange $2.cpp
g++ -c $1 -o $3
EOF
cat <<EOF > @clean.do
rm -rf *o hello
EOF
[Edit: Note that these are heredoc examples showing how to create the do scripts.]These are just shell scripts and can be extended as much as necesary. For instance, one can create a dependency on the compiler flags with these changes:
cat <<EOF | install -m 0755 /dev/stdin cc
#!/bin/sh
g++ -c "\$@"
EOF
# sed -i 's/^\(redo-ifchange.\+\)/\1 cc/' *.do
# sed -i 's}g++ -c}./cc}' *.do
sed calls could be combined; separated here for readablility.
JoshTriplett|12 years ago
And compared to that Makefile, the redo scripts you list don't seem simpler at all. I've seen reasonably compelling arguments for redo, but that wasn't one.
gyepi|12 years ago
You're right, of course.
> Also, I think you wanted .o, not o.
I would, yes, but I copied the Makefile ;)
Should have been clearer; I meant that redo is simpler (and more reliable) than make.
For simple projects, redo scripts are a bit longer. However, as the projects grow, the redo scripts reach an asymptote whereas Makefiles don't. The only way to reduce the growth in make is to add functions and implicit rules which get ugly real fast.
gcv|12 years ago
In general, I found CMake quite useable for my needs, and quite clean. It also required less build system code than redo. CMake fits quite nicely into a (C or C++) project which consists of many binaries and libraries which can depend on each other.
pekk|12 years ago
gyepi|12 years ago
Not quite sure what you mean here. The scripts don't do anything complicated and redo catches errors that could occur.
As for readability, etc, I suppose it's relative. Simple makefiles do read very nicely. Unfortunately, they aren't always simple and hairy makefiles are just horrible to write, read and maintain. I've had no such problems with do scripts.
malkia|12 years ago
With make it was easier for me to grasp the idea (or maybe I was simply 20 years younger then).
GrinningFool|12 years ago