| 1 | |
|---|
| 2 | # |
|---|
| 3 | # If you change any of these configuration options then you must |
|---|
| 4 | # 'make clean' before rebuilding. |
|---|
| 5 | # |
|---|
| 6 | verbose ?= n |
|---|
| 7 | perfc ?= n |
|---|
| 8 | perfc_arrays?= n |
|---|
| 9 | crash_debug ?= n |
|---|
| 10 | |
|---|
| 11 | XEN_ROOT=$(BASEDIR)/.. |
|---|
| 12 | include $(XEN_ROOT)/Config.mk |
|---|
| 13 | |
|---|
| 14 | # Hardcoded configuration implications and dependencies. |
|---|
| 15 | # Do this is a neater way if it becomes unwieldy. |
|---|
| 16 | ifeq ($(debug),y) |
|---|
| 17 | verbose := y |
|---|
| 18 | endif |
|---|
| 19 | ifeq ($(perfc_arrays),y) |
|---|
| 20 | perfc := y |
|---|
| 21 | endif |
|---|
| 22 | |
|---|
| 23 | # Set ARCH/SUBARCH appropriately. |
|---|
| 24 | override COMPILE_SUBARCH := $(XEN_COMPILE_ARCH) |
|---|
| 25 | override TARGET_SUBARCH := $(XEN_TARGET_ARCH) |
|---|
| 26 | override COMPILE_ARCH := $(shell echo $(XEN_COMPILE_ARCH) | \ |
|---|
| 27 | sed -e 's/x86.*/x86/' \ |
|---|
| 28 | -e 's/powerpc.*/powerpc/') |
|---|
| 29 | override TARGET_ARCH := $(shell echo $(XEN_TARGET_ARCH) | \ |
|---|
| 30 | sed -e 's/x86.*/x86/' \ |
|---|
| 31 | -e 's/powerpc.*/powerpc/') |
|---|
| 32 | |
|---|
| 33 | TARGET := $(BASEDIR)/xen |
|---|
| 34 | |
|---|
| 35 | HDRS := $(wildcard $(BASEDIR)/include/xen/*.h) |
|---|
| 36 | HDRS += $(wildcard $(BASEDIR)/include/public/*.h) |
|---|
| 37 | HDRS += $(wildcard $(BASEDIR)/include/compat/*.h) |
|---|
| 38 | HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/*.h) |
|---|
| 39 | HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/$(TARGET_SUBARCH)/*.h) |
|---|
| 40 | |
|---|
| 41 | include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk |
|---|
| 42 | |
|---|
| 43 | # Do not depend on auto-generated header files. |
|---|
| 44 | AHDRS := $(filter-out %/include/xen/compile.h,$(HDRS)) |
|---|
| 45 | HDRS := $(filter-out %/asm-offsets.h,$(AHDRS)) |
|---|
| 46 | |
|---|
| 47 | # Note that link order matters! |
|---|
| 48 | ALL_OBJS-y += $(BASEDIR)/common/built_in.o |
|---|
| 49 | ALL_OBJS-y += $(BASEDIR)/drivers/built_in.o |
|---|
| 50 | ALL_OBJS-$(ACM_SECURITY) += $(BASEDIR)/acm/built_in.o |
|---|
| 51 | ALL_OBJS-y += $(BASEDIR)/arch/$(TARGET_ARCH)/built_in.o |
|---|
| 52 | |
|---|
| 53 | CFLAGS-y += -g -D__XEN__ |
|---|
| 54 | CFLAGS-$(ACM_SECURITY) += -DACM_SECURITY |
|---|
| 55 | CFLAGS-$(verbose) += -DVERBOSE |
|---|
| 56 | CFLAGS-$(crash_debug) += -DCRASH_DEBUG |
|---|
| 57 | CFLAGS-$(perfc) += -DPERF_COUNTERS |
|---|
| 58 | CFLAGS-$(perfc_arrays) += -DPERF_ARRAYS |
|---|
| 59 | |
|---|
| 60 | ifneq ($(max_phys_cpus),) |
|---|
| 61 | CFLAGS-y += -DMAX_PHYS_CPUS=$(max_phys_cpus) |
|---|
| 62 | endif |
|---|
| 63 | |
|---|
| 64 | AFLAGS-y += -D__ASSEMBLY__ |
|---|
| 65 | |
|---|
| 66 | ALL_OBJS := $(ALL_OBJS-y) |
|---|
| 67 | |
|---|
| 68 | CFLAGS := $(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 |
|---|
| 72 | AFLAGS := $(strip $(AFLAGS) $(AFLAGS-y)) |
|---|
| 73 | AFLAGS += $(patsubst -std=gnu%,,$(CFLAGS)) |
|---|
| 74 | |
|---|
| 75 | # LDFLAGS are only passed directly to $(LD) |
|---|
| 76 | LDFLAGS := $(strip $(LDFLAGS) $(LDFLAGS_DIRECT)) |
|---|
| 77 | |
|---|
| 78 | include Makefile |
|---|
| 79 | |
|---|
| 80 | # Ensure each subdirectory has exactly one trailing slash. |
|---|
| 81 | subdir-n := $(patsubst %,%/,$(patsubst %/,%,$(subdir-n))) |
|---|
| 82 | subdir-y := $(patsubst %,%/,$(patsubst %/,%,$(subdir-y))) |
|---|
| 83 | |
|---|
| 84 | # Add explicitly declared subdirectories to the object list. |
|---|
| 85 | obj-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. |
|---|
| 89 | subdir-y += $(filter %/,$(obj-y)) |
|---|
| 90 | obj-y := $(patsubst %/,%/built-in.o,$(obj-y)) |
|---|
| 91 | |
|---|
| 92 | subdir-all := $(subdir-y) $(subdir-n) |
|---|
| 93 | |
|---|
| 94 | built_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 |
|---|
| 99 | FORCE: |
|---|
| 100 | |
|---|
| 101 | %/built_in.o: FORCE |
|---|
| 102 | $(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in.o |
|---|
| 103 | |
|---|
| 104 | .PHONY: clean |
|---|
| 105 | clean:: $(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 $@ |
|---|