Get the ARM port building again.
[newos.git] / make.syscfg
blob9ef7f587d9a953004ec7bc9cb6ace8e5c618d94a
2 ifeq ($(HOSTTYPE),)
3         HOSTTYPE := $(shell uname -m)
4 endif
5 ifeq ($(OSTYPE),)
6         OSTYPE := $(shell uname -s | awk -F_ '{print $$1}' | tr A-Z a-z)
7 endif
8 ifeq ($(HOSTTYPE),i586)
9         HOSTTYPE = i386
10 endif
11 ifeq ($(HOSTTYPE),i686)
12         HOSTTYPE = i386
13 endif
14 ifeq ($(HOSTTYPE), )
15         HOSTTYPE = i386
16 endif
17 ifeq ($(findstring Macintosh,$(HOSTTYPE)),Macintosh)
18         HOSTTYPE := ppc
19 endif
20 ifeq ($(HOSTTYPE),macintosh)
21         ifeq ($(MACHTYPE),powerpc)
22                 HOSTTYPE := ppc
23         endif
24 endif
25 ifeq ($(ARCH), )
26 #ARCH = $(HOSTTYPE)
27 ARCH = i386
28 #ARCH = sparc
29 #ARCH = sh4
30 #ARCH = alpha
31 #ARCH = sparc64
32 endif
34 HOST_CC := gcc
35 HOST_LD := $(LD)
36 HOST_AS := $(AS)
37 HOST_AR := $(AR)
38 HOST_OBJCOPY := objcopy
39 HOST_OBJDUMP := objdump
40 HOST_STRIP := strip
41 HOST_SIZE := size
43 # setup some local commands
44 ECHO := echo
45 AWK := awk
46 ifeq ($(OSTYPE),SunOS)
47         ECHO := /usr/ucb/echo
48         AWK := gawk
49 endif
50 ifeq ($(findstring solaris,$(OSTYPE)),solaris)
51         ECHO := /usr/ucb/echo
52         AWK := gawk
53 endif
55 CC = $(HOST_CC)
56 LD = $(HOST_LD)
57 AS = $(HOST_AS)
58 AR = $(HOST_AR)
59 OBJCOPY = $(HOST_OBJCOPY)
60 OBJDUMP = $(HOST_OBJDUMP)
61 STRIP = $(HOST_STRIP)
62 SIZE = $(HOST_SIZE)
64 ifeq ($(ARCH),i386)
65         ifneq ($(HOSTTYPE),i386)
66                 CC = i386-elf-gcc
67                 LD = i386-elf-ld
68                 AS = i386-elf-as
69                 AR = i386-elf-ar
70                 OBJCOPY = i386-elf-objcopy
71                 STRIP = i386-elf-strip
72         endif
73         ifeq ($(OSTYPE),cygwin)
74                 CC = i386-elf-gcc
75                 LD = i386-elf-ld
76                 AS = i386-elf-as
77                 AR = i386-elf-ar
78                 OBJCOPY = i386-elf-objcopy
79                 STRIP = i386-elf-strip
80         endif
81         GLOBAL_CFLAGS = -O2 -g
82         KERNEL_CFLAGS = -fno-pic
83         USER_CFLAGS = -fpic
84         GLOBAL_LDFLAGS = -g
85         TOOLCHAIN_ARCH = i386
86 endif
88 ifeq ($(ARCH),x86_64)
89         CC = x86_64-elf-gcc
90         LD = x86_64-elf-ld
91         AS = x86_64-elf-as
92         AR = x86_64-elf-ar
93         OBJCOPY = x86_64-elf-objcopy
94         STRIP = x86_64-elf-strip
95         GLOBAL_CFLAGS = -O2 -g 
96         KERNEL_CFLAGS = -fpic
97         USER_CFLAGS = -fpic
98         GLOBAL_LDFLAGS = -g -m elf_x86_64
99         TOOLCHAIN_ARCH = x86_64
100 endif
102 ifeq ($(ARCH),sh4)
103         CC = sh-elf-gcc
104         LD = sh-elf-ld
105         AS = sh-elf-as
106         AR = sh-elf-ar
107         OBJCOPY = sh-elf-objcopy
108         STRIP = sh-elf-strip
109         GLOBAL_CFLAGS = -ml -m4-single-only -mhitachi -O1
110         KERNEL_CFLAGS = -fno-pic
111         USER_CFLAGS = -fpic
112         GLOBAL_LDFLAGS = -EL
113         TOOLCHAIN_ARCH = sh
114 endif
116 ifeq ($(ARCH),sparc64)
117         CC = sparc64-elf-gcc
118         LD = sparc64-elf-ld
119         AS = sparc64-elf-as
120         AR = sparc64-elf-ar
121         OBJCOPY = sparc64-elf-objcopy
122         STRIP = sparc64-elf-strip
123         GLOBAL_CFLAGS =
124         GLOBAL_LDFLAGS =
125         TOOLCHAIN_ARCH = sparc64
126 endif
128 ifeq ($(ARCH),sparc)
129         ifneq ($(HOSTTYPE),sparc)
130                 CC = sparc-elf-gcc
131                 LD = sparc-elf-ld
132                 AS = sparc-elf-as
133                 AR = sparc-elf-ar
134                 OBJCOPY = sparc-elf-objcopy
135                 STRIP = sparc-elf-strip
136         endif
137         GLOBAL_CFLAGS =
138         GLOBAL_LDFLAGS =
139         TOOLCHAIN_ARCH = sparc
140 endif
142 ifeq ($(ARCH),m68k)
143         ifneq ($(HOSTTYPE),m68k)
144                 CC = m68k-elf-gcc
145                 LD = m68k-elf-ld
146                 AS = m68k-elf-as
147                 AR = m68k-elf-ar
148                 OBJCOPY = m68k-elf-objcopy
149                 STRIP = m68k-elf-strip
150                 SIZE = m68k-elf-size
151         endif
152         GLOBAL_CFLAGS = -O0 -g -m68040
153         KERNEL_CFLAGS = -fno-pic
154         USER_CFLAGS = -fpic
155         GLOBAL_LDFLAGS = -g
156         TOOLCHAIN_ARCH = m68k
157 endif
159 ifeq ($(ARCH),alpha)
160         ifneq ($(HOSTTYPE),alpha)
161                 CC = alpha-elf-gcc
162                 LD = alpha-elf-ld
163                 AS = alpha-elf-as
164                 AR = alpha-elf-ar
165                 OBJCOPY = alpha-elf-objcopy
166         endif
167         GLOBAL_CFLAGS =
168         GLOBAL_LDFLAGS =
169         TOOLCHAIN_ARCH = alpha
170 endif
172 ifeq ($(ARCH),mips)
173         ifneq ($(HOSTTYPE),mips)
174                 CC = mips-elf-gcc
175                 LD = mips-elf-ld
176                 AS = mips-elf-as
177                 AR = mips-elf-ar
178                 OBJCOPY = mips-elf-objcopy
179         endif
180         GLOBAL_CFLAGS = -fno-pic -mips4 -meb -G 0
181         GLOBAL_LDFLAGS =
182         TOOLCHAIN_ARCH = mips
183 endif
185 ifeq ($(ARCH),ppc)
186         ifneq ($(HOSTTYPE),ppc)
187                 CC = ppc-elf-gcc
188                 LD = ppc-elf-ld
189                 AS = ppc-elf-as
190                 AR = ppc-elf-ar
191                 OBJCOPY = ppc-elf-objcopy
192                 STRIP = ppc-elf-strip
193         endif
194         GLOBAL_CFLAGS = -fno-pic -O -D__PPC__ -mregnames
195         GLOBAL_LDFLAGS =
196         TOOLCHAIN_ARCH = ppc
197 endif
199 ifeq ($(ARCH),arm)
200         ifneq ($(HOSTTYPE),arm)
201                 CC = arm-elf-gcc
202                 LD = arm-elf-ld
203                 AS = arm-elf-as
204                 AR = arm-elf-ar
205                 OBJCOPY = arm-elf-objcopy
206                 STRIP = arm-elf-strip
207         endif
208         GLOBAL_CFLAGS = -O2 -g
209         KERNEL_CFLAGS = -fno-pic
210         USER_CFLAGS = -fpic
211         GLOBAL_LDFLAGS =
212         TOOLCHAIN_ARCH = arm
213 endif
215 # try to detect if the user has ARCH-newos-gcc installed
217 #  NOTE:
218 #       the "| cat" below looks unnecesary, this is
219 #       to avoid a bug in liberty in certain versions
220 #       of gmake for BeOS
221 FOO := $(shell $(TOOLCHAIN_ARCH)-newos-gcc --version | cat)
222 ifneq ($(FOO),)
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
232 else
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)
236 endif
238 ifneq ($(USE_DISTCC),)
239 $(warning using distcc)
240         CC := distcc $(CC)
241 endif
243 ifneq ($(USE_CCACHE),)
244 $(warning using ccache)
245         CC := ccache $(CC)
246 endif
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__
255 # find libgcc
256 LIBGCC := -lgcc
257 LIBGCC_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -print-libgcc-file-name))
258 ifeq ($(ARCH),arm)
259 LIBGCC_PATH := /usr/local/arm-newos/lib/gcc-lib/arm-newos/3.3.3
260 endif
261 $(warning LIBGCC_PATH = $(LIBGCC_PATH))
262 ifneq ($(ARCH),sh4)
263 LIBGCC_INCLUDE += -I$(LIBGCC_PATH)/include
264 endif
267 # print some info
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))