1#! /bin/sh
2
3if [ $1 ]; then
4    uname="$1"
5else
6    uname=`uname -m`
7    echo "Defaulting to this machine's architecture, $uname, for linking."
8    echo "This may be overridden on the command line (i386,x86_64,ia64)."
9fi
10
11C=$(cd $(dirname $0) && pwd)
12R=${C%/*/*}
13
14if [ -n "$XEN" -a -d "$XEN" ]; then
15  XEN=$(cd $XEN && pwd)
16else
17  XEN=$R/xen
18fi
19echo "Xen tree: $XEN"
20
21if [ -n "$XL" -a -d "$XL" ]; then
22  XL=$(cd $XL && pwd)
23else
24  XL=$R/linux-2.6.18-xen.hg
25fi
26echo "Linux tree: $XL"
27
28cd $C
29
30for d in $(find ${XL}/drivers/xen/ -mindepth 1 -maxdepth 1 -type d); do
31    test -d $(basename $d) || continue
32    lndir $d $(basename $d) > /dev/null 2>&1
33done
34
35ln -sf ${XL}/drivers/xen/core/gnttab.c platform-pci
36if [ -f ${XL}/drivers/xen/core/features.c ]; then
37    ln -sf ${XL}/drivers/xen/core/features.c platform-pci
38else
39    ln -sf ${XL}/drivers/xen/features.c platform-pci
40fi
41ln -sf ${XL}/drivers/xen/core/xen_proc.c xenbus
42ln -sf ${XL}/drivers/xen/core/reboot.c platform-pci
43
44mkdir -p include/asm include/xen
45
46lndir -silent ${XL}/include/xen include/xen
47ln -nsf ${XEN}/include/public include/xen/interface
48
49# Need to be quite careful here: we don't want the files we link in to
50# risk overriding the native Linux ones (in particular, system.h must
51# be native and not xenolinux).
52case "$uname" in
53i[34567]86|x86_64)
54    if [ -d ${XL}/arch/x86/include/mach-xen ]; then
55        ln -sf ${XL}/arch/x86/include/mach-xen/asm/hypervisor.h include/asm
56        ln -sf ${XL}/arch/x86/include/mach-xen/asm/hypercall*.h include/asm
57        ln -sf ${XL}/arch/x86/include/mach-xen/asm/synch_bitops*.h include/asm
58        ln -sf ${XL}/arch/x86/include/mach-xen/asm/maddr*.h include/asm
59        ln -sf ${XL}/arch/x86/include/mach-xen/asm/gnttab_dma.h include/asm
60        ln -sf ${XL}/arch/x86/lib/scrub.c balloon
61    elif [ -d ${XL}/include/asm-x86 ]; then
62        ln -sf ${XL}/include/asm-x86/mach-xen/asm/hypervisor.h include/asm
63        ln -sf ${XL}/include/asm-x86/mach-xen/asm/hypercall*.h include/asm
64        ln -sf ${XL}/include/asm-x86/mach-xen/asm/synch_bitops*.h include/asm
65        ln -sf ${XL}/include/asm-x86/mach-xen/asm/maddr*.h include/asm
66        ln -sf ${XL}/include/asm-x86/mach-xen/asm/gnttab_dma.h include/asm
67        ln -sf ${XL}/arch/x86/lib/scrub.c balloon
68    else
69        if [ $uname = x86_64 ]; then
70            mkdir -p include/asm-i386
71            lndir -silent ${XL}/include/asm-i386 include/asm-i386
72        else
73            uname=i386
74        fi
75        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/hypervisor.h include/asm
76        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/hypercall.h include/asm
77        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/synch_bitops.h include/asm
78        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/maddr.h include/asm
79        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/gnttab_dma.h include/asm
80    fi
81  ;;
82"ia64")
83    ln -sf ${XL}/include/asm-ia64/hypervisor.h include/asm
84    ln -sf ${XL}/include/asm-ia64/hypercall.h include/asm
85    ln -sf ${XL}/include/asm-ia64/synch_bitops.h include/asm
86    ln -sf ${XL}/include/asm-ia64/maddr.h include/asm
87    ln -sf ${XL}/include/asm-ia64/gnttab_dma.h include/asm
88    mkdir -p include/asm/xen
89    ln -sf ${XL}/include/asm-ia64/xen/xcom_hcall.h include/asm/xen
90    ln -sf ${XL}/include/asm-ia64/xen/xencomm.h include/asm/xen
91    ln -sf ${XL}/arch/ia64/xen/xcom_hcall.c platform-pci/
92    ln -sf ${XL}/arch/ia64/xen/xcom_asm.S platform-pci/
93    ln -sf ${XL}/arch/ia64/xen/xencomm.c platform-pci/xencomm_arch.c
94    ln -sf ${XL}/drivers/xen/core/xencomm.c platform-pci
95  ;;
96*)
97    echo unknown architecture $uname
98    exit 1
99  ;;
100esac
101