[GRASS-dev] new digitization tool compilation

Glynn Clements glynn at gclements.plus.com
Fri Feb 1 07:40:11 EST 2008


Jachym Cepicky wrote:

> I try to compile new wx v.digit, however without success:
> 
> make
> [...]
> c++ -c -c -fpic
> -I/home/jachym/src/grass/grass_trunk/dist.i686-pc-linux-gnu/include
> -I/usr/include/python2.5 `wx-config --cxxflags`
> grass6_wxvdigit_wrap.cxx -o OBJ.i686-pc-linux-gnu/grass6_wxvdigit_wrap.o
> In file included
> from /home/jachym/src/grass/grass_trunk/dist.i686-pc-linux-gnu/include/grass/vect/digit.h:3,
> 
> from /home/jachym/src/grass/grass_trunk/dist.i686-pc-linux-gnu/include/grass/Vect.h:4,
>                  from grass6_wxvdigit_wrap.cxx:2579:
> /home/jachym/src/grass/grass_trunk/dist.i686-pc-linux-gnu/include/grass/vect/dig_structs.h:22:21: error: ogr_api.h: No such file or directory
> /home/jachym/src/grass/grass_trunk/dist.i686-pc-linux-gnu/include/grass/vect/dig_structs.h:170: error: ‘OGRDataSourceH’ does not name a type
> [...]
> 
> the ogr_api.h is in /usr/include/gdal/ 
> 
> what to do?

vdigit/Makefile needs to have -I$(GDALCFLAGS) added to the compilation
flags. Maybe $(PROJINC) also?

Actually, vdigit needs more substantial synchronisation to the GRASS
build system.

E.g. it should use the global rules from Rules.make for compiling C++
files (it also needs to change the source files from .cxx -> .cc to
match existing C++ files). Also:

	CXXFLAGS=-c -fpic -I$(ARCH_DISTDIR)/include  -I/usr/include/python$(PYTHONVERSION) `wx-config --cxxflags`

To use the output from a command in a variable assignment, you need to
use e.g. $(shell wx-config --cxxflags) rather than backticks. Any such
assignments should use := rather than = to prevent the command from
being run repeatedly, e.g.:

	WXCXXFLAGS := $(shell wx-config --cxxflags)

When a variable assignment uses "=", the RHS is assigned literally
rather than being expanded. The value will be expanded at the point
that the variable appears in a prerequisite or command. If the
variable occurs in multiple prerequisites or commands, it will be
expanded each time. If the expansion involves $(shell ...), the
command will be run each time, which is inefficient.

When an assignment uses ":=", the RHS is expanded before it is
assigned to the variable. Any variables which it uses must have
already been defined prior to that point. For this reason, it's
preferable for any use of $(shell ...) to be assigned directly to a
variable, rather than appearing in the middle of a more complex
assignment. IOW, rather than e.g.:

	CXXFLAGS=-c -fpic -I$(ARCH_DISTDIR)/include -I/usr/include/python$(PYTHONVERSION) $(shell wx-config --cxxflags)

use e.g.:

	WXCXXFLAGS := $(shell wx-config --cxxflags)
	CXXFLAGS = -c -fpic -I$(ARCH_DISTDIR)/include -I/usr/include/python$(PYTHONVERSION) $(WXCXXFLAGS)

This allows the bulk of the definition to use "=" (deferred
expansion), with ":=" (immediate expansion) reserved for the part that
really needs it.

Ultimately, the use of wx-config should go into configure.in. Apart
from anything else, this allows the user to manually edit
Platform.make if configure cannot get it right by itself.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list