09.06.2013 Views

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

make: Program Maintainer <strong>XENIX</strong> Programming<br />

The most com mon use of the library naming convention is to create a makefile that<br />

automatically maintains an archive library. For example, the following dependency<br />

lines define the commands required to create a library, named lib, containing up · to date<br />

versions of the files filel.o, file2.o, and file3.o.<br />

lib:<br />

.c. a:<br />

lib(file1.o) lib(fi le2.o) lib(file3.o)<br />

@echo lib is now up to date<br />

$(CC) -c $(CFLAGS) $<<br />

ar rv $@ $*.o<br />

rm -f $*.o<br />

The .c.a rule shows how to redefine a built-in rule for a library. In the following<br />

example, the built-in rule is disabled, allowing the first dependency to create the<br />

library.<br />

lib:<br />

.c.a:;<br />

lib(file1.o) lib(file2.o) lib(fi le3.o)<br />

$(CC) -c $(CFLAGS) $(?: .o = .c)<br />

ar rv lib $?<br />

rm $?<br />

@echo lib is now up to date<br />

In this example, a substitution sequence is used to change the value of the $? macro<br />

from the names of the object files "filel.o", "file2.o", and "file3.o" to "filel.c", "file2.c",<br />

and "file3.c".<br />

Troubleshooting<br />

Most difficulties in using make arise from make's specific meaning of dependency. If<br />

the file x.c has the line<br />

#include "defs"<br />

then the object file x.o depends on defs; the source file x.c does not. (If defs is changed,<br />

it is not necessary to do anything to the file x.c, while it is necessary to recreate x.o.)<br />

To determine which commands make will execute, without actually executing them, use<br />

the -n option. For example, the command<br />

make -n<br />

prints out the commands make would normally execute without actually executing them.<br />

4-12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!