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

Last change on this file since 93584 was 93584, checked in by pixilla@…, 8 years ago

_resources/port1.0/group:

  • Add perl5.16 to branches.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.0 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 93584 2012-05-27 17:34:44Z pixilla@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.branches {"5.8 5.10 5.12 5.14 5.16"}
43default perl5.default_branch {[perl5_get_default_branch]}
44proc perl5_get_default_branch {} {
45    global prefix
46    # use whatever ${prefix}/bin/perl5 was chosen, and if none, fall back to 5.12
47    if {![catch {set val [lindex [split [exec ${prefix}/bin/perl5 -V:version] {'}] 1]}]} {
48        return [join [lrange [split $val .] 0 1] .]
49    } else {
50        return 5.12
51    }
52}
53
54proc perl5.extract_config {var {default ""}} {
55    global perl5.bin
56
57    if {[catch {set val [lindex [split [exec ${perl5.bin} -V:${var}] {'}] 1]}]} {
58        set val ${default}
59    }
60
61    return $val
62}
63
64# Set some variables.
65options perl5.version perl5.major perl5.arch perl5.lib perl5.archlib perl5.bin
66default perl5.version {[perl5.extract_config version]}
67default perl5.major {${perl5.default_branch}}
68default perl5.arch {[perl5.extract_config archname ${os.platform}]}
69default perl5.bin {${prefix}/bin/perl${perl5.major}}
70
71# define installation libraries as vendor location
72default perl5.lib {${prefix}/lib/perl5/vendor_perl/${perl5.version}}
73default perl5.archlib {${perl5.lib}/${perl5.arch}}
74
75default livecheck.version {${perl5.moduleversion}}
76
77default configure.universal_args {}
78
79# define these empty initially, they are set by perl5.setup arguments
80set perl5.module ""
81set perl5.moduleversion ""
82set perl5.cpandir ""
83
84# perl5 group setup procedure
85proc perl5.setup {module vers {cpandir ""}} {
86    global perl5.branches perl5.default_branch perl5.bin perl5.lib \
87           perl5.module perl5.moduleversion perl5.cpandir \
88           prefix subport name
89
90    # define perl5.module
91    set perl5.module ${module}
92    set perl5.moduleversion $vers
93
94    # define perl5.cpandir
95    # check if optional CPAN dir specified to perl5.setup
96    if {[string length ${cpandir}] == 0} {
97        # if not, default to the first word (before a dash) from the
98        # module name, this is the normal convention on CPAN
99        set perl5.cpandir [lindex [split ${perl5.module} {-}] 0]
100    } else {
101        # else, use what was passed
102        set perl5.cpandir ${cpandir}
103    }
104
105    if {![info exists name]} {
106        name            p5-[string tolower ${perl5.module}]
107    }
108    version             [perl5_convert_version ${perl5.moduleversion}]
109    categories          perl
110    homepage            http://search.cpan.org/dist/${perl5.module}/
111
112    master_sites        perl_cpan:${perl5.cpandir}
113    distname            ${perl5.module}-${perl5.moduleversion}
114    dist_subdir         perl5
115
116    if {[string match p5-* $name]} {
117        set rootname        [string range $name 3 end]
118
119        foreach v ${perl5.branches} {
120            subport p${v}-${rootname} {
121                depends_lib port:perl${v}
122                perl5.major ${v}
123            }
124        }
125
126        if {$subport == $name} {
127            perl5.major
128            distfiles
129            supported_archs noarch
130            replaced_by p[option perl5.default_branch]-${rootname}
131            depends_lib port:p[option perl5.default_branch]-${rootname}
132            use_configure no
133            build {}
134            destroot {
135                xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
136                system "echo $name is a stub port > ${destroot}${prefix}/share/doc/${name}/README"
137            }
138        }
139    } else {
140        depends_lib port:perl${perl5.default_branch}
141    }
142    if {![string match p5-* $name] || $subport != $name} {
143        configure.cmd       ${perl5.bin}
144        configure.env       PERL_AUTOINSTALL=--skipdeps
145        configure.pre_args  Makefile.PL
146        configure.args      INSTALLDIRS=vendor
147
148        # CCFLAGS can be passed in to "configure" but it's not necessarilary inherited
149        # LDFLAGS can't be passed in (or if it can, it's not easy to figure out how)
150        post-configure {
151            system "find ${worksrcpath} -name Makefile | xargs /usr/bin/sed -i \"\" '/^CCFLAGS *=/s/$/ [get_canonical_archflags cc]/' \;"
152            system "find ${worksrcpath} -name Makefile | xargs /usr/bin/sed -i \"\" '/^OTHERLDFLAGS *=/s/$/ [get_canonical_archflags ld]/'"
153        }
154
155        test.run            yes
156
157        destroot.target     pure_install
158
159        post-destroot {
160            fs-traverse file ${destroot}${perl5.lib} {
161                if {[file tail ${file}] eq ".packlist"} {
162                    ui_info "Fixing packlist ${file}"
163                    reinplace -n "s|${destroot}||p" ${file}
164                }
165            }
166        }
167    }
168
169    livecheck.type      regexm
170    livecheck.url       http://search.cpan.org/dist/${perl5.module}/
171    livecheck.regex     _gaq.push\\(\\\["_setCustomVar",5,"Release","[quotemeta ${perl5.module}]-(\[^"\]+?)\"
172}
173
174# Switch from default MakeMaker-style routine to Module::Build-style
175proc perl5.use_module_build {} {
176    global perl5.bin destroot perl5.major
177
178    if {${perl5.major} == ""} {
179        return
180    }
181
182    depends_lib-append  port:p${perl5.major}-module-build
183
184    configure.pre_args  Build.PL
185    configure.args      installdirs=vendor
186
187    build.cmd           ${perl5.bin}
188    build.pre_args      Build
189    build.args          build
190
191    test.pre_args       Build
192    test.args           test
193
194    destroot.cmd        ${perl5.bin}
195    destroot.pre_args   Build
196    destroot.args       install
197    destroot.destdir    destdir=${destroot}
198}
199
200# convert a floating point version to an dotted-integer one
201proc perl5_convert_version {vers} {
202    set index [string first . $vers]
203    set other_dot [string first . [string range $vers [expr $index + 1] end]]
204    if {$index == -1 || $other_dot != -1} {
205        return $vers
206    }
207    set ret [string range $vers 0 [expr $index - 1]]
208    incr index
209    set fractional [string range $vers $index end]
210    set index 0
211    while {$index < [string length $fractional] || $index < 6} {
212        set sub [string range $fractional $index [expr $index + 2]]
213        if {[string length $sub] < 3} {
214            append sub [string repeat "0" [expr 3 - [string length $sub]]]
215        }
216        append ret ".[scan $sub %u]"
217        incr index 3
218    }
219    return $ret
220}
Note: See TracBrowser for help on using the repository browser.