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
81 GLOBAL_CFLAGS = -O2 -g
82 KERNEL_CFLAGS = -fno-pic
93 OBJCOPY = x86_64-elf-objcopy
94 STRIP = x86_64-elf-strip
95 GLOBAL_CFLAGS = -O2 -g
98 GLOBAL_LDFLAGS = -g -m elf_x86_64
99 TOOLCHAIN_ARCH = x86_64
107 OBJCOPY = sh-elf-objcopy
109 GLOBAL_CFLAGS = -ml -m4-single-only -mhitachi -O1
110 KERNEL_CFLAGS = -fno-pic
116 ifeq ($(ARCH),sparc64)
121 OBJCOPY = sparc64-elf-objcopy
122 STRIP = sparc64-elf-strip
125 TOOLCHAIN_ARCH = sparc64
129 ifneq ($(HOSTTYPE),sparc)
134 OBJCOPY = sparc-elf-objcopy
135 STRIP = sparc-elf-strip
139 TOOLCHAIN_ARCH = sparc
143 ifneq ($(HOSTTYPE),m68k)
148 OBJCOPY = m68k-elf-objcopy
149 STRIP = m68k-elf-strip
152 GLOBAL_CFLAGS = -O0 -g -m68040
153 KERNEL_CFLAGS = -fno-pic
156 TOOLCHAIN_ARCH = m68k
160 ifneq ($(HOSTTYPE),alpha)
165 OBJCOPY = alpha-elf-objcopy
169 TOOLCHAIN_ARCH = alpha
173 ifneq ($(HOSTTYPE),mips)
178 OBJCOPY = mips-elf-objcopy
180 GLOBAL_CFLAGS = -fno-pic -mips4 -meb -G 0
182 TOOLCHAIN_ARCH = mips
186 ifneq ($(HOSTTYPE),ppc)
191 OBJCOPY = ppc-elf-objcopy
192 STRIP = ppc-elf-strip
194 GLOBAL_CFLAGS = -fno-pic -O -D__PPC__ -mregnames
200 ifneq ($(HOSTTYPE),arm)
205 OBJCOPY = arm-elf-objcopy
206 STRIP = arm-elf-strip
208 GLOBAL_CFLAGS = -O2 -g
209 KERNEL_CFLAGS = -fno-pic
215 # try to detect if the user has ARCH-newos-gcc installed
218 # the "| cat" below looks unnecesary, this is
219 # to avoid a bug in liberty in certain versions
221 FOO := $(shell $(TOOLCHAIN_ARCH)-newos-gcc --version | cat)
223 $(warning found newos toolchain!)
224 CC = $(TOOLCHAIN_ARCH)-newos-gcc
225 LD = $(TOOLCHAIN_ARCH)-newos-ld
226 AS = $(TOOLCHAIN_ARCH)-newos-as
227 AR = $(TOOLCHAIN_ARCH)-newos-ar
228 OBJCOPY = $(TOOLCHAIN_ARCH)-newos-objcopy
229 OBJDUMP = $(TOOLCHAIN_ARCH)-newos-objdump
230 STRIP = $(TOOLCHAIN_ARCH)-newos-strip
231 SIZE = $(TOOLCHAIN_ARCH)-newos-size
233 $(warning WARNING: custom newos toolchain not found!)
234 $(warning download the appropriate toolchain for your build environment)
235 $(warning at http://newos.sourceforge.net/download.php)
238 ifneq ($(USE_DISTCC),)
239 $(warning using distcc)
243 ifneq ($(USE_CCACHE),)
244 $(warning using ccache)
248 GLOBAL_CFLAGS += -finline -nostdinc -fno-builtin
249 GLOBAL_CFLAGS += -Wall -W -Wno-multichar -Wno-unused-parameter -Wmissing-prototypes
250 GLOBAL_CFLAGS += -DARCH_$(ARCH) -DNEWOS=1 -D__ARCH__=$(ARCH) -U$(ARCH)
251 GLOBAL_CPPFLAGS = $(GLOBAL_CFLAGS)
253 GLOBAL_ASFLAGS += -D__ASSEMBLY__
257 LIBGCC_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -print-libgcc-file-name))
259 LIBGCC_PATH := /usr/local/arm-newos/lib/gcc-lib/arm-newos/3.3.3
261 $(warning LIBGCC_PATH = $(LIBGCC_PATH))
263 LIBGCC_INCLUDE += -I$(LIBGCC_PATH)/include
268 $(warning ARCH = $(ARCH))
270 # figure out where the build dir will be
271 BUILD_DIR = build/$(ARCH)
272 $(warning build dir will be $(BUILD_DIR))
273 $(shell mkdir -p $(BUILD_DIR))