| 1 | // Configure the two X server profiles shipped in Vinix's X11 sidecar. |
| 2 | module main |
| 3 | |
| 4 | import os |
| 5 | |
| 6 | fn 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 | mut cppflags := os.getenv('CPPFLAGS') + ' -D__vinix__' |
| 18 | if profile == 'accelerated' { |
| 19 | // The Xorg-only glamor module includes xf86drm.h outside the DRI3 build. |
| 20 | cppflags += ' -I' + root + '/usr/include/libdrm' |
| 21 | } |
| 22 | os.setenv('CPPFLAGS', cppflags.trim_space(), true) |
| 23 | os.setenv('LDFLAGS', (os.getenv('LDFLAGS') + ' -Wl,-rpath-link,' + root + '/usr/lib -rdynamic').trim_space(), true) |
| 24 | mut args := [script, '--localstatedir=/var', '--with-xkb-bin-directory=/usr/bin', |
| 25 | '--with-xkb-path=/usr/share/X11/xkb', '--with-xkb-output=/var/lib/xkb', |
| 26 | '--with-fontrootdir=/usr/share/fonts/X11', '--enable-xvfb', '--disable-xephyr', |
| 27 | '--disable-xnest', '--disable-suid-wrapper', '--disable-pciaccess', '--disable-dpms', |
| 28 | '--disable-xres', '--disable-xvmc', '--disable-systemd-logind', '--disable-secure-rpc', |
| 29 | '--disable-config-udev', '--disable-dri', '--disable-dri2', '--disable-int10-module', |
| 30 | '--disable-vgahw', '--disable-xinerama', '--enable-screensaver'] |
| 31 | setting := if profile == 'accelerated' { '--enable-' } else { '--disable-' } |
| 32 | for feature in ['xorg', 'dri3', 'libdrm', 'glamor', 'glx'] { |
| 33 | args << setting + feature |
| 34 | } |
| 35 | os.execvp('vinix-configure', args)! |
| 36 | } |
| 37 | |
| 38 | fn main() { |
| 39 | if os.args.len != 4 { |
| 40 | eprintln('usage: configure.v PROFILE XORG_SOURCE BUILD_DIRECTORY') |
| 41 | exit(2) |
| 42 | } |
| 43 | configure(os.args[1], os.args[2], os.args[3]) or { |
| 44 | eprintln(err) |
| 45 | exit(1) |
| 46 | } |
| 47 | } |
| 48 | |