2e65000eb7e3e0c6c989fd966f85efe5bc706a22
[jackhill/guix/guix.git] / gnu / packages / xfig.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
3 ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages xfig)
21 #:use-module (guix packages)
22 #:use-module ((guix licenses) #:select (bsd-2))
23 #:use-module (guix download)
24 #:use-module (guix build-system gnu)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages xorg)
27 #:use-module (gnu packages image)
28 #:use-module (gnu packages groff)
29 #:use-module (gnu packages compression))
30
31 (define-public xfig
32 (package
33 (name "xfig")
34 (version "3.2.5c")
35 (source
36 (origin
37 (method url-fetch)
38 (uri (string-append "mirror://sourceforge/mcj/mcj-source/xfig."
39 version ".full.tar.gz"))
40 (sha256
41 (base32
42 "1yd1jclvw5w3ja4jjzr1ysbn8iklh88wq84jn9d1gavrbfbqyqpa"))))
43 (build-system gnu-build-system)
44 (native-inputs
45 `(("imake" ,imake)
46 ("makedepend" ,makedepend)
47 ("groff" ,groff))) ;for creating some doc
48 (inputs
49 `(("libxaw3d" ,libxaw3d)
50 ;; Requires libjpeg>=9a, otherwise jmorecfg.h define an enum FALSE that
51 ;; conflicts with the FALSE macro from X11/Intrinsic.h
52 ("libjpeg" ,libjpeg)
53 ("libpng" ,libpng)
54 ("libxpm" ,libxpm)
55 ("libx11" ,libx11)
56 ("libxmu" ,libxmu)
57 ("libxt" ,libxt)
58 ("zlib" ,zlib)))
59 (arguments
60 `(#:tests? #f
61 #:phases
62 (modify-phases %standard-phases
63 (replace 'configure
64 (lambda* (#:key inputs outputs #:allow-other-keys)
65 (let ((imake (assoc-ref inputs "imake"))
66 (out (assoc-ref outputs "out")))
67 (substitute* "Imakefile"
68 (("XCOMM XAPPLOADDIR = /home/user/xfig *")
69 (string-append "XAPPLOADDIR = " out ,%app-defaults-dir))
70 (("XCOMM (BINDIR = )[[:graph:]]*" _ front)
71 (string-append front out "/bin"))
72 (("(PNGLIBDIR = )[[:graph:]]*" _ front)
73 (string-append front (assoc-ref inputs "libpng") "/lib"))
74 (("(PNGINC = -I)[[:graph:]]*" _ front)
75 (string-append front (assoc-ref inputs "libpng") "/include"))
76 (("(JPEGLIBDIR = )[[:graph:]]*" _ front)
77 (string-append front (assoc-ref inputs "libjpeg") "/lib"))
78 (("(JPEGINC = -I)[[:graph:]]*" _ front)
79 (string-append front (assoc-ref inputs "libjpeg") "/include"))
80 (("(ZLIBDIR = )[[:graph:]]*" _ front)
81 (string-append front (assoc-ref inputs "zlib") "/lib"))
82 (("(XPMLIBDIR = )[[:graph:]]*" _ front)
83 (string-append front (assoc-ref inputs "libxpm") "/lib"))
84 (("(XPMINC = -I)[[:graph:]]*" _ front)
85 (string-append front (assoc-ref inputs "libxpm") "/include"))
86 (("(XFIGLIBDIR = )[[:graph:]]*" _ front)
87 (string-append front out "/lib"))
88 (("(XFIGDOCDIR = )[[:graph:]]*" _ front)
89 (string-append front out "/share/doc"))
90 (("XCOMM USEINLINE") "USEINLINE"))
91 ;; The -a argument is required in order to pick up the correct paths
92 ;; to several X header files.
93 (zero? (system* "xmkmf" "-a"))
94 ;; Reset some variables that are inherited from imake templates
95 (substitute* "Makefile"
96 ;; These imake variables somehow remain undefined
97 (("DefaultGcc2[[:graph:]]*Opt") "-O2")
98 ;; Reset a few variable defaults that are set in imake templates
99 ((imake) out)
100 (("(MANPATH = )[[:graph:]]*" _ front)
101 (string-append front out "/share/man"))
102 (("(CONFDIR = )([[:graph:]]*)" _ front default)
103 (string-append front out default))))
104 #t))
105 (add-after
106 'install 'install/libs
107 (lambda _
108 (zero? (system* "make" "install.libs"))))
109 (add-after
110 'install 'install/doc
111 (lambda _
112 (begin
113 ;; The Doc/xfig_man.html file is expected by the install.html
114 ;; target, but is not present in the tarball, so generate it.
115 (use-modules (ice-9 popen))
116 (let* ((in (open-pipe* OPEN_READ
117 "groff" "-mandoc" "-Thtml"
118 "Doc/xfig.man"))
119 (out (open-output-file "Doc/xfig_man.html")))
120 (begin
121 (dump-port in out)
122 (close-pipe in)
123 (close-port out)))
124 (zero? (system* "make" "install.doc"))))))))
125 (home-page "http://xfig.org/")
126 (synopsis "Interactive drawing tool")
127 (description
128 "Xfig is an interactive drawing tool which runs under X Window System.
129 In xfig, figures may be drawn using objects such as circles, boxes, lines,
130 spline curves, text, etc. It is also possible to import images in formats
131 such as GIF, JPEG, EPSF (PostScript), etc. Those objects can be created,
132 deleted, moved or modified. Attributes such as colors or line styles can be
133 selected in various ways. For text, 35 fonts are available.")
134 (license bsd-2)))
135
136 (define-public transfig
137 (package
138 (name "transfig")
139 (version "3.2.5e")
140 (source
141 (origin
142 (method url-fetch)
143 (uri (string-append "mirror://sourceforge/mcj/mcj-source/transfig."
144 version ".tar.gz"))
145 (sha256
146 (base32
147 "0i3p7qmg2w8qrad3pn42b0miwarql7yy0gpd49b1bpal6bqsiicf"))))
148 (build-system gnu-build-system)
149 (native-inputs
150 `(("imake" ,imake)
151 ("makedepend" ,makedepend)))
152 (inputs
153 `(("xfig" ,xfig)
154 ("libjpeg" ,libjpeg)
155 ("libpng" ,libpng)
156 ("libxpm" ,libxpm)
157 ("libx11" ,libx11)
158 ("zlib" ,zlib)))
159 (arguments
160 `(#:tests? #f
161 #:phases
162 (alist-replace
163 'configure
164 (lambda* (#:key inputs outputs #:allow-other-keys)
165 (let ((imake (assoc-ref inputs "imake"))
166 (out (assoc-ref outputs "out")))
167 (substitute* '("fig2dev/Imakefile"
168 "transfig/Imakefile")
169 (("XCOMM (BINDIR = )[[:graph:]]*" _ front)
170 (string-append front out "/bin"))
171 (("XCOMM USEINLINE") "USEINLINE")
172 ;; The variable name is deceptive. The directory is used as an
173 ;; installation path for bitmaps.
174 (("(XFIGLIBDIR =[[:blank:]]*)[[:graph:]]*" _ front)
175 (string-append front out "/lib"))
176 (("(XPMLIBDIR = )[[:graph:]]*" _ front)
177 (string-append front (assoc-ref inputs "libxpm") "/lib"))
178 (("(XPMINC = -I)[[:graph:]]*" _ front)
179 (string-append front (assoc-ref inputs "libxpm") "/include/X11"))
180 (("/usr/local/lib/fig2dev") (string-append out "/lib")))
181 ;; The -a argument is required in order to pick up the correct paths
182 ;; to several X header files.
183 (zero? (system* "xmkmf" "-a"))
184 (substitute* '("Makefile"
185 "fig2dev/Makefile"
186 "transfig/Makefile")
187 ;; These imake variables somehow remain undefined
188 (("DefaultGcc2[[:graph:]]*Opt") "-O2")
189 ;; Reset a few variable defaults that are set in imake templates
190 ((imake) out)
191 (("(MANPATH = )[[:graph:]]*" _ front)
192 (string-append front out "/share/man"))
193 (("(CONFDIR = )([[:graph:]]*)" _ front default)
194 (string-append front out default)))))
195 (alist-cons-after
196 'install 'install/doc
197 (lambda _
198 (zero? (system* "make" "install.man")))
199 %standard-phases))))
200 (home-page "http://www.xfig.org/")
201 (synopsis "Create portable LaTeX figures")
202 (description
203 "Transfig creates a makefile to translate figures described in Fig code
204 or PIC into a specified LaTeX graphics language. PIC files are identified by
205 the suffix \".pic\"; Fig files can be specified either with or without the
206 suffix \".fig\". Transfig also creates a TeX macro file appropriate to the
207 target language.")
208 (license bsd-2)))