From 2c2f03c9e44aa9f5659b27aee0dfc3470c8ef56d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 24 Nov 2019 11:14:14 +0100 Subject: [PATCH] mescc: Honor --includedir, --libdir. * guix/git/mes.scm (mes): * module/mescc.scm (%includedir, %libdir): New variable. (mescc:main): Add them to options. * module/mescc/mescc.scm (mescc:preprocess, c->info): Add %includedir. (arch-find): Use %libdir instead of prefix-file. (prefix-file): Remove. * scripts/mescc.scm.in (%includedir, %libdir): Initialize from and set in environment. xx * module/mescc/mescc.scm : --- module/mescc.scm | 4 ++++ module/mescc/mescc.scm | 14 +++++--------- scripts/mescc.in | 6 +++++- scripts/mescc.scm.in | 22 +++++++++++++++++----- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/module/mescc.scm b/module/mescc.scm index 707a85eb..875514d6 100644 --- a/module/mescc.scm +++ b/module/mescc.scm @@ -38,6 +38,8 @@ (define %host-arch (or (getenv "%arch") %arch)) (define %prefix (getenv "%prefix")) +(define %includedir (getenv "%includedir")) +(define %libdir (getenv "%libdir")) (define %version (getenv "%version")) (when (and=> (getenv "V") (lambda (v) (and (= (string-length v) 1) (> (string->number v) 1)))) @@ -155,6 +157,8 @@ General help using GNU software: (args (append-map unclump-single args)) (options (parse-opts args)) (options (acons 'prefix %prefix options)) + (options (acons 'includedir %includedir options)) + (options (acons 'libdir %libdir options)) (arch (option-ref options 'arch %host-arch)) (options (if arch (acons 'arch arch options) options)) (dumpmachine? (option-ref options 'dumpmachine #f)) diff --git a/module/mescc/mescc.scm b/module/mescc/mescc.scm index 2660a452..a49c6afa 100644 --- a/module/mescc/mescc.scm +++ b/module/mescc/mescc.scm @@ -53,6 +53,7 @@ (dir (dirname input-file-name)) (defines (reverse (filter-map (multi-opt 'define) options))) (includes (reverse (filter-map (multi-opt 'include) options))) + (includes (cons (option-ref options 'includedir #f) includes)) (includes (cons dir includes)) (prefix (option-ref options 'prefix "")) (machine (option-ref options 'machine "32")) @@ -87,9 +88,10 @@ ((.E? file-name) (E->info options file-name)))) (define (c->info options file-name) - (let* ((defines (reverse (filter-map (multi-opt 'define) options))) + (let* ((dir (dirname file-name)) + (defines (reverse (filter-map (multi-opt 'define) options))) (includes (reverse (filter-map (multi-opt 'include) options))) - (dir (dirname file-name)) + (includes (cons (option-ref options 'includedir #f) includes)) (includes (cons dir includes)) (prefix (option-ref options 'prefix "")) (defines (cons (arch-get-define options) defines)) @@ -260,7 +262,7 @@ (arch (string-append (arch-get options) "-mes")) (path (cons* "." srcdir-lib - (prefix-file options "lib") + (option-ref options 'libdir "lib") (filter-map (multi-opt 'library-dir) options))) (arch-file-name (string-append arch "/" file-name)) (verbose? (count-opt options 'verbose))) @@ -272,12 +274,6 @@ (or file (error (format #f "mescc: file not found: ~s" arch-file-name)))))) -(define (prefix-file options file-name) - (let ((prefix (option-ref options 'prefix ""))) - (define (prefix-file o) - (if (string-null? prefix) o (string-append prefix "/" o))) - (prefix-file file-name))) - (define (assert-system* . args) (let ((status (apply system* args))) (when (not (zero? status)) diff --git a/scripts/mescc.in b/scripts/mescc.in index 504b3717..777d3dbd 100644 --- a/scripts/mescc.in +++ b/scripts/mescc.in @@ -38,7 +38,11 @@ GUILE_LOAD_PATH=@guile_site_dir@${GUILE_LOAD_PATH+:}${GUILE_LOAD_PATH} export GUILE_LOAD_PATH MES=${MES-@prefix@/bin/mes} -bindir=${bindir-@bindir@/mes} +bindir=${bindir-@bindir@} +includedir=${includedir-@includedir@} +export includedir +libdir=${libdir-@libdir@} +export libdir if [ ! -f $bindir/mescc.scm ]; then bindir=$(dirname $0) diff --git a/scripts/mescc.scm.in b/scripts/mescc.scm.in index 45652842..c4719d22 100644 --- a/scripts/mescc.scm.in +++ b/scripts/mescc.scm.in @@ -24,16 +24,28 @@ (guile (define %arch (car (string-split %host-type #\-))))) -(setenv "%prefix" (or (getenv "MES_PREFIX") +(define %prefix (or (getenv "MES_PREFIX") (if (string-prefix? "@prefix" "@prefix@") "" "@prefix@"))) -(setenv "%version" (if (string-prefix? "@VERSION" "@VERSION@") "git" - "@VERSION@")) +(define %includedir (or (getenv "includedir") + (string-append %prefix "/include"))) -(setenv "%arch" (if (string-prefix? "@mes_cpu" "@mes_cpu@") %arch - "@mes_cpu@")) +(define %libdir (or (getenv "libdir") + (string-append %prefix "/lib"))) + +(define %version (if (string-prefix? "@VERSION" "@VERSION@") "git" + "@VERSION@")) + +(define %arch (if (string-prefix? "@mes_cpu" "@mes_cpu@") %arch + "@mes_cpu@")) + +(setenv "%prefix" %prefix) +(setenv "%includedir" %includedir) +(setenv "%libdir" %libdir) +(setenv "%version" %version) +(setenv "%arch" %arch) (cond-expand (mes