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

Volker Kuhlmann list57 at top.geek.nz
Mon Aug 3 11:37:14 BST 2020


On Mon 03 Aug 2020 20:02:05 NZST +1200, Robin Gilks wrote:

> The error actually occurs on compiling project B when
> ../common/src/fileD.c is compiled instead of src/fileD.c. I assume this is
> due to the vpath using a sorted list of directories and common/src comes
> before src.

Uhmm, compiling a C program with two modules both called fileD is
begging for trouble. Bad idea.

> The reason I'm using vpath is because the template used by stm32CubeMX to
> generate makefiles uses it. Until yesterday I had no idea it might cause
> problems.

Well unless you explicitly say where each .c is located, you're going to
have to use vpath, so that's not the real problem. The real problem is
having two files with the same name.

One way around it might be to turn your common stuff into a library.
Then you can choose the linking order, i.e. the order in which modules
get searched for functions to link in. It looks like you want the
project modules first, so add the library after.

There is some sense to compile objects into their own directory, if you
have a src/ subdirectory already. I'd put it next to src, and you can
deal with that inside implicit rules by using relative paths.

> I don't seems to be able to get 'make' to compile all the files from the
> C_SOURCES variable without using vpath - basically because I don't really
> know how 'make' works!

man make    ;-)))

The info documentation is good (that's a manual in info format). It was
enough for me to work out some reasonably complex stuff.

Volker

-- 
Volker Kuhlmann
http://volker.top.geek.nz/	Please do not CC list postings to me.



More information about the Chchrobotics mailing list