0

I'm working on a large firmware and I've to add GNU gprof to only some modules(file directories) of it. The makefiles have inherited structure. So I do it this way:

ft/*.o : ft/*.c
       CFLAGS += -pg
ft/*.o : ft/*.c
       LDFLAGS += -pg

But this gives me a warning that it will overwrite the CFLAGS and then it adds the gprof to all the modules. My guess is that CFLAG is somewhere common. How can I make sure that CFLAG only works on the part of module(directory) I want on?

too honest for this site
  • 12,050
  • 4
  • 30
  • 52

1 Answers1

2

You can do it using target-specific variables.

The correct syntax is:

ft/*.o : CFLAGS += -pg
ft/*.o : LDFLAGS += -pg

These are the lines you need to add.

Alternatively, you can add these flags to executables, shared and static libraries. Target specific variables propagate to its prerequisites, i.e. the .o files comprising your binaries.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271