-
Notifications
You must be signed in to change notification settings - Fork 51
/
Makefile.in
315 lines (283 loc) · 10.1 KB
/
Makefile.in
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
srcdir := @abs_top_srcdir@
builddir := @abs_top_builddir@
INSTALL_DIR := @prefix@
PACKAGES :=
DISTDIR ?= /var/cache/distfiles
GNU_MIRROR := http://mirrors.kernel.org/gnu
gcc_url := $(GNU_MIRROR)/gcc/gcc-$(gcc_version)/gcc-$(gcc_version).tar.gz
glibc_url := $(GNU_MIRROR)/glibc/glibc-$(glibc_version).tar.gz
newlib_url := ftp://sourceware.org/pub/newlib/newlib-$(newlib_version).tar.gz
WITH_ARCH ?= @WITH_ARCH@
WITH_ABI ?= @WITH_ABI@
SYSROOT := $(INSTALL_DIR)/sysroot
SHELL := /bin/sh
AWK := @GAWK@
SED := @GSED@
PATH := $(INSTALL_DIR)/bin:$(PATH)
# Check to see if we need wrapper scripts for awk/sed (which point to
# gawk/gsed on platforms where these aren't the default), otherwise
# don't override these as the wrappers don't always work.
ifneq (@GSED@,/bin/sed)
PATH := $(base_dir)/sed:$(PATH)
endif
ifneq (@GAWK@,/usr/bin/gawk)
PATH := $(base_dir)/awk:$(PATH)
endif
export PATH AWK SED
MULTILIB_FLAGS := @multilib_flags@
MULTILIB_NAMES := @multilib_names@
GCC_CHECKING_FLAGS := @gcc_checking@
XLEN := $(shell echo $(WITH_ARCH) | tr A-Z a-z | sed 's/.*rv\([0-9]*\).*/\1/')
ifneq ($(XLEN),32)
XLEN := 64
endif
ifeq ($(MULTILIB_NAMES),)
MULTILIB_NAMES := $(XLEN)
endif
make_tuple = riscv$(1)-unknown-$(2)
LINUX_TUPLE := $(call make_tuple,$(XLEN),linux-gnu)
NEWLIB_TUPLE := $(call make_tuple,$(XLEN),elf)
CFLAGS_FOR_TARGET := $(CFLAGS_FOR_TARGET_EXTRA) @cmodel@
ASFLAGS_FOR_TARGET := $(ASFLAGS_FOR_TARGET_EXTRA) @cmodel@
GLIBC_TARGET_FLAGS := $(GLIBC_TARGET_FLAGS_EXTRA)
GLIBC_CC_FOR_TARGET ?= $(LINUX_TUPLE)-gcc
GLIBC_CXX_FOR_TARGET ?= $(LINUX_TUPLE)-g++
NEWLIB_CC_FOR_TARGET ?= $(NEWLIB_TUPLE)-gcc
NEWLIB_CXX_FOR_TARGET ?= $(NEWLIB_TUPLE)-g++
CONFIGURE_HOST = @configure_host@
all: @default_target@
newlib: stamps/build-gcc-newlib-stage2
linux: stamps/build-gcc-linux-stage2
$(addprefix src/original-,$(PACKAGES)):
mkdir -p src
rm -rf $@ $(subst original-,,$@)-*
cd src && (cat $(DISTDIR)/$(subst src/original-,,$@)-$($(subst src/original-,,$@)_version).tar.gz || @FETCHER@ $($(subst src/original-,,$@)_url)) | tar zxf -
mv $(subst original-,,$@)-$($(subst src/original-,,$@)_version) $@
$(addprefix src/,$(PACKAGES)): src/%: src/original-%
rm -rf $@ [email protected]
cp -a $< [email protected]
$(srcdir)/scripts/cp_s $(srcdir)/$(notdir $@) [email protected]
cd [email protected] && patch -p1 < $(srcdir)/patches/$(notdir $@)
if test -f [email protected]/contrib/download_prerequisites && test "@NEED_GCC_EXTERNAL_LIBRARIES@" == "true"; then cd [email protected] && ./contrib/download_prerequisites; fi
mv [email protected] $@
.PHONY: patches $(addprefix $(srcdir)/patches/,$(PACKAGES))
$(addprefix $(srcdir)/patches/,$(PACKAGES)): $(srcdir)/patches/%: src/%
-cd src/$(notdir $@) && rm `cd $(srcdir)/$(notdir $@) && find . -type f`
-cd src && diff --exclude=manual --exclude=autom4te.cache -rupN original-$(notdir $@) $(notdir $@) | filterdiff --remove-timestamps > $@
$(srcdir)/scripts/cp_s $(srcdir)/$(notdir $@) $<
patches: $(addprefix $(srcdir)/patches/,$(PACKAGES))
stamps/build-binutils-linux: $(srcdir)/riscv-binutils-gdb
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=$(LINUX_TUPLE) \
$(CONFIGURE_HOST) \
--prefix=$(INSTALL_DIR) \
--with-sysroot=$(SYSROOT) \
$(MULTILIB_FLAGS) \
@with_guile@ \
--disable-werror \
--disable-nls
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@
stamps/build-linux-headers:
mkdir -p $(SYSROOT)/usr/
cp -a $(srcdir)/linux-headers/include $(SYSROOT)/usr/
mkdir -p $(dir $@) && touch $@
stamps/build-glibc-linux-headers: $(srcdir)/riscv-glibc stamps/build-gcc-linux-stage1
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && CC="$(GLIBC_CC_FOR_TARGET)" $</configure \
--host=$(LINUX_TUPLE) \
--prefix=$(SYSROOT)/usr \
--enable-shared \
--with-headers=$(srcdir)/linux-headers/include \
--disable-multilib \
--enable-kernel=3.0.0
$(MAKE) -C $(notdir $@) install-headers
mkdir -p $(dir $@) && touch $@
stamps/build-glibc-linux-%: $(srcdir)/riscv-glibc stamps/build-gcc-linux-stage1
$(eval $@_ARCH := $(word 4,$(subst -, ,$@)))
$(eval $@_ABI := $(word 5,$(subst -, ,$@)))
$(eval $@_LIBDIRSUFFIX := $(if $($@_ABI),$(shell echo $($@_ARCH) | sed 's/.*rv\([0-9]*\).*/\1/')/$($@_ABI),))
$(eval $@_XLEN := $(if $($@_ABI),$(shell echo $($@_ARCH) | sed 's/.*rv\([0-9]*\).*/\1/'),$(XLEN)))
$(eval $@_CFLAGS := $(if $($@_ABI),-march=$($@_ARCH) -mabi=$($@_ABI),))
$(eval $@_LIBDIROPTS := $(if $@_LIBDIRSUFFIX,--libdir=/usr/lib$($@_LIBDIRSUFFIX) libc_cv_slibdir=/lib$($@_LIBDIRSUFFIX) libc_cv_rtlddir=/lib,))
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && \
CC="$(GLIBC_CC_FOR_TARGET) $($@_CFLAGS)" \
CFLAGS="$(CFLAGS_FOR_TARGET) -g -O2 $($@_CFLAGS)" \
ASFLAGS="$(ASFLAGS_FOR_TARGET) $($@_CFLAGS)" \
$</configure \
--host=$(call make_tuple,$($@_XLEN),linux-gnu) \
--prefix=/usr \
--disable-werror \
--enable-shared \
--with-headers=$(srcdir)/linux-headers/include \
$(MULTILIB_FLAGS) \
--enable-kernel=3.0.0 \
$(GLIBC_TARGET_FLAGS) \
$($@_LIBDIROPTS)
$(MAKE) -C $(notdir $@)
+flock $(SYSROOT)/.lock $(MAKE) -C $(notdir $@) install install_root=$(SYSROOT)
mkdir -p $(dir $@) && touch $@
stamps/build-gcc-linux-stage1: $(srcdir)/riscv-gcc stamps/build-binutils-linux \
stamps/build-linux-headers
if test -f $</contrib/download_prerequisites && test "@NEED_GCC_EXTERNAL_LIBRARIES@" == "true"; then cd $< && ./contrib/download_prerequisites; fi
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=$(LINUX_TUPLE) \
$(CONFIGURE_HOST) \
--prefix=$(INSTALL_DIR) \
--with-sysroot=$(SYSROOT) \
--with-newlib \
--without-headers \
--disable-shared \
--disable-threads \
@with_system_zlib@ \
--enable-tls \
--enable-languages=c \
--disable-libatomic \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-libgomp \
--disable-nls \
--disable-bootstrap \
$(GCC_CHECKING_FLAGS) \
$(MULTILIB_FLAGS) \
$(WITH_ABI) \
$(WITH_ARCH)
$(MAKE) -C $(notdir $@) inhibit-libc=true all-gcc
$(MAKE) -C $(notdir $@) inhibit-libc=true install-gcc
$(MAKE) -C $(notdir $@) inhibit-libc=true all-target-libgcc
$(MAKE) -C $(notdir $@) inhibit-libc=true install-target-libgcc
mkdir -p $(dir $@) && touch $@
stamps/build-gcc-linux-stage2: $(srcdir)/riscv-gcc $(addprefix stamps/build-glibc-linux-,$(MULTILIB_NAMES)) \
stamps/build-glibc-linux-headers
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=$(LINUX_TUPLE) \
$(CONFIGURE_HOST) \
--prefix=$(INSTALL_DIR) \
--with-sysroot=$(SYSROOT) \
@with_system_zlib@ \
--enable-shared \
--enable-tls \
--enable-languages=c,c++,fortran \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-nls \
--disable-bootstrap \
$(GCC_CHECKING_FLAGS) \
$(MULTILIB_FLAGS) \
$(WITH_ABI) \
$(WITH_ARCH)
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
cp -a $(INSTALL_DIR)/$(LINUX_TUPLE)/lib* $(SYSROOT)
mkdir -p $(dir $@) && touch $@
stamps/build-binutils-newlib: $(srcdir)/riscv-binutils-gdb
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=$(NEWLIB_TUPLE) \
$(CONFIGURE_HOST) \
--prefix=$(INSTALL_DIR) \
@with_guile@ \
--disable-werror
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@
stamps/build-gcc-newlib-stage1: $(srcdir)/riscv-gcc stamps/build-binutils-newlib
if test -f $</contrib/download_prerequisites && test "@NEED_GCC_EXTERNAL_LIBRARIES@" == "true"; then cd $< && ./contrib/download_prerequisites; fi
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=$(NEWLIB_TUPLE) \
$(CONFIGURE_HOST) \
--prefix=$(INSTALL_DIR) \
--disable-shared \
--disable-threads \
--disable-tls \
--enable-languages=c,c++ \
@with_system_zlib@ \
--with-newlib \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-libgomp \
--disable-nls \
$(GCC_CHECKING_FLAGS) \
$(MULTILIB_FLAGS) \
$(WITH_ABI) \
$(WITH_ARCH) \
CFLAGS_FOR_TARGET="-Os $(CFLAGS_FOR_TARGET)"
$(MAKE) -C $(notdir $@) all-gcc
$(MAKE) -C $(notdir $@) install-gcc
mkdir -p $(dir $@) && touch $@
stamps/build-newlib: $(srcdir)/riscv-newlib stamps/build-gcc-newlib-stage1
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=$(NEWLIB_TUPLE) \
$(CONFIGURE_HOST) \
--prefix=$(INSTALL_DIR) \
--enable-newlib-io-long-double \
--enable-newlib-io-long-long \
--enable-newlib-io-c99-formats \
CFLAGS_FOR_TARGET="-Os $(CFLAGS_FOR_TARGET)"
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@
stamps/build-gcc-newlib-stage2: $(srcdir)/riscv-gcc stamps/build-newlib
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=$(NEWLIB_TUPLE) \
$(CONFIGURE_HOST) \
--prefix=$(INSTALL_DIR) \
--disable-shared \
--disable-threads \
--enable-languages=c,c++ \
@with_system_zlib@ \
--enable-tls \
--with-newlib \
--with-headers=$(INSTALL_DIR)/$(NEWLIB_TUPLE)/include \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-libgomp \
--disable-nls \
$(GCC_CHECKING_FLAGS) \
$(MULTILIB_FLAGS) \
$(WITH_ABI) \
$(WITH_ARCH) \
CFLAGS_FOR_TARGET="-Os $(CFLAGS_FOR_TARGET)"
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@
.PHONY: check-gcc-newlib
check-gcc-newlib: stamps/build-gcc-newlib-stage2
export PATH=$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH) && \
export DEJAGNULIBS=$(srcdir)/riscv-dejagnu && \
export RISC_V_SYSROOT=$(SYSROOT) && \
cd build-gcc-newlib-stage2 && \
$(MAKE) check-gcc "RUNTESTFLAGS=--target_board=riscv-sim"
check-gcc-linux: stamps/build-gcc-linux-stage2
export PATH=$(srcdir)/scripts/wrapper/qemu:$(INSTALL_DIR)/bin:$(PATH) && \
export DEJAGNULIBS=$(srcdir)/riscv-dejagnu && \
export RISC_V_SYSROOT=$(SYSROOT) && \
cd build-gcc-linux-stage2 && \
$(MAKE) check-gcc "RUNTESTFLAGS=--target_board=riscv-sim"
clean:
rm -rf build-* $(addprefix src/,$(PACKAGES)) stamps
distclean: clean
rm -rf src
# All of the packages install themselves, so our install target does nothing.
install: