xref: /netbsd-src/external/mit/xorg/lib/gallium.old/Makefile (revision 4c0c17af69bdb1c1dee877863d44a90e4cb219f5)
1# $NetBSD: Makefile,v 1.9 2024/04/04 23:50:13 christos Exp $
2
3# Transparent struct/union broken
4NOLINT=yes
5
6# Link the gallium mega driver.
7
8LIBISMODULE=	yes
9LIBISCXX=     yes
10
11.include <bsd.own.mk>
12
13.include "../mesa-which.mk"
14
15SHLIB_MAJOR=    0
16
17LIB=		gallium_dri
18DRIDIR=		${X11USRLIBDIR}/modules/dri
19DRIDEBUGDIR=	${DEBUGDIR}${X11USRLIBDIR}/modules/dri
20
21LLVM_INCLUDE_OBJDIR!=	cd ${NETBSDSRCDIR}/external/apache2/llvm/include && ${PRINTOBJDIR}
22
23CWARNFLAGS.clang += -Wno-atomic-alignment -Wno-unknown-warning-option -Wno-implicit-int-float-conversion
24
25CXXFLAGS+=	-std=c++14
26CFLAGS+=	-std=gnu11
27CPPFLAGS+=	-I${DESTDIR}${X11INCDIR}/libdrm \
28		-I${NETBSDSRCDIR}/external/apache2/llvm/dist/llvm/include \
29		-I${LLVM_INCLUDE_OBJDIR} -I${NETBSDSRCDIR}/external/apache2/llvm/config
30
31CFLAGS+=	-pthread
32LDFLAGS+=	-pthread
33
34# Reduce debugging for these extremely large objects.
35.if ${MKDEBUG:Uno} != "no"
36CXXFLAGS+=	-g1 -gdwarf-3
37CFLAGS+=	-g1 -gdwarf-3
38.endif
39
40GALLIUM_SUBDIRS= \
41	auxiliary \
42	auxiliary/cso_cache \
43	auxiliary/draw \
44	auxiliary/driver_ddebug \
45	auxiliary/driver_noop \
46	auxiliary/driver_rbug \
47	auxiliary/driver_trace \
48	auxiliary/hud \
49	auxiliary/indices \
50	auxiliary/nir \
51	auxiliary/os \
52	auxiliary/pipebuffer \
53	auxiliary/pipe-loader \
54	auxiliary/postprocess \
55	auxiliary/rbug \
56	auxiliary/renderonly \
57	auxiliary/rtasm \
58	auxiliary/tgsi \
59	auxiliary/translate \
60	auxiliary/util \
61	auxiliary/vl \
62	drivers/noop \
63	drivers/rbug \
64	drivers/softpipe \
65	winsys/sw/dri \
66	winsys/sw/kms-dri \
67	winsys/sw/null \
68	winsys/sw/wrapper \
69	state_trackers/dri
70
71GALLIUM_SUBDIRS_VDPAU=	\
72	state_trackers/vdpau
73
74GALLIUM_SUBDIRS_LLVMPIPE= \
75	auxiliary/gallivm \
76	drivers/llvmpipe
77
78GALLIUM_SUBDIRS_ATI= \
79	drivers/radeon \
80	drivers/radeonsi \
81	drivers/r300 \
82	drivers/r300/compiler \
83	drivers/r600 \
84	drivers/r600/sb \
85	winsys/radeon/drm \
86	winsys/amdgpu/drm
87
88GALLIUM_SUBDIRS_I915= \
89	drivers/i915 \
90	winsys/i915/drm
91
92GALLIUM_SUBDIRS_NOUVEAU= \
93	drivers/nouveau \
94	drivers/nouveau/nv30 \
95	drivers/nouveau/nv50 \
96	drivers/nouveau/codegen \
97	drivers/nouveau/nvc0 \
98	winsys/nouveau/drm
99
100BUILD_RADEON=0
101BUILD_NOUVEAU=0
102BUILD_VDPAU=0
103BUILD_LLVMPIPE=0
104BUILD_I915=0
105.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
106BUILD_I915=1
107.endif
108.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || ${MACHINE} == "evbarm"
109BUILD_NOUVEAU=1
110. if ${MKLLVMRT} != "no"
111BUILD_RADEON=1
112. endif
113BUILD_VDPAU=1
114.endif
115
116.if ${MACHINE_ARCH} == "i386" || \
117    ${MACHINE_ARCH} == "x86_64" || \
118    ${MACHINE_ARCH} == "powerpc" || \
119    ${MACHINE_ARCH} == "powerpc64" || \
120    !empty(MACHINE_ARCH:Maarch64*) || \
121    !empty(MACHINE_ARCH:Mmips*) || \
122    !empty(MACHINE_ARCH:Mearm*) || \
123    !empty(MACHINE_ARCH:Marm*)
124. if ${MKLLVMRT} != "no"
125BUILD_LLVMPIPE=1
126. endif
127.endif
128
129DRIVERS=		kms_swrast swrast
130.if ${BUILD_RADEON} == 1
131DRIVERS+=		r600 r300 radeonsi
132GALLIUM_SUBDIRS+=	${GALLIUM_SUBDIRS_ATI}
133.endif
134.if ${BUILD_NOUVEAU} == 1
135DRIVERS+=		nouveau
136GALLIUM_SUBDIRS+=	${GALLIUM_SUBDIRS_NOUVEAU}
137.endif
138.if ${BUILD_VDPAU} == 1
139GALLIUM_SUBDIRS+=	${GALLIUM_SUBDIRS_VDPAU}
140.endif
141.if ${BUILD_I915} == 1
142GALLIUM_SUBDIRS+=	${GALLIUM_SUBDIRS_I915}
143.endif
144.if ${BUILD_LLVMPIPE} == 1
145GALLIUM_SUBDIRS+=	${GALLIUM_SUBDIRS_LLVMPIPE}
146.endif
147
148GALLIUM_SOURCES.auxiliary/cso_cache= \
149	cso_cache.c \
150	cso_context.c \
151	cso_hash.c
152
153GALLIUM_SOURCES.auxiliary/draw= \
154	draw_context.c \
155	draw_fs.c \
156	draw_gs.c \
157	draw_pipe_aaline.c \
158	draw_pipe_aapoint.c \
159	draw_pipe.c \
160	draw_pipe_clip.c \
161	draw_pipe_cull.c \
162	draw_pipe_flatshade.c \
163	draw_pipe_offset.c \
164	draw_pipe_pstipple.c \
165	draw_pipe_stipple.c \
166	draw_pipe_twoside.c \
167	draw_pipe_unfilled.c \
168	draw_pipe_util.c \
169	draw_pipe_validate.c \
170	draw_pipe_vbuf.c \
171	draw_pipe_wide_line.c \
172	draw_pipe_wide_point.c \
173	draw_prim_assembler.c \
174	draw_pt.c \
175	draw_pt_emit.c \
176	draw_pt_fetch.c \
177	draw_pt_fetch_emit.c \
178	draw_pt_fetch_shade_emit.c \
179	draw_pt_fetch_shade_pipeline.c \
180	draw_pt_post_vs.c \
181	draw_pt_so_emit.c \
182	draw_pt_util.c \
183	draw_pt_vsplit.c \
184	draw_vertex.c \
185	draw_vs.c \
186	draw_vs_exec.c \
187	draw_vs_variant.c
188
189.if ${MKLLVMRT} != "no"
190GALLIUM_SOURCES.auxiliary/draw+= \
191	draw_llvm.c \
192	draw_llvm_sample.c \
193	draw_pt_fetch_shade_pipeline_llvm.c \
194	draw_vs_llvm.c
195.endif
196
197GALLIUM_SOURCES.auxiliary/hud= \
198	font.c \
199	hud_context.c \
200	hud_cpu.c \
201	hud_nic.c \
202	hud_cpufreq.c \
203	hud_diskstat.c \
204	hud_sensors_temp.c \
205	hud_fps.c \
206	hud_driver_query.c
207GALLIUM_SOURCES.auxiliary/indices= \
208	u_primconvert.c
209GALLIUM_SOURCES.auxiliary/os= \
210	os_process.c
211GALLIUM_SOURCES.auxiliary/pipe-loader= \
212	pipe_loader.c \
213	pipe_loader_drm.c \
214	pipe_loader_sw.c
215
216.for _f in ${GALLIUM_SOURCES.auxiliary/pipe-loader}
217CPPFLAGS.${_f} +=	-DHAVE_PIPE_LOADER_KMS=1 \
218			-DHAVE_PIPE_LOADER_DRI=1 \
219			-DGALLIUM_STATIC_TARGETS=1 \
220			-I${X11SRCDIR.Mesa}/src/gallium/winsys \
221			-I${X11SRCDIR.Mesa}/src/loader \
222			-I${X11SRCDIR.Mesa}/../src/util
223.endfor
224
225GALLIUM_SOURCES.auxiliary/pipebuffer= \
226	pb_buffer_fenced.c \
227	pb_bufmgr_cache.c \
228	pb_bufmgr_debug.c \
229	pb_bufmgr_mm.c \
230	pb_bufmgr_slab.c \
231	pb_cache.c \
232	pb_slab.c \
233	pb_validate.c
234GALLIUM_SOURCES.auxiliary/postprocess= \
235	pp_celshade.c \
236	pp_colors.c \
237	pp_init.c \
238	pp_mlaa.c \
239	pp_run.c \
240	pp_program.c
241GALLIUM_SOURCES.auxiliary/rbug= \
242	rbug_connection.c \
243	RBUGrbug_context.c \
244	RBUGrbug_core.c \
245	rbug_demarshal.c \
246	rbug_texture.c \
247	rbug_shader.c
248GALLIUM_SOURCES.auxiliary/rtasm= \
249	rtasm_cpu.c \
250	rtasm_execmem.c \
251	rtasm_x86sse.c
252GALLIUM_SOURCES.auxiliary/tgsi= \
253	tgsi_aa_point.c \
254	tgsi_build.c \
255	tgsi_dump.c \
256	tgsi_exec.c \
257	tgsi_emulate.c \
258	tgsi_from_mesa.c \
259	tgsi_info.c \
260	tgsi_iterate.c \
261	tgsi_lowering.c \
262	tgsi_parse.c \
263	tgsi_point_sprite.c \
264	tgsi_sanity.c \
265	tgsi_scan.c \
266	tgsi_strings.c \
267	tgsi_text.c \
268	tgsi_transform.c \
269	tgsi_two_side.c \
270	tgsi_ureg.c \
271	tgsi_util.c
272GALLIUM_SOURCES.auxiliary/translate= \
273	translate.c \
274	translate_cache.c \
275	translate_generic.c \
276	translate_sse.c
277GALLIUM_SOURCES.auxiliary/util= \
278	os_misc.c \
279	u_async_debug.c \
280	u_bitmask.c \
281	u_blit.c \
282	u_blitter.c \
283	u_cache.c \
284	u_debug.c \
285	u_debug_describe.c \
286	u_debug_flush.c \
287	u_debug_gallium.c \
288	u_debug_image.c \
289	u_debug_memory.c \
290	u_debug_refcnt.c \
291	u_debug_stack.c \
292	u_debug_symbol.c \
293	u_dl.c \
294	u_draw.c \
295	u_draw_quad.c \
296	u_dump_defines.c \
297	u_dump_state.c \
298	u_format.c \
299	u_format_bptc.c \
300	u_format_etc.c \
301	u_format_latc.c \
302	u_format_other.c \
303	u_format_rgtc.c \
304	u_format_s3tc.c \
305	u_format_tests.c \
306	u_format_yuv.c \
307	u_format_zs.c \
308	u_framebuffer.c \
309	u_gen_mipmap.c \
310	u_handle_table.c \
311	u_hash_table.c \
312	u_helpers.c \
313	u_idalloc.c \
314	u_index_modify.c \
315	u_linear.c \
316	u_log.c \
317	u_mm.c \
318	u_network.c \
319	u_prim.c \
320	u_prim_restart.c \
321	u_pstipple.c \
322	u_resource.c \
323	u_ringbuffer.c \
324	u_sampler.c \
325	u_screen.c \
326	u_simple_shaders.c \
327	u_suballoc.c \
328	u_surface.c \
329	u_surfaces.c \
330	u_tests.c \
331	u_texture.c \
332	u_tile.c \
333	u_transfer.c \
334	u_transfer_helper.c \
335	u_threaded_context.c \
336	u_upload_mgr.c \
337	u_vbuf.c
338GALLIUM_SOURCES.auxiliary/nir = \
339	tgsi_to_nir.c
340GALLIUM_SOURCES.auxiliary/vl= \
341	vl_bicubic_filter.c \
342	vl_compositor.c \
343	vl_compositor_cs.c \
344	vl_compositor_gfx.c \
345	vl_csc.c \
346	vl_decoder.c \
347	vl_deint_filter.c \
348	vl_idct.c \
349	vl_matrix_filter.c \
350	vl_mc.c \
351	vl_median_filter.c \
352	vl_mpeg12_bitstream.c \
353	vl_mpeg12_decoder.c \
354	vl_vertex_buffers.c \
355	vl_video_buffer.c \
356	vl_winsys_dri.c \
357	vl_zscan.c
358
359# Generated
360.PATH: ${X11SRCDIR.Mesa}/../src/gallium/auxiliary
361GALLIUM_SOURCES.auxiliary= \
362	u_indices_gen.c \
363	u_unfilled_gen.c \
364	u_format_table.c
365.for _f in ${GALLIUM_SOURCES.auxiliary/vl}
366CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/loader
367.endfor
368.for _f in ${GALLIUM_SOURCES.auxiliary}
369CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/gallium/auxiliary/util
370CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/util
371.endfor
372
373GALLIUM_SOURCES.auxiliary/renderonly= \
374	renderonly.c
375
376GALLIUM_SOURCES.auxiliary/gallivm= \
377	lp_bld_arit.c \
378	lp_bld_arit_overflow.c \
379	lp_bld_assert.c \
380	lp_bld_bitarit.c \
381	lp_bld_const.c \
382	lp_bld_conv.c \
383	lp_bld_flow.c \
384	lp_bld_format_aos_array.c \
385	lp_bld_format_aos.c \
386	lp_bld_format_float.c \
387	lp_bld_format.c \
388	lp_bld_format_soa.c \
389	lp_bld_format_s3tc.c \
390	lp_bld_format_srgb.c \
391	lp_bld_format_yuv.c \
392	lp_bld_gather.c \
393	lp_bld_init.c \
394	lp_bld_intr.c \
395	lp_bld_logic.c \
396	lp_bld_misc.cpp \
397	lp_bld_pack.c \
398	lp_bld_printf.c \
399	lp_bld_quad.c \
400	lp_bld_sample_aos.c \
401	lp_bld_sample.c \
402	lp_bld_sample_soa.c \
403	lp_bld_struct.c \
404	lp_bld_swizzle.c \
405	lp_bld_tgsi_action.c \
406	lp_bld_tgsi_aos.c \
407	lp_bld_tgsi.c \
408	lp_bld_tgsi_info.c \
409	lp_bld_tgsi_soa.c \
410	lp_bld_type.c
411	#lp_bld_debug.cpp
412
413.for _f in ${GALLIUM_SOURCES.auxiliary/gallivm}
414CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/gallium/auxiliary/util
415.endfor
416
417
418GALLIUM_SOURCES.auxiliary/driver_ddebug = \
419        dd_context.c \
420	dd_draw.c \
421	dd_screen.c
422
423GALLIUM_SOURCES.auxiliary/driver_noop = \
424        noop_pipe.c \
425        noop_state.c
426
427GALLIUM_SOURCES.auxiliary/driver_trace = \
428        tr_context.c \
429        tr_dump.c \
430        tr_dump_state.c \
431        tr_screen.c \
432        tr_texture.c
433
434GALLIUM_SOURCES.auxiliary/driver_rbug = \
435        DRIVERrbug_core.c \
436        DRIVERrbug_context.c \
437        rbug_objects.c \
438        rbug_screen.c
439# Conflicts with auxiliary/rbug/ files
440BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/auxiliary/rbug/rbug_core.c		RBUGrbug_core.c
441BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/auxiliary/rbug/rbug_context.c		RBUGrbug_context.c
442BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/auxiliary/driver_rbug/rbug_core.c	DRIVERrbug_core.c
443BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/auxiliary/driver_rbug/rbug_context.c	DRIVERrbug_context.c
444CPPFLAGS.DRIVERrbug_core.c+=	-I${X11SRCDIR.Mesa}/src/gallium/auxiliary
445CPPFLAGS.DRIVERrbug_core.c+=	-I${X11SRCDIR.Mesa}/src/gallium/auxiliary/driver_rbug
446CPPFLAGS.DRIVERrbug_core.c+=	-I${X11SRCDIR.Mesa}/src/gallium/drivers
447CPPFLAGS.DRIVERrbug_context.c+=	-I${X11SRCDIR.Mesa}/src/gallium/auxiliary
448CPPFLAGS.DRIVERrbug_context.c+=	-I${X11SRCDIR.Mesa}/src/gallium/auxiliary/driver_rbug
449CPPFLAGS.DRIVERrbug_context.c+=	-I${X11SRCDIR.Mesa}/src/gallium/drivers
450
451GALLIUM_SOURCES.drivers/i915= \
452	i915_blit.c \
453	i915_clear.c \
454	i915_context.c \
455	i915_debug.c \
456	i915_debug_fp.c \
457	i915_flush.c \
458	i915_fpc_emit.c \
459	i915_fpc_optimize.c \
460	i915_fpc_translate.c \
461	i915_prim_emit.c \
462	i915_prim_vbuf.c \
463	i915_query.c \
464	i915_resource_buffer.c \
465	i915_resource.c \
466	i915_resource_texture.c \
467	i915_screen.c \
468	i915_state.c \
469	i915_state_derived.c \
470	i915_state_dynamic.c \
471	i915_state_emit.c \
472	i915_state_fpc.c \
473	i915_state_immediate.c \
474	i915_state_sampler.c \
475	i915_state_static.c \
476	i915_surface.c
477
478GALLIUM_SOURCES.winsys/i915/drm= \
479	i915_drm_batchbuffer.c \
480	i915_drm_buffer.c \
481	i915_drm_fence.c \
482	i915_drm_winsys.c
483
484# Conflicts with r600/radeon_video.c and radeon/radeon_video.c
485BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/drivers/r600/radeon_video.c r600_radeon_video.c
486BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/drivers/radeon/radeon_video.c radeon_radeon_video.c
487BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/drivers/r600/radeon_vce.c r600_radeon_vce.c
488BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/drivers/radeon/radeon_vce.c radeon_radeon_vce.c
489BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/drivers/r600/radeon_uvd.c r600_radeon_uvd.c
490BUILDSYMLINKS+=	${X11SRCDIR.Mesa}/src/gallium/drivers/radeon/radeon_uvd.c radeon_radeon_uvd.c
491
492GALLIUM_SOURCES.drivers/radeon = \
493        cayman_msaa.c \
494        r600_buffer_common.c \
495        r600_pipe_common.c \
496        r600_query.c \
497        r600_streamout.c \
498        r600_texture.c \
499        radeon_radeon_uvd.c \
500	radeon_uvd_enc.c \
501	radeon_uvd_enc_1_1.c \
502        radeon_vce_40_2_2.c \
503	radeon_vce_50.c \
504	radeon_vce_52.c \
505	radeon_vcn_dec.c \
506	radeon_vcn_dec_jpeg.c \
507	radeon_vcn_enc.c \
508	radeon_vcn_enc_1_2.c \
509        radeon_radeon_vce.c \
510        radeon_radeon_video.c \
511
512GALLIUM_SOURCES.drivers/r600 = \
513	eg_debug.c \
514	r600_gpu_load.c \
515	r600_perfcounter.c \
516	r600_radeon_vce.c \
517	r600_radeon_video.c \
518        compute_memory_pool.c \
519	r600_viewport.c \
520        eg_asm.c \
521        evergreen_compute.c \
522        evergreen_hw_context.c \
523        evergreen_state.c \
524        r600_asm.c \
525        r600_blit.c \
526        r600_hw_context.c \
527        r600_isa.c \
528        r600_pipe.c \
529        r600_shader.c \
530        r600_state.c \
531        r600_state_common.c \
532        r600_uvd.c \
533        r600_radeon_uvd.c \
534	r600_test_dma.c \
535        r700_asm.c
536GALLIUM_SOURCES.drivers/r600/sb = \
537        sb_bc_builder.cpp \
538        sb_bc_decoder.cpp \
539        sb_bc_dump.cpp \
540        sb_bc_finalize.cpp \
541        sb_bc_parser.cpp \
542        sb_context.cpp \
543        sb_core.cpp \
544        sb_dce_cleanup.cpp \
545        sb_def_use.cpp \
546        sb_dump.cpp \
547        sb_expr.cpp \
548        sb_gcm.cpp \
549        sb_gvn.cpp \
550        sb_if_conversion.cpp \
551        sb_ir.cpp \
552        sb_liveness.cpp \
553        sb_pass.cpp \
554        sb_peephole.cpp \
555        sb_psi_ops.cpp \
556        sb_ra_checker.cpp \
557        sb_ra_coalesce.cpp \
558        sb_ra_init.cpp \
559        sb_sched.cpp \
560        sb_shader.cpp \
561        sb_ssa_builder.cpp \
562        sb_valtable.cpp
563
564GALLIUM_SOURCES.drivers/r300 = \
565	r300_blit.c \
566	r300_chipset.c \
567	r300_context.c \
568	r300_debug.c \
569	r300_emit.c \
570	r300_flush.c \
571	r300_fs.c \
572	r300_hyperz.c \
573	r300_query.c \
574	r300_render.c \
575	r300_render_stencilref.c \
576	r300_render_translate.c \
577	r300_resource.c \
578	r300_screen_buffer.c \
579	r300_screen.c \
580	r300_state.c \
581	r300_state_derived.c \
582	r300_texture.c \
583	r300_texture_desc.c \
584	r300_tgsi_to_rc.c \
585	r300_transfer.c \
586	r300_vs.c \
587	r300_vs_draw.c
588
589GALLIUM_SOURCES.drivers/r300/compiler = \
590	memory_pool.c \
591	r300_fragprog.c \
592	r300_fragprog_emit.c \
593	r300_fragprog_swizzle.c \
594	r3xx_fragprog.c \
595	r3xx_vertprog.c \
596	r3xx_vertprog_dump.c \
597	r500_fragprog.c \
598	r500_fragprog_emit.c \
599	radeon_code.c \
600	radeon_compiler.c \
601	radeon_compiler_util.c \
602	radeon_dataflow.c \
603	radeon_dataflow_deadcode.c \
604	radeon_dataflow_swizzles.c \
605	radeon_emulate_branches.c \
606	radeon_emulate_loops.c \
607	radeon_inline_literals.c \
608	radeon_list.c \
609	radeon_opcodes.c \
610	radeon_optimize.c \
611	radeon_pair_dead_sources.c \
612	radeon_pair_regalloc.c \
613	radeon_pair_schedule.c \
614	radeon_pair_translate.c \
615	radeon_program_alu.c \
616	radeon_program.c \
617	radeon_program_pair.c \
618	radeon_program_print.c \
619	radeon_program_tex.c \
620	radeon_remove_constants.c \
621	radeon_rename_regs.c \
622	radeon_variable.c \
623	radeon_vert_fc.c
624
625GALLIUM_SOURCES.drivers/radeonsi = \
626	cik_sdma.c \
627	si_blit.c \
628	si_buffer.c \
629	si_clear.c \
630	si_compute.c \
631	si_compute_blit.c \
632	si_cp_dma.c \
633	si_debug.c \
634	si_descriptors.c \
635	si_dma.c \
636	si_dma_cs.c \
637	si_fence.c \
638	si_get.c \
639	si_gfx_cs.c \
640	si_gpu_load.c \
641	si_pipe.c \
642	si_pm4.c \
643	si_perfcounter.c \
644	si_query.c \
645	si_shader.c \
646	si_shader_nir.c \
647	si_shader_tgsi_alu.c \
648	si_shader_tgsi_mem.c \
649	si_shader_tgsi_setup.c \
650	si_shaderlib_tgsi.c \
651	si_state.c \
652	si_state_binning.c \
653	si_state_draw.c \
654	si_state_msaa.c \
655	si_state_shaders.c \
656	si_state_streamout.c \
657	si_state_viewport.c \
658	si_test_dma.c \
659	si_test_dma_perf.c \
660	si_texture.c \
661	si_uvd.c
662
663.for _f in ${GALLIUM_SOURCES.drivers/radeon}
664CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/gallium/drivers/radeon
665.endfor
666
667.for _f in ${GALLIUM_SOURCES.drivers/r300} ${GALLIUM_SOURCES.drivers/r300/compiler}
668CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/gallium/drivers/r300 \
669			-I${X11SRCDIR.Mesa}/src/gallium/drivers/r300/compiler
670.endfor
671
672.for _f in ${GALLIUM_SOURCES.drivers/r600} ${GALLIUM_SOURCES.drivers/r600/sb} ${GALLIUM_SOURCES.drivers/radeonsi}
673CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/gallium/drivers/r600
674CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/../src/gallium/drivers/r600
675CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/amd/common
676CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/../src/amd/common
677.endfor
678
679.for _f in ${GALLIUM_SOURCES.drivers/radeon}
680CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/gallium/drivers/radeonsi
681CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/amd/common
682.endfor
683
684GALLIUM_SOURCES.drivers/nouveau = \
685	nouveau_buffer.c \
686	nouveau_fence.c \
687	nouveau_heap.c \
688	nouveau_mm.c \
689	nouveau_screen.c \
690	nouveau_video.c \
691	nouveau_vp3_video_bsp.c \
692	nouveau_vp3_video.c \
693	nouveau_vp3_video_vp.c
694
695GALLIUM_SOURCES.drivers/nouveau/nv30 = \
696	nv30_clear.c \
697	nv30_context.c \
698	nv30_draw.c \
699	nv30_format.c \
700	nv30_fragprog.c \
701	nv30_fragtex.c \
702	nv30_miptree.c \
703	nv30_push.c \
704	nv30_query.c \
705	nv30_resource.c \
706	nv30_screen.c \
707	nv30_state.c \
708	nv30_state_validate.c \
709	nv30_texture.c \
710	nv30_transfer.c \
711	nv30_vbo.c \
712	nv30_vertprog.c \
713	nv40_verttex.c \
714	nvfx_fragprog.c \
715	nvfx_vertprog.c
716
717GALLIUM_SOURCES.drivers/nouveau/nv50 = \
718	nv50_compute.c \
719	nv50_context.c \
720	nv50_formats.c \
721	nv50_miptree.c \
722	nv50_program.c \
723	nv50_push.c \
724	nv50_query.c \
725	nv50_query_hw.c \
726	nv50_query_hw_metric.c \
727	nv50_query_hw_sm.c \
728	nv50_resource.c \
729	nv50_screen.c \
730	nv50_shader_state.c \
731	nv50_state.c \
732	nv50_state_validate.c \
733	nv50_surface.c \
734	nv50_tex.c \
735	nv50_transfer.c \
736	nv50_vbo.c \
737	nv84_video_bsp.c \
738	nv84_video.c \
739	nv84_video_vp.c \
740	nv98_video_bsp.c \
741	nv98_video.c \
742	nv98_video_ppp.c \
743	nv98_video_vp.c
744
745GALLIUM_SOURCES.drivers/nouveau/codegen = \
746	nv50_ir.cpp \
747	nv50_ir_bb.cpp \
748	nv50_ir_build_util.cpp \
749	nv50_ir_emit_gk110.cpp \
750	nv50_ir_emit_gm107.cpp \
751	nv50_ir_emit_nv50.cpp \
752	nv50_ir_emit_nvc0.cpp \
753	nv50_ir_from_common.cpp \
754	nv50_ir_from_nir.cpp \
755	nv50_ir_from_tgsi.cpp \
756	nv50_ir_graph.cpp \
757	nv50_ir_lowering_gm107.cpp \
758	nv50_ir_lowering_helper.cpp \
759	nv50_ir_lowering_nv50.cpp \
760	nv50_ir_lowering_nvc0.cpp \
761	nv50_ir_peephole.cpp \
762	nv50_ir_print.cpp \
763	nv50_ir_ra.cpp \
764	nv50_ir_ssa.cpp \
765	nv50_ir_target.cpp \
766	nv50_ir_target_nv50.cpp \
767	nv50_ir_util.cpp \
768	nv50_ir_target_gm107.cpp \
769	nv50_ir_target_nvc0.cpp
770
771GALLIUM_SOURCES.drivers/nouveau/nvc0 = \
772	nvc0_compute.c \
773	nvc0_context.c \
774	nvc0_formats.c \
775	nvc0_miptree.c \
776	nvc0_resource.c \
777	nvc0_screen.c \
778	nvc0_state.c \
779	nvc0_state_validate.c \
780	nvc0_surface.c \
781	nvc0_tex.c \
782	nvc0_transfer.c \
783	nvc0_vbo.c \
784	nvc0_vbo_translate.c \
785	nvc0_program.c \
786	nvc0_shader_state.c \
787	nvc0_query.c \
788	nvc0_query_hw.c \
789	nvc0_query_hw_metric.c \
790	nvc0_query_hw_sm.c \
791	nvc0_query_sw.c \
792	nve4_compute.c \
793	nvc0_video.c \
794	nvc0_video_bsp.c \
795	nvc0_video_vp.c \
796	nvc0_video_ppp.c
797
798
799GALLIUM_SOURCES.winsys/nouveau/drm = \
800        nouveau_drm_winsys.c
801
802.for _f in ${GALLIUM_SOURCES.drivers/nouveau} \
803	   ${GALLIUM_SOURCES.drivers/nouveau/nv30} \
804	   ${GALLIUM_SOURCES.drivers/nouveau/nv50} \
805	   ${GALLIUM_SOURCES.drivers/nouveau/codegen} \
806	   ${GALLIUM_SOURCES.drivers/nouveau/nvc0} \
807	   ${GALLIUM_SOURCES.winsys/nouveau/drm}
808CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/gallium/drivers/nouveau \
809			-I${DESTDIR}${X11INCDIR}/libdrm/nouveau
810.endfor
811
812GALLIUM_SOURCES.winsys/radeon/drm = \
813        radeon_drm_bo.c \
814        radeon_drm_cs.c \
815	radeon_drm_surface.c \
816        radeon_drm_winsys.c
817
818GALLIUM_SOURCES.winsys/amdgpu/drm = \
819	amdgpu_bo.c \
820	amdgpu_cs.c \
821	amdgpu_surface.c \
822	amdgpu_winsys.c
823
824.for _f in ${GALLIUM_SOURCES.winsys/amdgpu/drm}
825CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/amd
826.endfor
827
828GALLIUM_SOURCES.state_trackers/vdpau = \
829	bitmap.c \
830	decode.c \
831	device.c \
832	ftab.c \
833	htab.c \
834	mixer.c \
835	output.c \
836	preemption.c \
837	presentation.c \
838	query.c \
839	surface.c
840
841GALLIUM_SOURCES.drivers/llvmpipe = \
842	lp_bld_alpha.c \
843	lp_bld_blend_aos.c \
844	lp_bld_blend.c \
845	lp_bld_blend_logicop.c \
846	lp_bld_depth.c \
847	lp_bld_interp.c \
848	lp_clear.c \
849	lp_context.c \
850	lp_draw_arrays.c \
851	lp_fence.c \
852	lp_flush.c \
853	lp_jit.c \
854	lp_memory.c \
855	lp_perf.c \
856	lp_query.c \
857	lp_rast.c \
858	lp_rast_debug.c \
859	lp_rast_tri.c \
860	lp_scene.c \
861	lp_scene_queue.c \
862	lp_screen.c \
863	lp_setup.c \
864	lp_setup_line.c \
865	lp_setup_point.c \
866	lp_setup_tri.c \
867	lp_setup_vbuf.c \
868	lp_state_blend.c \
869	lp_state_clip.c \
870	lp_state_derived.c \
871	lp_state_fs.c \
872	lp_state_gs.c \
873	lp_state_rasterizer.c \
874	lp_state_sampler.c \
875	lp_state_setup.c \
876	lp_state_so.c \
877	lp_state_surface.c \
878	lp_state_vertex.c \
879	lp_state_vs.c \
880	lp_surface.c \
881	lp_tex_sample.c \
882	lp_texture.c
883
884GALLIUM_SOURCES.drivers/softpipe = \
885	sp_buffer.c \
886	sp_clear.c \
887	sp_context.c \
888	sp_compute.c \
889	sp_draw_arrays.c \
890	sp_fence.c \
891	sp_flush.c \
892	sp_fs_exec.c \
893	sp_image.c \
894	sp_prim_vbuf.c \
895	sp_quad_blend.c \
896	sp_quad_depth_test.c \
897	sp_quad_fs.c \
898	sp_quad_pipe.c \
899	sp_quad_stipple.c \
900	sp_query.c \
901	sp_screen.c \
902	sp_setup.c \
903	sp_state_blend.c \
904	sp_state_clip.c \
905	sp_state_derived.c \
906	sp_state_image.c \
907	sp_state_rasterizer.c \
908	sp_state_sampler.c \
909	sp_state_shader.c \
910	sp_state_so.c \
911	sp_state_surface.c \
912	sp_state_vertex.c \
913	sp_surface.c \
914	sp_tex_sample.c \
915	sp_tex_tile_cache.c \
916	sp_texture.c \
917	sp_tile_cache.c
918
919GALLIUM_SOURCES.winsys/sw/null = \
920	null_sw_winsys.c
921
922GALLIUM_SOURCES.winsys/sw/wrapper = \
923	wrapper_sw_winsys.c
924
925GALLIUM_SOURCES.winsys/sw/dri = \
926	dri_sw_winsys.c
927
928GALLIUM_SOURCES.winsys/sw/kms-dri = \
929	kms_dri_sw_winsys.c
930
931GALLIUM_SOURCES.state_trackers/dri = \
932        dri_context.c \
933        dri_drawable.c \
934	dri_helpers.c \
935        dri_query_renderer.c \
936        dri_screen.c \
937	drisw.c \
938	dri2.c
939.for _f in ${GALLIUM_SOURCES.state_trackers/dri}
940CPPFLAGS.${_f} +=	-I${X11SRCDIR.Mesa}/src/gallium/state_trackers/dri/common
941.endfor
942
943# missing
944CPPFLAGS+=	\
945	-DGALLIUM_SOFTPIPE \
946	-DGALLIUM_STATIC_TARGETS=1 \
947	-DMESA_EGL_NO_X11_HEADERS
948
949.for _d in ${GALLIUM_SUBDIRS}
950SRCS+=	${GALLIUM_SOURCES.${_d}}
951.PATH: ${X11SRCDIR.Mesa}/src/gallium/${_d}
952. for _s in ${GALLIUM_SOURCES.${_d}}
953CPPFLAGS.${_s}+= -I${X11SRCDIR.Mesa}/src/gallium/${_d}
954. endfor
955.endfor
956
957#. if defined(${GALLIUM_SOURCES.${_d}})
958#SRCS+=	${GALLIUM_SOURCES.${_d}}
959#. endif
960
961.include "../libloader.old.mk"
962
963.if ${BUILD_RADEON} == 1
964CFLAGS+=	-pthread
965LDFLAGS+=	-pthread
966.endif
967
968LIBDPLIBS+=	X11-xcb         ${.CURDIR}/../libX11/libX11-xcb
969LIBDPLIBS+=	xcb-dri2        ${.CURDIR}/../libxcb/dri2
970LIBDPLIBS+=	xcb		${.CURDIR}/../libxcb/libxcb
971.if ${BUILD_RADEON} == 1 || ${BUILD_NOUVEAU} == 1
972LIBDPLIBS+= 	drm		${.CURDIR}/../libdrm
973.if ${BUILD_I915} == 1
974LIBDPLIBS+= 	drm_intel	${.CURDIR}/../libdrm_intel
975.endif
976.if ${BUILD_RADEON} == 1
977LIBDPLIBS+= 	drm_radeon	${.CURDIR}/../libdrm_radeon
978LIBDPLIBS+= 	drm_amdgpu	${.CURDIR}/../libdrm_amdgpu
979.endif	# ${BUILD_RADEON} == 1
980.if ${BUILD_NOUVEAU} == 1
981LIBDPLIBS+= 	drm_nouveau	${.CURDIR}/../libdrm_nouveau
982.endif	# ${BUILD_NOUVEAU} == 1
983.endif	# ${BUILD_RADEON} == 1 || ${BUILD_NOUVEAU} == 1
984LIBDPLIBS+= 	glapi		${.CURDIR}/../libglapi${OLD_SUFFIX}
985LIBDPLIBS+=	expat		${.CURDIR}/../../../../../external/mit/expat/lib/libexpat
986LIBDPLIBS+=	terminfo	${.CURDIR}/../../../../../lib/libterminfo
987LIBDPLIBS+=	execinfo	${.CURDIR}/../../../../../lib/libexecinfo
988
989LIBDPLIBS+=	elf		${NETBSDSRCDIR}/external/bsd/elftoolchain/lib/libelf
990LIBDPLIBS+=	z		${.CURDIR}/../../../../../lib/libz
991LIBDPLIBS+=	m		${.CURDIR}/../../../../../lib/libm
992
993# gallium drivers requiring LLVM
994.if ${BUILD_LLVMPIPE} == 1 || ${BUILD_RADEON} == 1
995
996LLVMRT_LIBS=	\
997		MCJIT \
998		ExecutionEngine \
999		ExecutionEngineOrcTargetProcess \
1000		ExecutionEngineOrcShared \
1001		Orc \
1002		RuntimeDyld
1003
1004.if ${BUILD_RADEON} == 1
1005LLVMRT_LIBS+=	\
1006		AMDGPUCodeGen \
1007		AMDGPUMCTargetDesc \
1008		AMDGPUTargetInfo \
1009		AMDGPUAsmParser \
1010		AMDGPUUtils
1011.endif
1012
1013.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
1014# XXX duplicates
1015LLVMRT_LIBS+=	\
1016		X86Disassembler \
1017		X86CodeGen \
1018		X86MCTargetDesc \
1019		X86Disassembler \
1020		X86MCTargetDesc \
1021		X86TargetInfo
1022.endif
1023
1024.if ${MACHINE_CPU} == "aarch64"
1025LLVMRT_LIBS+=	\
1026		AArch64AsmParser \
1027		AArch64CodeGen \
1028		AArch64MCTargetDesc \
1029		AArch64Utils \
1030		AArch64Disassembler \
1031		AArch64TargetInfo
1032.endif
1033
1034.if ${MACHINE_CPU} == "arm"
1035LLVMRT_LIBS+=	\
1036		ARMCodeGen \
1037		ARMDisassembler \
1038		ARMTargetInfo \
1039		ARMMCTargetDesc \
1040		ARMAsmParser \
1041		ARMUtils
1042.endif
1043
1044.if ${MACHINE_CPU} == "mips"
1045LLVMRT_LIBS+=	\
1046		MipsCodeGen \
1047		MipsDisassembler \
1048		MipsAsmParser \
1049		MipsMCTargetDesc \
1050		MipsTargetInfo
1051.endif
1052
1053.if ${MACHINE_CPU} == "powerpc"
1054LLVMRT_LIBS+=	\
1055		PowerPCCodeGen \
1056		PowerPCDisassembler \
1057		PowerPCTargetInfo \
1058		PowerPCMCTargetDesc \
1059		PowerPCAsmParser
1060.endif
1061
1062LLVMRT_LIBS+=	\
1063		Passes \
1064		TransformsCoroutines \
1065		ObjCARC \
1066		GlobalISel \
1067		MCDisassembler \
1068		SelectionDAG \
1069		AsmPrinter \
1070		CodeGen \
1071		TransformsCFGuard \
1072		Target \
1073		InstCombine \
1074		ScalarOpts \
1075		DebugInfoCodeView \
1076		DebugInfoDWARF \
1077		Object \
1078		BitReader \
1079		TextAPI \
1080		MIRParser \
1081		MCParser \
1082		MC \
1083		ipo \
1084		BitWriter \
1085		FrontendOpenMP \
1086		Instrumentation \
1087		IRReader \
1088		AsmParser \
1089		Vectorize \
1090		TransformsAggressiveInstCombine \
1091		ProfileData \
1092		TransformsUtils \
1093		Analysis \
1094		IR \
1095		Remarks \
1096		BitstreamReader \
1097		Linker \
1098		BinaryFormat \
1099		Support \
1100		Demangle
1101
1102.include "${NETBSDSRCDIR}/external/apache2/llvm/link.mk"
1103
1104.endif  # ${BUILD_LLVM_PIPE} == 1 || ${BUILD_RADEON} == 1
1105
1106LDFLAGS+=	-Wl,--version-script=${X11SRCDIR.Mesa}/src/gallium/targets/dri/dri.sym
1107.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || ${MACHINE_CPU} == "aarch64"
1108LDFLAGS+=	-Wl,-z,defs
1109.endif
1110
1111##  build mesagallium parts
1112MESA_SRC_MODULES=  main math vbo state_tracker program asm_s
1113.if ${BUILD_RADEON} == 1
1114MESA_SRC_MODULES+= amd
1115.endif
1116
1117.include "../libmesa.old.mk"
1118.include "../libglsl.old.mk"
1119
1120# Special addition for just gallium; it misses the rest of asm_c files.
1121.PATH: ${X11SRCDIR.Mesa}/src/mesa/x86
1122SRCS+=	common_x86.c
1123
1124.if ${MACHINE} == "amd64" || ${MACHINE} == "i386"
1125SRCS+=	streaming-load-memcpy.c
1126CPPFLAGS.streaming-load-memcpy.c+= -msse4.1
1127.endif
1128
1129# Needs 64bit atomics
1130CPPFLAGS.i386+= -march=i586
1131CPPFLAGS+=	${CPPFLAGS.${XORG_MACHINE_ARCH:U${MACHINE_ARCH}}}
1132
1133CPPFLAGS.r600_pipe_common.c+=	-DMESA_LLVM_VERSION_STRING=\"${LLVM_VERSION}\"
1134CPPFLAGS.si_get.c+=	-DMESA_LLVM_VERSION_STRING=\"${LLVM_VERSION}\"
1135
1136.include "../driver${OLD_SUFFIX}.mk"
1137
1138
1139.PATH: ${X11SRCDIR.Mesa}/src/gallium/targets/dri
1140SRCS+=	target.c
1141
1142CPPFLAGS+= \
1143	-I${X11SRCDIR.Mesa}/src/gallium/include \
1144	-I${X11SRCDIR.Mesa}/src/gallium/auxiliary \
1145	-I${X11SRCDIR.Mesa}/src/gallium/drivers \
1146	-I${X11SRCDIR.Mesa}/../src/mesa/drivers/dri/common
1147
1148CPPFLAGS.target.c += \
1149	-DDRI_TARGET \
1150	-DGALLIUM_NOOP \
1151	-DGALLIUM_RBUG \
1152	-DGALLIUM_TRACE \
1153	-DGALLIUM_SOFTPIPE \
1154	-I${X11SRCDIR.Mesa}/src/gallium/state_trackers/dri \
1155	-I${X11SRCDIR.Mesa}/src/loader \
1156	-I${X11SRCDIR.Mesa}/../src/util \
1157	-I${X11SRCDIR.Mesa}/../src/gallium/drivers \
1158	-I${X11SRCDIR.Mesa}/src/gallium/winsys
1159
1160.if ${BUILD_LLVMPIPE} == 1
1161CPPFLAGS.target.c += \
1162	-DGALLIUM_LLVMPIPE
1163.endif  #${BUILD_LLVMPIPE} == 1
1164
1165.if ${BUILD_I915} == 1
1166CPPFLAGS.target.c += \
1167	-DGALLIUM_I915 \
1168	-DGALLIUM_ILO
1169.endif
1170
1171.if ${BUILD_RADEON} == 1
1172CPPFLAGS.target.c += \
1173	-DGALLIUM_R200 \
1174	-DGALLIUM_R300 \
1175	-DGALLIUM_R600 \
1176	-DGALLIUM_RADEONSI
1177.endif	# ${BUILD_RADEON} == 1
1178
1179.if ${BUILD_NOUVEAU} == 1
1180CPPFLAGS.target.c += \
1181	-DGALLIUM_NOUVEAU
1182.endif	# ${BUILD_NOUVEAU} == 1
1183
1184CWARNFLAGS.clang+=	-Wno-error=constant-conversion \
1185			-Wno-error=tautological-constant-out-of-range-compare \
1186			-Wno-error=pointer-sign \
1187			-Wno-error=switch \
1188			-Wno-error=absolute-value \
1189			-Wno-error=tautological-compare \
1190			-Wno-error=static-in-inline \
1191			-Wno-error=logical-not-parentheses \
1192			-Wno-error=constant-logical-operand \
1193			-Wno-error=unknown-warning-option \
1194			-Wno-error=typedef-redefinition \
1195			-Wno-error=enum-conversion # https://bugs.freedesktop.org/show_bug.cgi?id=109761
1196
1197CWARNFLAGS+=		-Wno-error=stack-protector
1198
1199.include <bsd.x11.mk>
1200LIBDIR=		${X11USRLIBDIR}/modules/dri
1201
1202.for _d in ${DRIVERS}
1203SYMLINKS+= gallium_dri.so ${DRIDIR}/${_d}_dri.so
1204SYMLINKS+= gallium_dri.so.${SHLIB_MAJOR} ${DRIDIR}/${_d}_dri.so.${SHLIB_MAJOR}
1205.if ${MKDEBUG} != "no"
1206SYMLINKS+= gallium_dri.so.${SHLIB_MAJOR}.debug ${DRIDEBUGDIR}/${_d}_dri.so.${SHLIB_MAJOR}.debug
1207.endif
1208.endfor
1209
1210.if ${MACHINE_ARCH} == "sparc" || ${COMMON_MACHINE_ARCH:U} == "sparc"
1211COPTS+=	${${ACTIVE_CC} == "clang":? -Wa,-Av8plus  :}
1212.endif
1213
1214# XXXGCC12
1215.if ${MACHINE_ARCH} == "m68k"
1216COPTS.st_glsl_to_tgsi.cpp += -O1
1217COPTS.vl_bicubic_filter.c += -O1
1218COPTS.nir_opt_algebraic.c += -Os -fno-jump-tables
1219.endif
1220
1221COPTS.u_atomic.c+=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-builtin-declaration-mismatch :}
1222
1223COPTS.prog_opt_constant_fold.c+=	${CC_WNO_STRINGOP_OVERREAD}
1224
1225.include <bsd.lib.mk>
1226# Don't regenerate c files
1227.y.c:
1228