import xyz
import shutil

class Qemu(xyz.Package):
    pkg_name = 'QEMU'
    deps = ['pkg-config', 'gettext', 'glib']
    uses_osx_frameworks = True

    def configure(self):
        args = ('{source_dir_from_build}/configure',
                '--prefix={prefix}',
                '--disable-cocoa',
                '--target-list=arm-softmmu',
                '--disable-curses',
                '--disable-vnc',
                '--disable-console',
                '--enable-werror',
                '--disable-slirp',
                '--disable-curl',
                '--disable-guest-base',
                '--disable-guest-agent' ,
                '--disable-blobs',
                '--audio-drv-list=',
                '--audio-card-list=',
                '--disable-usb',
                '--disable-smartcard',
                '--disable-ide',
                '--disable-pie',
                )
        base_env = {
            'PKG_CONFIG_PATH': '{devtree_dir_abs}/{host}/lib/pkgconfig',
            'QEMU_PKG_CONFIG_FLAGS': '--define-variable prefix={devtree_dir_abs} --define-variable exec_prefix={devtree_dir_abs}/{host} --static',
                    }
        self.cmd(*args, env=base_env)

    def install(self):
        super().install()
        # Now we go and remove all the stuff we don't want.
        # In fact, it may be easy to just install manually what we do want, but
        # to try and keep this working for future version we take this
        # approach for now.
        self.rmtree('{prefix_dir}', 'share', 'qemu')
        self.rmtree('{prefix_dir}', 'etc')

        # Copy qemu-system-arm to the right bin location...
        bin_dir = self.j('{prefix_dir}', 'bin')
        ebin_dir = self.j('{eprefix_dir}', 'bin')
        self.ensure_dir(ebin_dir)
        shutil.copy(self.j(bin_dir, 'qemu-system-arm'), ebin_dir)
        self.rmtree(bin_dir)

rules = Qemu

@@ -438,15 +438,131 @@
 ble-
-console
+tools',%0A                '--without-pixman',%0A                '--disable-console',%0A                '--disable-default-devices
 ',%0A 
@@ -920,17 +920,11 @@
 ble-
-smartcard
+ide
 ',%0A 
@@ -941,34 +941,34 @@
      '--disable-
+p
 i
-d
 e',%0A            
@@ -970,35 +970,36 @@
          '--
-dis
+en
 able-
-pie
+debug
 ',%0A         

Improve QEMU build.