1PORTNAME=	wine
2DISTVERSION=	9.0
3PORTREVISION=	3
4PORTEPOCH=	1
5CATEGORIES=	emulators
6MASTER_SITES=	https://dl.winehq.org/wine/source/9.0/
7
8MAINTAINER=	ports@MidnightBSD.org
9COMMENT=	Microsoft Windows compatibility environment
10
11LICENSE=	lgpl2.1 lgpl3
12LICENSE_COMB=	dual
13LICENSE_FILE=	${WRKSRC}/LICENSE
14
15ONLY_FOR_ARCHS=	amd64 i386
16
17BUILD_DEPENDS=	${LOCALBASE}/bin/flex:textproc/flex llvm${_LLVM_VERSION}>=0:devel/llvm${_LLVM_VERSION}
18
19USES=		bison cpe desktop-file-utils gmake localbase \
20		pkgconfig sdl shebangfix tar:xz
21USE_GCC=	yes
22USE_SDL=	sdl2
23
24CPE_VENDOR=	winehq
25
26CONFLICTS_INSTALL=	wine-devel
27
28GNU_CONFIGURE=	yes
29CONFIGURE_ARGS+=--verbose \
30		--disable-kerberos \
31		--disable-tests \
32		--without-capi \
33		--without-coreaudio \
34		--without-dbus \
35		--without-gettext --without-gettextpo \
36		--without-gphoto \
37		--without-gssapi \
38		--without-inotify \
39		--without-krb5 \
40		--with-mingw CROSSCC="clang" CROSSCFLAGS="-isystem ${FILESDIR}/clang" \
41		--without-netapi \
42		--without-opencl \
43		--without-osmesa \
44		--without-pcap \
45		--without-pcsclite \
46		--with-pthread \
47		--without-pulse \
48		--without-sane \
49		--with-sdl \
50		--without-udev \
51		--without-unwind \
52		--without-usb \
53		--without-wayland \
54		--build=${ARCH}-portbld-freebsd12.4 --host=${ARCH}-portbld-freebsd12.4
55CONFIGURE_ENV=	CPPBIN="${CPP}" FLEX="${LOCALBASE}/bin/flex"
56CONFIGURE_TARGET=	${ARCH}-portbld-freebsd12.4
57WINELIBDIR=	${PREFIX}/lib
58.if !defined(USE_LDCONFIG32)
59USE_LDCONFIG=	${WINELIBDIR} ${WINELIBDIR}/wine
60.endif
61SHEBANG_FILES=	tools/make_requests tools/winemaker/winemaker \
62		tools/winedump/function_grep.pl
63
64BINARY_ALIAS+=	clang=${LOCALBASE}/bin/clang${_LLVM_VERSION} \
65		lld-link=${LOCALBASE}/bin/lld-link${_LLVM_VERSION}
66
67SUB_FILES=	pkg-message
68
69PORTDATA=	wine.inf
70MAKE_ENV+=	__MidnightBSD__=3 MTERASE=12
71
72OPTIONS_DEFINE=	CUPS DOCS DOSBOX GNUTLS V4L WINEMAKER X11 GECKO MONO
73OPTIONS_DEFAULT=ALSA GNUTLS X11
74OPTIONS_RADIO=	AUDIO
75OPTIONS_RADIO_AUDIO=	ALSA OSS
76OPTIONS_SUB=	yes
77
78DOSBOX_DESC=	Use DOSBox to run MS-DOS programs
79WINEMAKER_DESC=	Fully support winemaker (requires Perl)
80GECKO_DESC=	Bundle Gecko MSI package for Wine
81MONO_DESC=	Bundle Mono MSI package for Wine
82
83PORTSCOUT=	limit:^8\.0
84
85ALSA_CONFIGURE_WITH=	alsa
86ALSA_USES=		gnome gstreamer
87ALSA_USE=		GNOME=glib20
88ALSA_LIB_DEPENDS=	libasound.so:audio/alsa-lib
89ALSA_RUN_DEPENDS=	alsa-plugins>0:audio/alsa-plugins
90
91CUPS_CONFIGURE_WITH=	cups
92CUPS_LIB_DEPENDS=	libcups.so:print/cups
93
94DOSBOX_RUN_DEPENDS=	dosbox:emulators/dosbox
95
96GECKO_RUN_DEPENDS=	wine-gecko>0:emulators/wine-gecko
97
98GNUTLS_CONFIGURE_WITH=	gnutls
99GNUTLS_LIB_DEPENDS=	libgnutls.so:security/gnutls
100
101MONO_RUN_DEPENDS=	wine-mono>0:emulators/wine-mono
102
103OSS_CONFIGURE_WITH=	oss
104OSS_USES=		gnome gstreamer
105OSS_USE=		GNOME=glib20
106
107V4L_CONFIGURE_WITH=	v4l2
108V4L_BUILD_DEPENDS=	${LOCALBASE}/include/linux/videodev2.h:multimedia/v4l_compat
109V4L_LIB_DEPENDS=	libv4l2.so:multimedia/libv4l
110
111WINEMAKER_RUN_DEPENDS=	p5-XML-LibXML>0:textproc/p5-XML-LibXML
112
113X11_CONFIGURE_WITH=	x fontconfig freetype opengl xinerama xinput2 xrandr xrender
114X11_USES=		gl xorg
115X11_USE=		GL=glu XORG=x11,xext,xcomposite,xcursor,xi,xinerama,xrandr,xrender
116X11_LIB_DEPENDS=	libfontconfig.so:x11-fonts/fontconfig \
117			libfreetype.so:print/freetype2 \
118			libvulkan.so:graphics/vulkan-loader
119
120.include <bsd.port.pre.mk>
121
122.if ${PORT_OPTIONS:MALSA} || ${PORT_OPTIONS:MOSS}
123CONFIGURE_ARGS+=	--with-gstreamer
124PLIST_SUB+=		GSTREAMER=""
125.else
126CONFIGURE_ARGS+=	--without-gstreamer
127PLIST_SUB+=		GSTREAMER="@comment "
128.endif
129
130.if ${LLVM_DEFAULT} == 11
131_LLVM_VERSION=	15
132.else
133_LLVM_VERSION=	${LLVM_DEFAULT}
134.endif
135
136.if ${ARCH} == amd64
137# Wine is composed of three parts:
138#  - wine (aka this port on MidnightBSD/i386) is the 32-bit component
139#       and runs 32-bit programs.
140#  - wine64 (aka this part of this port on MidnightBSD/amd64) is the
141#       64-bit component and runs 64-bit programs.
142#  - wow64 (aka this port built on MidnightBSD/i386) is a part of the
143#       64-bit component [wine64] that runs 32-bit programs on MidnightBSD/amd64.
144
145# --libdir is required since Wine defaults to "${PREFIX}/lib64" on amd64.
146CONFIGURE_ARGS+=	--enable-win64 --libdir=${PREFIX}/lib
147PLIST_SUB+=		WINE32="@comment " WINE64="" WINEARCH="x86_64" WINEIMPORTDIR="x86_64-unix"
148
149# Wine assumes a WoW64 package is available, which is not the case
150post-patch:
151	${REINPLACE_CMD} '/Exec/s|wine|wine64|g' ${WRKSRC}/loader/wine.desktop
152
153.else
154EXTRA_PATCHES+=	files/extra-patch-tools-winebuild-res32
155PLIST_SUB+=		WINE32="" WINE64="@comment " WINEARCH="i386" WINEIMPORTDIR="i386-windows"
156.endif
157
158pre-build:
159	cd ${WRKSRC} && ${SETENVI} ${WRK_ENV} ${MAKE_CMD} depend
160
161post-install:
162.if ${ARCH} == i386
163	${MV} ${PREFIX}/bin/wineserver	${PREFIX}/bin/wineserver32
164	${MV} ${PREFIX}/bin/wine		${PREFIX}/bin/wine.bin
165	-${ELFCTL} -e +noaslr				${PREFIX}/bin/wine.bin
166	${INSTALL_SCRIPT} ${FILESDIR}/wine.sh		${PREFIX}/bin/wine
167.else
168	${MV} ${PREFIX}/bin/wine64		${PREFIX}/bin/wine64.bin
169	-${ELFCTL} -e +noaslr				${PREFIX}/bin/wine64.bin
170	${INSTALL_SCRIPT} ${FILESDIR}/wine.sh		${PREFIX}/bin/wine64
171	${INSTALL_SCRIPT} ${FILESDIR}/wine-wow64.sh	${PREFIX}/bin/wine
172	${INSTALL_SCRIPT} ${FILESDIR}/pkg32.sh		${DATADIR}/pkg32.sh
173.endif
174
175	@${MKDIR} ${DOCSDIR}
176.for i in ANNOUNCE.md AUTHORS README.md
177	${INSTALL_DATA} ${WRKSRC}/${i} ${DOCSDIR}
178.endfor
179	${INSTALL_DATA} ${WRKSRC}/programs/winedbg/README ${DOCSDIR}/README.winedbg
180	${INSTALL_DATA} ${WRKSRC}/tools/winedump/README ${DOCSDIR}/README.winedump
181
182.include <bsd.port.post.mk>
183