1 | # $Id: octave-1.1.tcl $ |
---|
2 | # |
---|
3 | # Copyright (c) 2010 The MacPorts Project |
---|
4 | # All rights reserved. |
---|
5 | # |
---|
6 | # Redistribution and use in source and binary forms, with or without |
---|
7 | # modification, are permitted provided that the following conditions are |
---|
8 | # met: |
---|
9 | # |
---|
10 | # 1. Redistributions of source code must retain the above copyright |
---|
11 | # notice, this list of conditions and the following disclaimer. |
---|
12 | # 2. Redistributions in binary form must reproduce the above copyright |
---|
13 | # notice, this list of conditions and the following disclaimer in the |
---|
14 | # documentation and/or other materials provided with the distribution. |
---|
15 | # 3. Neither the name of The MacPorts Project nor the names of its |
---|
16 | # contributors may be used to endorse or promote products derived from |
---|
17 | # this software without specific prior written permission. |
---|
18 | # |
---|
19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
30 | # |
---|
31 | # This PortGroup automatically sets up the standard environment for |
---|
32 | # building an octave module. |
---|
33 | # |
---|
34 | # Usage: |
---|
35 | # |
---|
36 | # PortGroup octave 1.1 |
---|
37 | # octave.setup module version |
---|
38 | # |
---|
39 | # where module is the name of the module (e.g. communications) and |
---|
40 | # version is its version. |
---|
41 | |
---|
42 | options octave.module |
---|
43 | |
---|
44 | proc octave.setup {module version} { |
---|
45 | global octave.module |
---|
46 | |
---|
47 | octave.module ${module} |
---|
48 | name octave-${module} |
---|
49 | version ${version} |
---|
50 | categories math science |
---|
51 | homepage http://octave.sourceforge.net/${octave.module}/ |
---|
52 | master_sites sourceforge:octave |
---|
53 | distname ${octave.module}-${version} |
---|
54 | |
---|
55 | depends_lib path:bin/octave:octave |
---|
56 | |
---|
57 | worksrcdir ${octave.module} |
---|
58 | |
---|
59 | # octave is not universal |
---|
60 | |
---|
61 | universal_variant no |
---|
62 | |
---|
63 | # do not build in parallel; many can't, and these are small builds |
---|
64 | # anyway, so no major need for this. |
---|
65 | |
---|
66 | use_parallel_build no |
---|
67 | |
---|
68 | configure.pre_args |
---|
69 | configure.post_args |
---|
70 | |
---|
71 | livecheck.type regex |
---|
72 | livecheck.url http://octave.sourceforge.net/packages.php |
---|
73 | livecheck.regex http://downloads\\.sourceforge\\.net/octave/${octave.module}-(\\d+(\\.\\d+)*)\\.tar |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
77 | post-extract { |
---|
78 | |
---|
79 | # rename the effective worksrcdir to always be ${octave.module} |
---|
80 | |
---|
81 | set worksrcdir_name [exec /bin/ls ${workpath} | grep -v -E "^\\."] |
---|
82 | if {[string equal ${worksrcdir_name} ${octave.module}] == 0} { |
---|
83 | |
---|
84 | # work-around for case-insensitive file systems when the |
---|
85 | # extract directory name is the same as the octave module name |
---|
86 | # except for letter case; should always work no matter if the |
---|
87 | # file system is case-insensitive or case-sensitive. |
---|
88 | |
---|
89 | move ${workpath}/${worksrcdir_name} ${workpath}/tmp-${worksrcdir_name} |
---|
90 | move ${workpath}/tmp-${worksrcdir_name} ${workpath}/${octave.module} |
---|
91 | |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | configure { |
---|
96 | # In 10.8+, set the locale to "C" otherwise /usr/bin/sed can fail |
---|
97 | # with an error when processing unicode characters. |
---|
98 | |
---|
99 | set locale "" |
---|
100 | platform darwin { |
---|
101 | if {${os.major} >= 12} { |
---|
102 | set locale "-locale \"C\"" |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | # do not auto-load; like, ever. Not all files will need this, but |
---|
107 | # it's a simple catch-all. |
---|
108 | |
---|
109 | eval [subst { |
---|
110 | reinplace ${locale} "/Autoload/s@yes@no@g" ${worksrcpath}/DESCRIPTION |
---|
111 | }] |
---|
112 | |
---|
113 | # create a tarball of the resulting patched module |
---|
114 | |
---|
115 | system "cd ${workpath} && tar zcf .tmp/${octave.module}.tar.gz ${worksrcdir}" |
---|
116 | |
---|
117 | # delete the module's code since it is not used by Octave, but |
---|
118 | # remake the directory since configure (sometimes) expects it to |
---|
119 | # "cd" into for that stage. |
---|
120 | |
---|
121 | delete ${worksrcpath} |
---|
122 | xinstall -d -m 755 ${worksrcpath} |
---|
123 | |
---|
124 | } |
---|
125 | |
---|
126 | pre-build { |
---|
127 | |
---|
128 | # set parameters, now that variables are available for use |
---|
129 | |
---|
130 | build.cmd ${prefix}/bin/octave |
---|
131 | build.args -q -f --eval 'pkg build -verbose -nodeps ${worksrcpath} ${workpath}/.tmp/${octave.module}.tar.gz' |
---|
132 | build.target "" |
---|
133 | |
---|
134 | # fix usage of LAPACK_LIBS to include FLIBS, such that -lgfortran |
---|
135 | # is always paired with the appropriate -Lpath statement. |
---|
136 | |
---|
137 | build.env-append \ |
---|
138 | LAPACK_LIBS='[exec ${prefix}/bin/mkoctfile -p FLIBS] [exec ${prefix}/bin/mkoctfile -p LAPACK_LIBS]' |
---|
139 | |
---|
140 | platform darwin { |
---|
141 | if {${os.major} >= 12} { |
---|
142 | |
---|
143 | # In 10.8+, set the LC_CTYPE (locale) to "C" otherwise |
---|
144 | # /usr/bin/sed can fail with an error when processing |
---|
145 | # unicode characters. |
---|
146 | |
---|
147 | build.env-append LC_CTYPE="C" |
---|
148 | } |
---|
149 | } |
---|
150 | } |
---|
151 | |
---|
152 | destroot.keepdirs ${destroot}${prefix}/lib/octave/packages \ |
---|
153 | ${destroot}${prefix}/share/octave/packages |
---|
154 | |
---|
155 | pre-destroot { |
---|
156 | xinstall -d -m 755 ${destroot}${prefix}/lib/octave/packages |
---|
157 | xinstall -d -m 755 ${destroot}${prefix}/share/octave/packages |
---|
158 | } |
---|
159 | |
---|
160 | destroot { |
---|
161 | xinstall -m 644 ${worksrcpath}/${distname}.tar.gz ${destroot}${prefix}/share/octave/${octave.module}.tar.gz |
---|
162 | } |
---|
163 | |
---|
164 | post-deactivate { |
---|
165 | system "${prefix}/bin/octave -q -f --eval 'pkg prefix ${prefix}/share/octave/packages ${prefix}/lib/octave/packages; pkg uninstall -nodeps ${octave.module}'" |
---|
166 | system "${prefix}/bin/octave -q -f --eval 'pkg prefix ${prefix}/share/octave/packages ${prefix}/lib/octave/packages; pkg rebuild'" |
---|
167 | } |
---|
168 | |
---|
169 | post-activate { |
---|
170 | system "${prefix}/bin/octave -q -f --eval 'pkg prefix ${prefix}/share/octave/packages ${prefix}/lib/octave/packages; pkg install -verbose -global ${prefix}/share/octave/${octave.module}.tar.gz'" |
---|
171 | system "${prefix}/bin/octave -q -f --eval 'pkg prefix ${prefix}/share/octave/packages ${prefix}/lib/octave/packages; pkg rebuild'" |
---|
172 | } |
---|