]> git.proxmox.com Git - qemu.git/blame - scripts/update-linux-headers.sh
target-i386: kvm_cpu_fill_host: use GET_SUPPORTED_CPUID
[qemu.git] / scripts / update-linux-headers.sh
CommitLineData
87fdd476
JK
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
13tmpdir=`mktemp -d`
14linux="$1"
15output="$2"
16
17if [ -z "$linux" ] || ! [ -d "$linux" ]; then
18 cat << EOF
19usage: update-kernel-headers.sh LINUX_PATH [OUTPUT_PATH]
20
21LINUX_PATH Linux kernel directory to obtain the headers from
22OUTPUT_PATH output directory, usually the qemu source tree (default: $PWD)
23EOF
24 exit 1
25fi
26
27if [ -z "$output" ]; then
28 output="$PWD"
29fi
30
2879636d
PM
31# This will pick up non-directories too (eg "Kconfig") but we will
32# ignore them in the next loop.
33ARCHLIST=$(cd "$linux/arch" && echo *)
34
35for arch in $ARCHLIST; do
36 # Discard anything which isn't a KVM-supporting architecture
37 if ! [ -e "$linux/arch/$arch/include/asm/kvm.h" ]; then
38 continue
39 fi
40
41 # Blacklist architectures which have KVM headers but are actually dead
42 if [ "$arch" = "ia64" ]; then
43 continue
44 fi
45
87fdd476
JK
46 make -C "$linux" INSTALL_HDR_PATH="$tmpdir" SRCARCH=$arch headers_install
47
48 rm -rf "$output/linux-headers/asm-$arch"
49 mkdir -p "$output/linux-headers/asm-$arch"
50 for header in kvm.h kvm_para.h; do
51 cp "$tmpdir/include/asm/$header" "$output/linux-headers/asm-$arch"
52 done
53 if [ $arch = x86 ]; then
54 cp "$tmpdir/include/asm/hyperv.h" "$output/linux-headers/asm-x86"
55 fi
56done
57
58rm -rf "$output/linux-headers/linux"
59mkdir -p "$output/linux-headers/linux"
df8c1b02 60for header in kvm.h kvm_para.h vfio.h vhost.h virtio_config.h virtio_ring.h; do
87fdd476
JK
61 cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux"
62done
256d046c
PM
63rm -rf "$output/linux-headers/asm-generic"
64mkdir -p "$output/linux-headers/asm-generic"
65for header in kvm_para.h; do
66 cp "$tmpdir/include/asm-generic/$header" "$output/linux-headers/asm-generic"
67done
87fdd476
JK
68if [ -L "$linux/source" ]; then
69 cp "$linux/source/COPYING" "$output/linux-headers"
70else
71 cp "$linux/COPYING" "$output/linux-headers"
72fi
73
74rm -rf "$tmpdir"