-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
R.Wieser wrote:
> Dan,
>
>> Short version, when using `find', you have to have some idea of
>> where to look
>
>:-) not really a good argument I'm afraid.
>
> In the above case nothing stops anyone from starting the search at / --
> which is the equivalent of the "I have *no* idea where it is, just search
> *everywhere*".
Indeed, nothing stops you from using `find / [...]' However, that can
take quite a bit longer, not to mention having to also filter out all the
"Permission Denied" errors that you'll be getting.
time (find / -type f -name "*stdio*")
real 0m18.713s
user 0m0.684s
sys 0m1.316s
time (locate "*stdio*")
real 0m0.148s
user 0m0.148s
sys 0m0.000s
>
> In the case of that locate command (with its database), if you cannot
> indicate where to start looking (one way or the other) you can easily be
> innundated with lots of irrelevant results. Because the results are
> not in a specific subtree.
The whole point of 'locate' is "I have no idea where to look, or whether
the one I know about in /some/path is the correct (or only) file.
>
> In other words, being able to specify where to start looking is, in my
> book, a *good* thing.
Which is why we also have find. While they overlap in their
functionality to some degree, they each also have some features that
make them a better choice depending on the situation.
>
>> A makefile is precisely a config file for `make'.
>
> I know. As I've mentioned it, I've tried to use it years ago, on Windows.
Yes, and "on windows" is a poor choice of comparison to "on linux".
You're effectively comparing apples to the sun.
>
>> Come to think of it, a lot of larger projects (say gcc, for example)
>> also come with a "configure" script. I bet looking at one of those
>> would also help...
>
> I don't think so, as those are written to encompass pretty much *every*
> eventuality you could think of on a lot of different versions of Linux.
> The sheer ammount of of irrelevant cases (to my current environment)
> would probably just block me from being able to see what actually *is*
> important (I think I've seen a few).
>
> But pray tell, what is it actually ment for ? I do not assume that it
> will just generate makefiles outof thin air ...
What is what meant for? 'make' is a program that reads the makefile,
and in turn has a recipe for doing things, which it then executes.
Grabbing a short example from the gnu make manual
foo.o : foo.c defs.h
[tab]cc -c -g foo.c
[NOTE, the first line of a recipe MUST start with a tab(or whatever is
defined in .RECIPEPREFIX), I'm explicitly writing it as [tab] so it is
not simply whitespace]
We have the target 'foo.o', which in turn has prerequisites 'foo.c' and
'defs.h'. Assuming that's all good, we finally run the recipe 'cc -c -g
foo.c'.
Yes - you can do all this on the commandline, why should you go through
the "trouble" to create makefiles? Well, let's say you've got a larger
project, with one of the final recipes being this:
objects := $(patsubst %.c,%.o,$(wildcard *.c))
foo: $(objects)
[tab]cc -o foo $(objects)
There's a couple of things going on here
objects := [...] <-- set the variable "objects" to the value [...]
$(patsubst %.c,%.o,$(wildcard *.c)) <-- look up every file that matches
the wildcard "*.c", and do pattern substitution to replace ".c" with
".o"
foo : $(objects) <-- the target "foo" has the prereq of whatever is
contained in the variable "$(objects)".
cc -o foo $(objects) <-- compile foo
If you only ever compile 'foo' once, you don't gain much. BUT, let's
say you have a problem in bar.o. When you fix it (or well, bar.c), you
would have to manually recompile bar.c AND also recompile the final
program 'foo'. Not too hard, but a step you have to remember
nonetheless; and a step that can be forgotten during rounds of
debugging.
With the makefile, you fix bar.c and re-run make. make recompiles bar.c
into bar.o, and then when it checks the recipe for foo, sees that one of
its components is now newer than the program, so automatically
re-compiles foo for you.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQEcBAEBAgAGBQJaNEH6AAoJEI4R3fMSeaKBlLQIAJl+Cg3tGJpH3ZvIB8HIBe1t
OMEagVO8X/2Ujj62+6eVGmxDweBqL9Mv3itaGcwAfcvsOF2xdPAlLNpgQBLOnvoa
IngVZlr3UDjc4revrFSY/ZERZ1mHOOLAcJPgE5yH/dZFv+21L5qZgoTW9ZsTooTT
tbkr6iFkqQ3u3ICLYvwTo0clzGpTRX87T6hwx0WHMOndrr6WyIUUOeG51Xadtl3l
MuhXaqS57EcE+JXcrTxJ+3T47X9RN+br5Zbom5tsFydjfutmFquqRUc4PKsiaTjO
+upZgV6khCux24YxoSWbgEsUyNLgn4cmtr+C36uJHBtQSPHOvtFZTTPc9EC+Ynk=
=nh3W