From a7e91e187b41c793cb2a4cb9563f31e93440c265 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 25 Apr 2012 15:00:55 +0200 Subject: Make sure `skribilo/utils/images.scm' is rebuilt after `make clean'. * configure.ac: Don't output `src/guile/skribilo/utils/images.scm'. * src/guile/Makefile.am (EXTRA_DIST): Change `images.scm.in' to `images.in'. (BUILT_SOURCES): Add `skribilo/utils/images.scm'. * src/guile/skribilo/utils/images.scm.in: Rename to... * src/guile/skribilo/utils/images.in: ... this. * substitute.am: Substitute `FIG2DEV' and `CONVERT'. --- src/guile/Makefile.am | 6 +- src/guile/skribilo/utils/images.in | 102 +++++++++++++++++++++++++++++++++ src/guile/skribilo/utils/images.scm.in | 102 --------------------------------- 3 files changed, 106 insertions(+), 104 deletions(-) create mode 100644 src/guile/skribilo/utils/images.in delete mode 100644 src/guile/skribilo/utils/images.scm.in (limited to 'src') diff --git a/src/guile/Makefile.am b/src/guile/Makefile.am index 4f18b5d..9c2c706 100644 --- a/src/guile/Makefile.am +++ b/src/guile/Makefile.am @@ -21,7 +21,7 @@ EXTRA_DIST = \ README \ skribilo/source/lisp-lex.l \ skribilo/source/xml-lex.l skribilo/source/c-lex.l \ - skribilo/utils/images.scm.in skribilo/config.in \ + skribilo/utils/images.in skribilo/config.in \ srfi/srfi-64.scm srfi/srfi-64.upstream.scm SOURCES = \ @@ -93,7 +93,9 @@ nobase_nodist_module_DATA += \ endif ENABLE_GUILE_VM -BUILT_SOURCES = skribilo/config.scm +BUILT_SOURCES = \ + skribilo/config.scm \ + skribilo/utils/images.scm .in.scm: $(substitute) "$^" > "$@.tmp" && \ diff --git a/src/guile/skribilo/utils/images.in b/src/guile/skribilo/utils/images.in new file mode 100644 index 0000000..dd0c3a0 --- /dev/null +++ b/src/guile/skribilo/utils/images.in @@ -0,0 +1,102 @@ +;;; images.scm -- Images handling utilities. +;;; +;;; Copyright 2005, 2006, 2007, 2008 Ludovic Courtès +;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI +;;; +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 2 of the License, or +;;; (at your option) any later version. +;;; +;;; This program 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 General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software +;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +;;; USA. + +(define-module (skribilo utils images) + :export (convert-image + *fig-convert-program* *generic-convert-program*) + + :autoload (skribilo utils files) (file-suffix file-prefix) + :autoload (skribilo parameters) (*image-path* *verbose*) + :autoload (skribilo condition) (&file-search-error) + :autoload (srfi srfi-34) (raise) + :use-module (srfi srfi-35) + :use-module (srfi srfi-39)) + +;;; Author: Erick Gallesio, Ludovic Courtès +;;; +;;; Commentary: +;;; +;;; This module provides convenience functions to handle image files, notably +;;; for format conversion via ImageMagick's `convert'. +;;; +;;; Code: + +(define *fig-convert-program* (make-parameter "@FIG2DEV@ -L")) +(define *generic-convert-program* (make-parameter "@CONVERT@")) + +(define (builtin-convert-image from fmt dir) + (let* ((s (file-suffix from)) + (f (string-append (file-prefix (basename from)) "." fmt)) + (to (string-append dir "/" f))) ;; FIXME: + (cond + ((string=? s fmt) + to) + ((file-exists? to) + to) + (else + (let ((c (if (string=? s "fig") + (string-append (*fig-convert-program*) " " + fmt " " from " > " to) + (string-append (*generic-convert-program*) " " + from " " to)))) + (cond + ((> (*verbose*) 1) + (format (current-error-port) " [converting image: ~S (~S)]~%" from c)) + ((> (*verbose*) 0) + (format (current-error-port) " [converting image: ~S]~%" from))) + (and (zero? (system c)) + to)))))) + +(define (convert-image file formats) + (let ((path (search-path (*image-path*) file))) + (if (not path) + (raise (condition (&file-search-error (file-name file) + (path (*image-path*))))) + (let ((suf (file-suffix file))) + (if (member suf formats) + (let* ((dir (if (string? (*destination-file*)) + (dirname (*destination-file*)) + #f))) + (if dir + (let* ((dest (basename path)) + (dest-path (string-append dir "/" dest))) + (if (and (not (string=? path dest-path)) + (not (file-exists? dest-path))) + (copy-file path dest-path)) + dest) + path)) + (let loop ((fmts formats)) + (if (null? fmts) + #f + (let* ((dir (if (string? (*destination-file*)) + (dirname (*destination-file*)) + ".")) + (p (builtin-convert-image path (car fmts) dir))) + (if (string? p) + p + (loop (cdr fmts))))))))))) + + +;;; Local Variables: +;;; coding: latin-1 +;;; End: + +;;; images.scm ends here diff --git a/src/guile/skribilo/utils/images.scm.in b/src/guile/skribilo/utils/images.scm.in deleted file mode 100644 index dd0c3a0..0000000 --- a/src/guile/skribilo/utils/images.scm.in +++ /dev/null @@ -1,102 +0,0 @@ -;;; images.scm -- Images handling utilities. -;;; -;;; Copyright 2005, 2006, 2007, 2008 Ludovic Courtès -;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI -;;; -;;; -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2 of the License, or -;;; (at your option) any later version. -;;; -;;; This program 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 General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software -;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -;;; USA. - -(define-module (skribilo utils images) - :export (convert-image - *fig-convert-program* *generic-convert-program*) - - :autoload (skribilo utils files) (file-suffix file-prefix) - :autoload (skribilo parameters) (*image-path* *verbose*) - :autoload (skribilo condition) (&file-search-error) - :autoload (srfi srfi-34) (raise) - :use-module (srfi srfi-35) - :use-module (srfi srfi-39)) - -;;; Author: Erick Gallesio, Ludovic Courtès -;;; -;;; Commentary: -;;; -;;; This module provides convenience functions to handle image files, notably -;;; for format conversion via ImageMagick's `convert'. -;;; -;;; Code: - -(define *fig-convert-program* (make-parameter "@FIG2DEV@ -L")) -(define *generic-convert-program* (make-parameter "@CONVERT@")) - -(define (builtin-convert-image from fmt dir) - (let* ((s (file-suffix from)) - (f (string-append (file-prefix (basename from)) "." fmt)) - (to (string-append dir "/" f))) ;; FIXME: - (cond - ((string=? s fmt) - to) - ((file-exists? to) - to) - (else - (let ((c (if (string=? s "fig") - (string-append (*fig-convert-program*) " " - fmt " " from " > " to) - (string-append (*generic-convert-program*) " " - from " " to)))) - (cond - ((> (*verbose*) 1) - (format (current-error-port) " [converting image: ~S (~S)]~%" from c)) - ((> (*verbose*) 0) - (format (current-error-port) " [converting image: ~S]~%" from))) - (and (zero? (system c)) - to)))))) - -(define (convert-image file formats) - (let ((path (search-path (*image-path*) file))) - (if (not path) - (raise (condition (&file-search-error (file-name file) - (path (*image-path*))))) - (let ((suf (file-suffix file))) - (if (member suf formats) - (let* ((dir (if (string? (*destination-file*)) - (dirname (*destination-file*)) - #f))) - (if dir - (let* ((dest (basename path)) - (dest-path (string-append dir "/" dest))) - (if (and (not (string=? path dest-path)) - (not (file-exists? dest-path))) - (copy-file path dest-path)) - dest) - path)) - (let loop ((fmts formats)) - (if (null? fmts) - #f - (let* ((dir (if (string? (*destination-file*)) - (dirname (*destination-file*)) - ".")) - (p (builtin-convert-image path (car fmts) dir))) - (if (string? p) - p - (loop (cdr fmts))))))))))) - - -;;; Local Variables: -;;; coding: latin-1 -;;; End: - -;;; images.scm ends here -- cgit v1.2.3