source: trunk/packages/xen-common/xen-common/tools/xm-test/ramdisk/Makefile.am @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 3.4 KB
RevLine 
[34]1#
2# make existing:
3#
4#   Download a pre-built ramdisk.
5#     INITRD = <Directory to download ramdisk from>
6#
7# make initrd.img:
8#
9#   Make a ramdisk from scratch.
10#     BR_URL = <The URL of the Buildroot source code>
11#     BR_SNAPSHOT = 1  Set BR_URL to the upstream Buildroot daily snapshot.
12#     BR_ARCH = <The build architecture for the initrd>
13#
14
15INITRD ?= http://xm-test.xensource.com/ramdisks
16
17BR_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/ppc\(64\)*/powerpc/' -e 's/x86_64/i386/')
18
19@MK@ifdef BR_SNAPSHOT
20@MK@  BR_URL = http://buildroot.uclibc.org/downloads/snapshots/buildroot-snapshot.tar.bz2
21@MK@else
22@MK@  BR_URL = http://xm-test.xensource.com/ramdisks/buildroot-20061023.tar.bz2
23@MK@endif
24BR_TAR = $(notdir $(BR_URL))
25
26BR_SRC = buildroot
27BR_IMG = $(BR_SRC)/rootfs.$(BR_ARCH).ext2
28
29BR_ROOT = build_$(BR_ARCH)/root
30
31EXTRA_DIST = skel configs patches
32
33HVM_SCRIPT = bin/create_disk_image
34
35XMTEST_MAJ_VER = $(shell echo @PACKAGE_VERSION@ | perl -pe 's/(\d+)\.(\d+)\.\d+/\1.\2/')
36XMTEST_VER_IMG = initrd-$(XMTEST_MAJ_VER)-$(BR_ARCH).img
37XMTEST_DL_IMG = $(shell echo $(XMTEST_VER_IMG) | sed -e 's/x86_64/i386/g')
38
39EXTRA_ROOT_DIRS = sys modules
40
41BLKDRV = /lib/modules/$(shell uname -r)/kernel/drivers/xen/blkfront/xenblk.ko
42NETDRV = /lib/modules/$(shell uname -r)/kernel/drivers/xen/netfront/xennet.ko
43PKTDRV = /lib/modules/$(shell uname -r)/kernel/net/packet/af_packet.ko
44
45
46if HVM
47all: initrd.img disk.img
48else
49all: initrd.img
50endif
51
52$(BR_TAR):
53        wget $(BR_URL)
54
55$(BR_SRC): $(BR_TAR)
56        tar xjf $(BR_TAR)
57
58$(BR_IMG): $(BR_SRC)
59        cp configs/buildroot-$(BR_ARCH) $(BR_SRC)/.config
60        cp configs/busybox $(BR_SRC)/package/busybox/busybox.config
61        cp configs/uClibc $(BR_SRC)/toolchain/uClibc/uClibc.config
62        (for i in patches/buildroot/*.patch; do \
63          cd $(BR_SRC) && patch -p1 <../$$i && cd ..; done )
64        cd $(BR_SRC) && make oldconfig && make
65
66$(XMTEST_VER_IMG): $(BR_IMG)
67        chmod a+x skel/etc/init.d/rcS
68        cd skel && mkdir -p $(EXTRA_ROOT_DIRS)
69        -[ -e "$(BLKDRV)" ] && cp $(BLKDRV) skel/modules
70        -[ -e "$(NETDRV)" ] && cp $(NETDRV) skel/modules
71        -[ -e "$(PKTDRV)" ] && cp $(PKTDRV) skel/modules
72        (cd skel; tar cf - .) \
73                | (cd $(BR_SRC)/$(BR_ROOT); tar xvf -)
74        cd $(BR_SRC) && make
75        cp $(BR_IMG) $(XMTEST_VER_IMG)
76
77initrd.img: $(XMTEST_VER_IMG)
78        ln -sf $(XMTEST_VER_IMG) initrd.img
79
80disk.img: existing
81        chmod a+x $(HVM_SCRIPT)
82        @if test ! "$(HVMKERNEL)" = "no" -a ! "$(DRVDIR)" = "no"; then \
83                $(HVM_SCRIPT) -r $(XMTEST_VER_IMG) -k $(HVMKERNEL) \
84                        -d $(DRVDIR) -n $(NETDRV); \
85        elif test "$(HVMKERNEL)" = "no" -a ! "$(DRVDIR)" = "no"; then \
86                $(HVM_SCRIPT) -r $(XMTEST_VER_IMG) -d $(DRVDIR) -n $(NETDRV); \
87        elif test ! "$(HVMKERNEL)" = "no" -a "$(DRVDIR)" = "no"; then \
88                $(HVM_SCRIPT) -r $(XMTEST_VER_IMG) -k $(HVMKERNEL) \
89                        -n $(NETDRV); \
90        else \
91                $(HVM_SCRIPT) -r $(XMTEST_VER_IMG) -n $(NETDRV); \
92        fi
93
94existing:
95        @if [ -n "$(INITRD)" ] && [ ! -f $(XMTEST_VER_IMG) ] ; then \
96                if [ ! -f $(XMTEST_DL_IMG) ] ; then \
97                        wget $(INITRD)/$(XMTEST_DL_IMG); \
98                fi; \
99                if [ "$(XMTEST_DL_IMG)" != "$(XMTEST_VER_IMG)" ] ; then \
100                        ln -s $(XMTEST_DL_IMG) $(XMTEST_VER_IMG); \
101                fi \
102        fi
103        @if [ -f $(XMTEST_VER_IMG) ] ; then \
104                ln -sf $(XMTEST_VER_IMG) initrd.img; \
105        else \
106                echo Error, $(XMTEST_VER_IMG) not found;  \
107                false; \
108        fi
109
110clean-local: am_config_clean-local
111
112am_config_clean-local:
113        rm -Rf buildroot
114        rm -f *~
115        rm -f initrd.img
116        rm -f $(BR_TAR)
117        rm -f disk.img
Note: See TracBrowser for help on using the repository browser.