Get the sh4 (Dreamcast) port to compile and build again.
[newos.git] / make.syscfg
blob011036d84d4c7fe9b333432a23a730338f7655c3
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 ($(HOSTTYPE),macintosh)
18         ifeq ($(MACHTYPE),powerpc)
19                 HOSTTYPE := ppc
20         endif
21 endif
22 ifeq ($(ARCH), )
23 #ARCH = $(HOSTTYPE)
24 ARCH = i386
25 #ARCH = sparc
26 #ARCH = sh4
27 #ARCH = alpha
28 #ARCH = sparc64
29 endif
31 HOST_CC := gcc
32 HOST_LD := $(LD)
33 HOST_AS := $(AS)
34 HOST_AR := $(AR)
35 HOST_OBJCOPY := objcopy
36 HOST_STRIP := strip
37 HOST_SIZE := size
39 # setup some local commands
40 ECHO := echo
41 AWK := awk
42 ifeq ($(OSTYPE),SunOS)
43         ECHO := /usr/ucb/echo
44         AWK := gawk
45 endif
46 ifeq ($(findstring solaris,$(OSTYPE)),solaris)
47         ECHO := /usr/ucb/echo
48         AWK := gawk
49 endif
51 CC = $(HOST_CC)
52 LD = $(HOST_LD)
53 AS = $(HOST_AS)
54 AR = $(HOST_AR)
55 OBJCOPY = $(HOST_OBJCOPY)
56 STRIP = $(HOST_STRIP)
57 SIZE = $(HOST_SIZE)
59 ifeq ($(ARCH),i386)
60         ifneq ($(HOSTTYPE),i386)
61                 CC = i386-elf-gcc
62                 LD = i386-elf-ld
63                 AS = i386-elf-as
64                 AR = i386-elf-ar
65                 OBJCOPY = i386-elf-objcopy
66                 STRIP = i386-elf-strip
67         endif
68         ifeq ($(OSTYPE),cygwin)
69                 CC = i386-elf-gcc
70                 LD = i386-elf-ld
71                 AS = i386-elf-as
72                 AR = i386-elf-ar
73                 OBJCOPY = i386-elf-objcopy
74                 STRIP = i386-elf-strip
75         endif
76         GLOBAL_CFLAGS = -O2
77         KERNEL_CFLAGS = -fno-pic
78         USER_CFLAGS = -fpic
79         GLOBAL_LDFLAGS =
80         TOOLCHAIN_ARCH = i386
81 endif
83 ifeq ($(ARCH),sh4)
84         CC = sh-elf-gcc
85         LD = sh-elf-ld
86         AS = sh-elf-as
87         AR = sh-elf-ar
88         OBJCOPY = sh-elf-objcopy
89         STRIP = sh-elf-strip
90         GLOBAL_CFLAGS = -ml -m4-single-only -mhitachi -O1
91         KERNEL_CFLAGS = -fno-pic
92         USER_CFLAGS = -fpic
93         GLOBAL_LDFLAGS = -EL
94         TOOLCHAIN_ARCH = sh
95 endif
97 ifeq ($(ARCH),sparc64)
98         CC = sparc64-elf-gcc
99         LD = sparc64-elf-ld
100         AS = sparc64-elf-as
101         AR = sparc64-elf-ar
102         OBJCOPY = sparc64-elf-objcopy
103         STRIP = sparc64-elf-strip
104         GLOBAL_CFLAGS =
105         GLOBAL_LDFLAGS =
106         TOOLCHAIN_ARCH = sparc64
107 endif
109 ifeq ($(ARCH),sparc)
110         ifneq ($(HOSTTYPE),sparc)
111                 CC = sparc-elf-gcc
112                 LD = sparc-elf-ld
113                 AS = sparc-elf-as
114                 AR = sparc-elf-ar
115                 OBJCOPY = sparc-elf-objcopy
116                 STRIP = sparc-elf-strip
117         endif
118         GLOBAL_CFLAGS =
119         GLOBAL_LDFLAGS =
120         TOOLCHAIN_ARCH = sparc
121 endif
123 ifeq ($(ARCH),m68k)
124         ifneq ($(HOSTTYPE),m68k)
125                 CC = m68k-elf-gcc
126                 LD = m68k-elf-ld
127                 AS = m68k-elf-as
128                 AR = m68k-elf-ar
129                 OBJCOPY = m68k-elf-objcopy
130                 STRIP = m68k-elf-strip
131                 SIZE = m68k-elf-size
132         endif
133         GLOBAL_CFLAGS = -O0 -g
134         KERNEL_CFLAGS = -fno-pic
135         USER_CFLAGS = -fpic
136         GLOBAL_LDFLAGS = -g
137         TOOLCHAIN_ARCH = m68k
138 endif
140 ifeq ($(ARCH),alpha)
141         ifneq ($(HOSTTYPE),alpha)
142                 CC = alpha-elf-gcc
143                 LD = alpha-elf-ld
144                 AS = alpha-elf-as
145                 AR = alpha-elf-ar
146                 OBJCOPY = alpha-elf-objcopy
147         endif
148         GLOBAL_CFLAGS =
149         GLOBAL_LDFLAGS =
150         TOOLCHAIN_ARCH = alpha
151 endif
153 ifeq ($(ARCH),mips)
154         ifneq ($(HOSTTYPE),mips)
155                 CC = mips-elf-gcc
156                 LD = mips-elf-ld
157                 AS = mips-elf-as
158                 AR = mips-elf-ar
159                 OBJCOPY = mips-elf-objcopy
160         endif
161         GLOBAL_CFLAGS = -fno-pic -mips4 -meb -G 0
162         GLOBAL_LDFLAGS =
163         TOOLCHAIN_ARCH = mips
164 endif
166 ifeq ($(ARCH),ppc)
167         ifneq ($(HOSTTYPE),ppc)
168                 CC = ppc-elf-gcc
169                 LD = ppc-elf-ld
170                 AS = ppc-elf-as
171                 AR = ppc-elf-ar
172                 OBJCOPY = ppc-elf-objcopy
173                 STRIP = ppc-elf-strip
174         endif
175         GLOBAL_CFLAGS = -fno-pic -O -D__PPC__
176         GLOBAL_LDFLAGS =
177         TOOLCHAIN_ARCH = ppc
178 endif
180 # try to detect if the user has ARCH-newos-gcc installed
182 #  NOTE:
183 #       the "| cat" below looks unnecesary, this is
184 #       to avoid a bug in liberty in certain versions
185 #       of gmake for BeOS
186 FOO := $(shell $(TOOLCHAIN_ARCH)-newos-gcc --version | cat)
187 ifneq ($(FOO),)
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
196 endif
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
201 # find libgcc
202 LIBGCC := -lgcc
203 LIBGCC_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -print-libgcc-file-name))
204 $(warning LIBGCC_PATH = $(LIBGCC_PATH))
206 # print some info
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))