Skip to contentSkip to conversation

mini-os: New makefile structure for different architectures

PATCH Superseded Dietmar Hahn 1 participant 2 messages Nov 27, 2006 – Jan 8, 2007 5 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH 1/1 mini-os: New makefile structure for different architectures

Hi Gregor,

Quoted 2 lines

Yes, having Makefiles in each subdirectory is the way to go. The only reason we have one is that historically everything lived in mini-os

I tried a complete rewrite of the make structure for mini-os to get better support for different architectures (for me ia64).
Please have a look at it and give your comments. It's really needed to get publish the ia64 mini-os.
Thanks.

Dietmar.

Following structure:
mini-os/Makefile - common makefile.
mini-os/mini-os.mk - common makerules. arch/x86/Makefile - x86 family special makefile
arch/x86/arch.mk - x86 family special make rules
arch/ia64/Makefile - ia64 family special makefile arch/ia64/arch.mk - ia64 family special make rules

On start of make (with common makefile) tries to extract the correct architecture and sets up (and exports) some variables.
TARGET_ARCH - x86_32 or x86_64 or ia64 or ...
TARGET_ARCH_FAM - x86 (for x86_32, ...) or ia64 or ... TARGET_ARCH_DIR - arch/x86 or arch/ia64 or ...
MINI-OS_ROOT - The complete path to mini-os directory.

It includes the architecture specific arch.mk and mini-os.mk With both the make flags are built.

It tries to build libminios.a from
mini-os/*.c
console/*.c
xenbus/*.c
This is done like in the old make structure.

It goes to the arch/... directory and starts the special architecture Makefile, which must build the architecture specific library (e.g. libx86_32.a or libia64.a)
This Makefile includes the architecture special makerules file arch.mk and the global rule file ../../mini-os.mk

All architecture specific files are moved to the arch/... directory. This includes the linker script minios-*.lds and the assembler file with the _start function (e.g. x86_32.S). In the new make structure this file is handled separatly in the makerules to get it right on linking (see HEAD_ARCH_OBJ and HEAD_ARCH in minios.mk).

# HG changeset patch
# User [email protected]
# Date 1164631803 -3600
# Node ID 9eee9311895fb903896312b71e307c353caa76c8 # Parent 84c0f49de1b1e241a4b409a48192c110b01788a0

New make structure to support different architectures.

extras/mini-os/Makefile +66 -88
diff -r 84c0f49de1b1 -r 9eee9311895f extras/mini-os/Makefile
@@ -1,106 +1,79 @@ debug ?= y
-debug ?= y
+#
+# Common Makefile for mini-os.
+#
+
 pae ?= n
 
 XEN_ROOT = ../..
 include $(XEN_ROOT)/Config.mk
 
+XEN_INTERFACE_VERSION := 0x00030203
+export XEN_INTERFACE_VERSION
+
 # Set TARGET_ARCH
-override TARGET_ARCH     := $(XEN_TARGET_ARCH)
+override TARGET_ARCH := $(XEN_TARGET_ARCH)
 
-XEN_INTERFACE_VERSION := 0x00030203
+# Set mini-os root path, used in mini-os.mk.
+MINI-OS_ROOT=$(PWD)
+export MINI-OS_ROOT
 
-# 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)
+# 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
 
-ASFLAGS = -D__ASSEMBLY__
+# The architecture family directory below mini-os.
+TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FAM)
 
-LDLIBS =  -L. -lminios
-LDFLAGS := -N -T minios-$(TARGET_ARCH).lds
+# Export these variables for possible use in architecture dependent makefiles.
+export TARGET_ARCH
+export TARGET_ARCH_DIR
+export TARGET_ARCH_FAM
 
-# For possible special source directories.
-EXTRA_SRC =
+# 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 =
 
-# Standard name for architecture specific subdirectories.
-TARGET_ARCH_DIR = $(TARGET_ARCH)
-# This is used for architecture specific links.
-ARCH_LINKS =
+# Special build dependencies.
+# Build all after touching this/these file(s) (see minios.mk)
+SPEC_DEPENDS = minios.mk
 
-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
+# Include the architecture family's special makerules.
+# This must be before include minios.mk!
+include $(TARGET_ARCH_DIR)/arch.mk
 
-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
+# Include common mini-os makerules.
+include minios.mk
 
-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)
+# Define some default flags for linking.
+LDLIBS := -L. -lminios -L$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
+LDFLAGS := -N -T $(TARGET_ARCH_DIR)/minios-$(TARGET_ARCH).lds
 
 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)
@@ -110,26 +83,30 @@ links:	$(ARCH_LINKS)
 links:	$(ARCH_LINKS)
 	[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
 
-libminios.a: links $(OBJS) $(HEAD)
-	$(AR) r libminios.a $(HEAD) $(OBJS)
+libminios.a: links $(OBJS)
+	$(AR) r libminios.a $(OBJS)
 
-$(TARGET): libminios.a $(HEAD)
-	$(LD) $(LDFLAGS) $(HEAD) $(LDLIBS) -o [email protected]
+.PHONY: arch_lib
+arch_lib:
+	$(MAKE) --directory=$(TARGET_ARCH_DIR) || exit 1;
+
+$(TARGET): libminios.a arch_lib
+	$(LD) $(LDFLAGS) $(HEAD_OBJ) $(LDLIBS) -o [email protected]
 	gzip -f -9 -c [email protected] >[email protected]
 
-.PHONY: clean
-clean:
-	find . -type f -name '*.o' | xargs rm -f
-	rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
-	rm -f libminios.a
+.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
 	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 )
@@ -143,3 +120,4 @@ cscope:
 .PHONY: tags
 tags:
 	$(all_sources) | xargs ctags
+
extras/mini-os/arch/x86/Makefile new file +29 -0
diff -r 84c0f49de1b1 -r 9eee9311895f extras/mini-os/arch/x86/Makefile
@@ -0,0 +1,29 @@
+#
+# x86 architecture specific makefiles.
+# It's is used for x86_32, x86_32y and x86_64
+#
+
+# Build all after touching this file (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)
+
extras/mini-os/arch/x86/arch.mk new file +28 -0
diff -r 84c0f49de1b1 -r 9eee9311895f extras/mini-os/arch/x86/arch.mk
@@ -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
+
+
extras/mini-os/arch/x86/minios-x86_32.lds new file +45 -0

45 lines not on this page · raw message

extras/mini-os/arch/x86/minios-x86_64.lds new file +54 -0

54 lines not on this page · raw message

extras/mini-os/arch/x86/x86_32.S new file +287 -0

287 lines not on this page · raw message

extras/mini-os/arch/x86/x86_64.S new file +385 -0

385 lines not on this page · raw message

extras/mini-os/minios.mk new file +62 -0

62 lines not on this page · raw message

extras/mini-os/minios-x86_32.lds deleted +0 -45

45 lines not on this page · raw message

extras/mini-os/minios-x86_64.lds deleted +0 -54

54 lines not on this page · raw message

extras/mini-os/x86_32.S deleted +0 -287

287 lines not on this page · raw message

extras/mini-os/x86_64.S deleted +0 -385

385 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

PATCH RESEND 1/1 mini-os: New makefile structure for different architectures

Hi Gregor,

after 3.0.4 is ready I try again my patch for mini-os:

Am Mittwoch, 6. Dezember 2006 22:58 schrieb Grzegorz Milos:

Quoted 12 lines · Dietmar Hahn
Quoted 5 lines

Hi Gregor,

Quoted 3 lines

I tried a complete rewrite of the make structure for mini-os to get better
support for different architectures (for me ia64).

I've looked through the patch. It looks good (but I would appreciate if somebody knowing little more about Makefiles then me could have a look as well). Keir could you apply (the original message: http://
lists.xensource.com/archives/html/xen-devel/2006-11/msg01324.html).

The attached new patch is against the current change set. Thanks.

Dietmar.

# HG changeset patch
# User [email protected]
# Date 1168251028 -3600
# Node ID 2e60bbdeff48a57b5532b06a2d28c8a9eb7d528a # Parent 9865145e53eb02ddc2e2792f80bb7d54bc754a65 New make structure to support different architectures.

extras/mini-os/Makefile +69 -86
diff -r 9865145e53eb -r 2e60bbdeff48 extras/mini-os/Makefile
@@ -1,106 +1,83 @@ debug ?= y
-debug ?= y
+# Common Makefile for mini-os.
+#
+# Make structure:
+# mini-os directory contains Makefile and minios.mk.
+# Every architecture directory below mini-os/arch has to have a
+# own Makefile and a file arch.mk.
+#
+
 pae ?= n
 
 XEN_ROOT = ../..
 include $(XEN_ROOT)/Config.mk
 
+XEN_INTERFACE_VERSION := 0x00030203
+export XEN_INTERFACE_VERSION
+
 # Set TARGET_ARCH
-override TARGET_ARCH     := $(XEN_TARGET_ARCH)
+override TARGET_ARCH := $(XEN_TARGET_ARCH)
 
-XEN_INTERFACE_VERSION := 0x00030203
+# Set mini-os root path, used in mini-os.mk.
+MINI-OS_ROOT=$(PWD)
+export MINI-OS_ROOT
 
-# 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)
+# 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
 
-ASFLAGS = -D__ASSEMBLY__
+# The architecture family directory below mini-os.
+TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FAM)
 
-LDLIBS =  -L. -lminios
-LDFLAGS := -N -T minios-$(TARGET_ARCH).lds
+# Export these variables for possible use in architecture dependent makefiles.
+export TARGET_ARCH
+export TARGET_ARCH_DIR
+export TARGET_ARCH_FAM
 
-# For possible special source directories.
-EXTRA_SRC =
+# 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 =
 
-# Standard name for architecture specific subdirectories.
-TARGET_ARCH_DIR = $(TARGET_ARCH)
-# This is used for architecture specific links.
-ARCH_LINKS =
+# Special build dependencies.
+# Build all after touching this/these file(s) (see minios.mk)
+SPEC_DEPENDS = minios.mk
 
-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
+# Include the architecture family's special makerules.
+# This must be before include minios.mk!
+include $(TARGET_ARCH_DIR)/arch.mk
 
-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
+# Include common mini-os makerules.
+include minios.mk
 
-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)
+# Define some default flags for linking.
+LDLIBS := -L. -lminios -L$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
+LDFLAGS := -N -T $(TARGET_ARCH_DIR)/minios-$(TARGET_ARCH).lds
 
 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)
@@ -110,26 +87,31 @@ links:	$(ARCH_LINKS)
 links:	$(ARCH_LINKS)
 	[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
 
-libminios.a: links $(OBJS) $(HEAD)
-	$(AR) r libminios.a $(HEAD) $(OBJS)
+libminios.a: links $(OBJS)
+	$(AR) r libminios.a $(OBJS)
 
-$(TARGET): libminios.a $(HEAD)
-	$(LD) $(LDFLAGS) $(HEAD) $(LDLIBS) -o [email protected]
+.PHONY: arch_lib
+arch_lib:
+	$(MAKE) --directory=$(TARGET_ARCH_DIR) || exit 1;
+
+$(TARGET): libminios.a arch_lib
+	$(LD) $(LDFLAGS) $(HEAD_OBJ) $(LDLIBS) -o [email protected]
 	gzip -f -9 -c [email protected] >[email protected]
 
-.PHONY: clean
-clean:
-	find . -type f -name '*.o' | xargs rm -f
+.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
 	rm -f libminios.a
 	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 )
@@ -143,3 +125,4 @@ cscope:
 .PHONY: tags
 tags:
 	$(all_sources) | xargs ctags
+
extras/mini-os/arch/x86/Makefile new file +29 -0
diff -r 9865145e53eb -r 2e60bbdeff48 extras/mini-os/arch/x86/Makefile
@@ -0,0 +1,29 @@
+#
+# x86 architecture specific makefiles.
+# It's is used for x86_32, x86_32y and x86_64
+#
+
+# Build all after touching this file (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)
+
extras/mini-os/arch/x86/arch.mk new file +28 -0
diff -r 9865145e53eb -r 2e60bbdeff48 extras/mini-os/arch/x86/arch.mk
@@ -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
+
+
extras/mini-os/arch/x86/minios-x86_32.lds new file +45 -0

45 lines not on this page · raw message

extras/mini-os/arch/x86/minios-x86_64.lds new file +54 -0

54 lines not on this page · raw message

extras/mini-os/arch/x86/x86_32.S new file +287 -0

287 lines not on this page · raw message

extras/mini-os/arch/x86/x86_64.S new file +385 -0

385 lines not on this page · raw message

extras/mini-os/minios.mk new file +62 -0

62 lines not on this page · raw message

extras/mini-os/minios-x86_32.lds deleted +0 -45

45 lines not on this page · raw message

extras/mini-os/minios-x86_64.lds deleted +0 -54

54 lines not on this page · raw message

extras/mini-os/x86_32.S deleted +0 -287

287 lines not on this page · raw message

extras/mini-os/x86_64.S deleted +0 -385

385 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel