ia64/xen-unstable

view extras/mini-os/Makefile @ 12770:3bd721db6db5

[XEN] Fix 32-bit build.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Dec 03 17:44:14 2006 +0000 (2006-12-03)
parents a3c6479c87ef
children 38fcc7646959
line source
1 debug ?= y
2 pae ?= n
4 XEN_ROOT = ../..
5 include $(XEN_ROOT)/Config.mk
7 # Set TARGET_ARCH
8 override TARGET_ARCH := $(XEN_TARGET_ARCH)
10 XEN_INTERFACE_VERSION := 0x00030203
12 # NB. '-Wcast-qual' is nasty, so I omitted it.
13 CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
14 CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
15 CFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
17 ASFLAGS = -D__ASSEMBLY__
19 LDLIBS = -L. -lminios
20 LDFLAGS := -N -T minios-$(TARGET_ARCH).lds
22 # For possible special source directories.
23 EXTRA_SRC =
24 # For possible special header directories.
25 EXTRA_INC =
27 # Standard name for architecture specific subdirectories.
28 TARGET_ARCH_DIR = $(TARGET_ARCH)
29 # This is used for architecture specific links.
30 ARCH_LINKS =
32 ifeq ($(TARGET_ARCH),x86_32)
33 CFLAGS += -m32 -march=i686
34 LDFLAGS += -m elf_i386
35 TARGET_ARCH_DIR = x86
36 EXTRA_INC += $(TARGET_ARCH_DIR)/$(TARGET_ARCH)
37 EXTRA_SRC += arch/$(EXTRA_INC)
38 endif
40 ifeq ($(TARGET_ARCH)$(pae),x86_32y)
41 CFLAGS += -DCONFIG_X86_PAE=1
42 ASFLAGS += -DCONFIG_X86_PAE=1
43 TARGET_ARCH_DIR = x86
44 EXTRA_INC += $(TARGET_ARCH_DIR)/$(TARGET_ARCH)
45 EXTRA_SRC += arch/$(EXTRA_INC)
46 endif
48 ifeq ($(TARGET_ARCH),x86_64)
49 CFLAGS += -m64 -mno-red-zone -fpic -fno-reorder-blocks
50 CFLAGS += -fno-asynchronous-unwind-tables
51 LDFLAGS += -m elf_x86_64
52 TARGET_ARCH_DIR = x86
53 EXTRA_INC += $(TARGET_ARCH_DIR)/$(TARGET_ARCH)
54 EXTRA_SRC += arch/$(EXTRA_INC)
55 endif
57 ifeq ($(TARGET_ARCH),ia64)
58 CFLAGS += -mfixed-range=f2-f5,f12-f15,f32-f127 -mconstant-gp
59 ASFLAGS += -x assembler-with-cpp -Wall
60 ASFLAGS += -mfixed-range=f2-f5,f12-f15,f32-f127 -fomit-frame-pointer
61 ASFLAGS += -fno-builtin -fno-common -fno-strict-aliasing -mconstant-gp
62 ARCH_LINKS = IA64_LINKS # Special link on ia64 needed
63 define arch_links
64 [ -e include/ia64/asm-xsi-offsets.h ] || ln -sf ../../../../xen/include/asm-ia64/asm-xsi-offsets.h include/ia64/asm-xsi-offsets.h
65 endef
66 endif
68 ifeq ($(debug),y)
69 CFLAGS += -g
70 else
71 CFLAGS += -O3
72 endif
74 # Add the special header directories to the include paths.
75 extra_incl := $(foreach dir,$(EXTRA_INC),-Iinclude/$(dir))
76 override CPPFLAGS := -Iinclude $(CPPFLAGS) -Iinclude/$(TARGET_ARCH_DIR) $(extra_incl)
78 TARGET := mini-os
80 HEAD := $(TARGET_ARCH).o
81 OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
82 OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
83 OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
84 OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c))
85 OBJS += $(patsubst %.S,%.o,$(wildcard arch/$(TARGET_ARCH_DIR)/*.S))
86 OBJS += $(patsubst %.c,%.o,$(wildcard arch/$(TARGET_ARCH_DIR)/*.c))
87 # For special wanted source directories.
88 extra_objs := $(foreach dir,$(EXTRA_SRC),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
89 OBJS += $(extra_objs)
90 extra_objs := $(foreach dir,$(EXTRA_SRC),$(patsubst %.S,%.o,$(wildcard $(dir)/*.S)))
91 OBJS += $(extra_objs)
93 HDRS := $(wildcard include/*.h)
94 HDRS += $(wildcard include/xen/*.h)
95 HDRS += $(wildcard include/$(TARGET_ARCH_DIR)/*.h)
96 # For special wanted header directories.
97 extra_heads := $(foreach dir,$(EXTRA_INC),$(wildcard $(dir)/*.h))
98 HDRS += $(extra_heads)
100 .PHONY: default
101 default: $(TARGET)
103 # Create special architecture specific links.
104 ifneq ($(ARCH_LINKS),)
105 $(ARCH_LINKS):
106 $(arch_links)
107 endif
109 .PHONY: links
110 links: $(ARCH_LINKS)
111 [ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
113 libminios.a: links $(OBJS) $(HEAD)
114 $(AR) r libminios.a $(HEAD) $(OBJS)
116 $(TARGET): libminios.a $(HEAD)
117 $(LD) $(LDFLAGS) $(HEAD) $(LDLIBS) -o $@.elf
118 gzip -f -9 -c $@.elf >$@.gz
120 .PHONY: clean
121 clean:
122 find . -type f -name '*.o' | xargs rm -f
123 rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
124 rm -f libminios.a
125 find . -type l | xargs rm -f
126 rm -f tags TAGS
128 %.o: %.c $(HDRS) Makefile
129 $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
131 %.o: %.S $(HDRS) Makefile
132 $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
134 define all_sources
135 ( find . -follow -name SCCS -prune -o -name '*.[chS]' -print )
136 endef
138 .PHONY: cscope
139 cscope:
140 $(all_sources) > cscope.files
141 cscope -k -b -q
143 .PHONY: tags
144 tags:
145 $(all_sources) | xargs ctags