Roland Ver. 4.5 Technical Information Seite 78

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 212
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 77
68 GNU make
The first line defines the CFLAGS variable with a reference to another variable, includes.
(CFLAGS is used by the rules for C compilation; see Section 10.2 [Catalogue of Built-In
Rules], page 112.) Using = for the definition makes CFLAGS a recursively-expanded variable,
meaning $(includes) -O is not expanded when make processes the definition of CFLAGS.
Thus, includes need not be defined yet for its value to take effect. It only has to be defined
before any reference to CFLAGS. If we tried to append to the value of CFLAGS without using
+=’, we might do it like this:
CFLAGS := $(CFLAGS) -pg # enable profiling
This is pretty close, but not quite what we want. Using := redefines CFLAGS as a simply-
expanded variable; this means make expands the text $(CFLAGS) -pg before setting the
variable. If includes is not yet defined, we get ‘ -O -pg’, and a later definition of includes
will have no effect. Conversely, by using += we set CFLAGS to the unexpanded value
$(includes) -O -pg’. Thus we preserve the reference to includes, so if that variable gets
defined at any later point, a reference like $(CFLAGS) still uses its value.
6.7 The override Directive
If a variable has been set with a command argument (see Section 9.5 [Overriding Variables],
page 103), then ordinary assignments in the makefile are ignored. If you want to set the
variable in the makefile even though it was set with a command argument, you can use an
override directive, which is a line that looks like this:
override variable = value
or
override variable := value
To append more text to a variable defined on the command line, use:
override variable += more text
See Section 6.6 [Appending More Text to Variables], page 66.
Variable assignments marked with the override flag have a higher priority than all other
assignments, except another override. Subsequent assignments or appends to this variable
which are not marked override will be ignored.
The override directive was not invented for escalation in the war between makefiles
and command arguments. It was invented so you can alter and add to values that the user
specifies with command arguments.
For example, suppose you always want the ‘-g’ switch when you run the C compiler, but
you would like to allow the user to specify the other switches with a command argument
just as usual. You could use this override directive:
override CFLAGS += -g
You can also use override directives with define directives. This is done as you might
expect:
override define foo =
bar
endef
See the next section for information about define.
Seitenansicht 77
1 2 ... 73 74 75 76 77 78 79 80 81 82 83 ... 211 212

Kommentare zu diesen Handbüchern

Keine Kommentare