~ chicken-core (chicken-5) dcb329be7c903ea7a9b33d926545bd5ce3542a3c
commit dcb329be7c903ea7a9b33d926545bd5ce3542a3c
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Fri Jul 21 15:38:41 2023 +0200
Commit: Peter Bex <peter@more-magic.net>
CommitDate: Tue Sep 19 14:17:23 2023 +0200
Allow overriding general installation prefix in "chicken-install"
When determining the destination location for extensions, programs, include files
and data files, respect CHICKEN_INSTALL_PREFIX (CHICKEN_INSTALL_REPOSITORY
still takes precedence for extensions). This variable was actually still
existing and used by "chicken-home" and in some places in the "chicken-install"
program. This patch removes the former use and makes this variable exclusively
a utility for "chicken-install" to override the CHICKEN installation prefix and
applies it consistently.
Signed-off-by: Peter Bex <peter@more-magic.net>
diff --git a/chicken-install.mdoc b/chicken-install.mdoc
index d075a692..4b5d19ff 100644
--- a/chicken-install.mdoc
+++ b/chicken-install.mdoc
@@ -115,10 +115,15 @@ Following environment variables change the behaviour of
.Bl -tag -width CHICKEN_INSTALL_REPOSITORY
.It Ev CHICKEN_EGG_CACHE
Location where eggs are retrieved and built.
+.It Ev CHICKEN_INSTALL_PREFIX
+The path prefix for all target files, as given when building the system.
+Use this variable to override where programs, include files and additional
+data files shall be intalled.
.It Ev CHICKEN_INSTALL_REPOSITORY
The path where extension libraries are installed. Defaults to the
package library path selected during configuration
.Pq usually $prefix/lib/chicken/<binary-version> .
+Note that this variable takes precedence to CHICKEN_INSTALL_PREFIX.
.It Ev SUDO
The command to execute when using
.Fl s
diff --git a/egg-compile.scm b/egg-compile.scm
index 99a94fe8..c9a5565e 100644
--- a/egg-compile.scm
+++ b/egg-compile.scm
@@ -118,6 +118,14 @@
(define (uses-compiled-import-library? mode)
(not (and (eq? mode 'host) staticbuild)))
+;; this one overrides "destination-repository" in egg-environment to allow use of
+;; CHICKEN_INSTALL_PREFIX (via "override-prefix")
+(define (effective-destination-repository mode #!optional run)
+ (if (eq? 'target mode)
+ (if run target-run-repo target-repo)
+ (or (get-environment-variable "CHICKEN_INSTALL_REPOSITORY")
+ (override-prefix (string-append "/lib/chicken/" (number->string binary-version))
+ host-repo))))
;;; topological sort with cycle check
@@ -148,7 +156,7 @@
(error "destination must be relative to CHICKEN install prefix" dest)
(normalize-pathname
(make-pathname (if (eq? mode 'target)
- default-prefix ; XXX wrong!
+ default-prefix
(override-prefix "/" host-prefix))
dest*)))))
@@ -228,7 +236,7 @@
(mods #f)
(opts opts))
(for-each compile-extension/program (cddr info))
- (let ((dest (destination-repository mode #t))
+ (let ((dest (effective-destination-repository mode #t))
;; Respect install-name if specified
(rtarget (or oname target)))
(when (eq? #t tfile) (set! tfile rtarget))
@@ -272,7 +280,7 @@
(mods #f)
(opts opts))
(for-each compile-extension/program (cddr info))
- (let ((dest (destination-repository mode #t))
+ (let ((dest (effective-destination-repository mode #t))
;; Respect install-name if specified
(rtarget (or oname target)))
(set! objs
@@ -291,7 +299,7 @@
(for-each compile-data/include (cddr info))
(let* ((dest (or (and dest (normalize-destination dest mode))
(if (eq? mode 'target)
- default-sharedir ; XXX wrong!
+ default-sharedir
(override-prefix "/share" host-sharedir))))
(dest (normalize-pathname (conc dest "/"))))
(addfiles (map (cut conc dest <>) files)))
@@ -320,7 +328,7 @@
(for-each compile-data/include (cddr info))
(let* ((dest (or (and dest (normalize-destination dest mode))
(if (eq? mode 'target)
- default-incdir ; XXX wrong!
+ default-incdir
(override-prefix "/include" host-incdir))))
(dest (normalize-pathname (conc dest "/"))))
(addfiles (map (cut conc dest <>) files)))
@@ -335,7 +343,7 @@
(for-each compile-data/include (cddr info))
(let* ((dest (or (and dest (normalize-destination dest mode))
(if (eq? mode 'target)
- default-sharedir ; XXX wrong!
+ default-sharedir
(override-prefix "/share" host-sharedir))))
(dest (normalize-pathname (conc dest "/"))))
(addfiles (map (cut conc dest <>) files)))
@@ -356,7 +364,7 @@
(opts opts))
(for-each compile-extension/program (cddr info))
(let ((dest (if (eq? mode 'target)
- default-bindir ; XXX wrong!
+ default-bindir
(override-prefix "/bin" host-bindir)))
;; Respect install-name if specified
(rtarget (or oname target)))
@@ -905,7 +913,7 @@
(out (qs* (target-file (conc sname ".static" ext) mode)
platform #t))
(outlnk (qs* (conc sname +link-file-extension+) platform #t))
- (dest (destination-repository mode))
+ (dest (effective-destination-repository mode))
(dfile (qs* dest platform #t))
(ddir (shell-variable "DESTDIR" platform)))
(print "\n" mkdir " " ddir dfile)
@@ -923,7 +931,7 @@
(mkdir (mkdir-command platform))
(sname (prefix srcdir name))
(out (qs* (target-file (conc sname ext) mode) platform #t))
- (dest (destination-repository mode))
+ (dest (effective-destination-repository mode))
(dfile (qs* dest platform #t))
(ddir (shell-variable "DESTDIR" platform))
(destf (qs* (conc dest "/" output-file ext) platform #t)))
@@ -944,7 +952,7 @@
(sname (prefix srcdir name))
(out (qs* (target-file (conc sname ".import.scm") mode)
platform #t))
- (dest (destination-repository mode))
+ (dest (effective-destination-repository mode))
(dfile (qs* dest platform #t))
(ddir (shell-variable "DESTDIR" platform)))
(print "\n" mkdir " " ddir dfile)
@@ -958,7 +966,7 @@
(mkdir (mkdir-command platform))
(out (qs* (prefix srcdir (conc types-file ".types"))
platform #t))
- (dest (destination-repository mode))
+ (dest (effective-destination-repository mode))
(dfile (qs* dest platform #t))
(ddir (shell-variable "DESTDIR" platform)))
(print "\n" mkdir " " ddir dfile)
@@ -972,7 +980,7 @@
(mkdir (mkdir-command platform))
(out (qs* (prefix srcdir (conc inline-file ".inline"))
platform #t))
- (dest (destination-repository mode))
+ (dest (effective-destination-repository mode))
(dfile (qs* dest platform #t))
(ddir (shell-variable "DESTDIR" platform)))
(print "\n" mkdir " " ddir dfile)
diff --git a/egg-environment.scm b/egg-environment.scm
index f429e214..fa0235a2 100644
--- a/egg-environment.scm
+++ b/egg-environment.scm
@@ -105,9 +105,12 @@ EOF
(define +egg-extension+ "egg")
(define (validate-environment)
- (let ((var (get-environment-variable "CHICKEN_INSTALL_REPOSITORY")))
- (unless (or (not var) (absolute-pathname? var))
- (error "CHICKEN_INSTALL_REPOSITORY must be an absolute pathname" var))))
+ (let ((var1 (get-environment-variable "CHICKEN_INSTALL_REPOSITORY"))
+ (var2 (get-environment-variable "CHICKEN_INSTALL_PREFIX")))
+ (unless (or (not var1) (absolute-pathname? var1))
+ (error "CHICKEN_INSTALL_REPOSITORY must be an absolute pathname" var1))
+ (unless (or (not var2) (absolute-pathname? var2))
+ (error "CHICKEN_INSTALL_PREFIX must be an absolute pathname" var2))))
(define (destination-repository mode #!optional run)
(if (eq? 'target mode)
diff --git a/library.scm b/library.scm
index f7d3c01d..7341bb66 100644
--- a/library.scm
+++ b/library.scm
@@ -6609,10 +6609,7 @@ static C_word C_fcall C_setenv(C_word x, C_word y) {
(define-foreign-variable installation-home c-string "C_INSTALL_SHARE_HOME")
(define-foreign-variable install-egg-home c-string "C_INSTALL_EGG_HOME")
-(define (chicken-home)
- (or (and-let* ((prefix (get-environment-variable "CHICKEN_INSTALL_PREFIX")))
- (string-append prefix "/share"))
- installation-home))
+(define (chicken-home) installation-home)
(define path-list-separator
(if ##sys#windows-platform #\; #\:))
diff --git a/manual/Extension tools b/manual/Extension tools
index c682a03d..23633dd7 100644
--- a/manual/Extension tools
+++ b/manual/Extension tools
@@ -71,7 +71,20 @@ separated by {{:}}/{{;}}) where eggs are to be
loaded from for all chicken-based programs. {{CHICKEN_INSTALL_REPOSITORY}}
is the place where eggs will be installed and which the egg-related
tools like {{chicken-install}}, {{chicken-uninstall}} and
-{{chicken-status}} consult and update. Make sure the paths given in these
+{{chicken-status}} consult and update.
+
+Finally, {{CHICKEN_INSTALL_PREFIX}} allows you to override where any
+installed files should be stored, including extension libraries, programs
+and data files. Effectively this variable overrides the installation
+prefix given when building and installing chicken. When installing eggs,
+the location where dependency extensions and tools are installed will
+not be automatically found, so setting this variable usually only makes
+sense when used in combination with {{CHICKEN_REPOSITORY_PATH}}.
+
+{{CHICKEN_INSTALL_PREFIX}} is intended for special sitautions and should be used
+with care. It is a last-resort utility to customize where build-results are placed.
+
+Make sure the paths given in these
environment variables are absolute and not relative.
=== Static linking
Trap