What does the following makefile command do? /no-symbols-control-file

242 views Asked by At

I cam across the following command in a makefile:

%-nosyms.$(TARGET).elf: %.co $(PROJECT_OBJECTFILES) $(INTERRUPT_OBJECTFILES) contiki-$(TARGET).a
$(CC) $(CFLAGS) -o $@ $(filter-out %.a,$^) $(filter %.a,$^) $(filter %.a,$^) $(LDFLAGS)

Source: Contiki/cpu/arm/stm32f103/Makefile.stm32f103 .

Does this command generate no-symbols-control-file? What is the use of a no symbol image file?

1

There are 1 answers

12
Eugeniu Rosca On BEST ANSWER

Piece by piece analysis:

The Makefile's target is:

%-nosyms.$(TARGET).elf

The list of prerequisites is:

%.co $(PROJECT_OBJECTFILES) $(INTERRUPT_OBJECTFILES) contiki-$(TARGET).a

The target recipe is:

$(CC) $(CFLAGS) -o $@ $(filter-out %.a,$^) $(filter %.a,$^) $(filter %.a,$^) $(LDFLAGS)

Makefile's logic is:

  1. If *-nosyms.$(TARGET).elf file exists, compare the file's timestamp to that of all its pre-requisites. Rebuild this file (i.e., run the given recipe) if any of the pre-requisites is newer. If the target is marked as .PHONY) (seems not to be the case), rebuild without checking the timestamp.

  2. Else, go to each prerequisite recipe and execute one by one (or in parallel if -j option provided to make):

    • %.co
    • $(PROJECT_OBJECTFILES)
    • $(INTERRUPT_OBJECTFILES)
    • contiki-$(TARGET).a
  3. Then, handle the recipe for the current target, by calling:

$(CC) $(CFLAGS) -o $@ $(filter-out %.a,$^) $(filter %.a,$^) $(filter %.a,$^) $(LDFLAGS)

Where:

  • $@: the name of the current target (i.e. *-nosyms.$(TARGET).elf)
  • $^: The list of prerequisites (i.e. %.co $(PROJECT_OBJECTFILES) $(INTERRUPT_OBJECTFILES) contiki-$(TARGET).a)
  • $(filter-out %.a,$^): the non-*.a files from the prerequisite list.
  • $(filter %.a,$^): the *.a files from the prerequisite list.