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

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

perl5-1.0: adjust some comments

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