Skip to contentSkip to conversation

Introduce Makefile config fragments for OS-specific differences.

PATCH In review John Levon 2 participants 3 messages Oct 17, 2006 Kbuild

lore
Share & tools
lore

John Levon

author
#0 lore raw

PATCH 1/1 Introduce Makefile config fragments for OS-specific differences.

# HG changeset patch
# User [email protected]
# Date 1161088787 25200
# Node ID 9ab13bf0dc8189319f78c8c33a632337ee80f390
# Parent 833f04aee836304d5f232daf18576952bb436f1b Introduce Makefile config fragments for OS-specific differences.

Config.mk +3 -30
@@ -4,43 +4,19 @@ debug ?= n
 debug ?= n
 
 XEN_COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/ \
-                                              -e s/ppc/powerpc/)
+                         -e s/ppc/powerpc/ -e s/i86pc/x86_32/)
 XEN_TARGET_ARCH     ?= $(XEN_COMPILE_ARCH)
 XEN_TARGET_X86_PAE  ?= n
+XEN_OS              ?= $(shell uname -s)
 
 # Tools to run on system hosting the build
 HOSTCC     = gcc
 HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer
 
-AS         = $(CROSS_COMPILE)as
-LD         = $(CROSS_COMPILE)ld
-CC         = $(CROSS_COMPILE)gcc
-CPP        = $(CROSS_COMPILE)gcc -E
-AR         = $(CROSS_COMPILE)ar
-RANLIB     = $(CROSS_COMPILE)ranlib
-NM         = $(CROSS_COMPILE)nm
-STRIP      = $(CROSS_COMPILE)strip
-OBJCOPY    = $(CROSS_COMPILE)objcopy
-OBJDUMP    = $(CROSS_COMPILE)objdump
-
 DISTDIR     ?= $(XEN_ROOT)/dist
 DESTDIR     ?= /
 
-INSTALL      = install
-INSTALL_DIR  = $(INSTALL) -d -m0755
-INSTALL_DATA = $(INSTALL) -m0644
-INSTALL_PROG = $(INSTALL) -m0755
-
-ifneq ($(debug),y)
-# Optimisation flags are overridable
-CFLAGS    ?= -O2 -fomit-frame-pointer
-CFLAGS    += -DNDEBUG
-else
-# Less than -O1 produces bad code and large stack frames
-CFLAGS    ?= -O1 -fno-omit-frame-pointer
-CFLAGS    += -g
-endif
-
+include $(XEN_ROOT)/config/$(XEN_OS).mk
 include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
 
 ifneq ($(EXTRA_PREFIX),)
@@ -57,9 +33,6 @@ CFLAGS     += $(call test-gcc-flag,$(CC)
 
 LDFLAGS += $(foreach i, $(EXTRA_LIB), -L$(i)) 
 CFLAGS += $(foreach i, $(EXTRA_INCLUDES), -I$(i))
-
-# Choose the best mirror to download linux kernel
-KERNEL_REPO = http://www.kernel.org
 
 # If ACM_SECURITY = y, then the access control module is compiled
 # into Xen and the policy type can be set by the boot policy file
Makefile +0 -5
@@ -1,11 +1,6 @@
 #
 # Grand Unified Makefile for Xen.
 #
-
-KERNELS ?= linux-2.6-xen
-# You may use wildcards in the above e.g. KERNELS=*2.6*
-
-XKERNELS := $(foreach kernel, $(KERNELS), $(patsubst buildconfigs/mk.%,%,$(wildcard buildconfigs/mk.$(kernel))) )
 
 # Export target architecture overrides to Xen and Linux sub-trees.
 ifneq ($(XEN_TARGET_ARCH),)
config/Linux.mk new file +39 -0
new file mode 100644
@@ -0,0 +1,39 @@
+# -*- mode: Makefile; -*-
+
+AS         = $(CROSS_COMPILE)as
+LD         = $(CROSS_COMPILE)ld
+CC         = $(CROSS_COMPILE)gcc
+CPP        = $(CROSS_COMPILE)gcc -E
+AR         = $(CROSS_COMPILE)ar
+RANLIB     = $(CROSS_COMPILE)ranlib
+NM         = $(CROSS_COMPILE)nm
+STRIP      = $(CROSS_COMPILE)strip
+OBJCOPY    = $(CROSS_COMPILE)objcopy
+OBJDUMP    = $(CROSS_COMPILE)objdump
+
+INSTALL      = install
+INSTALL_DIR  = $(INSTALL) -d -m0755
+INSTALL_DATA = $(INSTALL) -m0644
+INSTALL_PROG = $(INSTALL) -m0755
+
+LIB64DIR=lib64
+
+ifneq ($(debug),y)
+# Optimisation flags are overridable
+CFLAGS    ?= -O2 -fomit-frame-pointer
+CFLAGS    += -DNDEBUG
+else
+# Less than -O1 produces bad code and large stack frames
+CFLAGS    ?= -O1 -fno-omit-frame-pointer
+CFLAGS    += -g
+endif
+
+# Choose the best mirror to download linux kernel
+KERNEL_REPO = http://www.kernel.org
+
+KERNELS ?= linux-2.6-xen
+# You may use wildcards in the above e.g. KERNELS=*2.6*
+
+XKERNELS := $(foreach kernel, $(KERNELS), $(patsubst buildconfigs/mk.%,%,$(wildcard buildconfigs/mk.$(kernel))) )
+
+CONFIG_MBOOTPACK_OS = y
config/SunOS.mk new file +31 -0
new file mode 100644
@@ -0,0 +1,31 @@
+# -*- mode: Makefile; -*-
+
+AS         = $(CROSS_COMPILE)gas
+LD         = $(CROSS_COMPILE)gld
+CC         = $(CROSS_COMPILE)gcc
+CPP        = $(CROSS_COMPILE)gcc -E
+AR         = $(CROSS_COMPILE)gar
+RANLIB     = $(CROSS_COMPILE)granlib
+NM         = $(CROSS_COMPILE)gnm
+STRIP      = $(CROSS_COMPILE)gstrip
+OBJCOPY    = $(CROSS_COMPILE)gobjcopy
+OBJDUMP    = $(CROSS_COMPILE)gobjdump
+
+INSTALL      = ginstall
+INSTALL_DIR  = $(INSTALL) -d -m0755
+INSTALL_DATA = $(INSTALL) -m0644
+INSTALL_PROG = $(INSTALL) -m0755
+
+LIB64DIR=lib/amd64
+
+ifneq ($(debug),y)
+# Optimisation flags are overridable
+CFLAGS    ?= -O2 -fno-omit-frame-pointer
+CFLAGS    += -DNDEBUG
+else
+# Less than -O1 produces bad code and large stack frames
+CFLAGS    ?= -O1 -fno-omit-frame-pointer
+CFLAGS    += -g
+endif
+
+CONFIG_MBOOTPACK_OS = n
config/x86_32.mk +1 -1
@@ -3,7 +3,7 @@ CONFIG_MIGRATE := y
 CONFIG_MIGRATE := y
 CONFIG_XCUTILS := y
 CONFIG_IOEMU := y
-CONFIG_MBOOTPACK := y
+CONFIG_MBOOTPACK := $(CONFIG_MBOOTPACK_OS)
 
 CFLAGS += -m32 -march=i686
 LIBDIR := lib
config/x86_64.mk +2 -2
@@ -3,8 +3,8 @@ CONFIG_MIGRATE := y
 CONFIG_MIGRATE := y
 CONFIG_XCUTILS := y
 CONFIG_IOEMU := y
-CONFIG_MBOOTPACK := y
+CONFIG_MBOOTPACK := $(CONFIG_MBOOTPACK_OS)
 
 CFLAGS += -m64
 LDFLAGS += -m64
-LIBDIR = lib64
+LIBDIR = $(LIB64DIR)
#1 lore raw

Config.mk debug ?= n · line 42

Quoted 9 lines · John Levon
Config.mk +0 -9
-ifneq ($(debug),y)
-# Optimisation flags are overridable
-CFLAGS    ?= -O2 -fomit-frame-pointer
-CFLAGS    += -DNDEBUG
-else
-# Less than -O1 produces bad code and large stack frames
-CFLAGS    ?= -O1 -fno-omit-frame-pointer
-CFLAGS    += -g
-endif

Generally this patch is fine, but does the above chunk have to be made OS-specific? Does Solaris specifically have something against -fomit-frame-pointer?

Also, moving KERNEL_REPO/KERNELS/XKERNELS seems unnecessary. There are still rules consuming those variables in the root Makefile, so leaving KERNELS/XKERNELS nearby makes sense to me.

-- Keir

author
#2 lore raw
Quoted 5 lines · Keir Fraser
Quoted 5 lines
Config.mk +0 -5
-ifneq ($(debug),y)
-# Optimisation flags are overridable
-CFLAGS    ?= -O2 -fomit-frame-pointer
-CFLAGS    += -DNDEBUG
-else
Quoted 8 lines

Config.mk debug ?= n · line 42

Quoted 4 lines
Config.mk +0 -4
-# Less than -O1 produces bad code and large stack frames
-CFLAGS    ?= -O1 -fno-omit-frame-pointer
-CFLAGS    += -g
-endif

Generally this patch is fine, but does the above chunk have to be made OS-specific? Does Solaris specifically have something against -fomit-frame-pointer?

Yes, it's a fundamental principle that all the software we deliver can produce meaningful stack traces.

Quoted 3 lines

Also, moving KERNEL_REPO/KERNELS/XKERNELS seems unnecessary. There are still rules consuming those variables in the root Makefile, so leaving KERNELS/XKERNELS nearby makes sense to me.

This is specifically to make sure that KERNELS is empty on Solaris. Otherwise, we have to add some $(XEN_OS) gook to $(XEN_ROOT)/Makefile. Hopefully these are going away soonish anyway ;)

regards
john