summaryrefslogtreecommitdiff
path: root/packages/app-emulation/wine/wine.exlib
blob: 3829994f0d436d479936e4b4a74dbc7c3b7e5d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# Copyright 2009-2018 Wulf C. Krueger <philantrop@exherbo.org>
# Copyright 2015 Kylie McClain <somasis@exherbo.org>
# Distributed under the terms of the GNU General Public License v2

myexparam compholio_version=
myexparam gecko_version
myexparam mono_version

exparam -v COMPHOLIO_PV compholio_version

# NOTE: see dlls/appwiz.cpl/addons.c's GECKO_VERSION/MONO_VERSION macros
exparam -v GECKO_PV gecko_version
exparam -v MONO_PV mono_version

declare -A GECKO_NAME
GECKO_NAME=(
    [i686]=${PN}_gecko-${GECKO_PV}-x86.msi
    [x86_64]=${PN}_gecko-${GECKO_PV}-x86_64.msi
)
t=$(exhost --target)
MY_GECKO_NAME=${GECKO_NAME[${t%%-*}]}
unset t
MONO_NAME=${PN}-mono-${MONO_PV}.msi
STAGING_NAME=${PN}-staging
#STAGING_UNAME=${PN}-compholio
STAGING_UNAME=${STAGING_NAME}

DOWNLOADS="
    ${GECKO_NAME[@]/#/https://dl.winehq.org/wine/wine-gecko/${GECKO_PV}/}
    ${GECKO_NAME[@]/#/mirror://sourceforge/${PN}/}
    mono? (
        https://dl.winehq.org/wine/wine-mono/${MONO_PV}/${MONO_NAME}
        mirror://sourceforge/wine/Wine%20Mono/${MONO_PV}/${MONO_NAME}
    )
"
if [[ -n ${COMPHOLIO_PV} ]] && ! ever is_scm; then
    DOWNLOADS+="
        staging? ( https://github.com/${STAGING_UNAME}/${STAGING_NAME}/archive/v${COMPHOLIO_PV}.tar.gz -> ${STAGING_UNAME}-${COMPHOLIO_PV}.tar.gz )
    "
fi

if ever is_scm ; then
    SCM_REPOSITORY="git://source.winehq.org/git/${PN}.git"
    SCM_staging_REPOSITORY="https://github.com/${STAGING_UNAME}/${STAGING_NAME}.git"
    require scm-git
elif [[ $(ever range 2) -eq 0 ]]; then
    DOWNLOADS+="
        https://dl.winehq.org/wine/source/$(ever range 1).0/${PNV}.tar.xz
    "
elif [[ $(ever range 2) -gt 0 ]]; then
    DOWNLOADS+="
        https://dl.winehq.org/wine/source/$(ever range 1).x/${PNV}.tar.xz
    "
else
    DOWNLOADS+="
        https://dl.winehq.org/wine/source/$(ever range 1-2)/${PNV}.tar.xz
    "
fi

require freedesktop-desktop freedesktop-mime
require autotools [ supported_autoconf=[ 2.5 ] supported_automake=[ none ] ]

export_exlib_phases pkg_pretend src_prepare src_configure src_compile src_install pkg_postinst pkg_postrm

SUMMARY="compatibility layer capable of running Windows applications"
DESCRIPTION="
Wine is an implementation of the Windows API on top of X and Unix. It does not
require Microsoft Windows, but can use native Windows DLLs if they are available.
It provides both a development toolkit for porting Windows source code to Unix
as well as a program loader, allowing many unmodified Windows programs to run on
x86-based Unixes.
"
HOMEPAGE="http://www.winehq.org"
BUGS_TO="philantrop@exherbo.org"
REMOTE_IDS="freecode:${PN} sourceforge:${PN}"
LICENCES="
    LGPL-2.1 [[ note = [ wine ] ]]
    MPL-2.0  [[ note = [ wine-gecko ] ]]
    mono? ( LGPL-2 [[ note = [ wine-mono ] ]] )
"

if [[ -n ${COMPHOLIO_PV} ]]; then
    LICENCES+="
        staging? ( LGPL-2.1 [[ note = [ wine-staging ] ]] )
    "
fi

SLOT="0"

MYOPTIONS="
    alsa
    camera [[ description = [ Support for using digital cameras in Wine using libgphoto2 ] ]]
    cups
    gsm [[ description = [ Support the GSM 06.10 codec for lossy speech compression ] ]]
    gstreamer [[ description = [ Use GStreamer for codecs support ] ]]
    isdn [[ description = [ Support for ISDN equipment in Wine using libcapi20 ] ]]
    lcms
    ldap
    mp3
    mono [[ description = [ Use wine-mono, a replacement for Microsoft's .NET runtime based on mono ] ]]
    openal
    opengl
    oss
    pcap [[ description = [ Support for packet capturing ] ]]
    pulseaudio
    samba
    scanner
    tiff
    vulkan
    win64
    ( providers: ijg-jpeg jpeg-turbo ) [[ number-selected = exactly-one ]]
"

if [[ -n ${COMPHOLIO_PV} ]]; then
    MYOPTIONS+="
        gtk3 [[ requires = [ staging ] description = [ Add an option to use GTK3 for theming ] ]]
        staging [[ description = [ Add ALL wine-staging patches containing bug fixes and features not yet available in regular wine ] ]]
        vaapi [[ requires = [ staging ] description = [ Enable hardware accelerated video decode/encode ] ]]
    "
fi

DEPENDENCIES="
    build:
        sys-devel/bison
        sys-devel/flex[>=2.6.4] [[ note = [ https://bugs.winehq.org/show_bug.cgi?id=42132 ] ]]
        sys-devel/gettext
        virtual/pkg-config
        x11-proto/xorgproto
    build+run:
        dev-libs/glib:2
        dev-libs/gnutls
        dev-libs/libxml2
        dev-libs/libxslt
        media-libs/fontconfig
        media-libs/freetype:2[>=2.0.0]
        media-libs/libpng:=
        sys-apps/dbus
        x11-libs/libICE
        x11-libs/libSM
        x11-libs/libX11
        x11-libs/libXcursor
        x11-libs/libXcomposite
        x11-libs/libXext
        x11-libs/libXfixes
        x11-libs/libXi
        x11-libs/libXinerama
        x11-libs/libXrandr
        x11-libs/libXrender
        x11-libs/libXxf86vm
        alsa? ( sys-sound/alsa-lib )
        camera? ( media-libs/libgphoto2 )
        cups? ( net-print/cups )
        gsm? ( media-libs/gsm )
        gstreamer? (
            media-libs/gstreamer:1.0
            media-plugins/gst-plugins-base:1.0
        )
        isdn? ( dev-libs/libcapi20 )
        lcms? ( media-libs/lcms2 )
        ldap? ( net-directory/openldap )
        mp3? ( media-sound/mpg123 )
        openal? ( media-libs/openal )
        opengl? (
            x11-dri/glu
            x11-dri/mesa[>=9.0]
        )
        oss? ( sys-sound/oss )
        pcap? ( dev-libs/libpcap )
        providers:ijg-jpeg? ( media-libs/jpeg:= )
        providers:jpeg-turbo? ( media-libs/libjpeg-turbo )
        pulseaudio? ( media-sound/pulseaudio )
        samba? ( net-fs/samba[>=3.0.25] )
        scanner? ( media-gfx/sane-backends )
        tiff? ( media-libs/tiff )
    suggestion:
        fonts/corefonts [[ description = [ Many Windows apps need the MS corefonts ] ]]
"

if [[ -n ${COMPHOLIO_PV} ]]; then
    DEPENDENCIES+="
        build:
            staging? (
                dev-lang/perl:=
                dev-perl/XML-Simple
            )
        build+run:
            gtk3? ( x11-libs/gtk+:3 )
            staging? ( sys-apps/attr )
            vaapi? ( x11-libs/libva[X] )
    "
fi

# The tests need a running X and even then they're unreliable
RESTRICT="test"

# Wine's configure checks for 64bit x86 platforms and tries to add -m32 to CC if --enable-win64 is
# not given. This check (yes, that means the amd64 stuff) is chosen to be equivalent to wine's check
# in configure.ac.
my_win64_enable() {
    case "${1}" in
        x86_64*|amd64*)
            echo "--enable-win64"
            ;;
        *)
            echo "--disable-win64"
            ;;
    esac
}

ECONF_SOURCE=${WORK}
WORK_HOST=${WORK}-host

DEFAULT_SRC_CONFIGURE_PARAMS=(
    --hates=disable-dependency-tracking
    --hates=disable-silent-rules
    --hates=enable-fast-install
    --disable-tests
    --with-curses
    --with-dbus
    --with-fontconfig
    --with-freetype
    --with-gettext
    --with-gnutls
    --without-gssapi
    --with-jpeg
    --with-png
    --with-pthread
    --with-x
    --with-xcomposite
    --with-xcursor
    --with-xfixes
    --with-xinerama
    --with-xinput
    --with-xinput2
    --with-xml
    --with-xrandr
    --with-xrender
    --with-xshape
    --with-xshm
    --with-xslt
    --with-xxf86vm
    --with-zlib
    --without-coreaudio
    --without-gettextpo
    --without-hal
    --without-krb5
    --without-opencl
    --without-sdl
    --without-v4l
    $(my_win64_enable $(exhost --target))
    $(exhost --is-native -q || echo --with-wine-tools="${WORK_HOST}")
)


DEFAULT_SRC_CONFIGURE_OPTION_WITHS=(
    alsa
    "camera gphoto"
    cups
    gsm
    gstreamer
    "isdn capi"
    "lcms cms"
    ldap
    "mp3 mpg123"
    openal
    opengl
    "opengl glu"
    "opengl osmesa"
    oss
    pcap
    "pulseaudio pulse"
    "samba netapi"
    "scanner sane"
    tiff
    vulkan
)

#if ever at_least 3.11 ; then
#    DEFAULT_SRC_CONFIGURE_OPTION_WITHS+=(
#     "vulkan vkd3d"
#   )
#fi



if [[ -n ${COMPHOLIO_PV} ]]; then
    DEFAULT_SRC_CONFIGURE_OPTION_WITHS+=(
        gtk3
        "staging xattr"
        "vaapi va"
    )
fi

DEFAULT_SRC_COMPILE_PARAMS=(
    LDFLAGS=${CFLAGS}
)

wine_pkg_pretend() {
    if [[ -z ${COMPHOLIO_PV} ]] && has_version --root ${CATEGORY}/${PN}[staging]; then
        ewarn "The staging patch for ${PNV} hasn't been released yet. If you rely on it, don't install ${PNV}."
    fi
}

wine_src_prepare() {
    default

    if [[ -n ${COMPHOLIO_PV} ]] && option staging ; then
        edo ../${STAGING_NAME}-${COMPHOLIO_PV}/patches/patchinstall.sh --all --backend=patch DESTDIR="${WORK}"
    fi

    # Generate `nm` shim so winebuild will use the correct binary path
    # export PATH="${WORK}/shims:${PATH}"
    edo mkdir shims
    edo ln -s /usr/host/bin/$(exhost --tool-prefix)nm ./shims/nm
    edo ln -s /usr/host/bin/$(exhost --tool-prefix)as ./shims/as
    edo ln -s /usr/host/bin/$(exhost --tool-prefix)ar ./shims/ar
    edo ln -s /usr/host/bin/$(exhost --tool-prefix)ranlib ./shims/ranlib

    # Don't run update-desktop-database to avoid sandbox violations.
    edo sed -i -e '/^UPDATE_DESKTOP_DATABASE/s:=.*:= true:' tools/Makefile.in

    # Remove the mimetype from Wine's desktop file to avoid conflicts with Mono
    # and other stuff that sometimes uses .exe extensions.
    edo sed -i -e '/^MimeType/d' loader/wine.desktop

    if ! exhost --is-native -q; then
        # we need winetools built for the native arch and wine's build system doesn't do that
        edo mkdir "${WORK_HOST}"
    fi

    if [[ $(exhost --target) == x86_64* ]]; then
        edo sed -i -e "s:wine:&64:g" tools/wineapploader.in
    fi
    if option win64; then
        edo sed -i -e 's/"\/.wine"/"\/.wine64"/g' libs/wine/config.c
    else
        edo sed -i -e 's/"\/.wine"/"\/.wine32"/g' libs/wine/config.c
    fi

    eautoconf
}

wine_src_configure() {
    if ! exhost --is-native -q; then
        edo pushd "${WORK_HOST}"

        local old_cc=${CC} old_cxx=${CXX}

        # TODO: properly handle using the build host's tools
        CC=$(exhost --build)-cc
        CXX=$(exhost --build)-c++

        # We don't need to enable all host stuff. The tools we're about to build don't depend on
        # anything (except sfnt2fon, which requires freetype on the host).
        econf \
            "${params[@]}" \
            --host=$(exhost --build) \
            --hates=disable-dependency-tracking \
            --hates=disable-silent-rules \
            --hates=enable-fast-install \
            --with-freetype \
           $(my_win64_enable $(exhost --build))

        # we need to compile here so the actual target configure script doesn't reject
        # our tool directory
        emake tools tools/{sfnt2fon,widl,winebuild,winedump,winegcc,wmc,wrc}

        CC=${old_cc}
        CXX=${old_cxx}

        edo popd
    fi

    

    # NOTE(compnerd) the configure script is broken and checks with_lcms2 for the --with{,out}-cms
    # option, so specify this in addition to the proper handling of the option
    # NOTE --with-wine-tools while cross-compiling disables all build rules for the tools and
    # makes a cross-compiled install different from a native one except if we enable those tools
    # again
    enable_tools=yes \
    with_lcms2=$(option_enable lcms) \
        default
}

wine_src_compile() {
    export PATH="${WORK}/shims:${PATH}"

    default
}

wine_src_install() {
    default

    # in almost all cases, arch-specific things should not go in /usr/share.
    # however, this is where wine looks for gecko's msi in, and expects it
    # to be at if it is installed.
    insinto /usr/share/wine/gecko
    doins "${FETCHEDDIR}"/${MY_GECKO_NAME}

    if option mono ; then
       insinto /usr/share/wine/mono
       doins "${FETCHEDDIR}"/${MONO_NAME}
    fi
}

wine_pkg_postinst() {
    freedesktop-desktop_pkg_postinst
    freedesktop-mime_pkg_postinst
}

wine_pkg_postrm() {
    freedesktop-desktop_pkg_postrm
    freedesktop-mime_pkg_postrm
}