From c2cd2567032c5d43c47c4f9eeb36566cc23c0615 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Thu, 22 Mar 2012 11:09:44 -0400 Subject: [PATCH] Move towards build-time configuration of variables 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 Signed-off-by: Jason Stephenson --- Open-ILS/src/Makefile.am | 58 +++++++++++++++++++++++++++++-- Open-ILS/src/perlmods/Makefile.am | 12 +++++-- configure.ac | 18 ++-------- 3 files changed, 68 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/Makefile.am b/Open-ILS/src/Makefile.am index 9eeb330793..4a4d9aca71 100644 --- a/Open-ILS/src/Makefile.am +++ b/Open-ILS/src/Makefile.am @@ -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: diff --git a/Open-ILS/src/perlmods/Makefile.am b/Open-ILS/src/perlmods/Makefile.am index 4f492642a4..64f350d322 100644 --- a/Open-ILS/src/perlmods/Makefile.am +++ b/Open-ILS/src/perlmods/Makefile.am @@ -11,9 +11,14 @@ # 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" diff --git a/configure.ac b/configure.ac index dd0b098b5f..1d99e190cb 100644 --- a/configure.ac +++ b/configure.ac @@ -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 -- 2.43.2