Use html for the code block in README
[guile-gdal] / guix.scm
1 ;;; guile-gdal --- FFI bindings for GDAL
2 ;;; Copyright (c)  2021 Ahmet Artu Yildirim <ahmet@artulab.com>
3
4 ;;; Commentary:
5 ;;
6 ;; GNU Guix development package.  To build and install, run:
7 ;;
8 ;;   guix package -f guix.scm
9 ;;
10 ;; To use as the basis for a development environment, run:
11 ;;
12 ;;   guix environment -l guix.scm
13 ;;
14 ;;; Code:
15
16 (use-modules (ice-9 match)
17              (ice-9 popen)
18              (ice-9 rdelim)
19              (srfi srfi-1)
20              (srfi srfi-26)
21              (guix gexp)
22              (guix packages)
23              (guix licenses)
24              (guix git-download)
25              (guix build-system gnu)
26              ((guix build utils) #:select (with-directory-excursion))
27              (gnu packages)
28              (gnu packages autotools)
29              (gnu packages guile)
30              (gnu packages pkg-config)
31              (gnu packages geo)
32              (gnu packages texinfo))
33
34 (define %source-dir (dirname (current-filename)))
35
36 (define git-file?
37   (let* ((pipe (with-directory-excursion %source-dir
38                  (open-pipe* OPEN_READ "git" "ls-files")))
39          (files (let loop ((lines '()))
40                   (match (read-line pipe)
41                     ((? eof-object?)
42                      (reverse lines))
43                     (line
44                      (loop (cons line lines))))))
45          (status (close-pipe pipe)))
46     (lambda (file stat)
47       (match (stat:type stat)
48         ('directory #t)
49         ((or 'regular 'symlink)
50          (any (cut string-suffix? <> file) files))
51         (_ #f)))))
52
53 (package
54   (name "guile-gdal")
55   (version "0.1.0")
56   (source (local-file %source-dir  #:recursive? #t #:select? git-file?))
57   (build-system gnu-build-system)
58   (arguments
59    '(#:configure-flags 
60                  (list (string-append "--with-libgdal-path=" (assoc-ref %build-inputs "gdal") "/lib/libgdal.so"))
61      #:make-flags '("GUILE_AUTO_COMPILE=0")
62      #:phases
63      (modify-phases %standard-phases
64        (add-after 'unpack 'bootstrap
65          (lambda _ (zero? (system* "sh" "bootstrap")))))))
66   (native-inputs
67    `(("autoconf" ,autoconf)
68      ("automake" ,automake)
69      ("pkg-config" ,pkg-config)
70      ("texinfo" ,texinfo)))
71   (inputs
72    `(("guile" ,guile-2.2)
73      ("gdal" ,gdal)
74 ))
75   (synopsis "Guile bindings for GDAL")
76   (description "Guile-GDAL provides pure Guile Scheme bindings to the
77 GDAL C shared library via the foreign function interface.")
78   (home-page "https://gitlab.com/ayild/guile-gdal.git")
79   (license gpl3+))
80