2 # figure out a few things about the host build system
4 HOSTTYPE := $(shell uname -m)
7 OSTYPE := $(shell uname -s | awk -F_ '{print $$1}' | tr A-Z a-z)
9 ifeq ($(HOSTTYPE),i586)
12 ifeq ($(HOSTTYPE),i686)
18 ifeq ($(findstring Macintosh,$(HOSTTYPE)),Macintosh)
21 ifeq ($(HOSTTYPE),macintosh)
22 ifeq ($(MACHTYPE),powerpc)
27 # allow for a specific PLATFORM to override ARCH
30 # by default, build for a i386-pc
35 # some platforms only support one arch
36 ifeq ($(PLATFORM),pegasos)
39 ifeq ($(PLATFORM),mac)
45 ifeq ($(PLATFORM),xbox)
49 # build the TARGET variable
50 TARGET := $(ARCH)-$(PLATFORM)
52 # HOST_* is for local targets (tools)
57 HOST_OBJCOPY := objcopy
58 HOST_OBJDUMP := objdump
62 # setup some local commands
65 ifeq ($(OSTYPE),SunOS)
69 ifeq ($(findstring solaris,$(OSTYPE)),solaris)
74 # TOOLCHAIN_ARCH is usually ARCH, except in a few cases
75 TOOLCHAIN_ARCH := $(ARCH)
80 # try to detect if the user has ARCH-newos-gcc installed
83 # the "| cat" below looks unnecesary, this is
84 # to avoid a bug in liberty in certain versions
86 FOO := $(shell $(TOOLCHAIN_ARCH)-newos-gcc --version | cat)
88 $(warning found newos toolchain!)
89 CC = $(TOOLCHAIN_ARCH)-newos-gcc
90 LD = $(TOOLCHAIN_ARCH)-newos-ld
91 AS = $(TOOLCHAIN_ARCH)-newos-as
92 AR = $(TOOLCHAIN_ARCH)-newos-ar
93 OBJCOPY = $(TOOLCHAIN_ARCH)-newos-objcopy
94 OBJDUMP = $(TOOLCHAIN_ARCH)-newos-objdump
95 STRIP = $(TOOLCHAIN_ARCH)-newos-strip
96 SIZE = $(TOOLCHAIN_ARCH)-newos-size
98 $(warning WARNING: custom newos toolchain not found!)
99 $(warning This build will probably fail miserably)
100 $(warning Download the appropriate toolchain for your build environment)
101 $(warning at http://newos.sourceforge.net/download.php)
106 OBJCOPY = $(HOST_OBJCOPY)
107 OBJDUMP = $(HOST_OBJDUMP)
108 STRIP = $(HOST_STRIP)
112 # set up some particular options for various architectures
114 GLOBAL_CFLAGS = -O2 -g
115 KERNEL_CFLAGS = -fno-pic
120 ifeq ($(ARCH),x86_64)
121 GLOBAL_CFLAGS = -O2 -g
122 KERNEL_CFLAGS = -fpic
124 GLOBAL_LDFLAGS = -g -m elf_x86_64
128 GLOBAL_CFLAGS = -fno-pic -O -D__PPC__ -mregnames
138 GLOBAL_CFLAGS = -O2 -g
139 KERNEL_CFLAGS = -fno-pic
145 GLOBAL_CFLAGS = -ml -m4-single-only -mhitachi -O1
146 KERNEL_CFLAGS = -fno-pic
151 ifeq ($(ARCH),sparc64)
162 GLOBAL_CFLAGS = -O0 -g -m68040
163 KERNEL_CFLAGS = -fno-pic
174 GLOBAL_CFLAGS = -fno-pic -mips4 -meb -G 0
178 # check to see if we should use distcc and/or ccache
179 ifneq ($(USE_DISTCC),)
180 $(warning using distcc)
184 ifneq ($(USE_CCACHE),)
185 $(warning using ccache)
189 # these options are on for all architectures
190 GLOBAL_CFLAGS += -finline -fno-builtin
191 GLOBAL_CFLAGS += -Wall -W -Wno-multichar -Wno-unused-parameter -Wmissing-prototypes
192 GLOBAL_CFLAGS += -DNEWOS=1
193 GLOBAL_CFLAGS += -DARCH_$(ARCH)=1 -D__ARCH__=$(ARCH) -U$(ARCH)
194 GLOBAL_CFLAGS += -DPLATFORM_$(PLATFORM)=1
196 GLOBAL_CPPFLAGS = $(GLOBAL_CFLAGS)
198 GLOBAL_ASFLAGS += -D__ASSEMBLY__
202 LIBGCC_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -print-libgcc-file-name))
204 LIBGCC_PATH := /usr/local/arm-newos/lib/gcc-lib/arm-newos/3.3.3
206 $(warning LIBGCC_PATH = $(LIBGCC_PATH))
208 LIBGCC_INCLUDE += -I$(LIBGCC_PATH)/include
213 $(warning ARCH = $(ARCH))
214 $(warning PLATFORM = $(PLATFORM))
215 $(warning TARGET = $(TARGET))
217 # figure out where the build dir will be
218 BUILD_DIR = build/$(TARGET)
219 $(warning build dir will be $(BUILD_DIR))
220 $(shell mkdir -p $(BUILD_DIR))