Roland Ver. 4.5 Informações Técnicas Página 33

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 212
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 32
Chapter 4: Writing Rules 23
$(OBJS): | $(OBJDIR)
$(OBJDIR):
mkdir $(OBJDIR)
Now the rule to create the objdir directory will be run, if needed, before any .o is
built, but no .o will be built because the objdir directory timestamp changed.
4.3 Using Wildcard Characters in File Names
A single file name can specify many files using wildcard characters. The wildcard characters
in make are *’, ? and [...]’, the same as in the Bourne shell. For example, *.c specifies
a list of all the files (in the working directory) whose names end in .c’.
The character ~ at the beginning of a file name also has special significance. If alone,
or followed by a slash, it represents your home directory. For example ~/bin expands to
/home/you/bin. If the ~ is followed by a word, the string represents the home directory
of the user named by that word. For example ~john/bin expands to /home/john/bin. On
systems which don’t have a home directory for each user (such as MS-DOS or MS-Windows),
this functionality can be simulated by setting the environment variable HOME.
Wildcard expansion is performed by make automatically in targets and in prerequisites.
In recipes, the shell is responsible for wildcard expansion. In other contexts, wildcard
expansion happens only if you request it explicitly with the wildcard function.
The special significance of a wildcard character can be turned off by preceding it with
a backslash. Thus, foo\*bar would refer to a specific file whose name consists of foo’, an
asterisk, and bar’.
4.3.1 Wildcard Examples
Wildcards can be used in the recipe of a rule, where they are expanded by the shell. For
example, here is a rule to delete all the object files:
clean:
rm -f *.o
Wildcards are also useful in the prerequisites of a rule. With the following rule in the
makefile, make print will print all the .c files that have changed since the last time you
printed them:
print: *.c
lpr -p $?
touch print
This rule uses print as an empty target file; see Section 4.7 [Empty Target Files to Record
Events], page 31. (The automatic variable $? is used to print only those files that have
changed; see Section 10.5.3 [Automatic Variables], page 120.)
Wildcard expansion does not happen when you define a variable. Thus, if you write this:
objects = *.o
then the value of the variable objects is the actual string *.o’. However, if you use the
value of objects in a target or prerequisite, wildcard expansion will take place there. If
Vista de página 32
1 2 ... 28 29 30 31 32 33 34 35 36 37 38 ... 211 212

Comentários a estes Manuais

Sem comentários