forked from riscv-collab/riscv-gnu-toolchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
executable file
·242 lines (215 loc) · 7.38 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
srcdir := @abs_top_srcdir@
builddir := @abs_top_builddir@
INSTALL_DIR := @prefix@
PACKAGES := binutils gcc glibc newlib
gcc_version := 5.2.0
binutils_version := 2.25
glibc_version := 2.22
newlib_version := 2.2.0
DISTDIR ?= /var/cache/distfiles
GNU_MIRROR := http://mirrors.kernel.org/gnu
gcc_url := $(GNU_MIRROR)/gcc/gcc-$(gcc_version)/gcc-$(gcc_version).tar.gz
binutils_url := $(GNU_MIRROR)/binutils/binutils-$(binutils_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
XLEN ?= @XLEN@
WITH_ARCH ?= @WITH_ARCH@
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@
ATOMIC_CFLAGS := @atomic_cflags@
FLOAT_CFLAGS := @float_cflags@
FLOAT_ASFLAGS := @float_asflags@
GLIBC_CONFIGURE_FLAGS := @glibc_configure_flags@
CFLAGS_FOR_TARGET := $(CFLAGS_FOR_TARGET_EXTRA) $(ATOMIC_CFLAGS) $(FLOAT_CFLAGS)
ASFLAGS_FOR_TARGET := $(ASFLAGS_FOR_TARGET_EXTRA) $(FLOAT_ASFLAGS)
all: @default_target@
newlib: stamps/build-gcc-newlib
ifneq ($(findstring --disable-multilib,$(MULTILIB_FLAGS)),)
linux: stamps/build-gcc-linux-stage2
else
linux:
$(MAKE) stamps/build-gcc-linux-stage1 XLEN=64
$(MAKE) stamps/build-glibc-linux64 XLEN=64
$(MAKE) stamps/build-glibc-linux32 XLEN=32 \
CC="riscv64-unknown-linux-gnu-gcc -m32" \
READELF=riscv64-unknown-linux-gnu-readelf \
CFLAGS_FOR_TARGET_EXTRA="-m32" \
ASFLAGS_FOR_TARGET_EXTRA="-m32"
$(MAKE) stamps/build-gcc-linux-stage2 XLEN=64
endif
$(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: src/binutils
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $(CURDIR)/$</configure \
--target=riscv$(XLEN)-unknown-linux-gnu \
--prefix=$(INSTALL_DIR) \
--with-sysroot=$(SYSROOT) \
$(MULTILIB_FLAGS) \
--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: src/glibc stamps/build-gcc-linux-stage1
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
mkdir -p $(SYSROOT)/usr/lib $(SYSROOT)/lib
cd $(notdir $@) && $(CURDIR)/$</configure \
--host=riscv$(XLEN)-unknown-linux-gnu \
--prefix=/usr \
libc_cv_forced_unwind=yes \
libc_cv_c_cleanup=yes \
--enable-shared \
--enable-__thread \
--disable-multilib \
--enable-kernel=2.6.32
$(MAKE) -C $(notdir $@) install-headers install_root=$(SYSROOT)
mkdir -p $(dir $@) && touch $@
stamps/build-glibc-linux$(XLEN): src/glibc stamps/build-gcc-linux-stage1
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
mkdir -p $(SYSROOT)/usr/lib $(SYSROOT)/lib
cd $(notdir $@) && CFLAGS="$(CFLAGS_FOR_TARGET) -g -O2" \
ASFLAGS="$(ASFLAGS_FOR_TARGET)" \
$(CURDIR)/$</configure \
--host=riscv$(XLEN)-unknown-linux-gnu \
--prefix=/usr \
libc_cv_forced_unwind=yes \
libc_cv_c_cleanup=yes \
--enable-shared \
--enable-__thread \
$(MULTILIB_FLAGS) \
--enable-kernel=2.6.32 \
$(GLIBC_CONFIGURE_FLAGS)
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install install_root=$(SYSROOT)
mkdir -p $(dir $@) && touch $@
stamps/build-gcc-linux-stage1: src/gcc stamps/build-binutils-linux \
stamps/build-linux-headers
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $(CURDIR)/$</configure \
--target=riscv$(XLEN)-unknown-linux-gnu \
--prefix=$(INSTALL_DIR) \
--with-sysroot=$(SYSROOT) \
--with-newlib \
--without-headers \
--disable-shared \
--disable-threads \
--enable-tls \
--enable-languages=c \
--disable-libatomic \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-libgomp \
--disable-nls \
--disable-bootstrap \
$(MULTILIB_FLAGS) \
$(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: src/gcc stamps/build-glibc-linux$(XLEN) \
stamps/build-glibc-linux-headers
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $(CURDIR)/$</configure \
--target=riscv$(XLEN)-unknown-linux-gnu \
--prefix=$(INSTALL_DIR) \
--with-sysroot=$(SYSROOT) \
--enable-shared \
--enable-tls \
--enable-languages=c,c++,fortran \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-nls \
$(MULTILIB_FLAGS) \
--disable-bootstrap \
$(WITH_ARCH)
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@
stamps/build-binutils-newlib: src/binutils
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $(CURDIR)/$</configure \
--target=riscv$(XLEN)-unknown-elf \
--prefix=$(INSTALL_DIR) \
--enable-tls \
--disable-werror
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@
src/newlib-gcc: src/gcc src/newlib
rm -rf $@ [email protected]
cp -a src/gcc [email protected]
cp -a src/newlib/newlib [email protected]
cp -a src/newlib/libgloss [email protected]
$(srcdir)/scripts/cp_s $(srcdir)/newlib [email protected]
mv [email protected] $@
stamps/build-gcc-newlib: src/newlib-gcc stamps/build-binutils-newlib
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $(CURDIR)/$</configure \
--target=riscv$(XLEN)-unknown-elf \
--prefix=$(INSTALL_DIR) \
--disable-shared \
--disable-threads \
--enable-tls \
--enable-languages=c,c++ \
--with-newlib \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-libgomp \
--disable-nls \
$(MULTILIB_FLAGS) \
$(WITH_ARCH)
$(MAKE) -C $(notdir $@) inhibit-libc=true
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@
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: