// Configure the two X server profiles shipped in Vinix's X11 sidecar. module main import os fn configure(profile string, source string, build string) ! { if profile !in ['headless', 'accelerated'] { return error('expected the headless or accelerated X server profile') } root := os.getenv('VPAC_MAKEPKG_ROOT') if !os.is_abs_path(root) { return error('set VPAC_MAKEPKG_ROOT to the staged target SDK') } script := os.abs_path(os.join_path(source, 'configure')) os.mkdir_all(build)! os.chdir(build)! mut cppflags := os.getenv('CPPFLAGS') + ' -D__vinix__' if profile == 'accelerated' { // The Xorg-only glamor module includes xf86drm.h outside the DRI3 build. cppflags += ' -I' + root + '/usr/include/libdrm' } os.setenv('CPPFLAGS', cppflags.trim_space(), true) os.setenv('LDFLAGS', (os.getenv('LDFLAGS') + ' -Wl,-rpath-link,' + root + '/usr/lib -rdynamic').trim_space(), true) mut args := [script, '--localstatedir=/var', '--with-xkb-bin-directory=/usr/bin', '--with-xkb-path=/usr/share/X11/xkb', '--with-xkb-output=/var/lib/xkb', '--with-fontrootdir=/usr/share/fonts/X11', '--enable-xvfb', '--disable-xephyr', '--disable-xnest', '--disable-suid-wrapper', '--disable-pciaccess', '--disable-dpms', '--disable-xres', '--disable-xvmc', '--disable-systemd-logind', '--disable-secure-rpc', '--disable-config-udev', '--disable-dri', '--disable-dri2', '--disable-int10-module', '--disable-vgahw', '--disable-xinerama', '--enable-screensaver'] setting := if profile == 'accelerated' { '--enable-' } else { '--disable-' } for feature in ['xorg', 'dri3', 'libdrm', 'glamor', 'glx'] { args << setting + feature } os.execvp('vinix-configure', args)! } fn main() { if os.args.len != 4 { eprintln('usage: configure.v PROFILE XORG_SOURCE BUILD_DIRECTORY') exit(2) } configure(os.args[1], os.args[2], os.args[3]) or { eprintln(err) exit(1) } }