Configure problem (and fix).

Started by Billy G. Allieabout 27 years ago3 messages
#1Billy G. Allie
Bill.Allie@mug.org
2 attachment(s)

I have come across a problem where the code generated by autoconf does not
subsitute correct values for the following variables:

bindir sbindir libexecdir
datadir sysconfdir sharedstatedir
localstatedir libdir includedir
oldincludedir infodir mandir

The problem is that they reference the variables, 'prefix' and 'exec_prefix'
but those variables are not expanded in the subsitutions. For example,
referencing 'libdir' in an *.in file will have "${exec_prefix}/lib" placed in
the resulting output file. It should be "/usr/local/pgsql/lib" (if the
default exec_prefix (and prefix) value is used). The first patch
(uw7-1.patch) will correct the problem, which causes an incorrect
src/pl/plpgsql/src/mklang.sql file to be generated.

The second patch:

1. Adds a file (mklang.sql) that can be used to add the language
definitions for PL/TCL to a database.

2. Generalizes the mklang.sql in src/pl/plpgsql/test so that it will
reference the correct location for the plpgsql.so shared library.

3. Generalizes the test_mklang.sql file in src/pl/tcl/test so that is will
reference the correct localtion for the pltcl.so shared library.

IMPORTANT: Do not apply the second patch without applying the first patch!

Attachments:

uw7-1.patchapplication/x-patch; name=uw7-1.patchDownload
*** src/configure.in.orig	Fri Oct 23 22:35:51 1998
--- src/configure.in	Fri Oct 23 23:36:16 1998
***************
*** 905,910 ****
--- 905,939 ----
  	AC_SUBST(USE_ODBC)
  fi
  
+ # At this point we need to EVAL the following variables so that the
+ # 'prefix' and 'exec_prefix' are expanded to their correct values.
+ 
+ # autoconf sets prefix and exec_prefix to their default values after
+ # the following variable are expanded, so we need to set the default
+ # values here.
+ 
+ if test "$prefix" = "NONE"
+ then
+ 	prefix=$ac_default_prefix
+ fi
+ if test "$exec_prefix" = "NONE"
+ then
+ 	exec_prefix=$prefix
+ fi
+ 
+ eval bindir=$bindir
+ eval sbindir=$sbindir
+ eval libexecdir=$libexecdir
+ eval datadir=$datadir
+ eval sysconfdir=$sysconfdir
+ eval sharedstatedir=$sharedstatedir
+ eval localstatedir=$localstatedir
+ eval libdir=$libdir
+ eval includedir=$includedir
+ eval oldincludedir=$oldincludedir
+ eval infodir=$infodir
+ eval mandir=$mandir
+ 
  AC_OUTPUT(
  	GNUmakefile
  	Makefile.global
uw7-2.patchapplication/x-patch; name=uw7-2.patchDownload
*** src/pl/plpgsql/test/mklang.sql.in.orig	Fri Oct 23 23:44:39 1998
--- src/pl/plpgsql/test/mklang.sql.in	Fri Oct 23 23:44:00 1998
***************
*** 0 ****
--- 1,14 ----
+ --
+ -- PL/pgSQL language declaration
+ --
+ -- $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/mklang.sql.in,v 1.1 1998/10/12 04:55:03 momjian Exp $
+ --
+ 
+ create function plpgsql_call_handler() returns opaque
+ 	as '@libdir@/plpgsql.so'
+ 	language 'C';
+ 
+ create trusted procedural language 'plpgsql'
+ 	handler plpgsql_call_handler
+ 	lancompiler 'PL/pgSQL';
+ 
*** src/pl/tcl/test/test_mklang.sql.in.orig	Fri Oct 23 23:46:14 1998
--- src/pl/tcl/test/test_mklang.sql.in	Sat Oct 24 00:18:35 1998
***************
*** 0 ****
--- 1,9 ----
+ 
+ create function pltcl_call_handler() returns opaque
+ 	as '@libdir@/pltcl.so'
+ 	language 'C';
+ 
+ create trusted procedural language 'pltcl'
+ 	handler pltcl_call_handler
+ 	lancompiler 'PL/Tcl';
+ 
*** src/pl/tcl/mklang.sql.in.orig	Sat Oct 24 00:20:31 1998
--- src/pl/tcl/mklang.sql.in	Sat Oct 24 00:18:23 1998
***************
*** 0 ****
--- 1,14 ----
+ --
+ -- PL/TCL language declaration
+ --
+ -- ## Insert RCS Header Here ##
+ --
+ 
+ create function pltcl_call_handler() returns opaque
+ 	as '@libdir@/pltcl.so'
+ 	language 'C';
+ 
+ create trusted procedural language 'pltcl'
+ 	handler pltcl_call_handler
+ 	lancompiler 'PL/Tcl';
+ 
*** src/configure.in.orig	Fri Oct 23 23:42:40 1998
--- src/configure.in	Fri Oct 23 23:56:13 1998
***************
*** 954,958 ****
--- 954,961 ----
  	interfaces/odbc/Makefile.global
  	pl/plpgsql/src/Makefile
  	pl/plpgsql/src/mklang.sql
+ 	pl/plpgsql/test/mklang.sql
  	pl/tcl/mkMakefile.tcldefs.sh
+ 	pl/tcl/mklang.sql
+ 	pl/tcl/test/test_mklang.sql
  )
#2Brook Milligan
brook@trillium.NMSU.Edu
In reply to: Billy G. Allie (#1)
Re: [HACKERS] Configure problem (and fix).

I have come across a problem where the code generated by autoconf does not
subsitute correct values for the following variables:

bindir sbindir libexecdir
datadir sysconfdir sharedstatedir
localstatedir libdir includedir
oldincludedir infodir mandir

The normal usage is fine for things like Makefiles that know about
environment variables and do their own expansion (i.e., the vast
majority of the usage of these variables). In this one instance we
are constructing *.sql files that can't expand environment variables
and hence need to do that in advance during configuration.

It seems much cleaner to do the following:

- keep the unexpanded versions in the Makefiles (since it reduces
cluttered duplication and uses variables as they should be used for
indirect references), and

- introduce a new expanded variable for this purpose

The patches below replace Billie's and accomplish his intent of having
the *.sql files refer to the correct libraries without needlessly
expanding ALL the variables everywhere.

Note that the only difference from his patches for *.sql files is to
use @expanded_libdir@ instead of @libdir@. The difference for
configure.in is to create the variable $expanded_libdir without
affecting the rest of the "normal" variables.

Please use this set of patches instead of his.

Cheers,
Brook

===========================================================================
--- configure.in.orig	Fri Oct 23 01:00:15 1998
+++ configure.in	Sat Oct 24 12:06:13 1998
@@ -905,6 +905,15 @@
 	AC_SUBST(USE_ODBC)
 fi
+dnl expand some variables for use in files (e.g., *.sql)
+dnl without environment variables defined
+
+ice_save_exec_prefix=${exec_prefix}
+test "x$exec_prefix" = xNONE && eval exec_prefix=${prefix}
+eval expanded_libdir=${libdir}
+exec_prefix=${ice_save_exec_prefix}
+AC_SUBST(expanded_libdir)
+
 AC_OUTPUT(
 	GNUmakefile
 	Makefile.global
===========================================================================
--- pl/plpgsql/src/mklang.sql.in.orig	Sun Oct 11 22:55:03 1998
+++ pl/plpgsql/src/mklang.sql.in	Sat Oct 24 11:34:16 1998
@@ -5,7 +5,7 @@
 --
 create function plpgsql_call_handler() returns opaque
-	as '@libdir@/plpgsql.so'
+	as '@expanded_libdir@/plpgsql.so'
 	language 'C';
 create trusted procedural language 'plpgsql'
===========================================================================
*** pl/plpgsql/test/mklang.sql.in.orig	Fri Oct 23 23:44:39 1998
--- pl/plpgsql/test/mklang.sql.in	Fri Oct 23 23:44:00 1998
***************
*** 0 ****
--- 1,14 ----
+ --
+ -- PL/pgSQL language declaration
+ --
+ -- $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/mklang.sql.in,v 1.1 1998/10/12 04:55:03 momjian Exp $
+ --
+ 
+ create function plpgsql_call_handler() returns opaque
+ 	as '@expanded_libdir@/plpgsql.so'
+ 	language 'C';
+ 
+ create trusted procedural language 'plpgsql'
+ 	handler plpgsql_call_handler
+ 	lancompiler 'PL/pgSQL';
+ 
*** pl/tcl/test/test_mklang.sql.in.orig	Fri Oct 23 23:46:14 1998
--- pl/tcl/test/test_mklang.sql.in	Sat Oct 24 00:18:35 1998
***************
*** 0 ****
--- 1,9 ----
+ 
+ create function pltcl_call_handler() returns opaque
+ 	as '@expanded_libdir@/pltcl.so'
+ 	language 'C';
+ 
+ create trusted procedural language 'pltcl'
+ 	handler pltcl_call_handler
+ 	lancompiler 'PL/Tcl';
+ 
*** pl/tcl/mklang.sql.in.orig	Sat Oct 24 00:20:31 1998
--- pl/tcl/mklang.sql.in	Sat Oct 24 00:18:23 1998
***************
*** 0 ****
--- 1,14 ----
+ --
+ -- PL/TCL language declaration
+ --
+ -- ## Insert RCS Header Here ##
+ --
+ 
+ create function pltcl_call_handler() returns opaque
+ 	as '@expanded_libdir@/pltcl.so'
+ 	language 'C';
+ 
+ create trusted procedural language 'pltcl'
+ 	handler pltcl_call_handler
+ 	lancompiler 'PL/Tcl';
+ 
*** configure.in.orig	Fri Oct 23 23:42:40 1998
--- configure.in	Fri Oct 23 23:56:13 1998
***************
*** 954,958 ****
--- 954,961 ----
  	interfaces/odbc/Makefile.global
  	pl/plpgsql/src/Makefile
  	pl/plpgsql/src/mklang.sql
+ 	pl/plpgsql/test/mklang.sql
  	pl/tcl/mkMakefile.tcldefs.sh
+ 	pl/tcl/mklang.sql
+ 	pl/tcl/test/test_mklang.sql
  )
#3Billy G. Allie
Bill.Allie@mug.org
In reply to: Brook Milligan (#2)
Re: [HACKERS] Configure problem (and fix).

Brook Milligan wrote:

The normal usage is fine for things like Makefiles that know about
environment variables and do their own expansion (i.e., the vast
majority of the usage of these variables). In this one instance we
are constructing *.sql files that can't expand environment variables
and hence need to do that in advance during configuration.

It seems much cleaner to do the following:

- keep the unexpanded versions in the Makefiles (since it reduces
cluttered duplication and uses variables as they should be used for
indirect references), and

- introduce a new expanded variable for this purpose

Is it cleaner? It makes sense to me that if I want to use 'libdir' or any of
the other defined variables, it should have a value that can be anywhere it is
needed without having to depend on the expansion of variables in the place
where it is used. Configure knows the information needed to expand the
variables and should do so before making subsitutions. If this is not done,
it leave the door open for problems to occur. For instance, if after running
configure, the global makefile is modified so that 'prefix' is changed (an
assumption can be made that since the definitions have unexpanded variables,
then this can work without having to re-run configure), then the location of
'libdir' will be differenct from 'expanded_libdir' and the *.sql files will no
longer be correct. The assumption that a variable, such as 'prefix', can be
changed in the global makefile (an assumption encouraged by the way configure
works without my patch) and still have the system build correctly is incorrect.

The patches below replace Billie's and accomplish his intent of having

BTW: That's Billy's ----------^

My intent is to be able to use the subsitution feature of configure any where
it is needed without haveing to depend on expansion of embeded variable
occuring where they are used.

--
____ | Billy G. Allie | Domain....: Bill.Allie@mug.org
| /| | 7436 Hartwell | Compuserve: 76337,2061
|-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie@email.msn.com
|/ |LLIE | (313) 582-1540 |