source: trunk/packages/xen-common/xen-common/xen/Rules.mk @ 77

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

Add xen and xen-common

File size: 3.6 KB
Line 
1
2#
3# If you change any of these configuration options then you must
4# 'make clean' before rebuilding.
5#
6verbose     ?= n
7perfc       ?= n
8perfc_arrays?= n
9crash_debug ?= n
10
11XEN_ROOT=$(BASEDIR)/..
12include $(XEN_ROOT)/Config.mk
13
14# Hardcoded configuration implications and dependencies.
15# Do this is a neater way if it becomes unwieldy.
16ifeq ($(debug),y)
17verbose := y
18endif
19ifeq ($(perfc_arrays),y)
20perfc := y
21endif
22
23# Set ARCH/SUBARCH appropriately.
24override COMPILE_SUBARCH := $(XEN_COMPILE_ARCH)
25override TARGET_SUBARCH  := $(XEN_TARGET_ARCH)
26override COMPILE_ARCH    := $(shell echo $(XEN_COMPILE_ARCH) | \
27                              sed -e 's/x86.*/x86/' \
28                                  -e 's/powerpc.*/powerpc/')
29override TARGET_ARCH     := $(shell echo $(XEN_TARGET_ARCH) | \
30                              sed -e 's/x86.*/x86/' \
31                                  -e 's/powerpc.*/powerpc/')
32
33TARGET := $(BASEDIR)/xen
34
35HDRS := $(wildcard $(BASEDIR)/include/xen/*.h)
36HDRS += $(wildcard $(BASEDIR)/include/public/*.h)
37HDRS += $(wildcard $(BASEDIR)/include/compat/*.h)
38HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/*.h)
39HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/$(TARGET_SUBARCH)/*.h)
40
41include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
42
43# Do not depend on auto-generated header files.
44AHDRS := $(filter-out %/include/xen/compile.h,$(HDRS))
45HDRS  := $(filter-out %/asm-offsets.h,$(AHDRS))
46
47# Note that link order matters!
48ALL_OBJS-y               += $(BASEDIR)/common/built_in.o
49ALL_OBJS-y               += $(BASEDIR)/drivers/built_in.o
50ALL_OBJS-$(ACM_SECURITY) += $(BASEDIR)/acm/built_in.o
51ALL_OBJS-y               += $(BASEDIR)/arch/$(TARGET_ARCH)/built_in.o
52
53CFLAGS-y               += -g -D__XEN__
54CFLAGS-$(ACM_SECURITY) += -DACM_SECURITY
55CFLAGS-$(verbose)      += -DVERBOSE
56CFLAGS-$(crash_debug)  += -DCRASH_DEBUG
57CFLAGS-$(perfc)        += -DPERF_COUNTERS
58CFLAGS-$(perfc_arrays) += -DPERF_ARRAYS
59
60ifneq ($(max_phys_cpus),)
61CFLAGS-y               += -DMAX_PHYS_CPUS=$(max_phys_cpus)
62endif
63
64AFLAGS-y               += -D__ASSEMBLY__
65
66ALL_OBJS := $(ALL_OBJS-y)
67
68CFLAGS   := $(strip $(CFLAGS) $(CFLAGS-y))
69
70# Most CFLAGS are safe for assembly files:
71#  -std=gnu{89,99} gets confused by #-prefixed end-of-line comments
72AFLAGS   := $(strip $(AFLAGS) $(AFLAGS-y))
73AFLAGS   += $(patsubst -std=gnu%,,$(CFLAGS))
74
75# LDFLAGS are only passed directly to $(LD)
76LDFLAGS  := $(strip $(LDFLAGS) $(LDFLAGS_DIRECT))
77
78include Makefile
79
80# Ensure each subdirectory has exactly one trailing slash.
81subdir-n := $(patsubst %,%/,$(patsubst %/,%,$(subdir-n)))
82subdir-y := $(patsubst %,%/,$(patsubst %/,%,$(subdir-y)))
83
84# Add explicitly declared subdirectories to the object list.
85obj-y += $(patsubst %/,%/built_in.o,$(subdir-y))
86
87# Add implicitly declared subdirectories (in the object list) to the
88# subdirectory list, and rewrite the object-list entry.
89subdir-y += $(filter %/,$(obj-y))
90obj-y    := $(patsubst %/,%/built-in.o,$(obj-y))
91
92subdir-all := $(subdir-y) $(subdir-n)
93
94built_in.o: $(obj-y)
95        $(LD) $(LDFLAGS) -r -o $@ $^
96
97# Force execution of pattern rules (for which PHONY cannot be directly used).
98.PHONY: FORCE
99FORCE:
100
101%/built_in.o: FORCE
102        $(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in.o
103
104.PHONY: clean
105clean:: $(addprefix _clean_, $(subdir-all))
106        rm -f *.o *~ core
107_clean_%/: FORCE
108        $(MAKE) -f $(BASEDIR)/Rules.mk -C $* clean
109
110%.o: %.c $(HDRS) Makefile
111        $(CC) $(CFLAGS) -c $< -o $@
112
113%.o: %.S $(AHDRS) Makefile
114        $(CC) $(AFLAGS) -c $< -o $@
115
116%.i: %.c $(HDRS) Makefile
117        $(CPP) $(CFLAGS) $< -o $@
118
119# -std=gnu{89,99} gets confused by # as an end-of-line comment marker
120%.s: %.S $(AHDRS) Makefile
121        $(CPP) $(AFLAGS) $< -o $@
Note: See TracBrowser for help on using the repository browser.