update-linux-headers.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh -e
  2. #
  3. # Update Linux kernel headers QEMU requires from a specified kernel tree.
  4. #
  5. # Copyright (C) 2011 Siemens AG
  6. #
  7. # Authors:
  8. # Jan Kiszka <jan.kiszka@siemens.com>
  9. #
  10. # This work is licensed under the terms of the GNU GPL version 2.
  11. # See the COPYING file in the top-level directory.
  12. tmpdir=`mktemp -d`
  13. linux="$1"
  14. output="$2"
  15. if [ -z "$linux" ] || ! [ -d "$linux" ]; then
  16. cat << EOF
  17. usage: update-kernel-headers.sh LINUX_PATH [OUTPUT_PATH]
  18. LINUX_PATH Linux kernel directory to obtain the headers from
  19. OUTPUT_PATH output directory, usually the qemu source tree (default: $PWD)
  20. EOF
  21. exit 1
  22. fi
  23. if [ -z "$output" ]; then
  24. output="$PWD"
  25. fi
  26. for arch in x86 powerpc s390; do
  27. make -C "$linux" INSTALL_HDR_PATH="$tmpdir" SRCARCH=$arch headers_install
  28. rm -rf "$output/linux-headers/asm-$arch"
  29. mkdir -p "$output/linux-headers/asm-$arch"
  30. for header in kvm.h kvm_para.h; do
  31. cp "$tmpdir/include/asm/$header" "$output/linux-headers/asm-$arch"
  32. done
  33. if [ $arch = x86 ]; then
  34. cp "$tmpdir/include/asm/hyperv.h" "$output/linux-headers/asm-x86"
  35. fi
  36. done
  37. rm -rf "$output/linux-headers/linux"
  38. mkdir -p "$output/linux-headers/linux"
  39. for header in kvm.h kvm_para.h vhost.h virtio_config.h virtio_ring.h; do
  40. cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux"
  41. done
  42. if [ -L "$linux/source" ]; then
  43. cp "$linux/source/COPYING" "$output/linux-headers"
  44. else
  45. cp "$linux/COPYING" "$output/linux-headers"
  46. fi
  47. rm -rf "$tmpdir"