### this file is sourced not run
PKGVER=2.3.1
PKGBUILD=1
PKGARCH=x86_64

# source: james
TARBALL=qemu-2.3.1.tar.bz2
MD5SUM=fb6bbdb32e6af5c2d2980a32ac4ea051
SRC_URL=http://wiki.qemu-project.org/download/$TARBALL
BUNDLE=

SLACKREQ='libncurses libSDL gtk2 libusb libssh2 curl bluez libvte 
libaio libattr libiscsi'  # lzo2, libcap-ng, libusbredir build-time only
SLACKDESC='qemu-arm-x86_64: qemu-arm-x86_64 2.3.1 (QEMU for arm/x86_64)  
qemu-arm-x86_64:  
qemu-arm-x86_64: QEMU is a generic and open source machine emulator and 
qemu-arm-x86_64: virtualizer. This package provides emulation for ARM (system 
qemu-arm-x86_64: and linux) and x86_64 (system only).  
qemu-arm-x86_64: 
qemu-arm-x86_64: 
qemu-arm-x86_64: 
qemu-arm-x86_64: 
qemu-arm-x86_64: 
qemu-arm-x86_64:
'

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/qemu* &&
	patch -Np1 -i $CHROOT_DIR/tmp/pkg/qemu-2.0.0-virtfs-proxy-helper.patch
}

### package
pkg_package() {
	cp $CHROOT_DIR/tmp/pkg/uefi-bios.bin usr/share/qemu
}

### build
pkg_build() {
	cd /tmp/qemu*
	./configure $CONFFLAGS \
		--target-list="arm-softmmu arm-linux-user x86_64-softmmu" \
		--audio-drv-list="alsa sdl"  \
		--enable-guest-base --enable-guest-agent \
		--with-sdlabi=1.2 &&
	make $MAKEFLAGS && make install &&

	# extra docs
	cp -a docs /usr/share/doc/qemu &&
	chown -R 0:0 /usr/share/doc/qemu/docs &&

	pkg_build_slackdesc 
}

<< "EOF"
sh-4.2# ./configure --help

Usage: configure [options]
Options: [defaults in brackets after descriptions]

Standard options:
  --help                   print this message
  --prefix=PREFIX          install in PREFIX [/usr/local]
  --interp-prefix=PREFIX   where to find shared libraries, etc.
                           use %M for cpu name [/usr/gnemul/qemu-%M]
  --target-list=LIST       set target list (default: build everything)
                           Available targets: aarch64-softmmu alpha-softmmu 
                           arm-softmmu cris-softmmu i386-softmmu lm32-softmmu 
                           m68k-softmmu microblaze-softmmu microblazeel-softmmu 
                           mips-softmmu mips64-softmmu mips64el-softmmu 
                           mipsel-softmmu moxie-softmmu or32-softmmu 
                           ppc-softmmu ppc64-softmmu ppcemb-softmmu 
                           s390x-softmmu sh4-softmmu sh4eb-softmmu 
                           sparc-softmmu sparc64-softmmu tricore-softmmu 
                           unicore32-softmmu x86_64-softmmu xtensa-softmmu 
                           xtensaeb-softmmu aarch64-linux-user alpha-linux-user 
                           arm-linux-user armeb-linux-user cris-linux-user 
                           i386-linux-user m68k-linux-user 
                           microblaze-linux-user microblazeel-linux-user 
                           mips-linux-user mips64-linux-user 
                           mips64el-linux-user mipsel-linux-user 
                           mipsn32-linux-user mipsn32el-linux-user 
                           or32-linux-user ppc-linux-user ppc64-linux-user 
                           ppc64abi32-linux-user ppc64le-linux-user 
                           s390x-linux-user sh4-linux-user sh4eb-linux-user 
                           sparc-linux-user sparc32plus-linux-user 
                           sparc64-linux-user unicore32-linux-user 
                           x86_64-linux-user

Advanced options (experts only):
  --source-path=PATH       path of source code [/tmp/qemu-2.3.1]
  --cross-prefix=PREFIX    use PREFIX for compile tools []
  --cc=CC                  use C compiler CC [cc]
  --iasl=IASL              use ACPI compiler IASL [iasl]
  --host-cc=CC             use C compiler CC [cc] for code run at
                           build time
  --cxx=CXX                use C++ compiler CXX [c++]
  --objcc=OBJCC            use Objective-C compiler OBJCC [cc]
  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
  --make=MAKE              use specified make [make]
  --install=INSTALL        use specified install [install]
  --python=PYTHON          use specified python [python -B]
  --smbd=SMBD              use specified smbd [/usr/sbin/smbd]
  --static                 enable static build [no]
  --mandir=PATH            install man pages in PATH
  --datadir=PATH           install firmware in PATH/qemu
  --docdir=PATH            install documentation in PATH/qemu
  --bindir=PATH            install binaries in PATH
  --libdir=PATH            install libraries in PATH
  --sysconfdir=PATH        install config in PATH/qemu
  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [/qemu]
  --enable-modules         enable modules support
  --enable-debug-tcg       enable TCG debugging
  --disable-debug-tcg      disable TCG debugging (default)
  --enable-debug-info      enable debugging information (default)
  --disable-debug-info     disable debugging information
  --enable-debug           enable common debug build options
  --enable-sparse          enable sparse checker
  --disable-sparse         disable sparse checker (default)
  --disable-strip          disable stripping binaries
  --disable-werror         disable compilation abort on warning
  --disable-stack-protector disable compiler-provided stack protection
  --disable-sdl            disable SDL
  --enable-sdl             enable SDL
  --with-sdlabi            select preferred SDL ABI 1.2 or 2.0
  --disable-gtk            disable gtk UI
  --enable-gtk             enable gtk UI
  --with-gtkabi            select preferred GTK ABI 2.0 or 3.0
  --disable-virtfs         disable VirtFS
  --enable-virtfs          enable VirtFS
  --disable-vnc            disable VNC
  --enable-vnc             enable VNC
  --disable-cocoa          disable Cocoa (Mac OS X only)
  --enable-cocoa           enable Cocoa (default on Mac OS X)
  --audio-drv-list=LIST    set audio drivers list:
                           Available drivers: oss alsa sdl esd pa fmod
  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
  --block-drv-rw-whitelist=L
                           set block driver read-write whitelist
                           (affects only QEMU, not qemu-img)
  --block-drv-ro-whitelist=L
                           set block driver read-only whitelist
                           (affects only QEMU, not qemu-img)
  --disable-xen            disable xen backend driver support
  --enable-xen             enable xen backend driver support
  --disable-xen-pci-passthrough
  --enable-xen-pci-passthrough
  --disable-brlapi         disable BrlAPI
  --enable-brlapi          enable BrlAPI
  --disable-vnc-tls        disable TLS encryption for VNC server
  --enable-vnc-tls         enable TLS encryption for VNC server
  --disable-vnc-sasl       disable SASL encryption for VNC server
  --enable-vnc-sasl        enable SASL encryption for VNC server
  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server
  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server
  --disable-vnc-png        disable PNG compression for VNC server (default)
  --enable-vnc-png         enable PNG compression for VNC server
  --disable-vnc-ws         disable Websockets support for VNC server
  --enable-vnc-ws          enable Websockets support for VNC server
  --disable-curses         disable curses output
  --enable-curses          enable curses output
  --disable-curl           disable curl connectivity
  --enable-curl            enable curl connectivity
  --disable-fdt            disable fdt device tree
  --enable-fdt             enable fdt device tree
  --disable-bluez          disable bluez stack connectivity
  --enable-bluez           enable bluez stack connectivity
  --disable-slirp          disable SLIRP userspace network connectivity
  --disable-kvm            disable KVM acceleration support
  --enable-kvm             enable KVM acceleration support
  --disable-rdma           disable RDMA-based migration support
  --enable-rdma            enable RDMA-based migration support
  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
  --enable-system          enable all system emulation targets
  --disable-system         disable all system emulation targets
  --enable-user            enable supported user emulation targets
  --disable-user           disable all user emulation targets
  --enable-linux-user      enable all linux usermode emulation targets
  --disable-linux-user     disable all linux usermode emulation targets
  --enable-bsd-user        enable all BSD usermode emulation targets
  --disable-bsd-user       disable all BSD usermode emulation targets
  --enable-guest-base      enable GUEST_BASE support for usermode
                           emulation targets
  --disable-guest-base     disable GUEST_BASE support
  --enable-pie             build Position Independent Executables
  --disable-pie            do not build Position Independent Executables
  --fmod-lib               path to FMOD library
  --fmod-inc               path to FMOD includes
  --oss-lib                path to OSS library
  --cpu=CPU                Build for host CPU [x86_64]
  --disable-uuid           disable uuid support
  --enable-uuid            enable uuid support
  --disable-vde            disable support for vde network
  --enable-vde             enable support for vde network
  --disable-netmap         disable support for netmap network
  --enable-netmap          enable support for netmap network
  --disable-linux-aio      disable Linux AIO support
  --enable-linux-aio       enable Linux AIO support
  --disable-cap-ng         disable libcap-ng support
  --enable-cap-ng          enable libcap-ng support
  --disable-attr           disable attr and xattr support
  --enable-attr            enable attr and xattr support
  --disable-blobs          disable installing provided firmware blobs
  --enable-docs            enable documentation build
  --disable-docs           disable documentation build
  --disable-vhost-net      disable vhost-net acceleration support
  --enable-vhost-net       enable vhost-net acceleration support
  --enable-trace-backends=B Set trace backend
                           Available backends: nop, dtrace, ftrace, simple, stderr, ust
  --with-trace-file=NAME   Full PATH,NAME of file to store traces
                           Default:trace-<pid>
  --disable-spice          disable spice
  --enable-spice           enable spice
  --enable-rbd             enable building the rados block device (rbd)
  --disable-libiscsi       disable iscsi support
  --enable-libiscsi        enable iscsi support
  --disable-libnfs         disable nfs support
  --enable-libnfs          enable nfs support
  --disable-smartcard-nss  disable smartcard nss support
  --enable-smartcard-nss   enable smartcard nss support
  --disable-libusb         disable libusb (for usb passthrough)
  --enable-libusb          enable libusb (for usb passthrough)
  --disable-usb-redir      disable usb network redirection support
  --enable-usb-redir       enable usb network redirection support
  --enable-lzo             enable the support of lzo compression library
  --enable-snappy          enable the support of snappy compression library
  --enable-bzip2           enable the support of bzip2 compression library (for
                           reading bzip2-compressed dmg images)
  --disable-guest-agent    disable building of the QEMU Guest Agent
  --enable-guest-agent     enable building of the QEMU Guest Agent
  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
  --disable-seccomp        disable seccomp support
  --enable-seccomp         enable seccomp support
  --with-coroutine=BACKEND coroutine backend. Supported options:
                           gthread, ucontext, sigaltstack, windows
  --disable-coroutine-pool disable coroutine freelist (worse performance)
  --enable-coroutine-pool  enable coroutine freelist (better performance)
  --enable-glusterfs       enable GlusterFS backend
  --disable-glusterfs      disable GlusterFS backend
  --enable-archipelago     enable Archipelago backend
  --disable-archipelago    disable Archipelago backend
  --enable-gcov            enable test coverage analysis with gcov
  --gcov=GCOV              use specified gcov [gcov]
  --disable-tpm            disable TPM support
  --enable-tpm             enable TPM support
  --disable-libssh2        disable ssh block device support
  --enable-libssh2         enable ssh block device support
  --disable-vhdx           disable support for the Microsoft VHDX image format
  --enable-vhdx            enable support for the Microsoft VHDX image format
  --disable-quorum         disable quorum block filter support
  --enable-quorum          enable quorum block filter support
  --disable-numa           disable libnuma support
  --enable-numa            enable libnuma support

NOTE: The object files are built at the place where configure is launched
EOF
