From 1e5012ca803bbc4e08982f99d6c902e75dcb4421 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sat, 12 Nov 2016 16:23:00 +0100 Subject: build: Let 'make' generate 'src/cuirass/config.scm'. * Makefile.am (src/cuirass/config.scm, $(go_files)): New targets. (do_subst, generate_file, go_files): New variables. (EXTRA_DIST): Distribute 'src/cuirass/config.scm.in'. (DISTCLEANFILES): Rename to ... (MOSTLYCLEANFILES): ... this. * configure.ac (AC_CONFIG_FILES): Remove 'src/cuirass/config.scm'. (@expanded_datadir@, @expanded_localstatedir@): Delete. (AC_PROG_MKDIR_P, AC_PROG_SED): Use them. * src/cuirass/config.scm (%datadir): Set it to $(localstatedir). (%localstatdir): Set it to $(datadir). --- Makefile.am | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index d4ef8a0..cde4f67 100644 --- a/Makefile.am +++ b/Makefile.am @@ -86,18 +86,60 @@ sql-check: src/schema.sql EXTRA_DIST = \ .dir-locals.el \ bootstrap \ + src/cuirass/config.scm.in \ tests/gnu-system.scm \ tests/guix-jobs.scm \ tests/hello-singleton.scm \ tests/hello-subset.scm \ $(TESTS) -DISTCLEANFILES = src/cuirass/config.scm +MOSTLYCLEANFILES = src/cuirass/config.scm CLEANFILES = \ $(nodist_guilesite_DATA) \ $(dist_pkgmodule_DATA:%.scm=%.go) \ src/cuirass/config.go +## ----------------- ## +## Generated files. ## +## ----------------- ## + +# 'AC_CONFIG_FILES' doesn't fully expand variables that depend on ${prefix}. +# To use such variables in source files and scripts while following GNU Coding +# Standards, let 'make' manage their replacement. + +# Use config.status to substitute the remainder where a single expansion is +# sufficient. We use a funny notation here to avoid configure substitutions +# in our text. +do_subst = ( $(SED) \ + -e "s,@configure_input[@],Generated from $$in. Do not edit by hand.,g" \ + -e 's,@datadir[@],$(datadir),g' \ + -e 's,@localstatedir[@],$(localstatedir),g' \ + | $(SHELL) ./config.status --file=- ) + +# Generic instructions to perform the substitution. Generated files shouldn't +# contain unexpanded '@substitutions@', and should be made read-only, to +# prevent them from being edited by mistake instead of the file the are +# generated from. +generate_file = \ + $(AM_V_GEN)rm -f $@ $@-t; \ + $(MKDIR_P) $(@D); \ + in=$@.in && $(do_subst) <$(srcdir)/$$in >$@-t; \ + if LC_ALL=C grep '@[a-zA-Z0-9_][a-zA-Z0-9_]*@' $@-t; then \ + echo "$@ contains unexpanded substitution (see lines above)"; \ + exit 1; \ + fi; \ + chmod a-w $@-t; mv -f $@-t $@ + +# This file depends on Makefile so it is rebuilt if $(VERSION), +# $(datadir) or other do_subst'ituted variables change. +src/cuirass/config.scm: $(srcdir)/src/cuirass/config.scm.in Makefile + $(generate_file) + +# Guile modules require 'src/cuirass/config.scm' to exist before being +# compiled. +go_files = $(nodist_guilesite_DATA) $(dist_pkgmodule_DATA:%.scm=%.go) +$(go_files): src/cuirass/config.scm + ## -------------- ## ## Silent rules. ## ## -------------- ## -- cgit v1.2.3