Wednesday, 24 August 2016

shell scripting


Special Macros


Before issuing any command in a target rule set there are certain special macros predefined.

  • $@ is the name of the file to be made.
  • $? is the names of the changed dependents
    $< the name of the related file that caused the action.
  • $* the prefix shared by target and dependent files.

for example, we could use a rule


hello: main.cpp hello.cpp factorial.cpp
        $(CC) $(CFLAGS) $? $(LDFLAGS) -o $@

alternatively:

hello: main.cpp hello.cpp factorial.cpp
        $(CC) $(CFLAGS) $@.cpp $(LDFLAGS) -o $@

In this example $@ represents hello and $? or $@.cpp will pickup all the changed source files.

No comments:

Post a Comment