vinix-ports / ports / xorg-server / configure.v
42 lines · 39 sloc · 1.66 KB · c33d8afc2906b8dd9a8b905224eccd49a44f7ad5
Raw
1// Configure the two X server profiles shipped in Vinix's X11 sidecar.
2module main
3
4import os
5
6fn configure(profile string, source string, build string) ! {
7 if profile !in ['headless', 'accelerated'] {
8 return error('expected the headless or accelerated X server profile')
9 }
10 root := os.getenv('VPAC_MAKEPKG_ROOT')
11 if !os.is_abs_path(root) {
12 return error('set VPAC_MAKEPKG_ROOT to the staged target SDK')
13 }
14 script := os.abs_path(os.join_path(source, 'configure'))
15 os.mkdir_all(build)!
16 os.chdir(build)!
17 os.setenv('CPPFLAGS', (os.getenv('CPPFLAGS') + ' -D__vinix__').trim_space(), true)
18 os.setenv('LDFLAGS', (os.getenv('LDFLAGS') + ' -Wl,-rpath-link,' + root + '/usr/lib -rdynamic').trim_space(), true)
19 mut args := [script, '--localstatedir=/var', '--with-xkb-bin-directory=/usr/bin',
20 '--with-xkb-path=/usr/share/X11/xkb', '--with-xkb-output=/var/lib/xkb',
21 '--with-fontrootdir=/usr/share/fonts/X11', '--enable-xvfb', '--disable-xephyr',
22 '--disable-xnest', '--disable-suid-wrapper', '--disable-pciaccess', '--disable-dpms',
23 '--disable-xres', '--disable-xvmc', '--disable-systemd-logind', '--disable-secure-rpc',
24 '--disable-config-udev', '--disable-dri', '--disable-dri2', '--disable-int10-module',
25 '--disable-vgahw', '--disable-xinerama', '--enable-screensaver']
26 setting := if profile == 'accelerated' { '--enable-' } else { '--disable-' }
27 for feature in ['xorg', 'dri3', 'libdrm', 'glamor', 'glx'] {
28 args << setting + feature
29 }
30 os.execvp('vinix-configure', args)!
31}
32
33fn main() {
34 if os.args.len != 4 {
35 eprintln('usage: configure.v PROFILE XORG_SOURCE BUILD_DIRECTORY')
36 exit(2)
37 }
38 configure(os.args[1], os.args[2], os.args[3]) or {
39 eprintln(err)
40 exit(1)
41 }
42}
43