Roland Ver. 4.5 Technical Information Seite 139

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 212
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 138
Chapter 11: Using make to Update Archive Files 129
11 Using make to Update Archive Files
Archive files are files containing named sub-files called members; they are maintained with
the program ar and their main use is as subroutine libraries for linking.
11.1 Archive Members as Targets
An individual member of an archive file can be used as a target or prerequisite in make.
You specify the member named member in archive file archive as follows:
archive(member)
This construct is available only in targets and prerequisites, not in recipes! Most programs
that you might use in recipes do not support this syntax and cannot act directly on archive
members. Only ar and other programs specifically designed to operate on archives can do
so. Therefore, valid recipes to update an archive member target probably must use ar. For
example, this rule says to create a member hack.o in archive foolib by copying the file
hack.o:
foolib(hack.o) : hack.o
ar cr foolib hack.o
In fact, nearly all archive member targets are updated in just this way and there is an
implicit rule to do it for you. Please note: The c flag to ar is required if the archive file
does not already exist.
To specify several members in the same archive, you can write all the member names
together between the parentheses. For example:
foolib(hack.o kludge.o)
is equivalent to:
foolib(hack.o) foolib(kludge.o)
You can also use shell-style wildcards in an archive member reference. See Section 4.3
[Using Wildcard Characters in File Names], page 23. For example, foolib(*.o) ex-
pands to all existing members of the foolib archive whose names end in .o’; perhaps
foolib(hack.o) foolib(kludge.o)’.
11.2 Implicit Rule for Archive Member Targets
Recall that a target that looks like a(m) stands for the member named m in the archive file
a.
When make looks for an implicit rule for such a target, as a special feature it considers
implicit rules that match (m), as well as those that match the actual target a(m).
This causes one special rule whose target is (%) to match. This rule updates the target
a(m) by copying the file m into the archive. For example, it will update the archive member
target foo.a(bar.o) by copying the file bar.o into the archive foo.a as a member named
bar.o.
When this rule is chained with others, the result is very powerful. Thus, make
"foo.a(bar.o)" (the quotes are needed to protect the ( and ) from being interpreted
specially by the shell) in the presence of a file bar.c is enough to cause the following
recipe to be run, even without a makefile:
Seitenansicht 138
1 2 ... 134 135 136 137 138 139 140 141 142 143 144 ... 211 212

Kommentare zu diesen Handbüchern

Keine Kommentare