Roland Ver. 4.5 Technical Information Seite 82

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 212
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 81
72 GNU make
pattern ... : variable-assignment
where pattern is a %-pattern. As with target-specific variable values, multiple pattern
values create a pattern-specific variable value for each pattern individually. The variable-
assignment can be any valid form of assignment. Any command line variable setting will
take precedence, unless override is specified.
For example:
%.o : CFLAGS = -O
will assign CFLAGS the value of -O for all targets matching the pattern %.o.
If a target matches more than one pattern, the matching pattern-specific variables with
longer stems are interpreted first. This results in more specific variables taking precedence
over the more generic ones, for example:
%.o: %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
lib/%.o: CFLAGS := -fPIC -g
%.o: CFLAGS := -g
all: foo.o lib/bar.o
In this example the first definition of the CFLAGS variable will be used to update
lib/bar.o even though the second one also applies to this target. Pattern-specific
variables which result in the same stem length are considered in the order in which they
were defined in the makefile.
Pattern-specific variables are searched after any target-specific variables defined explic-
itly for that target, and before target-specific variables defined for the parent target.
6.13 Suppressing Inheritance
As described in previous sections, make variables are inherited by prerequisites. This capa-
bility allows you to modify the behavior of a prerequisite based on which targets caused it
to be rebuilt. For example, you might set a target-specific variable on a debug target, then
running make debug will cause that variable to be inherited by all prerequisites of debug,
while just running make all (for example) would not have that assignment.
Sometimes, however, you may not want a variable to be inherited. For these situations,
make provides the private modifier. Although this modifier can be used with any variable
assignment, it makes the most sense with target- and pattern-specific variables. Any variable
marked private will be visible to its local target but will not be inherited by prerequisites
of that target. A global variable marked private will be visible in the global scope but will
not be inherited by any target, and hence will not be visible in any recipe.
As an example, consider this makefile:
EXTRA_CFLAGS =
prog: private EXTRA_CFLAGS = -L/usr/local/lib
prog: a.o b.o
Due to the private modifier, a.o and b.o will not inherit the EXTRA_CFLAGS variable
assignment from the prog target.
Seitenansicht 81
1 2 ... 77 78 79 80 81 82 83 84 85 86 87 ... 211 212

Kommentare zu diesen Handbüchern

Keine Kommentare