ia64/xen-unstable

view extras/mini-os/Makefile @ 19836:d9890e67d2b7

tools: add SHAREDIR to buildmakevars2file

c/s 19818 dropped SHAREDIR from xen/util/path.py, which broke the "xm
new" command. This patch adds SHAREDIR back to the new
buildmakevars2file-closure function.

Signed-off-by: Ryan O'Connor <rjo@cs.ubc.ca>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 13:05:10 2009 +0100 (2009-06-25)
parents b33b745cd5ec
children
line source
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 #
7 export XEN_ROOT = ../..
8 include $(XEN_ROOT)/Config.mk
9 OBJ_DIR ?= $(CURDIR)
11 ifneq ($(stubdom),y)
12 include Config.mk
13 endif
15 # Include common mini-os makerules.
16 include minios.mk
18 # Set tester flags
19 # CFLAGS += -DBLKTEST_WRITE
21 # Define some default flags for linking.
22 LDLIBS :=
23 APP_LDLIBS :=
24 LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
25 LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).lds
27 # Prefix for global API names. All other symbols are localised before
28 # linking with EXTRA_OBJS.
29 GLOBAL_PREFIX := xenos_
30 EXTRA_OBJS =
32 TARGET := mini-os
34 # Subdirectories common to mini-os
35 SUBDIRS := lib xenbus console
37 # The common mini-os objects to build.
38 APP_OBJS :=
39 OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard *.c))
40 OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard lib/*.c))
41 OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard xenbus/*.c))
42 OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard console/*.c))
45 .PHONY: default
46 default: $(OBJ_DIR)/$(TARGET)
48 # Create special architecture specific links. The function arch_links
49 # has to be defined in arch.mk (see include above).
50 ifneq ($(ARCH_LINKS),)
51 $(ARCH_LINKS):
52 $(arch_links)
53 endif
55 .PHONY: links
56 links: $(ARCH_LINKS)
57 [ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
58 [ -e include/mini-os ] || ln -sf . include/mini-os
59 [ -e include/$(TARGET_ARCH_FAM)/mini-os ] || ln -sf . include/$(TARGET_ARCH_FAM)/mini-os
61 .PHONY: arch_lib
62 arch_lib:
63 $(MAKE) --directory=$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) || exit 1;
65 ifeq ($(lwip),y)
66 # lwIP library
67 LWC := $(shell find $(LWIPDIR)/ -type f -name '*.c')
68 LWC := $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC))
69 LWO := $(patsubst %.c,%.o,$(LWC))
70 LWO += $(addprefix $(OBJ_DIR)/,lwip-arch.o lwip-net.o)
72 $(OBJ_DIR)/lwip.a: $(LWO)
73 $(RM) $@
74 $(AR) cqs $@ $^
76 OBJS += $(OBJ_DIR)/lwip.a
77 endif
79 OBJS := $(filter-out $(OBJ_DIR)/lwip%.o $(LWO), $(OBJS))
81 ifeq ($(libc),y)
82 APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(XEN_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive
83 APP_LDLIBS += -lpci
84 APP_LDLIBS += -lz
85 APP_LDLIBS += -lm
86 LDLIBS += -lc
87 endif
89 ifneq ($(APP_OBJS)-$(lwip),-y)
90 OBJS := $(filter-out $(OBJ_DIR)/daytime.o, $(OBJS))
91 endif
93 $(OBJ_DIR)/$(TARGET)_app.o: $(APP_OBJS) app.lds
94 $(LD) -r -d $(LDFLAGS) -\( $^ -\) $(APP_LDLIBS) --undefined main -o $@
96 ifneq ($(APP_OBJS),)
97 APP_O=$(OBJ_DIR)/$(TARGET)_app.o
98 endif
100 $(OBJ_DIR)/$(TARGET): links $(OBJS) $(APP_O) arch_lib
101 $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(APP_O) $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@.o
102 $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o
103 $(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@
104 gzip -f -9 -c $@ >$@.gz
106 .PHONY: clean arch_clean
108 arch_clean:
109 $(MAKE) --directory=$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) clean || exit 1;
111 clean: arch_clean
112 for dir in $(addprefix $(OBJ_DIR)/,$(SUBDIRS)); do \
113 rm -f $$dir/*.o; \
114 done
115 rm -f $(OBJ_DIR)/*.o *~ $(OBJ_DIR)/core $(OBJ_DIR)/$(TARGET).elf $(OBJ_DIR)/$(TARGET).raw $(OBJ_DIR)/$(TARGET) $(OBJ_DIR)/$(TARGET).gz
116 find . $(OBJ_DIR) -type l | xargs rm -f
117 $(RM) $(OBJ_DIR)/lwip.a $(LWO)
118 rm -f tags TAGS
121 define all_sources
122 ( find . -follow -name SCCS -prune -o -name '*.[chS]' -print )
123 endef
125 .PHONY: cscope
126 cscope:
127 $(all_sources) > cscope.files
128 cscope -k -b -q
130 .PHONY: tags
131 tags:
132 $(all_sources) | xargs ctags
134 .PHONY: TAGS
135 TAGS:
136 $(all_sources) | xargs etags