Ticket #33205: Portfile

File Portfile, 6.0 KB (added by wiking@…, 12 years ago)

Portfile for shogun 2.0 release

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# $Id: Portfile 95161 2012-07-06 07:00:48Z mww@macports.org $
3
4PortSystem          1.0
5
6categories          math science
7name                shogun
8version             2.0.0
9set branch          [join [lrange [split ${version} .] 0 1] .]
10license             GPL-3
11maintainers         jameskyle
12
13platforms           darwin
14
15description         The machine learning toolbox's focus is on large scale \
16                    kernel methods
17
18long_description    ${description} and especially on Support Vector Machines \
19                    (SVM). It provides a generic SVM object interfacing to \
20                    several different SVM implementations, among them the \
21                    state of the art OCAS, LibSVM, SVMLight, SVMLin and GPDT.
22
23homepage            http://shogun-toolbox.org
24master_sites        ${homepage}/archives/shogun/releases/${branch}/sources/
25use_bzip2           yes
26
27checksums           md5     d4f3cd094a961db60bf3d576f2dd04d8 \
28                    sha1    4077b520c07669caf77f4c92e0fa6e5955dc929c \
29                    rmd160  a383e6aadd81ee4c6bc6630247ae3d483d0ca4a8
30
31worksrcdir          ${name}-${version}/src
32
33depends_build       port:bzip2 \
34                    port:gsed
35
36depends_lib         port:swig-python \
37                    port:readline \
38                    port:glpk \
39                    port:hdf5-18
40
41default_variants    +python27 +glpk
42
43universal_variant   no
44
45set python_prefix   ${prefix}/Library/Frameworks/Python.framework/Versions/2.7
46configure.args      --disable-svm-light \
47                    --libs=/usr/lib:${prefix}/lib \
48                    --install-path=${prefix} \
49                    --includes=${prefix}/include \
50                    --destdir=${destroot} \
51                    --disable-doxygen
52
53pre-fetch {
54  if {[ regexp {^[2-8]} ${os.major}]} {
55    return -code error "Shogun is only supported on leopard or above"
56  }
57}
58
59proc lremove {list elem} {
60    set index [lsearch -exact $list $elem]
61    return [lreplace $list $index $index]
62}
63
64# Interfaces are added by a comma delimited argument list to --interfaces.
65# We check for variants and then build this list accordingly
66set interfaces "cmdline_static python_modular"
67
68if {[variant_isset r]} {lappend interfaces "r_modular"}
69if {[variant_isset octave]} {lappend interfaces "octave_modular"}
70if {[variant_isset elwms]  && !([variant_isset python] &&
71    [variant_isset octave] &&   [variant_isset r])} {
72  return -code error "Must set python and both r and octave variants to build elwms interface"
73} elseif {[variant_isset elwms]} {
74  lappend interfaces "elwms"
75}
76
77# remove python interface if necessary before appending to args
78if {![variant_isset python27] && ![variant_isset python32]} {
79    set interfaces [lremove ${interfaces} "python_modular"]
80    depends_lib-delete port:swig-python
81}
82
83#if {[variant_isset matlab]} {lappend interfaces "matlab"}
84set interfaces [join $interfaces ","]
85
86configure.args-append --interfaces=$interfaces
87
88variant elwms description {Build elwms interface. requires python plus  one other interface} {}
89
90variant python32 conflicts python27 description {Build Python 3.2 API} {
91    configure.args-append \
92        --includes=${prefix}/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2 \
93        --python=${prefix}/Library/Frameworks/Python.framework/Versions/3.2/bin/python \
94        --pydir=${prefix}/Library/Frameworks/Python.framework/Versions/3.2/site-packages
95    depends_lib-append port:python32 \
96                       port:py32-numpy
97}
98
99variant hmm_parallel description {Enable parallel structures in hmm training} {
100  configure.args-append --enable-hmm-parallel
101}
102
103variant svm_light description {Enable parallel structures in hmm training} {
104  configure.args-delete --disable-svm-light
105  configure.args-append --enable-svm-light
106}
107
108variant python27 description {Build Python 2.7 API} {
109  configure.args-append \
110  --includes=${python_prefix}/include/python2.7 \
111  --python=${python_prefix}/bin/python2.7 \
112  --pydir=${python_prefix}/lib/python2.7/site-packages
113
114  depends_lib-append port:python27 \
115                     port:py27-numpy
116
117}
118
119variant r description {Build the R API} {
120    depends_lib-append port:swig-r
121}
122
123variant octave description {Build the Octave API} {
124    depends_lib-append port:swig-octave
125}
126
127variant glpk description {Enable glpk support} {
128    configure.args-append --enable-glpk
129     depends_lib-append port:glpk
130}
131
132#variant matlab description {Build the Matlab API} {}
133# variant doc description {Install the documentation for shogun} {
134#   depends_build-append port:texlive \
135#                        path:bin/dot:graphviz \
136#                        port:doxygen
137#
138#   configure.args-delete --disable-doxygen
139# }
140
141pre-extract {
142  # Before doing anything, verify the correct swig bindings are present for
143  # our variants
144  if {[file exists ${prefix}/bin/swig]} {
145      ui_debug "Attempting to find swig version"
146      set swig_version [exec ${prefix}/bin/swig -version]
147      regexp {(\d.?)+} $swig_version sversion
148      set sversion [string trimright $sversion \n]
149
150  } else {
151      set sversion 0.0.0
152  }
153  ui_debug "Found swig version ${sversion}"
154  if {[variant_isset python]} {
155
156  }
157  if {[variant_isset python] || [variant_isset python27]} {
158      ui_debug "Looking for swig python interface at ${prefix}/share/swig/${sversion}/python/python.swg"
159    if {![file exists ${prefix}/share/swig/${sversion}/python/python.swg]} {
160      ui_error "To install shogun with the python variant, swig must be installed with the python variant as well."
161      return -code error "incompatible swig installation"
162    }
163  }
164}
165
166pre-configure {
167  reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/configure
168  reinplace "s|= $\{_libdir\}/$\{_pydir\}|= $\{_pydir\}|g" ${worksrcpath}/configure
169}
170
171post-destroot {
172  if {[variant_isset doc]} {
173    system "cd ${worksrcpath}/../doc && make"
174    file mkdir ${destroot}${prefix}/share/doc/${name}
175    file copy ${worksrcpath}/../doc ${destroot}${prefix}/share/doc/${name}/doc
176
177  }
178}