unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH devel 0/6] Parameterize the parent constraints in htmlprag & varia
@ 2021-03-05  2:14 Maxim Cournoyer
  2021-03-05  2:35 ` [PATCH devel 1/6] Revert "When using guile-3.0, compile src/md5.scm using -O0" Maxim Cournoyer
  0 siblings, 1 reply; 7+ messages in thread
From: Maxim Cournoyer @ 2021-03-05  2:14 UTC (permalink / raw)
  To: guile-devel

Hello!

The following is an attempt to upstream the various fixes accumulated
for guile-lib in the Guix code base.  Among other things, it adds
support to configure or otherwise disable the parent constraints
feature of the htmlprag tokenizer.

Thank you,

Maxim

 HACK             |  47 ++++++++++++++++
 am/guile.mk      |  14 +----
 configure.ac     |  66 +++++++++++++++++-----
 m4/guile-ext.m4  |  74 ------------------------
 src/htmlprag.scm | 143 ++++++++++++++++++++++++++++++++++-------------
 src/md5.scm      |   6 +-
 6 files changed, 208 insertions(+), 142 deletions(-)
 create mode 100644 HACK
 delete mode 100644 m4/guile-ext.m4

Christopher Baines (1):
  build: Add support for cross-compilation.

Ludovic Courtès (1):
  Work around Guile 3.0.0 miscompilation at -O2.

Maxim Cournoyer (4):
  Revert "When using guile-3.0, compile src/md5.scm using -O0"
  Add a HACK file.
  htmlprag: Allow users to parameterize the parent constraints.
  configure.ac: Standardize default installation directory.

-- 
2.30.1

Message-ID: <877dmmpc4i.fsf@gmail.com>
X-Draft-From: ("nnimap+gmail:INBOX" 191731)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH devel 1/6] Revert "When using guile-3.0, compile src/md5.scm using -O0"
  2021-03-05  2:14 [PATCH devel 0/6] Parameterize the parent constraints in htmlprag & varia Maxim Cournoyer
@ 2021-03-05  2:35 ` Maxim Cournoyer
  2021-03-05  2:35   ` [PATCH devel 2/6] Work around Guile 3.0.0 miscompilation at -O2 Maxim Cournoyer
                     ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2021-03-05  2:35 UTC (permalink / raw)
  To: guile-devel; +Cc: Maxim Cournoyer

This reverts commit 437ddcdd359ce7daccd546be0060fb71c56a71d7.  I'm
proposing to add the fix from Guix, which is simpler.
---
 am/guile.mk  | 12 +-----------
 configure.ac |  4 +---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/am/guile.mk b/am/guile.mk
index 0cc75a7..6ab0750 100644
--- a/am/guile.mk
+++ b/am/guile.mk
@@ -27,7 +27,7 @@
 
 moddir=@SITEDIR@
 godir=@SITECCACHEDIR@
-major=@GUILE_MAJOR_VERSION@
+
 
 GOBJECTS = $(SOURCES:%.scm=%.go)
 
@@ -45,16 +45,6 @@ $(guile_install_go_files): install-nobase_modDATA
 GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
 
 SUFFIXES = .scm .go
-
 .scm.go:
 	$(AM_V_GEN)$(top_builddir)/pre-inst-env \
 	$(GUILD) compile $(GUILE_WARNINGS) -o "$@" "$<"
-
-md5.go : md5.scm
-	$(AM_V_GEN)if [ "$(major)" -eq "3" ]; then				\
-	  $(top_builddir)/pre-inst-env 						\
-	  $(GUILD) compile $(GUILE_WARNINGS) -O0 -o "$@" "$<";			\
-	else									\
-	  $(top_builddir)/pre-inst-env						\
-	  $(GUILD) compile $(GUILE_WARNINGS) -o  "$@" "$<";			\
-	fi
diff --git a/configure.ac b/configure.ac
index 3547035..07be121 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@ dnl
 
 define(GUILE_LIB_CONFIGURE_COPYRIGHT,[[
 
-Copyright (C) 2016 -  2018, 2020 David Pirotte
+Copyright (C) 2016 -  2018 David Pirotte
 David Pirotte <david at altosw dot be>
 
 This file is part of Guile-Lib.
@@ -92,8 +92,6 @@ fi
 AC_SUBST([SITEDIR])
 AC_SUBST([SITECCACHEDIR])
 
-GUILE_MAJOR_VERSION=`$GUILE -c '(display (major-version))'`
-AC_SUBST(GUILE_MAJOR_VERSION)
 
 AC_CONFIG_FILES(
   [pre-inst-env],
-- 
2.30.1




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH devel 2/6] Work around Guile 3.0.0 miscompilation at -O2.
  2021-03-05  2:35 ` [PATCH devel 1/6] Revert "When using guile-3.0, compile src/md5.scm using -O0" Maxim Cournoyer
@ 2021-03-05  2:35   ` Maxim Cournoyer
  2021-03-05  2:35   ` [PATCH devel 3/6] Add a HACK file Maxim Cournoyer
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2021-03-05  2:35 UTC (permalink / raw)
  To: guile-devel; +Cc: Ludovic Courtès, Maxim Cournoyer

From: Ludovic Courtès <ludo@gnu.org>

This bug would cause the test suite to hang and fully use one CPU core
and slowly consume all the memory.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
---
 src/md5.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/md5.scm b/src/md5.scm
index c30ef2c..48dfa63 100644
--- a/src/md5.scm
+++ b/src/md5.scm
@@ -68,8 +68,10 @@ referenced C implementation into Scheme.
 
 ;; Some math basics.
 
-(define f-add +)
-(define f-ash ash)
+;; Work around miscompilation on Guile 3 at -O2:
+;; <https://bugs.gnu.org/39251>.
+(define f-add (@ (guile) +))            ;(define f-add +)
+(define f-ash (@ (guile) ash))          ;(define f-ash ash)
 
 (define (+ . args)
   (modulo (apply f-add args) #x100000000))
-- 
2.30.1




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH devel 3/6] Add a HACK file.
  2021-03-05  2:35 ` [PATCH devel 1/6] Revert "When using guile-3.0, compile src/md5.scm using -O0" Maxim Cournoyer
  2021-03-05  2:35   ` [PATCH devel 2/6] Work around Guile 3.0.0 miscompilation at -O2 Maxim Cournoyer
@ 2021-03-05  2:35   ` Maxim Cournoyer
  2021-03-05  2:35   ` [PATCH devel 4/6] htmlprag: Allow users to parameterize the parent constraints Maxim Cournoyer
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2021-03-05  2:35 UTC (permalink / raw)
  To: guile-devel; +Cc: Maxim Cournoyer

To ease the hacking experience.

* HACK: New file.
---
 HACK | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 HACK

diff --git a/HACK b/HACK
new file mode 100644
index 0000000..a7cf01e
--- /dev/null
+++ b/HACK
@@ -0,0 +1,47 @@
+Dependencies
+============
+
+To completely build the guile-lib module and its Autoconf build
+system, you will need the following package installed on your machine:
+
+* autoconf
+* automake
+* gettext
+* guile
+* pkg-config
+* texinfo
+
+If you use Guix, you can use the following to spawn an environment
+with the above dependencies:
+
+$ guix environment guile-lib --ad-hoc autoconf automake gettext texinfo
+
+Generating the build system scripts
+===================================
+
+To generate the build system script, run:
+
+$ ./autogen.sh
+
+The produced configure script can then be used to configure the
+project and 'make' to build it.
+
+Running the test suite
+======================
+
+To run the test suite, you can use:
+
+$ make check
+
+Or to run a specific test:
+
+$ make check TESTS=htmlprag.scm
+
+Trying guile-lib without installing it
+======================================
+
+To run a Guile program or command in an environment where the
+GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH have been adjusted to use
+the guile-lib checkout directly, you can do:
+
+$ ./pre-inst-env your-program and its arguments
-- 
2.30.1




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH devel 4/6] htmlprag: Allow users to parameterize the parent constraints.
  2021-03-05  2:35 ` [PATCH devel 1/6] Revert "When using guile-3.0, compile src/md5.scm using -O0" Maxim Cournoyer
  2021-03-05  2:35   ` [PATCH devel 2/6] Work around Guile 3.0.0 miscompilation at -O2 Maxim Cournoyer
  2021-03-05  2:35   ` [PATCH devel 3/6] Add a HACK file Maxim Cournoyer
@ 2021-03-05  2:35   ` Maxim Cournoyer
  2021-03-05  2:35   ` [PATCH devel 5/6] build: Add support for cross-compilation Maxim Cournoyer
  2021-03-05  2:35   ` [PATCH devel 6/6] configure.ac: Standardize default installation directory Maxim Cournoyer
  4 siblings, 0 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2021-03-05  2:35 UTC (permalink / raw)
  To: guile-devel; +Cc: Maxim Cournoyer

These constraints are used to make the tokenizer more lenient in the
face of incomplete/invalid HTML; unfortunately it causes valid HTML to
be parsed incorrectly.  This change allows users to parameterize the
alist that defines which elements are treated specially via the
%PARENT-CONSTRAINTS parameter, or to disable the pragmatic behavior
completely via the %STRICT-TOKENIZER? parameter or the STRICT?
keyword argument of the HTML->SXML procedure (and its variants).

* src/htmlprag.scm: Update doc.
(%default-parent-constraints): New variable.
(%parent-constraints): New parameter.
(%strict-tokenizer?): Likewise.
(parse-html/tokenizer)[strict?]: New keyword argument.  Adjust to use
the newly added parameters and argument.
(htmlprag-internal:parse-html)[strict?]: New argument.
(test-htmlprag): Add tests.
(html->sxml-0nf, html->sxml-1nf, html->sxml-2nf)[strict?]: New argument.
---
 src/htmlprag.scm | 143 ++++++++++++++++++++++++++++++++++-------------
 1 file changed, 104 insertions(+), 39 deletions(-)

diff --git a/src/htmlprag.scm b/src/htmlprag.scm
index 3bd352b..79a7b2f 100644
--- a/src/htmlprag.scm
+++ b/src/htmlprag.scm
@@ -1,6 +1,7 @@
 ;; (htmlprag) -- pragmatic parsing of real-world HTML
 ;; Copyright (C) 2003-2004 Neil W. Van Dyke <neil at neilvandyke.org>
 ;; Modified 2004 by Andy Wingo to fit in with guile-lib.
+;; Modified 2021 by Maxim Cournoyer to parameterize the parent constraints.
 
 ;; This program is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU Lesser General Public License as
@@ -39,7 +40,12 @@
 ;;; defeat a strict or validating parser.  HtmlPrag's handling of errors is
 ;;; intended to generally emulate popular Web browsers' interpretation of the
 ;;; structure of erroneous HTML.  We euphemistically term this kind of parse
-;;; ``pragmatic.''
+;;; ``pragmatic.''  To disable the pragmatic behavior and parse HTML more
+;;; rigidly, the @code{%strict-tokenizer?} parameter can be set to
+;;; @code{#true}.  In this mode of operation, one ended HTML tags will not be
+;;; treated specially, for example, and their content will be coalesced.  On
+;;; the other side, valid HTML will parse more accurately.  When working with
+;;; HTML known to be valid, it makes sense to use this mode of operation.
 ;;;
 ;;; HtmlPrag also has some support for [XHTML], although XML namespace
 ;;; qualifiers [XML-Names] are currently accepted but stripped from the
@@ -1076,6 +1082,48 @@
 ;;; input port.  This procedure is used internally, and generally should not be
 ;;; called directly.
 
+;;; The alist below defines constraints about what possible parents a
+;;; tag may have.  This exists to allow parsing malformed HTML, e.g.,
+;;; in the presence of missing closing tags.  The drawback is that
+;;; this restricts where these tags may nested; for example, the
+;;; following HTML fragment
+;;; "<body><blockquote><p>foo</p>\n</blockquote></body>" parses to
+;;; '(*TOP* (body (blockquote) (p "foo") "\n")), which incorrectly
+;;; forces the 'p' tag to be a child of 'body' rather than of
+;;; 'blockquote'.
+(define %default-parent-constraints
+  '((area     . (map))
+    (body     . (html))
+    (caption  . (table))
+    (colgroup . (table))
+    (dd       . (dl))
+    (dt       . (dl))
+    (frame    . (frameset))
+    (head     . (html))
+    (isindex  . (head))
+    (li       . (dir menu ol ul))
+    (meta     . (head))
+    (noframes . (frameset))
+    (option   . (select))
+    (p        . (body td th))
+    (param    . (applet))
+    (tbody    . (table))
+    (td       . (tr))
+    (th       . (tr))
+    (thead    . (table))
+    (title    . (head))
+    (tr       . (table tbody thead))))
+
+;;; The following parameter enables users to parameterize which
+;;; constraints to use when tokenizing HTML.
+(define %parent-constraints (make-parameter %default-parent-constraints))
+
+;;; The following switch is disabled for historical reasons.  When true,
+;;; it disables the use of the above %parent-constraints parameter.
+;;; TODO: Set to #true when bumping the major version, which is a
+;;; better default in modern times, where most HTML is valid.
+(define %strict-tokenizer? (make-parameter #false))
+
 (define parse-html/tokenizer
   ;; TODO: Document the algorithm, then see if rewriting as idiomatic Scheme
   ;;       can make it more clear.
@@ -1084,32 +1132,9 @@
             ;;       acceptable way to parse old HTML that uses the `p' element
             ;;       as a paragraph terminator.
             htmlprag-internal:empty-elements)
-           (parent-constraints
-            ;; TODO: Maybe make this an option.
-            '((area     . (map))
-              (body     . (html))
-              (caption  . (table))
-              (colgroup . (table))
-              (dd       . (dl))
-              (dt       . (dl))
-              (frame    . (frameset))
-              (head     . (html))
-              (isindex  . (head))
-              (li       . (dir menu ol ul))
-              (meta     . (head))
-              (noframes . (frameset))
-              (option   . (select))
-              (p        . (body td th))
-              (param    . (applet))
-              (tbody    . (table))
-              (td       . (tr))
-              (th       . (tr))
-              (thead    . (table))
-              (title    . (head))
-              (tr       . (table tbody thead))))
            (start-tag-name (lambda (tag-token) (car tag-token)))
            (end-tag-name   (lambda (tag-token) (list-ref tag-token 1))))
-    (lambda (tokenizer normalized?)
+    (lambda* (tokenizer normalized? #:key (strict? 'unset))
       ;; Example `begs' value:
       ;;
       ;; ( ((head ...) . ( (title ...)                         ))
@@ -1169,7 +1194,14 @@
                            (add-to-current-beg tok))
                           ((eqv? kind shtml-start-symbol)
                            (let* ((name (start-tag-name tok))
-                                  (cell (assq name parent-constraints)))
+                                  ;; If STRICT? is a boolean, it means the
+                                  ;; user explicitly provided it, in which
+                                  ;; case it takes precedence over the
+                                  ;; %strict-tokenizer? parameter.
+                                  (cell (and (not (if (boolean? strict?)
+                                                      strict?
+                                                      (%strict-tokenizer?)))
+                                             (assq name (%parent-constraints)))))
                              (and cell (finish-begs-upto (cdr cell) begs))
                              (add-to-current-beg tok)
                              (or (memq name empty-elements)
@@ -1207,7 +1239,7 @@
 ;; variants, and should not be used directly by programs.  The interface is
 ;; likely to change in future versions of HtmlPrag.
 
-(define (htmlprag-internal:parse-html input normalized? top?)
+(define (htmlprag-internal:parse-html input normalized? top? strict?)
   (let ((parse
          (lambda ()
            (parse-html/tokenizer
@@ -1219,15 +1251,16 @@
                           "invalid input type"
                           input)))
              normalized?)
-            normalized?))))
+            normalized?
+            #:strict? strict?))))
     (if top?
         (cons shtml-top-symbol (parse))
         (parse))))
 
-;;; @defproc  html->sxml-0nf input
-;;; @defprocx html->sxml-1nf input
-;;; @defprocx html->sxml-2nf input
-;;; @defprocx html->sxml     input
+;;; @defproc  html->sxml-0nf input strict?
+;;; @defprocx html->sxml-1nf input strict?
+;;; @defprocx html->sxml-2nf input strict?
+;;; @defprocx html->sxml     input strict?
 ;;;
 ;;; Permissively parse HTML from @var{input}, which is either an input port or
 ;;; a string, and emit an SHTML equivalent or approximation.  To borrow and
@@ -1257,7 +1290,15 @@
 ;;; Note that in the emitted SHTML the text token @code{"still < bold"} is
 ;;; @emph{not} inside the @code{b} element, which represents an unfortunate
 ;;; failure to emulate all the quirks-handling behavior of some popular Web
-;;; browsers.
+;;; browsers.  When correctness is preferred over pragmatism, the
+;;; @code{%strict-tokenizer?} parameter can be set to true.  In the above
+;;; example, the unbound elements would nested, but valid HTML would parse
+;;; correctly, without the parsing quirk mentioned above.  Alternatively, the
+;;; @code{strict?} keyword argument can be set to true, in which case it takes
+;;; precedence over the value of the @code{%strict-tokenizer?} parameter.
+;;; Finally, the %parent-constraints parameter can also be used to customize
+;;; which elements should be treated specially, when operating in the default
+;;; pragmatic mode.
 ;;;
 ;;; The procedures @code{html->sxml-@var{n}nf} for @var{n} 0 through 2
 ;;; correspond to 0th through 2nd normal forms of SXML as specified in [SXML],
@@ -1267,9 +1308,12 @@
 ;;; @code{html->sxml-0nf}, and can be used in scripts and interactively, when
 ;;; terseness is important and any normal form of SXML would suffice.
 
-(define (html->sxml-0nf input) (htmlprag-internal:parse-html input #f #t))
-(define (html->sxml-1nf input) (htmlprag-internal:parse-html input #f #t))
-(define (html->sxml-2nf input) (htmlprag-internal:parse-html input #t #t))
+(define* (html->sxml-0nf input #:key (strict? 'unset))
+  (htmlprag-internal:parse-html input #f #t strict?))
+(define* (html->sxml-1nf input #:key (strict? 'unset))
+  (htmlprag-internal:parse-html input #f #t strict?))
+(define* (html->sxml-2nf input #:key (strict? 'unset))
+  (htmlprag-internal:parse-html input #t #t strict?))
 
 (define html->sxml  html->sxml-0nf)
 (define html->shtml html->sxml-0nf)
@@ -1660,7 +1704,7 @@
 ;;; @defproc test-htmlprag
 ;;;
 ;;; Run the test suite.  A log will be printed to the default output port.
-;;; Returns true iff all tests pass.
+;;; Returns true if all tests pass.
 
 (define (test-htmlprag)
   (letrec ((passed      0)
@@ -1708,10 +1752,10 @@
                                 (display ";;  ")
                                 (write expected)
                                 (newline))))))
-           (t1 (lambda (input expected)
+           (t1 (lambda* (input expected #:key (strict? 'unset))
                  (test html->shtml
                        'html->shtml
-                       (list input)
+                       (list input #:strict? strict?)
                        (cons shtml-top-symbol expected))))
            (t2 (lambda (input expected)
                  (test shtml->html
@@ -2019,6 +2063,20 @@
          "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
          " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"))
 
+    (parameterize ((%strict-tokenizer? #true))
+      ;; When using the strict tokenizer mode, the 'p' tag is correctly parsed
+      ;; as a child of blockquote.
+      (t1 "<body><blockquote><p>foo</p>\n</blockquote></body>"
+          '((body (blockquote (p "foo") "\n"))))
+      ;; Ensure the strict? argument takes precedence over %strict-tokenizer?.
+      (t1 "<body><blockquote><p>foo</p>\n</blockquote></body>"
+          '((body (blockquote) (p "foo") "\n"))
+          #:strict? #false)
+      ;; In strict tokenizer mode, missing closing tags are not handled
+      ;; specially.
+      (t1 "<body><blockquote><p>foo\n</blockquote></body>"
+          '((body (blockquote (p "foo\n"))))))
+
     ;; TODO: Write more test cases for HTML encoding.
 
     ;; TODO: Document this.
@@ -2213,6 +2271,9 @@ shtml-entity-value
 make-html-tokenizer
 tokenize-html
 shtml-token-kind
+%default-parent-constraints
+%parent-constraints
+%strict-tokenizer?
 parse-html/tokenizer
 html->sxml-0nf
 html->sxml-1nf
@@ -2227,3 +2288,7 @@ test-htmlprag
 )
 ;;; arch-tag: 491d7e61-5690-4b76-bc8f-d70315c10ed5
 ;;; htmlprag.scm ends here
+
+;; Local Variables:
+;; fill-column: 78
+;; End:
-- 
2.30.1




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH devel 5/6] build: Add support for cross-compilation.
  2021-03-05  2:35 ` [PATCH devel 1/6] Revert "When using guile-3.0, compile src/md5.scm using -O0" Maxim Cournoyer
                     ` (2 preceding siblings ...)
  2021-03-05  2:35   ` [PATCH devel 4/6] htmlprag: Allow users to parameterize the parent constraints Maxim Cournoyer
@ 2021-03-05  2:35   ` Maxim Cournoyer
  2021-03-05  2:35   ` [PATCH devel 6/6] configure.ac: Standardize default installation directory Maxim Cournoyer
  4 siblings, 0 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2021-03-05  2:35 UTC (permalink / raw)
  To: guile-devel; +Cc: Maxim Cournoyer

From: Christopher Baines <mail@cbaines.net>

This enables cross-compiling for systems different than the build
machine.

* configure.ac (GUILE_TARGET): New variable.
* am/guile.mk (.scm.go): Use it.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
---
 am/guile.mk  | 2 +-
 configure.ac | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/am/guile.mk b/am/guile.mk
index 6ab0750..11cd250 100644
--- a/am/guile.mk
+++ b/am/guile.mk
@@ -47,4 +47,4 @@ GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
 SUFFIXES = .scm .go
 .scm.go:
 	$(AM_V_GEN)$(top_builddir)/pre-inst-env \
-	$(GUILD) compile $(GUILE_WARNINGS) -o "$@" "$<"
+	$(GUILD) compile $(GUILE_WARNINGS) $(GUILE_TARGET) -o "$@" "$<"
diff --git a/configure.ac b/configure.ac
index 07be121..da741ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,11 @@ GUILE_GLOBAL_SITE_DIR
 GUILE_SITE_CCACHE_DIR
 GUILE_FLAGS
 
+dnl This argument is passed to guild; it ensures cross-compiling uses
+dnl the right target.
+if test -n "$host_alias"; then
+   AC_SUBST([GUILE_TARGET], [--target=$host_alias])
+fi
 
 AC_ARG_WITH(
   [guile-site],
-- 
2.30.1




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH devel 6/6] configure.ac: Standardize default installation directory.
  2021-03-05  2:35 ` [PATCH devel 1/6] Revert "When using guile-3.0, compile src/md5.scm using -O0" Maxim Cournoyer
                     ` (3 preceding siblings ...)
  2021-03-05  2:35   ` [PATCH devel 5/6] build: Add support for cross-compilation Maxim Cournoyer
@ 2021-03-05  2:35   ` Maxim Cournoyer
  4 siblings, 0 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2021-03-05  2:35 UTC (permalink / raw)
  To: guile-devel; +Cc: Maxim Cournoyer

And add a new --with-guile-site-dir option that allows specifying an
exact location explicitly.  Also add a --with-versioned-site-dir
option that appends the effective Guile version to the default site
directory when set to 'yes'.

* m4/guile-ext.m4: Remove file.
* configure.ac (GUILE_GLOBAL_SITE_DIR, GUILE_SITE_CCACHE_DIR): Remove
macro uses.  Adjust to use the GUILE_SITE and GUILE_SITE_CCACHE
variables defined by the GUILE_SITE_DIR macro from guile.m4.  The
default SITEDIR and SITECCACHEDIR values now match the more standard
layout suggested in the Guile Reference manual.  It's now also
possible to have the default SITEDIR versioned.
[--with-guile-site-dir]: New option to specify an exact site
installation directory.  Add it to the notice message.
---
 configure.ac    | 57 +++++++++++++++++++++++++++++--------
 m4/guile-ext.m4 | 74 -------------------------------------------------
 2 files changed, 45 insertions(+), 86 deletions(-)
 delete mode 100644 m4/guile-ext.m4

diff --git a/configure.ac b/configure.ac
index da741ba..dd5e91c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,6 +8,7 @@ define(GUILE_LIB_CONFIGURE_COPYRIGHT,[[
 
 Copyright (C) 2016 -  2018 David Pirotte
 David Pirotte <david at altosw dot be>
+Copyright (C) 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 
 This file is part of Guile-Lib.
 
@@ -63,8 +64,6 @@ dnl dependency version to 2.0.12 [or higher], because it has texinfo
 dnl patches so 'make check' pass.
 GUILE_PROGS([2.0.12])
 GUILE_SITE_DIR
-GUILE_GLOBAL_SITE_DIR
-GUILE_SITE_CCACHE_DIR
 GUILE_FLAGS
 
 dnl This argument is passed to guild; it ensures cross-compiling uses
@@ -78,22 +77,54 @@ AC_ARG_WITH(
   [AS_HELP_STRING(
      [--with-guile-site],
      [install source modules and compiled files using Guile's site and site-ccache dirs])],
-  [case "x$withval" in
-     xyes)
-     guile_site="yes";;
+  [case "$withval" in
+     yes)
+     guile_site=yes;;
      *)
-     guile_site="no";;
+     guile_site=no;;
    esac],
   [guile_site="no"])
 AC_SUBST([guile_site])
 
-if test "x$guile_site" = "xyes"; then
-   SITEDIR="$GUILE_GLOBAL_SITE";
-   SITECCACHEDIR="$GUILE_SITE_CCACHE";
+AC_ARG_WITH(
+  [guile-site-dir],
+  [AS_HELP_STRING(
+     [--with-guile-site-dir],
+     [install source modules to the provided directory])],
+  [guile_site_dir=$withval],
+  [guile_site_dir=""])
+AC_SUBST([guile_site_dir])
+
+AC_ARG_WITH(
+  [versioned-site-dir],
+  [AS_HELP_STRING(
+     [--with-versioned-site-dir],
+     [append the effective version of Guile to the default site directory])],
+  [case "$withval" in
+     yes)
+     versioned_site_dir=yes;;
+     *)
+     versioned_site_dir=no;;
+   esac],
+  [versioned_site_dir=no])
+AC_SUBST([versioned_site_dir])
+
+if test "$guile_site" = "yes"; then
+   SITEDIR=$GUILE_SITE
+   SITECCACHEDIR=$GUILE_SITE_CCACHE
 else
-   SITEDIR="$datadir/guile-lib";
-   SITECCACHEDIR="$libdir/guile-lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache";
+dnl These are the default values.
+   SITEDIR=$datadir/guile/site
+   test "$versioned_site_dir" = yes && SITEDIR+=/$GUILE_EFFECTIVE_VERSION
+   SITECCACHEDIR=$libdir/guile/$GUILE_EFFECTIVE_VERSION/site-ccache
 fi
+
+dnl Process guile_site_dir here, so that it takes precedence over any
+dnl other value.
+if test "$guile_site_dir" != ""; then
+   SITEDIR=$guile_site_dir
+fi
+
 AC_SUBST([SITEDIR])
 AC_SUBST([SITECCACHEDIR])
 
@@ -122,7 +153,9 @@ AC_MSG_NOTICE(
   [datarootdir=$datarootdir]
   [datadir=$datadir]
   []
-  [--with-guile-site="$guile_site"]
+  [--with-guile-site=$guile_site]
+  [--with-guile-site-dir=${guile_site_dir:-unspecified}]
+  [--with-versioned-site-dir=${versioned_site_dir}]
   []
   [sitedir (source code): ${SITEDIR}]
   [siteccachedir (compiled modules): ${SITECCACHEDIR}]
diff --git a/m4/guile-ext.m4 b/m4/guile-ext.m4
deleted file mode 100644
index 9eebcc5..0000000
--- a/m4/guile-ext.m4
+++ /dev/null
@@ -1,74 +0,0 @@
-## Autoconf macros for working with Guile.
-
-##   Copyright (C) 2017 Free Software Foundation, Inc.
-
-## This library is free software; you can redistribute it and/or
-## modify it under the terms of the GNU Lesser General Public License
-## as published by the Free Software Foundation; either version 3 of
-## the License, or (at your option) any later version.
-
-## This library is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## Lesser General Public License for more details.
-
-## You should have received a copy of the GNU Lesser General Public
-## License along with this library; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-## 02110-1301 USA
-
-# serial 10
-
-## Index
-## -----
-
-## GUILE_GLOBAL_SITE_DIR -- find path to Guile "global site" directory
-## GUILE_SITE_CCACHE_DIR -- find path to Guile "site-ccache" directory
-
-## Code
-## ----
-
-
-# GUILE_GLOBAL_SITE_DIR -- find path to Guile global site directory
-#
-# Usage: GUILE_GLOBAL_SITE_DIR
-#
-# This looks for Guile's global site directory, usually something like
-# PREFIX/share/guile/site, and sets var @var{GUILE_GLOBAL_SITE} to the
-# path.  Note that the var name is different from the macro name.
-#
-# The variable is marked for substitution, as by @code{AC_SUBST}.
-#
-AC_DEFUN([GUILE_GLOBAL_SITE_DIR],
- [AC_REQUIRE([GUILE_PROGS])
-  AC_MSG_CHECKING(for Guile global site directory)
-  GUILE_GLOBAL_SITE=`$GUILE -c "(display (%global-site-dir))"`
-  if test "$GUILE_GLOBAL_SITE" = ""; then
-     AC_MSG_FAILURE(global site dir not found)
-  fi
-  AC_MSG_RESULT($GUILE_GLOBAL_SITE)
-  AC_SUBST(GUILE_GLOBAL_SITE)
- ])
-
-
-# GUILE_SITE_CCACHE_DIR -- find path to Guile "site-ccache" directory
-#
-# Usage: GUILE_SITE_CCACHE_DIR
-#
-# This looks for Guile's "site-ccache" directory, usually something
-# like PREFIX/lib/guile/GUILE_EFFECTIVE_VERSION/site-ccache, and sets
-# var @var{GUILE_SITE_CCACHE} to the path.  Note that the var name is
-# different from the macro name.
-#
-# The variable is marked for substitution, as by @code{AC_SUBST}.
-#
-AC_DEFUN([GUILE_SITE_CCACHE_DIR],
- [AC_REQUIRE([GUILE_PROGS])
-  AC_MSG_CHECKING(for Guile site ccache directory)
-  GUILE_SITE_CCACHE=`$GUILE -c "(display (%site-ccache-dir))"`
-  if test "$GUILE_SITE_CCACHE" = ""; then
-     AC_MSG_FAILURE(site ccache dir not found)
-  fi
-  AC_MSG_RESULT($GUILE_SITE_CCACHE)
-  AC_SUBST(GUILE_SITE_CCACHE)
- ])
-- 
2.30.1




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-05  2:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05  2:14 [PATCH devel 0/6] Parameterize the parent constraints in htmlprag & varia Maxim Cournoyer
2021-03-05  2:35 ` [PATCH devel 1/6] Revert "When using guile-3.0, compile src/md5.scm using -O0" Maxim Cournoyer
2021-03-05  2:35   ` [PATCH devel 2/6] Work around Guile 3.0.0 miscompilation at -O2 Maxim Cournoyer
2021-03-05  2:35   ` [PATCH devel 3/6] Add a HACK file Maxim Cournoyer
2021-03-05  2:35   ` [PATCH devel 4/6] htmlprag: Allow users to parameterize the parent constraints Maxim Cournoyer
2021-03-05  2:35   ` [PATCH devel 5/6] build: Add support for cross-compilation Maxim Cournoyer
2021-03-05  2:35   ` [PATCH devel 6/6] configure.ac: Standardize default installation directory Maxim Cournoyer

unofficial mirror of guile-devel@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-devel/0 guile-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-devel guile-devel/ https://yhetil.org/guile-devel \
		guile-devel@gnu.org
	public-inbox-index guile-devel

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.devel
	nntp://news.gmane.io/gmane.lisp.guile.devel


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git