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 ($(HOSTTYPE),macintosh)
18 ifeq ($(MACHTYPE),powerpc)
35 HOST_OBJCOPY := objcopy
39 # setup some local commands
42 ifeq ($(OSTYPE),SunOS)
46 ifeq ($(findstring solaris,$(OSTYPE)),solaris)
55 OBJCOPY = $(HOST_OBJCOPY)
60 ifneq ($(HOSTTYPE),i386)
65 OBJCOPY = i386-elf-objcopy
66 STRIP = i386-elf-strip
68 ifeq ($(OSTYPE),cygwin)
73 OBJCOPY = i386-elf-objcopy
74 STRIP = i386-elf-strip
77 KERNEL_CFLAGS = -fno-pic
88 OBJCOPY = sh-elf-objcopy
90 GLOBAL_CFLAGS = -ml -m4-single-only -mhitachi -O1
91 KERNEL_CFLAGS = -fno-pic
97 ifeq ($(ARCH),sparc64)
102 OBJCOPY = sparc64-elf-objcopy
103 STRIP = sparc64-elf-strip
106 TOOLCHAIN_ARCH = sparc64
110 ifneq ($(HOSTTYPE),sparc)
115 OBJCOPY = sparc-elf-objcopy
116 STRIP = sparc-elf-strip
120 TOOLCHAIN_ARCH = sparc
124 ifneq ($(HOSTTYPE),m68k)
129 OBJCOPY = m68k-elf-objcopy
130 STRIP = m68k-elf-strip
133 GLOBAL_CFLAGS = -O0 -g
134 KERNEL_CFLAGS = -fno-pic
137 TOOLCHAIN_ARCH = m68k
141 ifneq ($(HOSTTYPE),alpha)
146 OBJCOPY = alpha-elf-objcopy
150 TOOLCHAIN_ARCH = alpha
154 ifneq ($(HOSTTYPE),mips)
159 OBJCOPY = mips-elf-objcopy
161 GLOBAL_CFLAGS = -fno-pic -mips4 -meb -G 0
163 TOOLCHAIN_ARCH = mips
167 ifneq ($(HOSTTYPE),ppc)
172 OBJCOPY = ppc-elf-objcopy
173 STRIP = ppc-elf-strip
175 GLOBAL_CFLAGS = -fno-pic -O -D__PPC__
180 # try to detect if the user has ARCH-newos-gcc installed
183 # the "| cat" below looks unnecesary, this is
184 # to avoid a bug in liberty in certain versions
186 FOO := $(shell $(TOOLCHAIN_ARCH)-newos-gcc --version | cat)
188 $(warning found newos toolchain!)
189 CC = $(TOOLCHAIN_ARCH)-newos-gcc
190 LD = $(TOOLCHAIN_ARCH)-newos-ld
191 AS = $(TOOLCHAIN_ARCH)-newos-as
192 AR = $(TOOLCHAIN_ARCH)-newos-ar
193 OBJCOPY = $(TOOLCHAIN_ARCH)-newos-objcopy
194 STRIP = $(TOOLCHAIN_ARCH)-newos-strip
195 SIZE = $(TOOLCHAIN_ARCH)-newos-size
198 GLOBAL_CFLAGS += -Wall -W -Wno-multichar -Wno-unused -Wmissing-prototypes -finline -nostdinc -fno-builtin -DARCH_$(ARCH) -DNEWOS=1
199 GLOBAL_CPPFLAGS = $(GLOBAL_CFLAGS) -fno-rtti
203 LIBGCC_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -print-libgcc-file-name))
204 $(warning LIBGCC_PATH = $(LIBGCC_PATH))
207 $(warning ARCH = $(ARCH))
209 # figure out where the build dir will be
210 BUILD_DIR = build/$(ARCH)
211 $(warning build dir will be $(BUILD_DIR))
212 $(shell mkdir -p $(BUILD_DIR))