source: trunk/dports/_resources/port1.0/group/perl5-1.0.tcl @ 96776

Last change on this file since 96776 was 96776, checked in by blair@…, 7 years ago

group/*: trim trailing whitespace.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.9 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
2# perl5-1.0.tcl
3#
4# $Id: perl5-1.0.tcl 96776 2012-08-19 05:52:01Z blair@macports.org $
5#
6# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>,
7#                    Toby Peterson <toby@opendarwin.org>
8# Copyright (c) 2002 Apple Computer, Inc.
9# All rights reserved.
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions are
13# met:
14#
15# 1. Redistributions of source code must retain the above copyright
16#    notice, this list of conditions and the following disclaimer.
17# 2. Redistributions in binary form must reproduce the above copyright
18#    notice, this list of conditions and the following disclaimer in the
19#    documentation and/or other materials provided with the distribution.
20# 3. Neither the name of Apple Computer, Inc. nor the names of its
21#    contributors may be used to endorse or promote products derived from
22#    this software without specific prior written permission.
23#
24# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35#
36
37# portfile configuration options
38# perl5.branches: the major perl version supported by this module. A
39#   subport will be created for each. e.g. p5.12-foo, p5.10-foo, ...
40# perl5.default_branch: the branch used when you request p5-foo
41options perl5.default_branch perl5.branches
42default perl5.default_branch {[perl5_get_default_branch]}
43# perl5.branches exists here for backward compatibility with old p5 portfiles.
44# You should still set it in the portfile.
45default perl5.branches {"5.8 5.10 5.12 5.14"}
46proc perl5_get_default_branch {} {
47    global prefix
48    # use whatever ${prefix}/bin/perl5 was chosen, and if none, fall back to 5.12
49    if {![catch {set val [lindex [split [exec ${prefix}/bin/perl5 -V:version] {'}] 1]}]} {
50        return [join [lrange [split $val .] 0 1] .]
51    } else {
52        return 5.12
53    }
54}
55
56proc perl5.extract_config {var {default ""}} {
57    global perl5.bin
58
59    if {[catch {set val [lindex [split [exec ${perl5.bin} -V:${var}] {'}] 1]}]} {
60        set val ${default}
61    }
62
63    return $val
64}
65
66# Set some variables.
67options perl5.version perl5.major perl5.arch perl5.lib perl5.bindir perl5.archlib perl5.bin
68default perl5.version {[perl5.extract_config version]}
69default perl5.major {${perl5.default_branch}}
70default perl5.arch {[perl5.extract_config archname ${os.platform}]}
71default perl5.bin {${prefix}/bin/perl${perl5.major}}
72
73# define installation libraries as vendor location
74default perl5.lib {${prefix}/lib/perl5/vendor_perl/${perl5.version}}
75default perl5.bindir {${prefix}/libexec/perl${perl5.major}}
76default perl5.archlib {${perl5.lib}/${perl5.arch}}
77
78default livecheck.version {${perl5.moduleversion}}
79
80default configure.universal_args {}
81
82options perl5.link_binaries perl5.link_binaries_suffix
83default perl5.link_binaries yes
84default perl5.link_binaries_suffix {-${perl5.major}}
85
86# define these empty initially, they are set by perl5.setup arguments
87set perl5.module ""
88set perl5.moduleversion ""
89set perl5.cpandir ""
90
91# perl5 group setup procedure
92proc perl5.setup {module vers {cpandir ""}} {
93    global perl5.branches perl5.default_branch perl5.bin perl5.lib \
94           perl5.module perl5.moduleversion perl5.cpandir \
95           prefix subport name
96
97    # define perl5.module
98    set perl5.module ${module}
99    set perl5.moduleversion $vers
100
101    # define perl5.cpandir
102    # check if optional CPAN dir specified to perl5.setup
103    if {[string length ${cpandir}] == 0} {
104        # if not, default to the first word (before a dash) from the
105        # module name, this is the normal convention on CPAN
106        set perl5.cpandir [lindex [split ${perl5.module} {-}] 0]
107    } else {
108        # else, use what was passed
109        set perl5.cpandir ${cpandir}
110    }
111
112    if {![info exists name]} {
113        name            p5-[string tolower ${perl5.module}]
114    }
115    version             [perl5_convert_version ${perl5.moduleversion}]
116    categories          perl
117    homepage            http://search.cpan.org/dist/${perl5.module}/
118
119    master_sites        perl_cpan:${perl5.cpandir}
120    distname            ${perl5.module}-${perl5.moduleversion}
121    dist_subdir         perl5
122
123    if {[string match p5-* $name]} {
124        set rootname        [string range $name 3 end]
125
126        foreach v ${perl5.branches} {
127            subport p${v}-${rootname} {
128                depends_lib port:perl${v}
129                perl5.major ${v}
130            }
131        }
132
133        if {$subport == $name} {
134            perl5.major
135            distfiles
136            supported_archs noarch
137            replaced_by p[option perl5.default_branch]-${rootname}
138            depends_lib port:p[option perl5.default_branch]-${rootname}
139            use_configure no
140            build {}
141            destroot {
142                xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
143                system "echo $name is a stub port > ${destroot}${prefix}/share/doc/${name}/README"
144            }
145        }
146    } else {
147        depends_lib port:perl${perl5.default_branch}
148    }
149    if {![string match p5-* $name] || $subport != $name} {
150        configure.cmd       ${perl5.bin}
151        configure.env       PERL_AUTOINSTALL=--skipdeps
152        configure.pre_args  Makefile.PL
153        default configure.args {"INSTALLDIRS=vendor CC=\"${configure.cc}\" LD=\"${configure.cc}\""}
154
155        # CCFLAGS can be passed in to "configure" but it's not necessarilary inherited
156        # LDFLAGS can't be passed in (or if it can, it's not easy to figure out how)
157        post-configure {
158            system "find ${worksrcpath} -name Makefile -type f -print0 | xargs -0 /usr/bin/sed -i \"\" '/^CCFLAGS *=/s/$/ [get_canonical_archflags cc]/' \;"
159            system "find ${worksrcpath} -name Makefile -type f -print0 | xargs -0 /usr/bin/sed -i \"\" '/^OTHERLDFLAGS *=/s/$/ [get_canonical_archflags ld]/'"
160        }
161
162        test.run            yes
163
164        destroot.target     pure_install
165
166        post-destroot {
167            fs-traverse file ${destroot}${perl5.lib} {
168                if {[file tail ${file}] eq ".packlist"} {
169                    ui_info "Fixing packlist ${file}"
170                    reinplace -n "s|${destroot}||p" ${file}
171                }
172            }
173            if {${perl5.link_binaries}} {
174                foreach bin [glob -nocomplain -tails -directory "${destroot}${perl5.bindir}" *] {
175                    if {[catch {file type "${destroot}${prefix}/bin/${bin}${perl5.link_binaries_suffix}"}]} {
176                        ln -s "${perl5.bindir}/${bin}" "${destroot}${prefix}/bin/${bin}${perl5.link_binaries_suffix}"
177                    }
178                }
179            }
180        }
181    }
182
183    livecheck.type      regexm
184    livecheck.url       http://search.cpan.org/dist/${perl5.module}/
185    livecheck.regex     _gaq.push\\(\\\["_setCustomVar",5,"Release","[quotemeta ${perl5.module}]-(\[^"\]+?)\"
186}
187
188# Switch from default MakeMaker-style routine to Module::Build-style
189proc perl5.use_module_build {} {
190    global perl5.bin destroot perl5.major
191
192    if {${perl5.major} == ""} {
193        return
194    }
195
196    depends_lib-append  port:p${perl5.major}-module-build
197
198    configure.pre_args  Build.PL
199    default configure.args {"installdirs=vendor --config cc=\"${configure.cc}\" --config ld=\"${configure.cc}\""}
200
201    build.cmd           ${perl5.bin}
202    build.pre_args      Build
203    build.args          build
204
205    test.pre_args       Build
206    test.args           test
207
208    destroot.cmd        ${perl5.bin}
209    destroot.pre_args   Build
210    destroot.args       install
211    destroot.destdir    destdir=${destroot}
212}
213
214# convert a floating point version to an dotted-integer one
215proc perl5_convert_version {vers} {
216    set index [string first . $vers]
217    set other_dot [string first . [string range $vers [expr $index + 1] end]]
218    if {$index == -1 || $other_dot != -1} {
219        return $vers
220    }
221    set ret [string range $vers 0 [expr $index - 1]]
222    incr index
223    set fractional [string range $vers $index end]
224    set index 0
225    while {$index < [string length $fractional] || $index < 6} {
226        set sub [string range $fractional $index [expr $index + 2]]
227        if {[string length $sub] < 3} {
228            append sub [string repeat "0" [expr 3 - [string length $sub]]]
229        }
230        append ret ".[scan $sub %u]"
231        incr index 3
232    }
233    return $ret
234}
Note: See TracBrowser for help on using the repository browser.