-
Notifications
You must be signed in to change notification settings - Fork 39
/
make.syscfg
250 lines (220 loc) · 5.39 KB
/
make.syscfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# figure out a few things about the host build system
ifeq ($(HOSTTYPE),)
HOSTTYPE := $(shell uname -m)
endif
ifeq ($(OSTYPE),)
OSTYPE := $(shell uname -s | awk -F_ '{print $$1}' | tr A-Z a-z)
endif
ifeq ($(HOSTTYPE),i586)
HOSTTYPE := i386
endif
ifeq ($(HOSTTYPE),i686)
HOSTTYPE := i386
endif
ifeq ($(HOSTTYPE), )
HOSTTYPE := i386
endif
ifeq ($(findstring Macintosh,$(HOSTTYPE)),Macintosh)
HOSTTYPE := ppc
endif
ifeq ($(HOSTTYPE),macintosh)
ifeq ($(MACHTYPE),powerpc)
HOSTTYPE := ppc
endif
endif
# default platform and arch
ifeq ($(PLATFORM),)
ifeq ($(ARCH),)
# by default, build for a i386-pc
ARCH := i386
PLATFORM := pc
endif
endif
# some platforms only support one arch
ifeq ($(PLATFORM),pegasos)
ARCH := ppc
endif
ifeq ($(PLATFORM),mac)
ARCH := ppc
endif
ifeq ($(PLATFORM),xbox)
ARCH := i386
endif
ifeq ($(PLATFORM),dreamcast)
ARCH := sh4
endif
# some arches only support one platform
ifeq ($(ARCH),x86_64)
PLATFORM := pc
endif
ifeq ($(ARCH),sh4)
PLATFORM := dreamcast
endif
# build the TARGET variable
TARGET := $(ARCH)-$(PLATFORM)
# HOST_* is for local targets (tools)
HOST_CC := gcc
HOST_LD := $(LD)
HOST_AS := $(AS)
HOST_AR := $(AR)
HOST_OBJCOPY := objcopy
HOST_OBJDUMP := objdump
HOST_STRIP := strip
HOST_SIZE := size
# setup some local commands
ECHO := echo
AWK := awk
ifeq ($(OSTYPE),SunOS)
ECHO := /usr/ucb/echo
AWK := gawk
endif
ifeq ($(findstring solaris,$(OSTYPE)),solaris)
ECHO := /usr/ucb/echo
AWK := gawk
endif
# TOOLCHAIN_ARCH is usually ARCH, except in a few cases
TOOLCHAIN_ARCH := $(ARCH)
ifeq ($(ARCH),sh4)
TOOLCHAIN_ARCH := sh
endif
# try to detect if the user has ARCH-newos-gcc installed
#
# NOTE:
# the "| cat" below looks unnecesary, this is
# to avoid a bug in liberty in certain versions
# of gmake for BeOS
CC :=
FOO := $(shell $(TOOLCHAIN_ARCH)-newos-gcc --version | cat)
ifneq ($(FOO),)
$(warning found newos toolchain!)
CC = $(TOOLCHAIN_ARCH)-newos-gcc
LD = $(TOOLCHAIN_ARCH)-newos-ld
AS = $(TOOLCHAIN_ARCH)-newos-as
AR = $(TOOLCHAIN_ARCH)-newos-ar
OBJCOPY = $(TOOLCHAIN_ARCH)-newos-objcopy
OBJDUMP = $(TOOLCHAIN_ARCH)-newos-objdump
STRIP = $(TOOLCHAIN_ARCH)-newos-strip
SIZE = $(TOOLCHAIN_ARCH)-newos-size
else
FOO := $(shell $(TOOLCHAIN_ARCH)-elf-gcc --version | cat)
ifneq ($(FOO),)
$(warning WARNING: custom newos toolchain not found!)
$(warning falling back to elf toolchain)
CC = $(TOOLCHAIN_ARCH)-elf-gcc
LD = $(TOOLCHAIN_ARCH)-elf-ld
AS = $(TOOLCHAIN_ARCH)-elf-as
AR = $(TOOLCHAIN_ARCH)-elf-ar
OBJCOPY = $(TOOLCHAIN_ARCH)-elf-objcopy
OBJDUMP = $(TOOLCHAIN_ARCH)-elf-objdump
STRIP = $(TOOLCHAIN_ARCH)-elf-strip
SIZE = $(TOOLCHAIN_ARCH)-elf-size
endif
endif
ifeq ($(CC),)
$(warning WARNING: custom newos toolchain not found!)
$(warning This build will probably fail miserably)
$(warning Download the appropriate toolchain for your build environment)
$(warning at http://newos.sourceforge.net/download.php)
CC = $(HOST_CC)
LD = $(HOST_LD)
AS = $(HOST_AS)
AR = $(HOST_AR)
OBJCOPY = $(HOST_OBJCOPY)
OBJDUMP = $(HOST_OBJDUMP)
STRIP = $(HOST_STRIP)
SIZE = $(HOST_SIZE)
endif
# set up some particular options for various architectures
ifeq ($(ARCH),i386)
GLOBAL_CFLAGS = -O2 -g
KERNEL_CFLAGS = -fno-pic
USER_CFLAGS = -fpic
GLOBAL_LDFLAGS = -g
endif
ifeq ($(ARCH),x86_64)
GLOBAL_CFLAGS = -O2 -g
KERNEL_CFLAGS = -fno-pic -mcmodel=kernel
USER_CFLAGS = -fpic
GLOBAL_LDFLAGS = -g -m elf_x86_64
endif
ifeq ($(ARCH),ppc)
GLOBAL_CFLAGS = -fno-pic -O -D__PPC__ -mregnames
GLOBAL_LDFLAGS =
endif
ifeq ($(ARCH),ppc64)
GLOBAL_CFLAGS =
GLOBAL_LDFLAGS =
endif
ifeq ($(ARCH),arm)
GLOBAL_CFLAGS = -O2 -g
KERNEL_CFLAGS = -fno-pic
USER_CFLAGS = -fpic
GLOBAL_LDFLAGS =
endif
ifeq ($(ARCH),sh4)
GLOBAL_CFLAGS = -ml -m4-single-only -mhitachi -O2 -g -D__SH4__
KERNEL_CFLAGS = -fno-pic
USER_CFLAGS = -fpic
GLOBAL_LDFLAGS = -EL
endif
ifeq ($(ARCH),sparc64)
GLOBAL_CFLAGS =
GLOBAL_LDFLAGS =
endif
ifeq ($(ARCH),sparc)
GLOBAL_CFLAGS =
GLOBAL_LDFLAGS =
endif
ifeq ($(ARCH),m68k)
GLOBAL_CFLAGS = -O0 -g -m68040
KERNEL_CFLAGS = -fno-pic
USER_CFLAGS = -fpic
GLOBAL_LDFLAGS = -g
endif
ifeq ($(ARCH),alpha)
GLOBAL_CFLAGS =
GLOBAL_LDFLAGS =
endif
ifeq ($(ARCH),mips)
GLOBAL_CFLAGS = -fno-pic -mips4 -meb -G 0
GLOBAL_LDFLAGS =
endif
# check to see if we should use distcc and/or ccache
ifneq ($(USE_DISTCC),)
$(warning using distcc)
CC := distcc $(CC)
endif
ifneq ($(USE_CCACHE),)
$(warning using ccache)
CC := ccache $(CC)
endif
# these options are on for all architectures
GLOBAL_CFLAGS += -finline -fno-builtin
GLOBAL_CFLAGS += -Wall -W -Wno-multichar -Wno-unused-parameter -Wmissing-prototypes
GLOBAL_CFLAGS += -DNEWOS=1
GLOBAL_CFLAGS += -DARCH_$(ARCH)=1 -D__ARCH__=$(ARCH) -U$(ARCH)
GLOBAL_CFLAGS += -DPLATFORM_$(PLATFORM)=1
GLOBAL_CPPFLAGS = $(GLOBAL_CFLAGS)
GLOBAL_ASFLAGS += -D__ASSEMBLY__
# find libgcc
LIBGCC := -lgcc
LIBGCC_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -print-libgcc-file-name))
ifeq ($(ARCH),arm)
LIBGCC_PATH := /usr/local/arm-newos/lib/gcc-lib/arm-newos/3.3.3
endif
$(warning LIBGCC_PATH = $(LIBGCC_PATH))
ifneq ($(ARCH),sh4)
LIBGCC_INCLUDE += -I$(LIBGCC_PATH)/include
endif
ifeq ($(ARCH),x86_64)
LIBGCC32_PATH := $(dir $(shell $(CC) $(GLOBAL_CFLAGS) -m32 -print-libgcc-file-name))
$(warning LIBGCC32_PATH = $(LIBGCC32_PATH))
endif
# print some info
$(warning ARCH = $(ARCH))
$(warning PLATFORM = $(PLATFORM))
$(warning TARGET = $(TARGET))
# figure out where the build dir will be
BUILD_DIR = build/$(TARGET)
$(warning build dir will be $(BUILD_DIR))
$(shell mkdir -p $(BUILD_DIR))