1 | # Common Makefile for mini-os. |
---|
2 | # |
---|
3 | # Every architecture directory below mini-os/arch has to have a |
---|
4 | # Makefile and a arch.mk. |
---|
5 | # |
---|
6 | |
---|
7 | XEN_ROOT = ../.. |
---|
8 | include $(XEN_ROOT)/Config.mk |
---|
9 | |
---|
10 | XEN_INTERFACE_VERSION := 0x00030205 |
---|
11 | export XEN_INTERFACE_VERSION |
---|
12 | |
---|
13 | # Set TARGET_ARCH |
---|
14 | override TARGET_ARCH := $(XEN_TARGET_ARCH) |
---|
15 | |
---|
16 | # Set mini-os root path, used in mini-os.mk. |
---|
17 | MINI-OS_ROOT=$(PWD) |
---|
18 | export MINI-OS_ROOT |
---|
19 | |
---|
20 | # Try to find out the architecture family TARGET_ARCH_FAM. |
---|
21 | # First check whether x86_... is contained (for x86_32, x86_32y, x86_64). |
---|
22 | # If not x86 then use $(TARGET_ARCH) -> for ia64, ... |
---|
23 | ifeq ($(findstring x86_,$(TARGET_ARCH)),x86_) |
---|
24 | TARGET_ARCH_FAM = x86 |
---|
25 | else |
---|
26 | TARGET_ARCH_FAM = $(TARGET_ARCH) |
---|
27 | endif |
---|
28 | |
---|
29 | # The architecture family directory below mini-os. |
---|
30 | TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FAM) |
---|
31 | |
---|
32 | # Export these variables for possible use in architecture dependent makefiles. |
---|
33 | export TARGET_ARCH |
---|
34 | export TARGET_ARCH_DIR |
---|
35 | export TARGET_ARCH_FAM |
---|
36 | export XEN_TARGET_X86_PAE |
---|
37 | |
---|
38 | # This is used for architecture specific links. |
---|
39 | # This can be overwritten from arch specific rules. |
---|
40 | ARCH_LINKS = |
---|
41 | |
---|
42 | # For possible special header directories. |
---|
43 | # This can be overwritten from arch specific rules. |
---|
44 | EXTRA_INC = |
---|
45 | |
---|
46 | # Include the architecture family's special makerules. |
---|
47 | # This must be before include minios.mk! |
---|
48 | include $(TARGET_ARCH_DIR)/arch.mk |
---|
49 | |
---|
50 | # Include common mini-os makerules. |
---|
51 | include minios.mk |
---|
52 | |
---|
53 | # Define some default flags for linking. |
---|
54 | LDLIBS := |
---|
55 | LDARCHLIB := -L$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME) |
---|
56 | LDFLAGS_FINAL := -N -T $(TARGET_ARCH_DIR)/minios-$(TARGET_ARCH).lds |
---|
57 | |
---|
58 | # Prefix for global API names. All other symbols are localised before |
---|
59 | # linking with EXTRA_OBJS. |
---|
60 | GLOBAL_PREFIX := xenos_ |
---|
61 | EXTRA_OBJS = |
---|
62 | |
---|
63 | TARGET := mini-os |
---|
64 | |
---|
65 | # Subdirectories common to mini-os |
---|
66 | SUBDIRS := lib xenbus console |
---|
67 | |
---|
68 | # The common mini-os objects to build. |
---|
69 | OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) |
---|
70 | OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c)) |
---|
71 | OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c)) |
---|
72 | OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c)) |
---|
73 | |
---|
74 | |
---|
75 | .PHONY: default |
---|
76 | default: $(TARGET) |
---|
77 | |
---|
78 | # Create special architecture specific links. The function arch_links |
---|
79 | # has to be defined in arch.mk (see include above). |
---|
80 | ifneq ($(ARCH_LINKS),) |
---|
81 | $(ARCH_LINKS): |
---|
82 | $(arch_links) |
---|
83 | endif |
---|
84 | |
---|
85 | .PHONY: links |
---|
86 | links: $(ARCH_LINKS) |
---|
87 | [ -e include/xen ] || ln -sf ../../../xen/include/public include/xen |
---|
88 | |
---|
89 | .PHONY: arch_lib |
---|
90 | arch_lib: |
---|
91 | $(MAKE) --directory=$(TARGET_ARCH_DIR) || exit 1; |
---|
92 | |
---|
93 | $(TARGET): links $(OBJS) arch_lib |
---|
94 | $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJS) $(LDARCHLIB) -o $@.o |
---|
95 | $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o |
---|
96 | $(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@ |
---|
97 | gzip -f -9 -c $@ >$@.gz |
---|
98 | |
---|
99 | .PHONY: clean arch_clean |
---|
100 | |
---|
101 | arch_clean: |
---|
102 | $(MAKE) --directory=$(TARGET_ARCH_DIR) clean || exit 1; |
---|
103 | |
---|
104 | clean: arch_clean |
---|
105 | for dir in $(SUBDIRS); do \ |
---|
106 | rm -f $$dir/*.o; \ |
---|
107 | done |
---|
108 | rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz |
---|
109 | find . -type l | xargs rm -f |
---|
110 | rm -f tags TAGS |
---|
111 | |
---|
112 | |
---|
113 | define all_sources |
---|
114 | ( find . -follow -name SCCS -prune -o -name '*.[chS]' -print ) |
---|
115 | endef |
---|
116 | |
---|
117 | .PHONY: cscope |
---|
118 | cscope: |
---|
119 | $(all_sources) > cscope.files |
---|
120 | cscope -k -b -q |
---|
121 | |
---|
122 | .PHONY: tags |
---|
123 | tags: |
---|
124 | $(all_sources) | xargs ctags |
---|
125 | |
---|