[GRASS-dev] GRASS Make-system question

Glynn Clements glynn at gclements.plus.com
Wed Jun 22 08:00:36 EDT 2011

Soeren Gebbert wrote:

> i have a problem to set up a correct Makefile to compiling two
> different modules using the same source file (main.c)

It can't be done. A specific object file is built from a specific
source file using a specific command. That object file won't be
re-built if it already exists and is newer than the source file.

If you want to build multiple modules which share (some) code, and
don't want to go as far as making the common code into a library, the
parts which differ must be in separate object files and thus separate
source files. See e.g. raster/r.mapcalc/Makefile (which builds both
r.mapcalc and r3.mapcalc).

> Can anybody give me a hint how to solve this.

Don't try to use quick hacks; do it properly. Either clone the file as
e.g. main3.c or make it support both 2d and 3d at run-time.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list