[chbot] Is there a GNU makefile guru out there?

Robin Gilks robin at gilks.org
Mon Aug 3 05:54:17 BST 2020


Greetings all

I've been build several project on what is basically the same hardware so
I have a lot of common files and each project has its own main.c and a
couple of other files that differ.


repo
  |
  +------- common
              |
              +------- src
                        |
                        +  commonA.c
                        +  commonB.c
                        + ....
  +------- projectA
              |
              +------- src
                        |
                        +  fileA.c
                        +  fileB.c
                        +  uniqueC.c
                        + ....
  +------- projectB
              |
              +------- src
                        |
                        +  fileA.c
                        +  fileB.c
                        +  uniqueD.c
                        + ....

I compile project A and all is good. Project B starts to compile fileA.c
and fileB.c from project A which has all the wrong headers (because
although they have the same name for consistency that are different) and
it goes all wrong.

I think the problem is in my vpath declaration in the makefile (they are
basically the same for both projects).
----- snip -----
C_SOURCES = ../common/commonA.c \
../common/commonB.c \
src/fileA.c \
src/fileB.c \
src/uniqueC.c


OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
----- snip -----

I can sort of work around it on some file (I think!!) by defining the



-- 
Robin Gilks





More information about the Chchrobotics mailing list