source: macports-ports/_resources/port1.0/group/octave-1.0.tcl

Last change on this file was c814cd7eccc2e7c8c7ccd46fa5420cbfc2b017e6, checked in by Schamschula (Marius Schamschula), 13 months ago

octave PG: comment out and move unneeded line

  • Property mode set to 100644
File size: 9.9 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2#
3# This PortGroup automatically sets up the standard environment for
4# building an octave module.
5#
6# Usage:
7#
8#   PortGroup               octave 1.0
9#   octave.module           module
10#
11# where module is the name of the module (e.g. communications)
12
13options octave.module octave.config_h
14
15# do not use this option unless absolutely necessary
16# see comments below
17# this should eventually be removed
18default octave.config_h {no}
19
20# some header files from Octave require C++-11
21PortGroup cxx11 1.1
22# overrule cxx11 PortGroup because octave can use GCC compilers for Fortran
23#    even if configure.cxx_stdlib is libc++
24compiler.blacklist-delete *gcc*
25
26# override universal_setup found in portutil.tcl so it uses muniversal PortGroup
27# see https://trac.macports.org/ticket/51643
28proc universal_setup {args} {
29    if {[variant_exists universal]} {
30        ui_debug "universal variant already exists, so not adding the default one"
31    } elseif {[exists universal_variant] && ![option universal_variant]} {
32        ui_debug "universal_variant is false, so not adding the default universal variant"
33    } elseif {[exists use_xmkmf] && [option use_xmkmf]} {
34        ui_debug "using xmkmf, so not adding the default universal variant"
35    } elseif {![exists os.universal_supported] || ![option os.universal_supported]} {
36        ui_debug "OS doesn't support universal builds, so not adding the default universal variant"
37    } elseif {[llength [option supported_archs]] == 1} {
38        ui_debug "only one arch supported, so not adding the default universal variant"
39    } else {
40        ui_debug "adding universal variant via PortGroup muniversal"
41        uplevel "PortGroup muniversal 1.0"
42        uplevel "default universal_archs_supported {i386 x86_64}"
43    }
44}
45
46proc octave.setup {module version} {
47    global octave.module
48    octave.module               ${module}
49    version                     ${version}
50}
51
52option_proc octave.module octave.set_module
53proc octave.set_module {opt action args} {
54    global octave.module
55    if {$action eq "set"} {
56        name     octave-${octave.module}
57        homepage https://octave.sourceforge.io/${octave.module}/
58    }
59}
60
61default categories   "math science"
62default master_sites {sourceforge:octave}
63default distname     {${octave.module}-${version}}
64default worksrcdir   {${octave.module}}
65# do not build in parallel; many can't, and these are small builds
66# anyway, so no major need for this.
67default use_parallel_build {no}
68default livecheck.type     {regex}
69default livecheck.url      {https://octave.sourceforge.io/${octave.module}/}
70default livecheck.regex    {"package=${octave.module}-(\\\\d+(.\\\\d+)*)"}
71
72depends_lib-append   path:bin/octave:octave
73# do not force all Portfiles to switch from depends_lib to depends_lib-append
74proc octave.add_dependencies {} {
75    depends_lib-delete path:bin/octave:octave
76    depends_lib-append path:bin/octave:octave
77}
78port::register_callback octave.add_dependencies
79
80# configure_make.m calls "make --jobs n ..."
81# use environmental variable to set the number of jobs to 1
82# parallel build is a problem for octave-optiminterp
83configure.env-append OMP_NUM_THREADS=1
84# do not force all Portfiles to switch from configure.env to configure.env-append
85proc octave.add_env {} {
86    global configure.cxx
87
88    configure.env-delete OMP_NUM_THREADS=1
89    configure.env-append OMP_NUM_THREADS=1
90
91    # Octave defaults to compilers used to build it
92    # see https://trac.macports.org/ticket/57419
93    configure.env-delete LD_CXX=${configure.cxx}
94    configure.env-append LD_CXX=${configure.cxx}
95
96    configure.env-delete DL_LD=${configure.cxx}
97    configure.env-append DL_LD=${configure.cxx}
98}
99port::register_callback octave.add_env
100
101post-extract {
102    # rename the effective worksrcdir to always be ${octave.module}
103
104    if {[exec /bin/ls ${workpath} | grep -v -E "^\\." | awk "END \{print NR\}"] == 2} {
105        delete ${workpath}/${octave.module}
106        move [glob ${workpath}/*-${version}] ${workpath}/${octave.module}
107    }
108#     set worksrcdir_name [exec /bin/ls ${workpath} | grep -v -E "^\\."]
109#     if {[string equal ${worksrcdir_name} ${octave.module}] == 0} {
110#         # work-around for case-insensitive file systems when the
111#         # extract directory name is the same as the octave module name
112#         # except for letter case; should always work no matter if the
113#         # file system is case-insensitive or case-sensitive.
114#
115#         move ${workpath}/${worksrcdir_name} ${workpath}/tmp-${worksrcdir_name}
116#         move ${workpath}/tmp-${worksrcdir_name} ${workpath}/${octave.module}
117#     }
118}
119
120configure.universal_args-delete --disable-dependency-tracking
121
122pre-configure {
123
124    set tar [findBinary tar ${portutil::autoconf::tar_path}]
125    system -W ${workpath} "${tar} cvfz ${distname}.tar.gz ${octave.module}"
126
127    if { [variant_exists universal] && [variant_isset universal] } {
128        global merger_configure_env
129        global merger_configure_args
130
131        foreach arch ${universal_archs_supported} {
132            lappend merger_configure_env(${arch}) \
133                OCTAVE_ARCH=${arch}
134        }
135
136        foreach arch ${universal_archs_supported} {
137            set merger_configure_args(${arch}) \
138                "'try; pkg build -verbose -nodeps ${workpath}/tmp-build-${arch} ${workpath}/${distname}.tar.gz; catch; disp(lasterror.message); exit(1); end_try_catch;'"
139        }
140
141    } else {
142        configure.env-append OCTAVE_ARCH=${build_arch}
143        configure.args \
144            "'try; pkg build -verbose -nodeps ${workpath}/tmp-build ${workpath}/${distname}.tar.gz; catch; disp(lasterror.message); exit(1); end_try_catch;'"
145
146        # fortran arch flag is not set automatically
147        if {${build_arch} eq "x86_64" || ${build_arch} eq "ppc64"} {
148            configure.fflags-append -m64
149        } else {
150            configure.fflags-append -m32
151        }
152    }
153
154    configure.cmd /usr/bin/arch -arch \$OCTAVE_ARCH ${prefix}/bin/octave-cli
155
156    configure.pre_args -q -f -H --eval
157    configure.post_args
158
159    configure.cxxflags-append -std=c++11
160}
161
162build {}
163
164pre-destroot {
165    set octave_api_version [exec "${prefix}/bin/octave-config" -p API_VERSION]
166
167    destroot.cmd /usr/bin/arch -arch \$OCTAVE_ARCH ${prefix}/bin/octave-cli
168    destroot.pre_args -q -f -H --eval
169
170    if { ${os.arch} eq "i386" } {
171        if { ${os.major} >= 9 && [sysctl hw.cpu64bit_capable] == 1 } {
172            set short_host_name x86_64-apple-${os.platform}${os.major}.x.x
173        } else {
174            set short_host_name i686-apple-${os.platform}${os.major}.x.x
175        }
176    } else {
177        if { ${os.major} >= 9 && [sysctl hw.cpu64bit_capable] == 1 } {
178            set short_host_name powerpc64-apple-${os.platform}${os.major}.x.x
179        } else {
180            set short_host_name powerpc-apple-${os.platform}${os.major}.x.x
181        }
182    }
183
184    if { [variant_exists universal] && [variant_isset universal] } {
185        global merger_destroot_env
186        global merger_destroot_args
187
188        foreach arch ${universal_archs_supported} {
189            set octave_install_share ${destroot}-${arch}${prefix}/share/octave/packages
190            set octave_install_lib   ${destroot}-${arch}${prefix}/lib/octave/packages
191            set octave_tgz_file ${workpath}/tmp-build-${arch}/[exec /bin/ls ${workpath}/tmp-build-${arch}]
192
193            lappend merger_destroot_env(${arch}) \
194                OCTAVE_ARCH=${arch}
195
196            destroot.args
197
198            set merger_destroot_args(${arch}) \
199                "'try;pkg prefix ${octave_install_share} ${octave_install_lib}; pkg install -verbose -nodeps -local ${octave_tgz_file}; delete(\"~/.octave_packages\"); catch; disp(lasterror.message); exit(1); end_try_catch;'"
200        }
201
202    } else {
203        set octave_install_share ${destroot}${prefix}/share/octave/packages
204        set octave_install_lib   ${destroot}${prefix}/lib/octave/packages
205        set octave_tgz_file ${workpath}/tmp-build/[exec /bin/ls ${workpath}/tmp-build]
206
207        destroot.env-append OCTAVE_ARCH=${build_arch}
208
209        destroot.args \
210            "'try; pkg prefix ${octave_install_share} ${octave_install_lib}; pkg install -verbose -nodeps -local ${octave_tgz_file}; catch; disp(lasterror.message); exit(1); end_try_catch;'"
211    }
212
213    destroot.post_args
214}
215
216post-deactivate {
217    set octave_install_share ${prefix}/share/octave/packages
218    set octave_install_lib   ${prefix}/lib/octave/packages
219    system "${prefix}/bin/octave-cli -q -f -H --eval 'try; pkg prefix ${octave_install_share} ${octave_install_lib}; pkg -verbose -global rebuild; catch; disp(lasterror.message); exit(1); end_try_catch;'"
220}
221
222post-activate {
223    set octave_install_share ${prefix}/share/octave/packages
224    set octave_install_lib   ${prefix}/lib/octave/packages
225    system "${prefix}/bin/octave-cli -q -f -H --eval 'try; pkg prefix ${octave_install_share} ${octave_install_lib}; pkg -verbose -global rebuild; disp(lasterror.message); catch; exit(1); end_try_catch;'"
226}
227
228# octave/config.h was removed from octave 4.4
229# some packages, however, still depend on it for information
230# see https://savannah.gnu.org/bugs/?41027
231# eventually, this code should be removed
232default compiler.cpath {[octave._cpath]}
233proc octave._cpath {} {
234    global prefix octave.config_h worksrcpath
235    if {${octave.config_h}} {
236        return "${prefix}/include ${worksrcpath}/macports_compat ${worksrcpath}/macports_compat/octave"
237    } else {
238        return ${prefix}/include
239    }
240}
241
242pre-configure {
243    if {${octave.config_h}} {
244        xinstall -d -m 0755 ${worksrcpath}/macports_compat/octave
245        set configf [open "${worksrcpath}/macports_compat/octave/config.h" w 0644]
246
247        puts  ${configf} "#include <octave/octave-config.h>"
248        foreach v {LOCALVERFCNFILEDIR LOCALVEROCTFILEDIR LOCALVERARCHLIBDIR CANONICAL_HOST_TYPE} {
249            set mv [exec ${prefix}/bin/octave-config -p ${v}]
250            puts  ${configf} "#define OCTAVE_${v}  \"${mv}\""
251        }
252        close ${configf}
253    }
254}
Note: See TracBrowser for help on using the repository browser.