3 HOSTTYPE := $(shell uname -m)
6 OSTYPE := $(shell uname -s | awk -F_ '{print $$1}' | tr A-Z a-z)
8 ifeq ($(HOSTTYPE),i586)
11 ifeq ($(HOSTTYPE),i686)
17 ifeq ($(findstring Macintosh,$(HOSTTYPE)),Macintosh)
20 ifeq ($(HOSTTYPE),macintosh)
21 ifeq ($(MACHTYPE),powerpc)
38 HOST_OBJCOPY := objcopy
39 HOST_OBJDUMP := objdump
43 # setup some local commands
46 ifeq ($(OSTYPE),SunOS)
50 ifeq ($(findstring solaris,$(OSTYPE)),solaris)
59 OBJCOPY = $(HOST_OBJCOPY)
60 OBJDUMP = $(HOST_OBJDUMP)
65 ifneq ($(HOSTTYPE),i386)
70 OBJCOPY = i386-elf-objcopy
71 STRIP = i386-elf-strip
73 ifeq ($(OSTYPE),cygwin)
78 OBJCOPY = i386-elf-objcopy
79 STRIP = i386-elf-strip
82 KERNEL_CFLAGS = -fno-pic
93 OBJCOPY = sh-elf-objcopy
95 GLOBAL_CFLAGS = -ml -m4-single-only -mhitachi -O1
96 KERNEL_CFLAGS = -fno-pic
102 ifeq ($(ARCH),sparc64)
107 OBJCOPY = sparc64-elf-objcopy
108 STRIP = sparc64-elf-strip
111 TOOLCHAIN_ARCH = sparc64
115 ifneq ($(HOSTTYPE),sparc)
120 OBJCOPY = sparc-elf-objcopy
121 STRIP = sparc-elf-strip
125 TOOLCHAIN_ARCH = sparc
129 ifneq ($(HOSTTYPE),m68k)
134 OBJCOPY = m68k-elf-objcopy
135 STRIP = m68k-elf-strip
138 GLOBAL_CFLAGS = -O0 -g -m68040
139 KERNEL_CFLAGS = -fno-pic
142 TOOLCHAIN_ARCH = m68k
146 ifneq ($(HOSTTYPE),alpha)
151 OBJCOPY = alpha-elf-objcopy
155 TOOLCHAIN_ARCH = alpha
159 ifneq ($(HOSTTYPE),mips)
164 OBJCOPY = mips-elf-objcopy
166 GLOBAL_CFLAGS = -fno-pic -mips4 -meb -G 0
168 TOOLCHAIN_ARCH = mips
172 ifneq ($(HOSTTYPE),ppc)
177 OBJCOPY = ppc-elf-objcopy
178 STRIP = ppc-elf-strip
180 GLOBAL_CFLAGS = -fno-pic -O -D__PPC__ -mregnames
186 ifneq ($(HOSTTYPE),arm)
191 OBJCOPY = arm-elf-objcopy
192 STRIP = arm-elf-strip
194 GLOBAL_CFLAGS = -fno-pic -O2
199 # try to detect if the user has ARCH-newos-gcc installed
202 # the "| cat" below looks unnecesary, this is
203 # to avoid a bug in liberty in certain versions
205 FOO := $(shell $(TOOLCHAIN_ARCH)-newos-gcc --version | cat)
207 $(warning found newos toolchain!)
208 CC = $(TOOLCHAIN_ARCH)-newos-gcc
209 LD = $(TOOLCHAIN_ARCH)-newos-ld
210 AS = $(TOOLCHAIN_ARCH)-newos-as
211 AR = $(TOOLCHAIN_ARCH)-newos-ar
212 OBJCOPY = $(TOOLCHAIN_ARCH)-newos-objcopy
213 OBJDUMP = $(TOOLCHAIN_ARCH)-newos-objdump
214 STRIP = $(TOOLCHAIN_ARCH)-newos-strip
215 SIZE = $(TOOLCHAIN_ARCH)-newos-size
217 $(warning WARNING: custom newos toolchain not found!)
218 $(warning download the appropriate toolchain for your build environment)
219 $(warning at http://newos.sourceforge.net/download.php)
222 GLOBAL_CFLAGS += -finline -nostdinc -fno-builtin
223 GLOBAL_CFLAGS += -Wall -W -Wno-multichar -Wno-unused-parameter -Wmissing-prototypes
224 GLOBAL_CFLAGS += -DARCH_$(ARCH) -DNEWOS=1 -D__ARCH__=$(ARCH) -U$(ARCH)
225 GLOBAL_CPPFLAGS = $(GLOBAL_CFLAGS) -fno-rtti
229 LIBGCC_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -print-libgcc-file-name))
230 $(warning LIBGCC_PATH = $(LIBGCC_PATH))
231 GLOBAL_CFLAGS += -I$(LIBGCC_PATH)/include
234 $(warning ARCH = $(ARCH))
236 # figure out where the build dir will be
237 BUILD_DIR = build/$(ARCH)
238 $(warning build dir will be $(BUILD_DIR))
239 $(shell mkdir -p $(BUILD_DIR))