6512
|
1 import os |
|
2 # |
|
3 from gub import context |
|
4 from gub import misc |
|
5 from gub import loggedos |
|
6 from gub import octal |
|
7 from gub import repository |
|
8 from gub import target |
|
9 from gub import tools |
|
10 |
|
11 class Guile (target.AutoBuild): |
|
12 # source = 'git://git.sv.gnu.org/guile.git&branch=branch_release-1-8&revision=bba579611b3671c7e4c1515b100f01c048a07935' |
|
13 source = 'http://ftp.gnu.org/pub/gnu/guile/guile-1.8.7.tar.gz' |
|
14 patches = ['guile-reloc-1.8.6.patch', |
|
15 'guile-cexp.patch', |
|
16 'guile-1.8.6-test-use-srfi.patch', |
|
17 'guile-1.8.7-doc-snarfing.patch'] |
|
18 dependencies = ['gettext-devel', 'gmp-devel', 'libtool', 'tools::guile'] |
|
19 guile_configure_flags = misc.join_lines (''' |
|
20 --without-threads |
|
21 --with-gnu-ld |
|
22 --enable-deprecated |
|
23 --enable-discouraged |
|
24 --disable-error-on-warning |
|
25 --enable-relocation |
|
26 --enable-rpath |
|
27 ''') |
|
28 configure_variables = (target.AutoBuild.configure_variables |
|
29 + misc.join_lines (''' |
|
30 CC_FOR_BUILD=" |
|
31 LD_PRELOAD= |
|
32 C_INCLUDE_PATH= |
|
33 CPPFLAGS= |
|
34 LIBRARY_PATH= |
|
35 PATH_SEPARATOR=':' |
|
36 PATH=/usr/bin:$PATH |
|
37 /usr/bin/cc |
|
38 -I%(builddir)s |
|
39 -I%(srcdir)s |
|
40 -I%(builddir)s/libguile |
|
41 -I. |
|
42 -I%(srcdir)s/libguile" |
|
43 ''')) |
|
44 # FIXME: guile runs gen_scmconfig [when not x-building also guile] |
|
45 # without setting the proper LD_LIBRARY_PATH. |
|
46 compile_flags_native = (' LD_PRELOAD= ' |
|
47 + ' LD_LIBRARY_PATH=%(tools_prefix)s/lib:${LD_LIBRARY_PATH-/foe} ' |
|
48 + ' cross_compiling=yes ') |
|
49 # FIXME: guile runs gen_scmconfig [when not x-building also guile] |
|
50 # without setting the proper LD_LIBRARY_PATH. |
|
51 configure_command = ('GUILE_FOR_BUILD=%(tools_prefix)s/bin/guile ' |
|
52 + target.AutoBuild.configure_command |
|
53 + guile_configure_flags) |
|
54 compile_command = ('preinstguile=%(tools_prefix)s/bin/guile ' |
|
55 + target.AutoBuild.compile_command) |
|
56 subpackage_names = ['doc', 'devel', 'runtime', ''] |
|
57 @staticmethod |
|
58 def version_from_VERSION (self): |
|
59 return self.version_from_shell_script ('GUILE-VERSION', |
|
60 'GUILE_MAJOR_VERSION', |
|
61 '%(GUILE_MAJOR_VERSION)s.%(GUILE_MINOR_VERSION)s.%(GUILE_MICRO_VERSION)s', |
|
62 '1.8.6') |
|
63 def __init__ (self, settings, source): |
|
64 target.AutoBuild.__init__ (self, settings, source) |
|
65 if isinstance (source, repository.Git): |
|
66 ##source.version = lambda: '1.8.6' |
|
67 source.version = misc.bind_method (Guile.version_from_VERSION, |
|
68 source) |
|
69 self.so_version = '17' |
|
70 def patch (self): |
|
71 self.dump ('''#!/bin/sh |
|
72 exec %(tools_prefix)s/bin/guile "$@" |
|
73 ''', "%(srcdir)s/pre-inst-guile.in") |
|
74 #self.autopatch () |
|
75 target.AutoBuild.patch (self) |
|
76 def autopatch (self): |
|
77 self.file_sub ([(r'AC_CONFIG_SUBDIRS\(guile-readline\)', '')], |
|
78 '%(srcdir)s/configure.in') |
|
79 self.file_sub ([(r'guile-readline', '')], |
|
80 '%(srcdir)s/Makefile.am') |
|
81 # Guile [doc] does not compile with dash *and* not with |
|
82 # librestrict-stat.so; patch out. |
|
83 if isinstance (self.source, repository.Git): |
|
84 self.file_sub ([(' doc ', ' ')], '%(srcdir)s/Makefile.am') |
|
85 self.file_sub ([('guile-readline', '')], '%(srcdir)s/Makefile.am') |
|
86 else: |
|
87 self.file_sub ([(' doc ', ' ')], '%(srcdir)s/Makefile.in') |
|
88 self.file_sub ([('guile-readline', '')], '%(srcdir)s/Makefile.in') |
|
89 self.dump ('', '%(srcdir)s/doc/ref/version.texi') |
|
90 self.dump ('', '%(srcdir)s/doc/tutorial/version.texi') |
|
91 def compile (self): |
|
92 ## Ugh: broken dependencies break parallel build with make -jX |
|
93 self.system ('cd %(builddir)s/libguile && make %(compile_flags_native)s gen-scmconfig guile_filter_doc_snarfage') |
|
94 # Remove -L %(system_root)s from `guile-config link' |
|
95 self.system ('cd %(builddir)s/libguile && make %(compile_flags_native)slibpath.h') |
|
96 self.file_sub ([('''-L *%(system_root)s''', '-L')], |
|
97 '%(builddir)s/libguile/libpath.h') |
|
98 target.AutoBuild.compile (self) |
|
99 def install (self): |
|
100 # with 1.8.7: libtool: cannot install directory not ending in... |
|
101 # after config.status is being re-run for building of libpath.h |
|
102 self.update_libtool () |
|
103 target.AutoBuild.install (self) |
|
104 majmin_version = '.'.join (self.expand ('%(version)s').split ('.')[0:2]) |
|
105 |
|
106 self.dump ("prependdir GUILE_LOAD_PATH=$INSTALLER_PREFIX/share/guile/%(majmin_version)s\n", |
|
107 '%(install_prefix)s/etc/relocate/guile.reloc', |
|
108 env=locals ()) |
|
109 version = self.expand ('%(version)s') |
|
110 #FIXME: c&p linux.py |
|
111 self.dump ('''\ |
|
112 #! /bin/sh |
|
113 test "$1" = "--version" && echo "%(target_architecture)s-guile-config - Guile version %(version)s" |
|
114 #test "$1" = "compile" && echo "-I $%(system_prefix)s/include" |
|
115 #test "$1" = "link" && echo "-L%(system_prefix)s/lib -lguile -lgmp" |
|
116 #prefix=$(dirname $(dirname $0)) |
|
117 prefix=%(system_prefix)s |
|
118 test "$1" = "compile" && echo "-I$prefix/include" |
|
119 test "$1" = "link" && echo "-L$prefix/lib -lguile -lgmp" |
|
120 test "$1" = "info" && test "$2" = "guileversion" && echo "%(version)s" |
|
121 exit 0 |
|
122 ''', |
|
123 '%(install_prefix)s%(cross_dir)s/bin/%(target_architecture)s-guile-config') |
|
124 self.chmod ('%(install_prefix)s%(cross_dir)s/bin/%(target_architecture)s-guile-config', octal.o755) |
|
125 self.system ('cd %(install_prefix)s%(cross_dir)s/bin && cp -pv %(target_architecture)s-guile-config guile-config') |
|
126 |
|
127 class Guile__mingw (Guile): |
|
128 def __init__ (self, settings, source): |
|
129 Guile.__init__ (self, settings, source) |
|
130 # Configure (compile) without -mwindows for console |
|
131 self.target_gcc_flags = '-mms-bitfields' |
|
132 dependencies = Guile.dependencies + ['regex-devel'] |
|
133 configure_flags = (Guile.configure_flags |
|
134 + ' --without-threads') |
|
135 configure_variables = (Guile.configure_variables |
|
136 .replace ("':'", "';'") |
|
137 + misc.join_lines (''' |
|
138 CFLAGS='-O2 -DHAVE_CONFIG_H=1 -I%(builddir)s' |
|
139 ''')) |
|
140 config_cache_overrides = Guile.config_cache_overrides + ''' |
|
141 scm_cv_struct_timespec=${scm_cv_struct_timespec=no} |
|
142 guile_cv_func_usleep_declared=${guile_cv_func_usleep_declared=yes} |
|
143 guile_cv_exeext=${guile_cv_exeext=} |
|
144 libltdl_cv_sys_search_path=${libltdl_cv_sys_search_path="%(system_prefix)s/lib"} |
|
145 ''' |
|
146 def configure (self): |
|
147 self.file_sub ([('''^#(LIBOBJS=".*fileblocks.*)''', r'\1')], |
|
148 '%(srcdir)s/configure') |
|
149 Guile.configure (self) |
|
150 for libtool in ['%(builddir)s/libtool']: # readline patched-out: '%(builddir)s/guile-readline/libtool']: |
|
151 self.file_sub ([('-mwindows', '')], libtool) |
|
152 def compile (self): |
|
153 ## Why the !?#@$ is .EXE only for guile_filter_doc_snarfage? |
|
154 self.system ('''cd %(builddir)s/libguile &&make %(compile_flags_native)sgen-scmconfig guile_filter_doc_snarfage.exe''') |
|
155 self.system ('cd %(builddir)s/libguile && cp guile_filter_doc_snarfage.exe guile_filter_doc_snarfage') |
|
156 Guile.compile (self) |
|
157 def install (self): |
|
158 Guile.install (self) |
|
159 # dlopen-able .la files go in BIN dir, BIN OR LIB package |
|
160 self.system ('''mv %(install_prefix)s/lib/lib*[0-9].la %(install_prefix)s/bin''') |
|
161 self.system ('''cd %(install_prefix)s/bin && cp guile.exe guile-windows.exe''') |
|
162 |
|
163 class Guile__linux (Guile): |
|
164 compile_command = ('export LD_LIBRARY_PATH=%(builddir)s/libguile/.libs:$LD_LIBRARY_PATH;' |
|
165 + Guile.compile_command) |
|
166 |
|
167 class Guile__linux__ppc (Guile__linux): |
|
168 config_cache_overrides = Guile__linux.config_cache_overrides + ''' |
|
169 guile_cv_have_libc_stack_end=no |
|
170 ''' |
|
171 |
|
172 class Guile__freebsd (Guile): |
|
173 config_cache_overrides = Guile.config_cache_overrides + ''' |
|
174 ac_cv_type_socklen_t=yes |
|
175 guile_cv_use_csqrt="no" |
|
176 ''' |
|
177 |
|
178 class Guile__darwin (Guile): |
|
179 patches = Guile.patches + ['guile-1.8.6-pthreads-cross.patch'] |
|
180 def install (self): |
|
181 Guile.install (self) |
|
182 def dylib_link (logger, fname): |
|
183 directory = os.path.split (fname)[0] |
|
184 src = os.path.basename (fname) |
|
185 dst = os.path.splitext (os.path.basename (fname))[0] + '.so' |
|
186 loggedos.symlink (logger, src, os.path.join (directory, dst)) |
|
187 self.map_locate (dylib_link, |
|
188 self.expand ('%(install_prefix)s/lib/'), |
|
189 'libguile-srfi*.dylib') |
|
190 def configure (self): |
|
191 self.file_sub ([('guile-readline', '')], |
|
192 '%(srcdir)s/Makefile.in') |
|
193 Guile.configure (self) |
|
194 |
|
195 class Guile__linux__x86 (Guile): |
|
196 patches = Guile.patches + ['guile-1.8.6-pthreads-cross.patch'] |
|
197 |
|
198 class Guile__tools (tools.AutoBuild, Guile): |
|
199 dependencies = (Guile.dependencies |
|
200 + ['autoconf', 'automake', 'gettext', 'flex', 'libtool']) |
|
201 make_flags = Guile.make_flags |
|
202 # Doing make gen-scmconfig, guile starts a configure recheck: |
|
203 # cd .. && make am--refresh |
|
204 # /bin/sh ./config.status --recheck |
|
205 # leading to |
|
206 # checking size of char... 0 |
|
207 # Great idea, let's re-check! You never know... :-) |
|
208 compile_flags_native = misc.join_lines (''' |
|
209 LD_LIBRARY_PATH=%(system_prefix)s/lib |
|
210 CFLAGS='-O2 -I%(system_prefix)s/include' |
|
211 LDFLAGS='-L%(system_prefix)s/lib %(rpath)s' |
|
212 ''') |
|
213 configure_command = ('LD_LIBRARY_PATH=%(system_prefix)s/lib:${LD_LIBRARY_PATH-/foe} ' |
|
214 + tools.AutoBuild.configure_command |
|
215 + Guile.guile_configure_flags) |
|
216 # FIXME: when configuring, guile runs binaries linked against |
|
217 # libltdl. |
|
218 # FIXME: when not x-building, guile runs gen_scmconfig, guile without |
|
219 # setting the proper LD_LIBRARY_PATH. |
|
220 compile_command = ('export LD_LIBRARY_PATH=%(builddir)s/libguile/.libs:%(system_prefix)s/lib:${LD_LIBRARY_PATH-/foe};' |
|
221 + Guile.compile_command) |
|
222 def patch (self): |
|
223 tools.AutoBuild.patch (self) |
|
224 #Guile.autopatch (self) |
|
225 def install (self): |
|
226 tools.AutoBuild.install (self) |
|
227 self.system ('cd %(install_root)s%(packaging_suffix_dir)s%(prefix_dir)s/bin && cp guile guile-1.8') |
|
228 self.file_sub ([('[(]string-join other-flags[)]', '(string-join (filter (lambda (x) (not (equal? x "-L/usr/lib"))) other-flags))')], |
|
229 '%(install_root)s%(packaging_suffix_dir)s%(prefix_dir)s/bin/guile-config', |
|
230 must_succeed=True) |