Simon Kitching wrote:
On 08/31/2015 07:37 PM, Bruce Dubbs wrote:
> I have split the examples into shorter lines as you suggested.
Much better.
The section on make could use an example.
Not sure what you meant here. There is an example showing
untar/configure/make/install. Can you suggest what would be useful here?
For example, to build a program that depends on source the Makefile has:
prog: prog.c prog.h libmylib.a
gcc -o prog prog.c -L. -lmylib
libmylib.a: libmylib.o
ar -rcs libmylib.a libmylib.o
libmylib.o: libmylib.c libmylib.h
gcc -c -o libmylib.o libmylib.c
The form of the entries (rules) are:
target: dependency1 [dependency-n ...]
<tab> command
...
If the target is older than any of the dependencies, then the command(s)
are run to create the target, but first each dependency is tested to see
if there is a rule that has it as a target. If so, that target is
tested first and (re-)built if the dependencies' time stamps indicate
that is needed.
Thus in the above set of rules, a change in libmylib.c will cause
libmylib.o to be rebuilt. Then libmylib.a is regenerated and finally
prog is rebuilt.
Makefiles can get very complicated and many are automatically generated,
but the above principles always apply.
-- Bruce
--
http://lists.linuxfromscratch.org/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page