Ticket #33430: Portfile

File Portfile, 4.1 KB (added by lockhart (Thomas Lockhart), 12 years ago)

Complete Portfile now including a test section. Also installs lmdemo which is the test program.

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 87721 2011-12-02 09:31:29Z stromnov@macports.org $
3
4PortSystem          1.0
5
6name                levmar
7version             2.6
8categories          devel
9platforms           darwin
10license             GPL
11
12maintainers         fourpalms.org:lockhart openmaintainer
13
14description         Levenberg-Marquardt nonlinear least squares algorithm
15long_description    levmar is a native ANSI C implementation of the Levenberg-Marquardt \
16                    optimization algorithm.  Both unconstrained and constrained (under linear \
17                    equations, inequality and box constraints) Levenberg-Marquardt variants are \
18                    included.  The LM algorithm is an iterative technique that finds a local \
19                    minimum of a function that is expressed as the sum of squares of nonlinear \
20                    functions.  It has become a standard technique for nonlinear least-squares \
21                    problems and can be thought of as a combination of steepest descent and the \
22                    Gauss-Newton method.  When the current solution is far from the correct on, \
23                    the algorithm behaves like a steepest descent method: slow, but guaranteed \
24                    to converge.  When the current solution is close to the correct solution, it \
25                    becomes a Gauss-Newton method.
26
27homepage            http://www.ics.forth.gr/~lourakis/levmar/
28master_sites        http://www.ics.forth.gr/~lourakis/levmar/
29
30extract.suffix      .tgz
31checksums           rmd160  2b29daea12804050c8d3939b8c142d27d36bffc8 \
32                    sha256  3bf4ef1ea4475ded5315e8d8fc992a725f2e7940a74ca3b0f9029d9e6e94bad7
33
34# Patch taken from levmar RPM by Eric Smith <eric@brouhaha.com>
35patch.pre_args      -p1
36patchfiles          patch-Makefile.so.diff
37
38use_configure       no
39#configure.args      --with-omniORB-config="${prefix}/etc/omniORB.cfg"
40
41universal_variant   no
42
43lassign [split ${version} "."] ver_major ver_minor
44lassign [split "2.2" "."] abi_major abi_minor
45
46post-patch {
47    set fl [open ${worksrcpath}/Makefile.so]
48    set lines [read $fl]
49    close $fl
50    foreach line [split $lines \n] {
51        if {[regexp {(MAJ|MIN)[[:space:]]*=[[:space:]]*([[:digit:]]+)} ${line} matched key value] == 1} {
52            if {${key} == "MAJ"} {
53                ui_debug "Found ABI major field ${value}"
54                set abi_major ${value}
55            } else {
56                ui_debug "Found ABI minor field ${value}"
57                set abi_minor ${value}
58            }
59        }
60    }
61
62    if {${abi_major} != ${ver_major} || ${abi_minor} > ${ver_minor}} {
63        ui_error "levmar version ${ver_major} is inconsistent with ABI version ${abi_major}.${abi_minor}"
64        return -code error
65    }
66
67    reinplace "s|\r||g" ${worksrcpath}/README.txt
68    file mkdir ${worksrcpath}/sobj
69}
70
71build.args-append   "-f Makefile.so"
72build.args-append   "LDFLAGS=-Wl,-rpath,${prefix}/lib"
73
74test.run            yes
75test.cmd            lmdemo
76test.target         {}
77test.env            DYLD_LIBRARY_PATH=${worksrcpath}/sobj
78
79destroot {
80    # library
81    xinstall -m 755 ${worksrcpath}/sobj/liblevmar.dylib.${abi_major}.${abi_minor} ${destroot}${prefix}/lib/liblevmar.dylib.${abi_major}.${abi_minor}
82
83    # test program
84    xinstall -m 755 ${worksrcpath}/lmdemo ${destroot}${prefix}/bin/lmdemo
85
86    # header files
87    xinstall -m 755 ${worksrcpath}/levmar.h ${destroot}${prefix}/include
88
89    # documentation
90    xinstall -m 755 -d ${destroot}${prefix}/share/${name}
91    xinstall -m 644 ${worksrcpath}/LICENSE ${destroot}${prefix}/share/${name}
92    xinstall -m 644 ${worksrcpath}/README.txt ${destroot}${prefix}/share/${name}
93}
94
95post-destroot {
96    system "cd ${destroot}${prefix}/lib/ && ln -s liblevmar.dylib.${abi_major}.${abi_minor} liblevmar.dylib.${abi_major} && ln -s liblevmar.dylib.${abi_major} liblevmar.dylib"
97}
98
99livecheck.type      regex
100livecheck.url       http://www.ics.forth.gr/~lourakis/levmar/
101livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)"