[GRASS5] nviz compile in grass51: source of problem

Glynn Clements glynn.clements at virgin.net
Sat Nov 30 14:14:58 EST 2002

Alex Shevlakov wrote:

> Also to handle the problem in compiling under grass51 which in my view comes
> out from fact that sources must compile under both GRASSes (i.e. 5.0 and 5.1) whilst
> config.in files in source trees differ in the way Postgres is defined:
> /* define if postgres exists */
> - in grass51
> and
> /* define if postgres.h exists */
> /* define if postgres_fe.h exists */
> So the check in nviz/src/runPg.c now looks like:
> #if defined(HAVE_POSTGRES) || defined(HAVE_POSTGRES_H) || defined(HAVE_POSTGRES_FE_H)

I suspect that it should probably just be

	#if defined(HAVE_POSTGRES)

Alternatively, add:


to config.h.in and use that instead of HAVE_POSTGRES.

> So that is how it is supposed to compile under both trees. I don't know if it's ok as
> doconfigure in turn defines if Postgres should be used from $(PQLIB). Optimal,
> they all should check one value rather than three or four different ones.

Both HAVE_POSTGRES_H and HAVE_POSTGRES_FE_H should be redundant if
g.column.pg no longer relies upon those headers for VARHDRSZ. In which
case, the checks should probably be removed from configure[.in], as
they require the user to provide the path to the "internal" headers. 
Assuming that the user even has those headers; it wouldn't be
unreasonable for vendors to put them in a separate package from
libpq-fe.h, given that they aren't needed by clients.

HAVE_POSTGRES is explicitly defined by configure (5.1 only) if
PostgreSQL support is enabled. Using HAVE_LIBPQ_FE_H might be
preferable, as it is set automatically by the header check.

If you need a symbol for use in a Makefile, add a line for
USE_POSTGRES to Platform.make.in. For each --with-* switch, a
corresponding USE_* configure variable is defined to "1" if the option
is enabled and to "" (empty) otherwise.

However, the real hack is the "doconfigure" script. It would be
preferable to just conditionalise the body of runPg.c upon
HAVE_POSTGRES (I've already done this part for 5.0), and merge
query_postgr_{orig,dummy}.c (which is trivial; query_postgr_dummy.c is
just a stub).

Similarly, panel_query_{orig,pg}.tcl should be merged. While this step
would constitute most of the work involved in removing the doconfigure
script, in some respects the situation for Tcl code is simpler than
for C, as undefined symbols don't matter if you don't actually execute
the corresponding code.

Alternatively, you could just have panel_query.tcl do e.g.:

	if {[have_postgres]} {
		source panel_query_pg.tcl
	} {
		source panel_query_orig.tcl

This would require that the nvwish binary provides a Tcl function
to indicate whether it was built with PostgreSQL support.

Glynn Clements <glynn.clements at virgin.net>

More information about the grass-dev mailing list