Partial fix for launchpad bug 489294: OpenSRF seems to depend on explicit --prefix...
authordbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 27 Nov 2009 22:47:49 +0000 (22:47 +0000)
committerdbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 27 Nov 2009 22:47:49 +0000 (22:47 +0000)
In the process of creating Perl and Python scripts using AC_SUBST(sysconfdir),
autoconf would generate variables like '${prefix}' if no explicit --prefix
option was passed to configure - and this would cause those scripts to fail
with syntax errors.

We can work around that, and so we shall. The bigger question is whether
creating scripts with hardcoded defaults results in problems when it comes
to creating system packages; according to http://www.gnu.org/software/hello/manual/autoconf/Installation-Directory-Variables.html
one should try to defer these changes to the Makefile so that the
destination directory can be specified at make or make install time,
instead.

At least this gets us working with no explicit configure options again.
Perhaps a packaging expert can help us out of this mire :)

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1863 9efc2488-bf62-4759-914b-345cdb29e865

bin/opensrf-perl.pl.in
configure.ac
doc/dokuwiki-doc-stubber.pl.in
examples/math_bench.pl.in
examples/math_client.py.in

index e650115..80b7df6 100755 (executable)
@@ -27,7 +27,7 @@ use OpenSRF::Utils::Config;
 
 my $opt_action = undef;
 my $opt_service = undef;
-my $opt_config = "@sysconfdir@/opensrf_core.xml";
+my $opt_config = "@CONF_DIR@/opensrf_core.xml";
 my $opt_pid_dir = "@TMP@";
 my $opt_no_daemon = 0;
 my $opt_settings_pause = 0;
@@ -215,7 +215,7 @@ sub msg {
 sub do_help {
     print <<HELP;
 
-    Usage: perl $0 --pid_dir @TMP@ --config @sysconfdir@/opensrf_core.xml --service opensrf.settings --action start
+    Usage: perl $0 --pid_dir @TMP@ --config @CONF_DIR@/opensrf_core.xml --service opensrf.settings --action start
 
     --action <action>
         Actions include start, stop, restart, and start_all, stop_all, and restart_all
index ddf5e70..c5e04e9 100644 (file)
@@ -24,11 +24,20 @@ AC_INIT([OpenSRF],[trunk],[open-ils-dev@list.georgialibraries.org])
 AM_INIT_AUTOMAKE([OpenSRF], [trunk])
 AC_REVISION($Revision: 0.1 $)
 AC_CONFIG_SRCDIR([configure.ac])
-AC_PREFIX_DEFAULT([/opensrf/])
+AC_PREFIX_DEFAULT([/opensrf])
 AC_CONFIG_MACRO_DIR([m4])
 
+# Enable $prefix to resolve to a reasonable value in substitutions in
+# scripts if no explict value was passed in to configure
+if test "$prefix" = "NONE"; then
+   prefix=$ac_default_prefix
+fi
+
+# Perl and Python scripts don't want ${prefix} if no value was specified
+eval "eval CONF_DIR=$sysconfdir"
+AC_SUBST([CONF_DIR])
+
 AC_SUBST(prefix)
-AC_SUBST(sysconfdir)
 AC_SUBST(bindir)
 
 
index 021f7d4..1edd4d1 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-use OpenSRF::System qw(@sysconfdir@/opensrf_core.xml);
+use OpenSRF::System qw(@CONF_DIR@/opensrf_core.xml);
 use Getopt::Long
 
 $| = 1;
index 5831e71..7752579 100755 (executable)
@@ -13,7 +13,7 @@ my $count = $ARGV[0];
 print "usage: $0 <num_requests>\n" and exit unless $count;
 
 # * connect to the Jabber network
-OpenSRF::System->bootstrap_client( config_file => "@sysconfdir@/opensrf_core.xml" );
+OpenSRF::System->bootstrap_client( config_file => "@CONF_DIR@/opensrf_core.xml" );
 $log->set_service('math_bench');
 
 # * create a new application session for the opensrf.math service
index 77d5885..d0e048d 100644 (file)
@@ -3,7 +3,7 @@ import osrf.system
 import osrf.ses
 
 # XXX: Replace with command line arguments
-file = '@sysconfdir@/opensrf_core.xml'
+file = '@CONF_DIR@/opensrf_core.xml'
 operator = 'add'
 operand1 = 5
 operand2 = 7