mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
[MINIOS] New make structure to support different architectures.
Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
This commit is contained in:
1 parent
4ff20a3034
commit
f515c2cf95
8 files changed
+195
-94
No files matched your search
+76
-94
@@ -1,112 +1,88 @@
|
||||
debug ?= y
|
||||
# Common Makefile for mini-os.
|
||||
#
|
||||
# Every architecture directory below mini-os/arch has to have a
|
||||
# Makefile and a arch.mk.
|
||||
#
|
||||
|
||||
pae ?= n
|
||||
|
||||
XEN_ROOT = ../..
|
||||
include $(XEN_ROOT)/Config.mk
|
||||
|
||||
# Set TARGET_ARCH
|
||||
override TARGET_ARCH := $(XEN_TARGET_ARCH)
|
||||
|
||||
XEN_INTERFACE_VERSION := 0x00030204
|
||||
export XEN_INTERFACE_VERSION
|
||||
|
||||
# NB. '-Wcast-qual' is nasty, so I omitted it.
|
||||
CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
|
||||
CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
|
||||
CFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
|
||||
# Set TARGET_ARCH
|
||||
override TARGET_ARCH := $(XEN_TARGET_ARCH)
|
||||
|
||||
ASFLAGS = -D__ASSEMBLY__
|
||||
# Set mini-os root path, used in mini-os.mk.
|
||||
MINI-OS_ROOT=$(PWD)
|
||||
export MINI-OS_ROOT
|
||||
|
||||
LDLIBS = -L. -lminios
|
||||
LDFLAGS_FINAL := -N -T minios-$(TARGET_ARCH).lds
|
||||
LDFLAGS :=
|
||||
# Try to find out the architecture family TARGET_ARCH_FAM.
|
||||
# First check whether x86_... is contained (for x86_32, x86_32y, x86_64).
|
||||
# If not x86 then use $(TARGET_ARCH) -> for ia64, ...
|
||||
ifeq ($(findstring x86_,$(TARGET_ARCH)),x86_)
|
||||
TARGET_ARCH_FAM = x86
|
||||
else
|
||||
TARGET_ARCH_FAM = $(TARGET_ARCH)
|
||||
endif
|
||||
|
||||
# The architecture family directory below mini-os.
|
||||
TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FAM)
|
||||
|
||||
# Export these variables for possible use in architecture dependent makefiles.
|
||||
export TARGET_ARCH
|
||||
export TARGET_ARCH_DIR
|
||||
export TARGET_ARCH_FAM
|
||||
|
||||
# This is used for architecture specific links.
|
||||
# This can be overwritten from arch specific rules.
|
||||
ARCH_LINKS =
|
||||
|
||||
# For possible special header directories.
|
||||
# This can be overwritten from arch specific rules.
|
||||
EXTRA_INC =
|
||||
|
||||
# Special build dependencies.
|
||||
# Build all after touching this/these file(s) (see minios.mk)
|
||||
SPEC_DEPENDS = minios.mk
|
||||
|
||||
# Include the architecture family's special makerules.
|
||||
# This must be before include minios.mk!
|
||||
include $(TARGET_ARCH_DIR)/arch.mk
|
||||
|
||||
# Include common mini-os makerules.
|
||||
include minios.mk
|
||||
|
||||
# Define some default flags for linking.
|
||||
LDLIBS :=
|
||||
LDFLAGS :=
|
||||
LDARCHLIB := -L$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
|
||||
LDFLAGS_FINAL := -N -T $(TARGET_ARCH_DIR)/minios-$(TARGET_ARCH).lds
|
||||
|
||||
# Prefix for global API names. All other symbols are localised before
|
||||
# linking with EXTRA_OBJS.
|
||||
GLOBAL_PREFIX := xenos_
|
||||
EXTRA_OBJS =
|
||||
|
||||
# For possible special source directories.
|
||||
EXTRA_SRC =
|
||||
# For possible special header directories.
|
||||
EXTRA_INC =
|
||||
|
||||
# Standard name for architecture specific subdirectories.
|
||||
TARGET_ARCH_DIR = $(TARGET_ARCH)
|
||||
# This is used for architecture specific links.
|
||||
ARCH_LINKS =
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86_32)
|
||||
CFLAGS += -m32 -march=i686
|
||||
LDFLAGS += -m elf_i386
|
||||
TARGET_ARCH_DIR = x86
|
||||
EXTRA_INC += $(TARGET_ARCH_DIR)/$(TARGET_ARCH)
|
||||
EXTRA_SRC += arch/$(EXTRA_INC)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH)$(pae),x86_32y)
|
||||
CFLAGS += -DCONFIG_X86_PAE=1
|
||||
ASFLAGS += -DCONFIG_X86_PAE=1
|
||||
TARGET_ARCH_DIR = x86
|
||||
EXTRA_INC += $(TARGET_ARCH_DIR)/$(TARGET_ARCH)
|
||||
EXTRA_SRC += arch/$(EXTRA_INC)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86_64)
|
||||
CFLAGS += -m64 -mno-red-zone -fpic -fno-reorder-blocks
|
||||
CFLAGS += -fno-asynchronous-unwind-tables
|
||||
LDFLAGS += -m elf_x86_64
|
||||
TARGET_ARCH_DIR = x86
|
||||
EXTRA_INC += $(TARGET_ARCH_DIR)/$(TARGET_ARCH)
|
||||
EXTRA_SRC += arch/$(EXTRA_INC)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),ia64)
|
||||
CFLAGS += -mfixed-range=f2-f5,f12-f15,f32-f127 -mconstant-gp
|
||||
ASFLAGS += -x assembler-with-cpp -Wall
|
||||
ASFLAGS += -mfixed-range=f2-f5,f12-f15,f32-f127 -fomit-frame-pointer
|
||||
ASFLAGS += -fno-builtin -fno-common -fno-strict-aliasing -mconstant-gp
|
||||
ARCH_LINKS = IA64_LINKS # Special link on ia64 needed
|
||||
define arch_links
|
||||
[ -e include/ia64/asm-xsi-offsets.h ] || ln -sf ../../../../xen/include/asm-ia64/asm-xsi-offsets.h include/ia64/asm-xsi-offsets.h
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(debug),y)
|
||||
CFLAGS += -g
|
||||
else
|
||||
CFLAGS += -O3
|
||||
endif
|
||||
|
||||
# Add the special header directories to the include paths.
|
||||
extra_incl := $(foreach dir,$(EXTRA_INC),-Iinclude/$(dir))
|
||||
override CPPFLAGS := -Iinclude $(CPPFLAGS) -Iinclude/$(TARGET_ARCH_DIR) $(extra_incl)
|
||||
|
||||
TARGET := mini-os
|
||||
|
||||
HEAD := $(TARGET_ARCH).o
|
||||
# Subdirectories common to mini-os
|
||||
SUBDIRS := lib xenbus console
|
||||
|
||||
# The common mini-os objects to build.
|
||||
OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
|
||||
OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
|
||||
OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
|
||||
OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c))
|
||||
OBJS += $(patsubst %.S,%.o,$(wildcard arch/$(TARGET_ARCH_DIR)/*.S))
|
||||
OBJS += $(patsubst %.c,%.o,$(wildcard arch/$(TARGET_ARCH_DIR)/*.c))
|
||||
# For special wanted source directories.
|
||||
extra_objs := $(foreach dir,$(EXTRA_SRC),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
|
||||
OBJS += $(extra_objs)
|
||||
extra_objs := $(foreach dir,$(EXTRA_SRC),$(patsubst %.S,%.o,$(wildcard $(dir)/*.S)))
|
||||
OBJS += $(extra_objs)
|
||||
|
||||
HDRS := $(wildcard include/*.h)
|
||||
HDRS += $(wildcard include/xen/*.h)
|
||||
HDRS += $(wildcard include/$(TARGET_ARCH_DIR)/*.h)
|
||||
# For special wanted header directories.
|
||||
extra_heads := $(foreach dir,$(EXTRA_INC),$(wildcard $(dir)/*.h))
|
||||
HDRS += $(extra_heads)
|
||||
|
||||
.PHONY: default
|
||||
default: $(TARGET)
|
||||
|
||||
# Create special architecture specific links.
|
||||
# Create special architecture specific links. The function arch_links
|
||||
# has to be defined in arch.mk (see include above).
|
||||
ifneq ($(ARCH_LINKS),)
|
||||
$(ARCH_LINKS):
|
||||
$(arch_links)
|
||||
@@ -116,24 +92,29 @@ endif
|
||||
links: $(ARCH_LINKS)
|
||||
[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
|
||||
|
||||
$(TARGET): links $(OBJS) $(HEAD)
|
||||
$(LD) -r $(LDFLAGS) $(HEAD) $(OBJS) -o $@.o
|
||||
.PHONY: arch_lib
|
||||
arch_lib:
|
||||
$(MAKE) --directory=$(TARGET_ARCH_DIR) || exit 1;
|
||||
|
||||
$(TARGET): links $(OBJS) arch_lib
|
||||
$(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJS) $(LDARCHLIB) -o $@.o
|
||||
$(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o
|
||||
$(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@
|
||||
gzip -f -9 -c $@ >$@.gz
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
find . -type f -name '*.o' | xargs rm -f
|
||||
rm -f *.o *~ core $(TARGET) $(TARGET).gz
|
||||
.PHONY: clean arch_clean
|
||||
|
||||
arch_clean:
|
||||
$(MAKE) --directory=$(TARGET_ARCH_DIR) clean || exit 1;
|
||||
|
||||
clean: arch_clean
|
||||
for dir in $(SUBDIRS); do \
|
||||
rm -f $$dir/*.o; \
|
||||
done
|
||||
rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
|
||||
find . -type l | xargs rm -f
|
||||
rm -f tags TAGS
|
||||
|
||||
%.o: %.c $(HDRS) Makefile
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.S $(HDRS) Makefile
|
||||
$(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
define all_sources
|
||||
( find . -follow -name SCCS -prune -o -name '*.[chS]' -print )
|
||||
@@ -147,3 +128,4 @@ cscope:
|
||||
.PHONY: tags
|
||||
tags:
|
||||
$(all_sources) | xargs ctags
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# x86 architecture specific makefiles.
|
||||
# It's is used for x86_32, x86_32y and x86_64
|
||||
#
|
||||
|
||||
# Rebuild all after touching this/these extra file(s) (see mini-os.mk)
|
||||
SPEC_DEP = arch.mk
|
||||
|
||||
# include arch.mk has to be before mini-os.mk!
|
||||
include arch.mk
|
||||
include ../../minios.mk
|
||||
|
||||
# Sources here are all *.c *.S without $(TARGET_ARCH).S
|
||||
# This is handled in $(HEAD_ARCH_OBJ)
|
||||
ARCH_SRCS := $(wildcard *.c)
|
||||
|
||||
# The objects built from the sources.
|
||||
ARCH_OBJS := $(patsubst %.c,%.o,$(ARCH_SRCS))
|
||||
|
||||
all: $(ARCH_LIB)
|
||||
|
||||
# $(HEAD_ARCH_OBJ) is only build here, needed on linking
|
||||
# in ../../Makefile.
|
||||
$(ARCH_LIB): $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
|
||||
$(AR) rv $(ARCH_LIB) $(ARCH_OBJS)
|
||||
|
||||
clean:
|
||||
rm -f $(ARCH_LIB) $(ARCH_OBJS)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Architecture special makerules for x86 family
|
||||
# (including x86_32, x86_32y and x86_64).
|
||||
#
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86_32)
|
||||
ARCH_CFLAGS := -m32 -march=i686
|
||||
ARCH_LDFLAGS := -m elf_i386
|
||||
EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
|
||||
EXTRA_SRC += arch/$(EXTRA_INC)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH)$(pae),x86_32y)
|
||||
ARCH_CFLAGS := -DCONFIG_X86_PAE=1
|
||||
ARCH_ASFLAGS := -DCONFIG_X86_PAE=1
|
||||
EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
|
||||
EXTRA_SRC += arch/$(EXTRA_INC)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86_64)
|
||||
ARCH_CFLAGS := -m64 -mno-red-zone -fpic -fno-reorder-blocks
|
||||
ARCH_CFLAGS := -fno-asynchronous-unwind-tables
|
||||
ARCH_LDFLAGS := -m elf_x86_64
|
||||
EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
|
||||
EXTRA_SRC += arch/$(EXTRA_INC)
|
||||
endif
|
||||
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,62 @@
|
||||
#
|
||||
# The file contains the common make rules for building mini-os.
|
||||
#
|
||||
|
||||
debug = y
|
||||
|
||||
# Define some default flags.
|
||||
# NB. '-Wcast-qual' is nasty, so I omitted it.
|
||||
DEF_CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
|
||||
DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
|
||||
DEF_CFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
|
||||
|
||||
DEF_ASFLAGS = -D__ASSEMBLY__
|
||||
|
||||
ifeq ($(debug),y)
|
||||
DEF_CFLAGS += -g
|
||||
else
|
||||
DEF_CFLAGS += -O3
|
||||
endif
|
||||
|
||||
# Build the CFLAGS and ASFLAGS for compiling and assembling.
|
||||
# DEF_... flags are the common mini-os flags,
|
||||
# ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk
|
||||
CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS)
|
||||
ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS)
|
||||
|
||||
# The path pointing to the architecture specific header files.
|
||||
ARCH_SPEC_INC := $(MINI-OS_ROOT)/include/$(TARGET_ARCH_FAM)
|
||||
|
||||
# Find all header files for checking dependencies.
|
||||
HDRS := $(wildcard $(MINI-OS_ROOT)/include/*.h)
|
||||
HDRS += $(wildcard $(MINI-OS_ROOT)/include/xen/*.h)
|
||||
HDRS += $(wildcard $(ARCH_SPEC_INC)/*.h)
|
||||
# For special wanted header directories.
|
||||
extra_heads := $(foreach dir,$(EXTRA_INC),$(wildcard $(dir)/*.h))
|
||||
HDRS += $(extra_heads)
|
||||
|
||||
# Add the special header directories to the include paths.
|
||||
extra_incl := $(foreach dir,$(EXTRA_INC),-I$(MINI-OS_ROOT)/include/$(dir))
|
||||
override CPPFLAGS := -I$(MINI-OS_ROOT)/include $(CPPFLAGS) -I$(ARCH_SPEC_INC) $(extra_incl)
|
||||
|
||||
# The name of the architecture specific library.
|
||||
# This is on x86_32: libx86_32.a
|
||||
# $(ARCH_LIB) has to built in the architecture specific directory.
|
||||
ARCH_LIB_NAME = $(TARGET_ARCH)
|
||||
ARCH_LIB := lib$(ARCH_LIB_NAME).a
|
||||
|
||||
# This object contains the entrypoint for startup from Xen.
|
||||
# $(HEAD_ARCH_OBJ) has to be built in the architecture specific directory.
|
||||
HEAD_ARCH_OBJ := $(TARGET_ARCH).o
|
||||
HEAD_OBJ := $(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ)
|
||||
|
||||
|
||||
%.o: %.c $(HDRS) Makefile $(SPEC_DEPENDS)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.S $(HDRS) Makefile $(SPEC_DEPENDS)
|
||||
$(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
|
||||
|
||||