summaryrefslogtreecommitdiff
path: root/pkg/libdrm/gen.lua
blob: 1bf8d7299cf4d22da6fc7d50291a800ea8987e66 (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
local function havedriver(name)
	local enabled = config.video_drivers and config.video_drivers[name]
	return '-D HAVE_'..name:upper()..'='..(enabled and '1' or '0')
end

cflags{
	'-include $dir/config.h',
	havedriver('intel'),
	havedriver('nouveau'),
	havedriver('amdgpu'),
	'-I $dir',
	'-I $srcdir',
	'-I $srcdir/include/drm',
	'-I $builddir/pkg/linux-headers/include',
}

pkg.hdrs = {
	copy('$outdir/include', '$srcdir', {'xf86drm.h', 'xf86drmMode.h'}),
	copy('$outdir/include', '$srcdir/amdgpu', {'amdgpu.h'}),
	copy('$outdir/include', '$srcdir/include/drm', {
		'drm.h',
		'drm_fourcc.h',
		'drm_mode.h',
		'drm_sarea.h',
		'i915_drm.h',
		'amdgpu_drm.h',
	}),
}

pkg.deps = {
	'pkg/linux-headers/headers',
}

lib('libdrm.a', {
	'xf86drm.c',
	'xf86drmHash.c',
	'xf86drmRandom.c',
	'xf86drmSL.c',
	'xf86drmMode.c',
})

if config.video_drivers and config.video_drivers['intel'] then
	cflags{'-I $builddir/pkg/libpciaccess/include'}
	table.insert(pkg.deps, 'pkg/libpciaccess/headers')
	lib('libdrm_intel.a', [[
		intel/(
			intel_bufmgr.c
			intel_bufmgr_fake.c
			intel_bufmgr_gem.c
			intel_decode.c
			mm.c
			intel_chipset.c
		)
		$builddir/pkg/libpciaccess/libpciaccess.a
	]])
end

if config.video_drivers and config.video_drivers['nouveau'] then
	lib('libdrm_nouveau.a', [[
		nouveau/(
			nouveau.c
			pushbuf.c
			bufctx.c
			abi16.c
		)
	]])
end

if config.video_drivers and config.video_drivers['amdgpu'] then
	cflags{string.format([[-D 'AMDGPU_ASIC_ID_TABLE="%s/share/libdrm/amdgpu.ids"']], config.prefix)}
	lib('libdrm_amdgpu.a', [[
		amdgpu/(
			amdgpu_asic_id.c
			amdgpu_bo.c
			amdgpu_cs.c
			amdgpu_device.c
			amdgpu_gpu_info.c
			amdgpu_vamgr.c
			amdgpu_vm.c
			handle_table.c
		)
	]])
	file('share/libdrm/amdgpu.ids', '644', '$srcdir/data/amdgpu.ids')
end

fetch 'git'