Ticket #65569: Portfile

File Portfile, 9.5 KB (added by lemzwerg (Werner Lemberg), 22 months ago)
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
3PortSystem 1.0
4PortGroup  active_variants 1.1
5
6# Need openat()
7PortGroup       legacysupport 1.1
8legacysupport.newest_darwin_requires_legacy 13
9
10name            emacs
11
12categories      editors
13license         GPL-3+
14maintainers     {dports @drkp} openmaintainer
15description     The GNU Emacs text editor
16long_description \
17    GNU Emacs is a self-documenting, customizable, extensible real-time \
18    display editor. Users new to Emacs will be able to use basic        \
19    features fairly rapidly by studying the tutorial and using the      \
20    self-documentation features. Emacs also has an extensive            \
21    interactive manual browser. It is easily extensible since its       \
22    editing commands are written in Lisp.
23
24platforms       darwin freebsd
25homepage        https://www.gnu.org/software/emacs/emacs.html
26master_sites    gnu
27
28if {$subport eq $name} {
29    conflicts   emacs-devel
30}
31subport emacs-devel {
32    conflicts   $name
33}
34subport emacs-app {
35    conflicts   emacs-app-devel
36}
37subport emacs-app-devel {
38    conflicts   emacs-app
39}
40
41depends_build-append port:autoconf port:automake port:libtool
42
43configure.args  --disable-silent-rules \
44                --without-ns \
45                --without-x \
46                --without-dbus \
47                --without-gconf \
48                --without-libotf \
49                --without-m17n-flt \
50                --with-gmp \
51                --with-gnutls \
52                --with-json \
53                --with-xml2 \
54                --with-modules \
55                --infodir ${prefix}/share/info/${name}
56
57depends_build-append   port:pkgconfig \
58                       port:texinfo
59depends_lib-append     port:gmp \
60                       port:gnutls \
61                       port:jansson \
62                       port:libxml2 \
63                       port:ncurses
64
65post-destroot {
66    xinstall -d ${destroot}${prefix}/share/emacs/${version}/leim
67    delete ${destroot}${prefix}/bin/ctags
68    delete ${destroot}${prefix}/share/man/man1/ctags.1.gz
69
70    # avoid conflicts with xemacs
71    if {$subport eq $name || $subport eq "emacs-devel"} {
72        move ${destroot}${prefix}/bin/etags ${destroot}${prefix}/bin/etags-emacs
73        move ${destroot}${prefix}/share/man/man1/etags.1.gz ${destroot}${prefix}/share/man/man1/etags-emacs.1.gz
74    }
75}
76
77platform darwin {
78    post-patch {
79        # Leopard's Xcode 3.1.x ld(1) man page claims -no_pie is supported, but it's not
80        if {${os.major} < 9} {
81            reinplace "s:-fno-pie::" ${worksrcpath}/configure
82        } elseif {${os.major} > 10} {
83            configure.ldflags-append -Wl,-no_pie
84        }
85    }
86}
87
88if {$subport eq $name || $subport eq "emacs-app"} {
89    version         27.2
90    revision        0
91
92    checksums       rmd160  5cf2927984b34cfd611114190c8b7f498093e994 \
93                    sha256  80ff6118fb730a6d8c704dccd6915a6c0e0a166ab1daeef9fe68afa9073ddb73 \
94                    size    67153050
95}
96
97patchfiles-append      patch-fstat.diff
98
99if {$subport eq "emacs-devel" || $subport eq "emacs-app-devel"} {
100    epoch           2
101    version         20210105
102
103    fetch.type      git
104    git.url         --depth=1000 https://github.com/emacs-mirror/emacs.git
105    git.branch      80e26472206cc44837521ba594cd50e724d9af5c
106
107    pre-configure {
108        system -W ${worksrcpath} "sh ./autogen.sh"
109    }
110
111    livecheck.type none
112
113    variant nativecomp description {Builds emacs with native compilation support} {
114        git.url-prepend  --branch feature/native-comp
115        git.branch       8ad983c4acef60a80e8d6b6ba891b1ef957f2d7c
116
117        depends_build-append     port:coreutils
118        depends_lib-append       port:gcc10
119
120        configure.install        ${prefix}/bin/ginstall
121        configure.args-append    --with-nativecomp
122
123        compiler.cpath-prepend   ${prefix}/include/gcc10
124        compiler.library_path-prepend \
125                                 ${prefix}/lib/gcc10
126
127        build.args-append        NATIVE_FULL_AOT=1 \
128            {BYTE_COMPILE_EXTRA_FLAGS='--eval "(setq comp-speed 2)"'}
129
130        if {$subport eq "emacs-app-devel"} {
131            post-patch {
132                reinplace {s|^ELN_DESTDIR =.*|ELN_DESTDIR="${ns_appbindir}/../"|g} \
133                    Makefile.in
134            }
135        }
136    }
137} else {
138    livecheck.type  regex
139    livecheck.url   https://ftp.gnu.org/gnu/emacs/?C=M&O=D
140    livecheck.regex ${name}-(\\d+\\.\\d+\\w*)\\.tar
141}
142
143if {$subport eq $name || $subport eq "emacs-devel"} {
144    PortGroup  muniversal 1.0
145
146    variant x11 description {Builds emacs as a X11 program with Lucid widgets} {
147        configure.args-delete   --without-x
148        configure.args-append   --with-x-toolkit=lucid \
149            --without-xaw3d \
150            --without-imagemagick \
151            --with-xpm \
152            --with-jpeg \
153            --with-tiff \
154            --with-gif \
155            --with-png \
156            --with-lcms2 \
157            --without-rsvg \
158            --with-xft
159        depends_lib-append      port:xorg-libXmu \
160            port:xorg-libXaw \
161            port:xpm \
162            path:include/turbojpeg.h:libjpeg-turbo \
163            port:tiff \
164            port:giflib \
165            port:libpng \
166            port:lcms2 \
167            port:Xft2 \
168            port:harfbuzz
169
170        # autoconf appears to be dropping linker flags for freetype &
171        # fontconfig; work around this. See #28083
172        configure.ldflags-append -lfreetype -lfontconfig
173    }
174
175    variant motif requires x11 description {Builds emacs as an X11 program with Motif widgets} {
176        configure.args-delete   --with-x-toolkit=lucid
177        configure.args-append   --with-x-toolkit=motif
178        depends_lib-append      lib:libXm:openmotif
179    }
180
181    variant gtk requires x11 description {Builds emacs as an X11 program with GTK+3 widgets} {
182        configure.args-delete   --with-x-toolkit=lucid
183        configure.args-delete   --without-gconf
184        configure.args-delete   --without-rsvg
185        configure.args-append   --with-x-toolkit=gtk3
186        configure.args-append   --with-gconf
187        configure.args-append   --with-rsvg
188        depends_lib-append      port:gtk3 \
189                                path:lib/pkgconfig/glib-2.0.pc:glib2 \
190                                port:gconf \
191                                port:librsvg
192        # see #21917
193        require_active_variants gtk2 x11
194    }
195
196    # imagemagick variant requires either x11 or quartz, so we have to
197    # define it twice; see #53315
198    variant imagemagick requires x11 description {Use ImageMagick} {
199        depends_lib-append  port:ImageMagick
200        configure.args-append --with-imagemagick
201    }
202
203    variant dbus description {Builds emacs with D-Bus support} {
204        # our dbus is autolaunched by launchd, so disable the check that it's running
205        patchfiles-append        patch-src_dbusbind.c.diff
206        configure.args-delete    --without-dbus
207        configure.args-append    --with-dbus
208        depends_lib-append       port:dbus
209    }
210
211    post-destroot {
212        xinstall -m 755 -d ${destroot}${prefix}/include/emacs
213        xinstall -m 644 ${worksrcpath}/src/emacs-module.h \
214                        ${destroot}${prefix}/include/emacs
215    }
216}
217
218if {$subport eq "emacs-app" || $subport eq "emacs-app-devel"} {
219    categories-append   aqua
220
221    configure.args-append  --with-ns \
222        --with-lcms2 \
223        --without-harfbuzz \
224        --without-imagemagick \
225        --without-rsvg \
226        --without-xaw3d \
227
228    configure.args-delete  --without-ns  --without-x
229
230    depends_lib-append  port:lcms2
231
232    universal_variant   no
233
234    if {$subport eq "emacs-app-devel"} {
235        patchfiles-append   patch-Info.plist.in-devel.diff
236    } else {
237        patchfiles-append   patch-Info.plist.in.diff
238    }
239    post-patch {
240        reinplace "s,@PATH@,${prefix}/bin:${prefix}/sbin:/usr/bin:/bin:/usr/sbin:/sbin," ${worksrcpath}/nextstep/templates/Info.plist.in
241    }
242
243    destroot {
244        system -W ${worksrcpath} "make install"
245        xinstall -m 755 -d ${destroot}${applications_dir}
246        file copy ${worksrcpath}/nextstep/Emacs.app \
247            ${destroot}${applications_dir}
248        # fix read-permission to resources
249        system "chmod a+r ${destroot}${applications_dir}/Emacs.app/Contents/Resources/*"
250        file copy ${filespath}/site-start.el \
251            ${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp
252        reinplace "s|__PREFIX__|${prefix}|g" \
253            ${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp/site-start.el
254    }
255
256    variant imagemagick description {Use ImageMagick} {
257        depends_lib-append     port:ImageMagick
258        configure.args-delete  --without-imagemagick
259        configure.args-append  --with-imagemagick
260    }
261
262    variant rsvg description {Use librsvg} {
263        depends_lib-append     port:librsvg
264        configure.args-delete  --without-rsvg
265        configure.args-append  --with-rsvg
266    }
267
268    default_variants +rsvg
269}
270
271if {$subport eq $name || $subport eq "emacs-devel"} {
272    variant xwidgets requires gtk description {Enable use of xwidgets in Emacs buffers} {
273        configure.args-append  --with-xwidgets
274    }
275} elseif {$subport eq "emacs-app-devel"} {
276    # Quartz support was added after 27.1 had released via commit: d089c4fbfc8be432dc3015a99b4044dab0a0de97
277    # As soon as the next version is released it should support also emacs-app
278    variant xwidgets description {Enable use of xwidgets in Emacs buffers} {
279        configure.args-append  --with-xwidgets
280    }
281}