1XEN_ROOT = $(CURDIR)/../..
2
3include $(XEN_ROOT)/Config.mk
4vpath %.c ../grub-upstream
5
6BOOT=$(OBJ_DIR)/boot-$(XEN_TARGET_ARCH).o
7
8DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/toollog/include
9DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libxc/include -I$(XEN_ROOT)/tools/include -I.
10DEF_CPPFLAGS += -I../grub-upstream/stage1
11DEF_CPPFLAGS += -I../grub-upstream/stage2
12DEF_CPPFLAGS += -I../grub-upstream/netboot
13DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/firmware/vgabios
14DEF_CPPFLAGS += -DWITHOUT_LIBC_STUBS
15DEF_CPPFLAGS += -DSUPPORT_NETBOOT
16DEF_CPPFLAGS += -DSUPPORT_GRAPHICS
17DEF_CPPFLAGS += -DSUPPORT_SERIAL
18DEF_CPPFLAGS += -DPRESET_MENU_STRING='""'
19DEF_CPPFLAGS += -DPACKAGE='"grubdom"' -DVERSION='"0.97"'
20
21all: $(OBJ_DIR)/main.a
22
23STAGE2_SOURCES=builtins.c char_io.c cmdline.c common.c console.c disk_io.c graphics.c gunzip.c md5.c serial.c stage2.c terminfo.c tparm.c
24
25NETBOOT_SOURCES=fsys_tftp.c main.c misc.c
26CPPFLAGS += -DFSYS_TFTP=1
27
28STAGE2_SOURCES+=fsys_ext2fs.c
29CPPFLAGS += -DFSYS_EXT2FS=1
30
31STAGE2_SOURCES+=fsys_fat.c
32CPPFLAGS += -DFSYS_FAT=1
33
34STAGE2_SOURCES+=fsys_ffs.c
35CPPFLAGS += -DFSYS_FFS=1
36
37STAGE2_SOURCES+=fsys_iso9660.c
38CPPFLAGS += -DFSYS_ISO9660=1
39
40STAGE2_SOURCES+=fsys_jfs.c
41CPPFLAGS += -DFSYS_JFS=1
42
43STAGE2_SOURCES+=fsys_minix.c
44CPPFLAGS += -DFSYS_MINIX=1
45
46STAGE2_SOURCES+=fsys_reiserfs.c
47CPPFLAGS += -DFSYS_REISERFS=1
48
49STAGE2_SOURCES+=fsys_ufs2.c
50CPPFLAGS += -DFSYS_UFS2=1
51
52STAGE2_SOURCES+=fsys_vstafs.c
53CPPFLAGS += -DFSYS_VSTAFS=1
54
55STAGE2_SOURCES+=fsys_xfs.c
56CPPFLAGS += -DFSYS_XFS=1
57
58STAGE2_SOURCES:=$(addprefix stage2/,$(STAGE2_SOURCES))
59NETBOOT_SOURCES:=$(addprefix netboot/,$(NETBOOT_SOURCES))
60
61$(BOOT): DEF_CPPFLAGS+=-D__ASSEMBLY__
62
63PV_GRUB_SOURCES = kexec.c mini-os.c
64PV_GRUB_SOURCES += ../polarssl-$(XEN_TARGET_ARCH)/library/sha1.o
65
66SOURCES = $(NETBOOT_SOURCES) $(STAGE2_SOURCES) $(PV_GRUB_SOURCES)
67
68OBJS = $(addprefix $(OBJ_DIR)/,$(SOURCES:.c=.o))
69
70$(OBJ_DIR)/dirs:
71	mkdir -p $(OBJ_DIR)/netboot $(OBJ_DIR)/stage2
72	touch $@
73
74$(OBJS): $(OBJ_DIR)/dirs
75
76$(OBJ_DIR)/main.a: $(BOOT) $(OBJS)
77	$(AR) cr $@ $^
78
79$(OBJ_DIR)/%.o: %.c
80	$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
81
82$(OBJ_DIR)/%.o: %.S
83	$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
84
85clean:
86	rm -fr dirs *.a *.o stage2 netboot
87