Ticket #49982: perl5.Portfile

File perl5.Portfile, 8.7 KB (added by mojca (Mojca Miklavec), 8 years ago)

"unified" Perl port (preliminary)

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 138591 2015-07-13 08:26:52Z mojca@macports.org $
3
4PortSystem          1.0
5PortGroup           perl5 1.0
6
7name                perl5
8version             5.16.3
9categories          lang
10platforms           darwin freebsd linux
11license             {Artistic-1 GPL}
12maintainers         devans mojca openmaintainer
13
14homepage            http://www.perl.org/
15master_sites        http://www.cpan.org/src/5.0/
16
17# obsolete Perl versions; remove after 2016-12-09
18foreach perl5.major {5.8 5.10 5.12 5.14} {
19    subport xperl${perl5.major} {
20        version             5.22.0
21        replaced_by         perl5.22
22        PortGroup           obsolete 1.0
23    }
24}
25
26# current Perl versions
27#
28# meaning of the fields:
29# - version
30# - subversion
31# - revision
32# - rmd160 sha256
33set perl5.versions_info {
34    5.16 3 1 f25fdd72449156a7cbe989e8bd339fdba1afabc0  bb7bc735e6813b177dcfccd480defcde7eddefa173b5967eac11babd1bfa98e8
35    5.18 4 1 d97181a98f7acc80125b0d2a182a6a2cd7542ceb  1fb4d27b75cd244e849f253320260efe1750641aaff4a18ce0d67556ff1b96a5
36    5.20 3 0 499846a1c92e00dd357cb782bc14787b8cd47051  1b40068166c242e34a536836286e70b78410602a80615143301e52aa2901493b
37    5.22 0 0 16f3ac6c5d4d72e599222bcbf2591c3b2aa2f857  3689fdb519133d039f49e12834764ff4c1de8f8d925dea44a952ca110d0ac9f7
38}
39
40foreach {perl5.major perl5.subversion perl5.revision perl5.rmd160 perl5.sha256} ${perl5.versions_info} {
41    subport xperl${perl5.major} {
42        version             ${perl5.major}.${perl5.subversion}
43        set minor           [lrange [split ${version} .] 1 1]
44        revision            ${perl5.revision}
45        checksums           rmd160 ${perl5.rmd160} sha256 ${perl5.sha256}
46
47        description         Perl ${version} - Practical Extraction and Report Language
48        long_description    Perl is a general-purpose programming language \
49                            originally developed for text manipulation and now \
50                            used for a wide range of tasks including system \
51                            administration, web development, network \
52                            programming, GUI development, and more.
53
54        depends_lib-append  port:gdbm
55
56        distname            perl-${version}
57        dist_subdir         perl${perl5.major}
58        use_bzip2           yes
59
60        post-patch {
61            reinplace -W ${worksrcpath} "s|__PREFIX__|${prefix}|g" \
62                    Configure Makefile.SH
63        }
64
65        configure.ccache    no
66        configure.distcc    no
67        configure.env       LC_ALL=C
68        configure.cmd       sh Configure
69        configure.pre_args
70        configure.universal_args-delete \
71                            --disable-dependency-tracking
72        configure.post_args -des \
73                            -Dprefix='${prefix}' \
74                            -Dscriptdir='${prefix}/bin' \
75                           {-Dcppflags="$CPPFLAGS"} \
76                           {-Dccflags="$CFLAGS"} \
77                           {-Dldflags="$LDFLAGS"} \
78                            -Dvendorprefix='${prefix}' \
79                            -Dusemultiplicity=y \
80                            -Dusethreads \
81                            -Duseshrplib \
82                           {-Dcc="$CC"} \
83                           {-Dld="env MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET $CC"} \
84                            -Dman1ext=1pm \
85                            -Dman3ext=3pm \
86                            -Dman1dir='${prefix}/share/man/man1p' \
87                            -Dman3dir='${prefix}/share/man/man3p' \
88                            -Dsitebin='${prefix}/libexec/perl${perl5.major}/sitebin' \
89                            -Dsiteman1dir='${prefix}/share/perl${perl5.major}/siteman/man1' \
90                            -Dsiteman3dir='${prefix}/share/perl${perl5.major}/siteman/man3' \
91                            -Dvendorbin='${prefix}/libexec/perl${perl5.major}' \
92                            -Dvendorman1dir='${prefix}/share/perl${perl5.major}/man/man1' \
93                            -Dvendorman3dir='${prefix}/share/perl${perl5.major}/man/man3' \
94                            -Dpager='/usr/bin/less -sR' \
95                            -Dperlpath="${perl5.bin}" \
96                            -Dstartperl="#!${perl5.bin}"
97
98        if {[variant_isset universal]} {
99            post-configure {
100                system "cd ${worksrcpath} && ed - ${worksrcpath}/config.h < ${filespath}/config.h.ed"
101            }
102        }
103
104        post-build {
105            reinplace -E {s/-arch [a-z0-9_]+//g} \
106                ${worksrcpath}/lib/Config_heavy.pl
107        }
108
109        test.run            yes
110
111        variant dtrace description {Build with DTrace probes} {
112            configure.args-append   -Dusedtrace
113        }
114
115        post-destroot {
116            # avoid conflicting with other perl versions
117            # perl5 creates unversioned symlinks
118            delete ${destroot}${prefix}/bin/perl
119            foreach binFile [glob -directory "${destroot}${prefix}/bin" *] {
120                if {$binFile ne "${destroot}${prefix}/bin/perl${version}"} {
121                    move ${binFile} ${binFile}-${perl5.major}
122                }
123            }
124            move ${destroot}${prefix}/bin/perl${version} ${destroot}${prefix}/bin/${name}
125            ln -s ${name} ${destroot}${prefix}/bin/perl${version}
126            foreach man1File [glob -directory "${destroot}${prefix}/share/man/man1p" *] {
127                regexp (.*)(\.1.*) ${man1File} -> program suffix
128                move ${man1File} ${program}-${perl5.major}${suffix}
129            }
130            foreach man3File [glob -directory "${destroot}${prefix}/share/man/man3p" *] {
131                regexp (.*)(\.3.*) ${man3File} -> program suffix
132                move ${man3File} ${program}-${perl5.major}${suffix}
133            }
134        }
135
136        livecheck.type      regex
137        livecheck.url       http://www.cpan.org/src
138        livecheck.regex     perl-(5\\.${minor}\\.\\d)\\.
139    }
140}
141
142# wrapper port
143if {$subport eq $name} {
144    description             Wrapper port for Perl 5.x
145    long_description        ${description}
146
147    supported_archs         noarch
148
149    perl5.require_variant   yes
150    perl5.conflict_variants yes
151    perl5.branches          5.16 5.18 5.20 5.22
152    perl5.create_variants   ${perl5.branches}
153    # perl5.default_branch    5.22
154
155    distfiles
156    use_configure           no
157    build                   {}
158
159    # if {[variant_isset perl5_16] || [variant_isset perl5_18] || [variant_isset perl5_20] || [variant_isset perl5_22]} {
160    #     depends_lib-append  port:perl${perl5.major}
161    # }
162
163    ##
164    ## Note:  the destroot section below currently uses lists of files
165    ##   to know what files to link.  In the future we can use
166    ##   something like:
167    ##     set contents_list [registry_port_registered $portname])
168    ##   to get the lists of binaries and man pages installed by
169    ##   the perl5.x ports.
170    ##
171    destroot {
172        if {[file exists ${perl5.bin}]} {
173            ln -s perl${perl5.major} ${destroot}${prefix}/bin/${name}
174            ln -s perl${perl5.major} ${destroot}${prefix}/bin/perl
175        } else {
176            ui_error "Can't find perl ${perl5.major} (as ${perl5.bin}) so can't link $name to it."
177            return -code error "perl${perl5.major} is missing"
178        }
179        # some binaries are not included in the list because they would conflict
180        # with module ports:
181        # config_data    -> p5-module-build (ticket #24025)
182        # corelist       -> p5-module-corelist (ticket #28485)
183        # instmodsh      -> p5-extutils-makemaker (ticket #24590)
184        # ptar, ptardiff -> p5-archive-tar (ticket #28255)
185        # shasum         -> p5-digest-sha (ticket #28580)
186        foreach list {binList man1pList man3pList} {
187            set fd [open ${filespath}/${list}]; set $list [read $fd]; close $fd
188        }
189        foreach binFile $binList {
190            if {[file exists ${prefix}/bin/${binFile}-${branch}]} {
191                ln -s ${binFile}-${branch} ${destroot}${prefix}/bin/${binFile}
192            }
193        }
194        file mkdir ${destroot}${prefix}/share/man/man1p
195        foreach manFile $man1pList {
196            if {[file exists ${prefix}/share/man/man1p/${manFile}-${branch}.1pm]} {
197                ln -s ${manFile}-${branch}.1pm ${destroot}${prefix}/share/man/man1p/${manFile}.1pm
198            }
199        }
200        file mkdir ${destroot}${prefix}/share/man/man3p
201        foreach manFile $man3pList {
202            if {[file exists ${prefix}/share/man/man3p/${manFile}-${branch}.3pm]} {
203                ln -s ${manFile}-${branch}.3pm ${destroot}${prefix}/share/man/man3p/${manFile}.3pm
204            }
205        }
206    }
207
208    livecheck.type      none
209}