Move towards build-time configuration of variables
authorDan Scott <dscott@laurentian.ca>
Thu, 22 Mar 2012 15:09:44 +0000 (11:09 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Thu, 29 Mar 2012 14:34:18 +0000 (10:34 -0400)
We moved a lot of variable configuration into AC_CONFIG_FILES in
autoconf for the sake of convenience, but that turned out to be
problematic, as James Fournie noted in LP 960552, as the warning in
http://www.gnu.org/software/automake/manual/html_node/Scripts.html
notes: "building scripts this way has one drawback: directory variables
such as $(datadir) are not fully expanded and may refer to other
directory variables".

This was particularly a problem for variables such as @sysconfdir@ in
code that doesn't understand shell syntax - such as Cronscript.pm.

This commit moves towards build-time configuration of those variables.
We still use *.in files, but mark the built versions as dependencies in
build recipes such that we can build and test within the source
directory without having to install the files. We also gain the
advantage of teaching "make clean" to clean up the built versions of the
files.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>

Open-ILS/src/Makefile.am
Open-ILS/src/perlmods/Makefile.am
configure.ac

index 9eeb330..4a4d9ac 100644 (file)
@@ -132,14 +132,41 @@ if BUILDEGJAVA
 OILSJAVA_DIR = java
 endif
 
-bin_SCRIPTS = $(core_scripts) $(reporter_scripts) $(installautojs) @srcdir@/extras/eg_config @srcdir@/extras/fast-extract @srcdir@/extras/import/marc2are.pl @srcdir@/extras/import/marc2bre.pl @srcdir@/extras/import/marc2sre.pl @srcdir@/extras/import/parallel_pg_loader.pl $(supportscr)/marc_export
+gen_scripts = \
+       @srcdir@/extras/fast-extract \
+       @srcdir@/extras/import/marc2are.pl \
+       @srcdir@/extras/import/marc2bre.pl \
+       @srcdir@/extras/import/marc2sre.pl \
+       @srcdir@/extras/import/parallel_pg_loader.pl \
+       $(supportscr)/authority_control_fields.pl \
+       $(supportscr)/marc_export
+
+bin_SCRIPTS = $(core_scripts) $(gen_scripts) $(reporter_scripts) $(installautojs)
+
+CLEANFILES = $(gen_scripts)
+
 data_DATA = $(core_data) $(reporter_data)
 
 # Take care of which subdirectories to build, and which extra files to include in a distribution.
 
 SUBDIRS = $(OILSCORE_DIRS) $(OILSWEB_DIR) $(OILSPYTHON_DIR) $(OILSJAVA_DIR)
 
-EXTRA_DIST = @srcdir@/perlmods @srcdir@/templates @top_srcdir@/Open-ILS/xsl @srcdir@/cgi-bin
+EXTRA_DIST = @srcdir@/perlmods \
+       @srcdir@/templates \
+       @top_srcdir@/Open-ILS/xsl \
+       @srcdir@/cgi-bin \
+       $(gen_scripts) \
+       @srcdir@/extras/eg_config
+
+do_subst = $(SED) \
+       -e 's,[@]bindir[@],$(bindir),g' \
+       -e 's,[@]datarootdir[@],$(datarootdir),g' \
+       -e 's,[@]docdir[@],$(docdir),g' \
+       -e 's,[@]exec_prefix[@],$(exec_prefix),g' \
+       -e 's,[@]includedir[@],$(includedir),g' \
+       -e 's,[@]libdir[@],$(libdir),g' \
+       -e 's,[@]prefix[@],$(prefix),g' \
+       -e 's,[@]sysconfdir[@],$(sysconfdir),g'
 
 # Install header files
 
@@ -156,6 +183,33 @@ uninstall-hook:
        rm -R $(XSLDIR)
        rm -R $(CGIDIR)
 
+@srcdir@/extras/fast-extract: @srcdir@/extras/fast-extract.in
+       $(do_subst) "$<" > "$@"
+       chmod 755 "$@"
+
+@srcdir@/extras/import/marc2are.pl: @srcdir@/extras/import/marc2are.pl.in
+       $(do_subst) "$<" > "$@"
+       chmod 755 "$@"
+
+@srcdir@/extras/import/marc2bre.pl: @srcdir@/extras/import/marc2bre.pl.in
+       $(do_subst) "$<" > "$@"
+       chmod 755 "$@"
+
+@srcdir@/extras/import/marc2sre.pl: @srcdir@/extras/import/marc2sre.pl.in
+       $(do_subst) "$<" > "$@"
+       chmod 755 "$@"
+
+@srcdir@/extras/import/parallel_pg_loader.pl: @srcdir@/extras/import/parallel_pg_loader.pl.in
+       $(do_subst) "$<" > "$@"
+       chmod 755 "$@"
+
+$(supportscr)/authority_control_fields.pl: $(supportscr)/authority_control_fields.pl.in
+       $(do_subst) "$<" > "$@"
+       chmod 755 "$@"
+
+$(supportscr)/marc_export: $(supportscr)/marc_export.in
+       $(do_subst) "$<" > "$@"
+       chmod 755 "$@"
 
 #perl-install and string-templates-install     
 ilscore-install:
index 4f49264..64f350d 100644 (file)
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-CLEANFILES = Build
+bin_SCRIPTS = Build lib/OpenILS/Utils/Cronscript.pm
+
+CLEANFILES = $(bin_SCRIPTS)
+
 DISTCLEANFILES = Makefile.in Makefile
 
+do_subst = $(SED) -e 's,[@]sysconfdir@,$(sysconfdir),g'
+
 all: build-perl
        ./Build || make -s build-perl-fail
 
@@ -23,9 +28,12 @@ check: build-perl
 install: build-perl
        ./Build install
 
-build-perl:
+build-perl: lib/OpenILS/Utils/Cronscript.pm
        perl Build.PL --destdir $(DESTDIR) || make -s build-perl-fail
 
+lib/OpenILS/Utils/Cronscript.pm: lib/OpenILS/Utils/Cronscript.pm.in
+       $(do_subst) "$<" > "$@"
+
 build-perl-fail:
        echo
        echo ">>> Build/test of Perl modules has failed. The most likely"
index dd0b098..1d99e19 100644 (file)
@@ -369,28 +369,14 @@ fi
 
 AC_CONFIG_FILES([Makefile
          Open-ILS/src/Makefile
+         Open-ILS/src/perlmods/Makefile
          Open-ILS/web/Makefile
          Open-ILS/updates/Makefile
          Open-ILS/xul/staff_client/Makefile
          Open-ILS/src/extras/eg_config
-         Open-ILS/src/extras/fast-extract
-         Open-ILS/src/extras/import/marc2are.pl
-         Open-ILS/src/extras/import/marc2bre.pl
-         Open-ILS/src/extras/import/marc2sre.pl
-         Open-ILS/src/extras/import/parallel_pg_loader.pl
-         Open-ILS/src/support-scripts/authority_control_fields.pl
-         Open-ILS/src/support-scripts/marc_export
-         Open-ILS/src/perlmods/Makefile
-         Open-ILS/src/perlmods/lib/OpenILS/Utils/Cronscript.pm],
+         ],
         [
             if test -e "./Open-ILS/src/extras/eg_config"; then chmod 755 Open-ILS/src/extras/eg_config; fi;
-            if test -e "./Open-ILS/src/extras/fast-extract"; then chmod 755 Open-ILS/src/extras/fast-extract; fi;
-            if test -e "./Open-ILS/src/extras/import/marc2are.pl"; then chmod 755 Open-ILS/src/extras/import/marc2are.pl; fi;
-            if test -e "./Open-ILS/src/extras/import/marc2bre.pl"; then chmod 755 Open-ILS/src/extras/import/marc2bre.pl; fi;
-            if test -e "./Open-ILS/src/extras/import/marc2sre.pl"; then chmod 755 Open-ILS/src/extras/import/marc2sre.pl; fi;
-            if test -e "./Open-ILS/src/extras/import/parallel_pg_loader.pl"; then chmod 755 Open-ILS/src/extras/import/parallel_pg_loader.pl; fi;
-            if test -e "./Open-ILS/src/support-scripts/authority_control_fields.pl"; then chmod 755 Open-ILS/src/support-scripts/authority_control_fields.pl; fi;
-            if test -e "./Open-ILS/src/support-scripts/marc_export"; then chmod 755 Open-ILS/src/support-scripts/marc_export; fi;
         ])
 AC_OUTPUT