summaryrefslogtreecommitdiff
path: root/graphics/MesaLib/Makefile
blob: 63f3562778bdf754d7b899b70442c89688a9cc89 (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
# $NetBSD: Makefile,v 1.190 2020/03/20 16:10:51 nia Exp $

DISTNAME=	mesa-20.0.2
PKGNAME=	${DISTNAME:S/mesa/MesaLib/}
CATEGORIES=	graphics
MASTER_SITES=	https://mesa.freedesktop.org/archive/
EXTRACT_SUFX=	.tar.xz

MAINTAINER=	nia@NetBSD.org
HOMEPAGE=	https://www.mesa3d.org/
COMMENT=	Open source OpenGL implementation
LICENSE=	mit

USE_TOOLS+=	bison flex pkg-config xgettext
USE_LANGUAGES=	c99 c++14
USE_LIBTOOL=	yes

# ERROR: C++ Compiler does not support -std=c++14
GCC_REQD+=	5

USE_FEATURES+=	strnlen

CFLAGS.SunOS+=		-D_POSIX_PTHREAD_SEMANTICS
CXXFLAGS.SunOS+=	-Drestrict=__restrict__
LDFLAGS.SunOS+=		-lsocket -lnsl

# Some of these get appended in options.mk.
DRI_DRIVERS=		#
GALLIUM_DRIVERS=	swrast
VULKAN_DRIVERS=		#
MESA_PLATFORMS=		#

.include "../../mk/compiler.mk"
.include "features.mk"
.include "options.mk"

PLIST_SUBST+=	GLVER="1.2.0"

# classic DRI drivers
PLIST_VARS+=		i915 i965 r100 r200 nouveau_dri

# Gallium drivers
PLIST_VARS+=		r300 svga nouveau vc4 lima panfrost

# other features
PLIST_VARS+=		kms vaapi

.if ${MESALIB_SUPPORTS_DRI} == "yes"
BUILDLINK_API_DEPENDS.libdrm+=	libdrm>=2.4.100
.include "../../x11/libdrm/buildlink3.mk"
MESA_PLATFORMS+=	drm surfaceless
MESON_ARGS+=		-Degl=true
MESON_ARGS+=		-Dgbm=true
MESON_ARGS+=		-Dgallium-xa=true
PLIST.kms=		yes
.  if !empty(MACHINE_ARCH:M*arm*) || \
      ${MACHINE_ARCH} == "aarch64"
# ARM Mali Utgard
GALLIUM_DRIVERS+=	lima
PLIST.lima=		yes
# ARM Mali Midgard, Bifrost
GALLIUM_DRIVERS+=	panfrost
PLIST.panfrost=		yes
# Vivante GCxxx
#GALLIUM_DRIVERS+=	etnaviv
#PLIST.etnaviv=		yes
# Qualcomm Snapdragon
#GALLIUM_DRIVERS+=	freedreno
#PLIST.freedreno=	yes
# Broadcom VideoCore 4
GALLIUM_DRIVERS+=	vc4
PLIST.vc4=		yes
.  endif
.  if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
GALLIUM_DRIVERS+=	svga
DRI_DRIVERS+=		i915 i965
PLIST.svga=		yes
PLIST.i915=		yes
PLIST.i965=		yes
.  endif
# FreeBSD lacks nouveau support (there are official binaries from Nvidia)
.  if ${OPSYS} != "FreeBSD"
PLIST.nouveau=		yes
PLIST.nouveau_dri=	yes
GALLIUM_DRIVERS+=	nouveau
DRI_DRIVERS+=		nouveau
.  endif
.  if !empty(MACHINE_PLATFORM:MLinux-*-x86_64)
# qemu Linux guest driver
# XXX test this
#GALLIUM_DRIVERS+=	virgl
#PLIST.virgl=		yes
.  endif
# theoretically cross platform PCI drivers
.  if empty(MACHINE_PLATFORM:MNetBSD-*-*arm*) && \
      empty(MACHINE_PLATFORM:MNetBSD-*-mipsel)
DRI_DRIVERS+=		r100 r200
GALLIUM_DRIVERS+=	r300
PLIST.r100=		yes
PLIST.r200=		yes
PLIST.r300=		yes
.  endif
.  include "../../multimedia/libva/available.mk"
.  if ${VAAPI_AVAILABLE} == "yes" && \
      !(empty(GALLIUM_DRIVERS:Mr600) && empty(GALLIUM_DRIVERS:Mradeonsi) && \
        empty(GALLIUM_DRIVERS:Mnouveau))
MESON_ARGS+=		-Dgallium-va=true
PLIST.vaapi=		yes
.    include "../../multimedia/libva/buildlink3.mk"
.  else
MESON_ARGS+=		-Dgallium-va=false
.  endif
.else
MESA_PLATFORMS+=	surfaceless
MESON_ARGS+=		-Degl=false
MESON_ARGS+=		-Dgbm=false
.endif # ${MESALIB_SUPPORTS_DRI} == "yes"

MESON_ARGS+=	-Dgallium-drivers=${GALLIUM_DRIVERS:ts,}
MESON_ARGS+=	-Ddri-drivers=${DRI_DRIVERS:ts,}
MESON_ARGS+=	-Dvulkan-drivers=${VULKAN_DRIVERS:ts,}
MESON_ARGS+=	-Dplatforms=${MESA_PLATFORMS:ts,}

.if ${MACHINE_ARCH} == "i386"
MESON_ARGS+=	-Dglx-read-only-text=true
CFLAGS+=	-march=i586
CXXFLAGS+=	-march=i586
.endif

MESON_ARGS+=	-Dgles1=true
MESON_ARGS+=	-Dgles2=true
MESON_ARGS+=	-Dosmesa=gallium
MESON_ARGS+=	-Dshared-glapi=true
MESON_ARGS+=	-Dgallium-xvmc=false

CPPFLAGS+=	-DHAVE_NOATEXIT
CPPFLAGS+=	-DSYSCONFDIR=${PKG_SYSCONFDIR}

TOOL_DEPENDS+=	${PYPKGPREFIX}-mako-[0-9]*:../../devel/py-mako

# needed to build vulkan support
TOOL_DEPENDS+=	${PYPKGPREFIX}-cElementTree-[0-9]*:../../textproc/py-cElementTree

BUILDLINK_TRANSFORM+=		rm:-Werror=incompatible-pointer-types

# https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1854
BUILDLINK_TRANSFORM+=		rm:-Werror=return-type

# ../src/intel/perf/gen_perf.c:426:7: error: %m is only allowed in syslog(3) like functions
BUILDLINK_TRANSFORM+=		rm:-Werror=format
BUILDLINK_TRANSFORM+=		rm:-Wformat-security

# https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1853
BUILDLINK_TRANSFORM.SunOS+=	rm:-Wl,--build-id=sha1

# Work around Xorg segfaulting in radeon driver due to wrong alloca being used
CFLAGS.NetBSD+=		-Dalloca=__builtin_alloca
CXXFLAGS.NetBSD+=	-Dalloca=__builtin_alloca

EGDIR=		${PREFIX}/share/examples/mesa

CONF_FILES+=	${EGDIR}/00-mesa-defaults.conf ${PKG_SYSCONFDIR}/drirc

INSTALLATION_DIRS+=	${EGDIR}

PYTHON_FOR_BUILD_ONLY=		tool
PYTHON_VERSIONS_INCOMPATIBLE=	27

PKGCONFIG_OVERRIDE_STAGE=	pre-install
PKGCONFIG_OVERRIDE+=		output/meson-private/glesv1_cm.pc
PKGCONFIG_OVERRIDE+=		output/meson-private/glesv2.pc
PKGCONFIG_OVERRIDE+=		output/meson-private/dri.pc
PKGCONFIG_OVERRIDE+=		output/meson-private/gbm.pc
PKGCONFIG_OVERRIDE+=		output/meson-private/egl.pc
PKGCONFIG_OVERRIDE+=		output/meson-private/osmesa.pc
PKGCONFIG_OVERRIDE+=		output/meson-private/xatracker.pc
PKGCONFIG_OVERRIDE+=		output/meson-private/gl.pc

post-install:
	${MV} ${DESTDIR}${PREFIX}/share/drirc.d/00-mesa-defaults.conf ${DESTDIR}${EGDIR}
.if ${OPSYS} == "Darwin"
	install_name_tool -id ${PREFIX}/lib/dri/swrast_dri.so \
	    ${DESTDIR}${PREFIX}/lib/dri/swrast_dri.so
.endif

.include "../../devel/meson/build.mk"
.include "../../devel/zlib/buildlink3.mk"
.include "../../lang/python/tool.mk"
.include "../../textproc/expat/buildlink3.mk"
.include "../../mk/bsd.pkg.mk"