Benutzer-Werkzeuge

Webseiten-Werkzeuge


becki:linux:gnu_make

Dies ist eine alte Version des Dokuments!


GNU Make

Anatomy of a Make Rule

target: prerequisite prerequisite prerequisite ...
    recipe

Source

Misc

  • A line beginning with # is a comment
  • '@' at the beginning of a command runs the command but does not copy the line to stdout
  • '-' at the beginning of a command runs the command but does not abort make if command fails
  • make -n or make --dry-run - Don't actually run any commands; just print them.
  • If a target begins with %, the whole rule is a definition of an implicit rule, called pattern rule

Automatic variables

  • $@ or $(@) contains the name of the target. It does oviously not work in prerequsites, only in recipie!
  • $< The name of the first prerequisite. Useful in the recipe
  • $* is useful for constructing names of related files. FIXME

See Automatic-Variables

Rules for overwriting variables

  1. Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value.
  2. An explicit assignment in the makefile overrides the environment
  3. An assignment in the makefile can be overridden by the command line argument, eg make CFLAGS='-g -O' [target]

Sources: 1 2

Variable assignment

a = Peter
c =  $(a)
d := $(a)
a = Franz
 
test:
        @echo c expands to $(c) # Franz
        @echo d expands to $(d) # Peter

CFLAGS usage

Implicit rules

Example: file.o is made automatically from file.c with a command of the form `$(CC) -c $(CPPFLAGS) $(CFLAGS)'

Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website. Weitere Information
becki/linux/gnu_make.1522304798.txt.gz · Zuletzt geändert: 2018-03-29 06:26 von becki

Impressum - Datenschutzerklärung