47ca58026da2f1e40a2c649fae0fa4573984a037
[akaros.git] / tools / compilers / gcc-glibc / Makefile
1 # Number of make jobs to spawn.  Define it in Makelocal
2 MAKE_JOBS :=
3
4 # Defines where to install the toolchain
5 -include Makelocal
6
7 ifndef RISCV_INSTDIR
8 ifndef I686_INSTDIR
9 ifndef X86_64_INSTDIR
10 ifndef X86_64_NATIVE_INSTDIR
11 busted: 
12         @echo "You need to setup either a RISCV_INSTDIR, an I686_INSTDIR, or an X86_64_INSTDIR to point to where you want the tools installed. The best way to do this is to create a 'Makelocal' file in the current directory and put it in there."; false
13 riscv: busted
14 i686: busted
15 x86_64: busted
16 x86_64-native: busted
17 endif
18 endif 
19 endif 
20 endif 
21
22 # Check to make sure that we have gawk installed on our system and not some
23 # other version of awk
24 AWK := $(shell awk -W version 2>&1 | head -n 1 | awk '{print $$1}')
25 ifneq ($(AWK),GNU)
26 $(error You need to have 'gawk' installed on your system!)
27 endif
28
29 # Check to make sure that we have the GMP, MPFR, and MPC libraries installed
30 GMP_OK := $(shell echo "int main() {return 0;}" | gcc -x c - -lgmp -lmpfr -lmpc -o /dev/null > /dev/null && echo OK)
31 ifneq ($(GMP_OK),OK)
32 $(error You need to have the libraries GMP, MPFR, and MPC installed on your system!)
33 endif
34
35 BINUTILS_VERSION := 2.21.1
36 GCC_VERSION := 4.6.1
37 GLIBC_VERSION := 2.14.1
38 GMP_VERSION := 5.1.3
39 MPFR_VERSION := 3.1.2
40 MPC_VERSION := 1.0.2
41
42 BUILDDIR ?= $(shell pwd)/
43 ROSDIR ?= $(BUILDDIR)/../../../
44 DESTDIR ?= /
45
46 # Configuration parameters for make-riscv
47 RISCV_ARCH := riscv
48 RISCV_BINARY_PREFIX := $(RISCV_ARCH)-ros-
49 RISCV_GLIBC_CONFIGURE_FLAGS := 
50 RISCV_GCC_BUILD_FLAGS := 
51 RISCV_CFLAGS :=
52
53 # Configuration parameters for x86
54 I686_ARCH := i686
55 I686_BINARY_PREFIX := $(I686_ARCH)-ros-
56 I686_GLIBC_CONFIGURE_FLAGS := 
57 I686_GCC_BUILD_FLAGS := 
58 I686_CFLAGS := -march=i486
59
60 # Configuration parameters for x86_64
61 X86_64_ARCH := x86_64
62 X86_64_BINARY_PREFIX := $(X86_64_ARCH)-ros-
63 X86_64_GLIBC_CONFIGURE_FLAGS := "--disable-multi-arch"
64 X86_64_GCC_BUILD_FLAGS := CFLAGS="-fPIC"
65 X86_64_CFLAGS :=
66
67 # Configuration parameters for x86_64-native
68 X86_64_NATIVE_ARCH := x86_64
69 X86_64_NATIVE_BINARY_PREFIX := $(X86_64_NATIVE_ARCH)-native-ros-
70 X86_64_NATIVE_GCC_BUILD_FLAGS := CFLAGS="-fPIC"
71 X86_64_NATIVE_CFLAGS :=
72
73 #If actually building the cross compiler, make sure that the akaros tree is
74 #properly configured for the architecture we are creating the cross compiler
75 #for.
76 ifneq (,$(filter riscv,$(MAKECMDGOALS)))
77 ifeq (,$(shell grep "CONFIG_RISCV=y" $(ROSDIR)/.config))
78 error: 
79         @echo "Akaros tree not configured for riscv"
80         @echo "Make sure you have configured ROSDIR for this architecture before proceeding"
81         @echo "e.g. cd \$$ROSDIR"
82         @echo "     make ARCH=riscv defconfig"
83         @false
84 riscv: error
85 endif
86 endif
87 ifneq (,$(filter i686,$(MAKECMDGOALS)))
88 ifeq (,$(shell grep "CONFIG_X86_32=y" $(ROSDIR)/.config))
89 error: 
90         @echo "Akaros tree not configured for i686"
91         @echo "Make sure you have configured ROSDIR for this architecture before proceeding"
92         @echo "e.g. cd \$$ROSDIR"
93         @echo "     make ARCH=x86 defconfig"
94         @false
95 i686: error
96 endif
97 endif
98 ifneq (,$(filter x86_64,$(MAKECMDGOALS)))
99 ifeq (,$(shell grep "CONFIG_X86_64=y" $(ROSDIR)/.config))
100 error: 
101         @echo "Akaros tree not configured for x86_64"
102         @echo "Make sure you have configured ROSDIR for this architecture before proceeding"
103         @echo "e.g. cd \$$ROSDIR"
104         @echo "     make ARCH=x86 defconfig"
105         @echo "     make ARCH=x86 menuconfig -> Set 64 bit option"
106         @false
107 x86_64: error
108 endif
109 endif
110 ifneq (,$(filter x86_64-native,$(MAKECMDGOALS)))
111 ifeq (,$(shell which x86_64-ros-gcc))
112 error: 
113         @echo "No x86_64 Akaros cross-compiler installed in path"
114         @echo "Make sure you have built and installed the x86_64 cross-compiler using 'make x86_64'
115         @echo "before trying to build the crossed-native compiler.
116         @false
117 x86_64: error
118 endif
119 endif
120
121 all:
122         @echo "You need to run one of the following commands, "
123         @echo "depending on which version of the cross compiler you are trying to generate:"
124         @echo "  make riscv"
125         @echo "  make i686"
126         @echo "  make x86_64"
127         @echo "  make x86-64-native"
128         @echo "  make riscv-revert"
129         @echo "  make i686-revert"
130         @echo "  make x86_64-revert"
131         @echo "  make x86_64-native-revert"
132         @echo "  make riscv-uninstall"
133         @echo "  make i686-uninstall"
134         @echo "  make x86_64-uninstall"
135         @echo "  make x86_64-native-uninstall"
136         @echo "  make clean"
137
138 riscv:
139         export LD_LIBRARY_PATH=; \
140         export DESTDIR=$(DESTDIR);\
141         export INSTDIR=$(RISCV_INSTDIR);\
142         export PATH=$(DESTDIR)$(RISCV_INSTDIR)/bin:$(PATH);\
143         export ARCH=$(RISCV_ARCH);\
144         export ARCH_CFLAGS=$(RISCV_CFLAGS);\
145         export ROS_ARCH_DIR=$(RISCV_ARCH);\
146         export BINARY_PREFIX=$(RISCV_BINARY_PREFIX);\
147         export GLIBC_CONFIGURE_FLAGS=$(RISCV_GLIBC_CONFIGURE_FLAGS);\
148         export GCC_BUILD_FLAGS=$(RISCV_GCC_BUILD_FLAGS);\
149         $(MAKE) make-all
150
151 i686:
152         export LD_LIBRARY_PATH=; \
153         export DESTDIR=$(DESTDIR);\
154         export INSTDIR=$(I686_INSTDIR);\
155         export PATH=$(DESTDIR)$(I686_INSTDIR)/bin:$(PATH);\
156         export ARCH=$(I686_ARCH);\
157         export ARCH_CFLAGS=$(I686_CFLAGS);\
158         export ROS_ARCH_DIR=x86;\
159         export BINARY_PREFIX=$(I686_BINARY_PREFIX);\
160         export GLIBC_CONFIGURE_FLAGS=$(I686_GLIBC_CONFIGURE_FLAGS);\
161         export GCC_BUILD_FLAGS=$(I686_GCC_BUILD_FLAGS);\
162         $(MAKE) make-all
163
164 x86_64:
165         export LD_LIBRARY_PATH=; \
166         export DESTDIR=$(DESTDIR);\
167         export INSTDIR=$(X86_64_INSTDIR);\
168         export PATH=$(DESTDIR)$(X86_64_INSTDIR)/bin:$(PATH);\
169         export ARCH=$(X86_64_ARCH);\
170         export ARCH_CFLAGS=$(X86_64_CFLAGS);\
171         export ROS_ARCH_DIR=x86;\
172         export BINARY_PREFIX=$(X86_64_BINARY_PREFIX);\
173         export GLIBC_CONFIGURE_FLAGS=$(X86_64_GLIBC_CONFIGURE_FLAGS);\
174         export GCC_BUILD_FLAGS=$(X86_64_GCC_BUILD_FLAGS);\
175         $(MAKE) make-all
176
177 x86_64-native:
178         export NATIVE_BUILD=true; \
179         export LD_LIBRARY_PATH=; \
180         export DESTDIR=$(DESTDIR);\
181         export INSTDIR=$(X86_64_NATIVE_INSTDIR);\
182         export ARCH=$(X86_64_NATIVE_ARCH);\
183         export BINARY_PREFIX=$(X86_64_NATIVE_BINARY_PREFIX);\
184         export GCC_BUILD_FLAGS=$(X86_64_NATIVE_GCC_BUILD_FLAGS);\
185         export CXXROOT=$(shell dirname $(shell which $(X86_64_NATIVE_ARCH)-ros-gcc))/..; \
186         $(MAKE) make-native-all
187
188 make-all: 
189         $(MAKE) .$(BINARY_PREFIX)binutils-install
190         $(MAKE) .$(BINARY_PREFIX)gcc-stage1-install
191         $(MAKE) .$(BINARY_PREFIX)ros-headers-install
192         $(MAKE) .$(BINARY_PREFIX)dummy-libs-install
193         $(MAKE) .$(BINARY_PREFIX)glibc-stage1-install
194         $(MAKE) .$(BINARY_PREFIX)gcc-stage2-install
195         $(MAKE) .$(BINARY_PREFIX)glibc-stage2-install
196         $(MAKE) .$(BINARY_PREFIX)ros-libs-install
197         $(MAKE) .$(BINARY_PREFIX)gcc-stage3-install
198         $(MAKE) .$(BINARY_PREFIX)gmp-install
199         $(MAKE) .$(BINARY_PREFIX)mpfr-install
200         $(MAKE) .$(BINARY_PREFIX)mpc-install
201
202 make-native-all:
203         $(MAKE) .$(BINARY_PREFIX)binutils-install
204         $(MAKE) .$(BINARY_PREFIX)gcc-stage3-install
205
206 riscv-uninstall:
207         -rm -rf $(RISCV_INSTDIR)
208
209 i686-uninstall:
210         -rm -rf $(I686_INSTDIR)
211
212 x86_64-uninstall:
213         -rm -rf $(X86_64_INSTDIR)
214
215 x86_64-native-uninstall:
216         -rm -rf $(X86_64_NATIVE_INSTDIR)
217
218 riscv-revert:
219         rm -rf $(RISCV_INSTDIR)
220         cp -r $(RISCV_BINARY_PREFIX)install.bak $(RISCV_INSTDIR)
221
222 i686-revert: 
223         rm -rf $(I686_INSTDIR)
224         cp -r $(I686_BINARY_PREFIX)install.bak $(I686_INSTDIR)
225
226 x86_64-revert: 
227         rm -rf $(X86_64_INSTDIR)
228         cp -r $(X86_64_BINARY_PREFIX)install.bak $(X86_64_INSTDIR)
229
230 x86_64-native-revert: 
231         rm -rf $(X86_64_NATIVE_INSTDIR)
232         cp -r $(X86_64_NATIVE_BINARY_PREFIX)install.bak $(X86_64_NATIVE_INSTDIR)
233
234 %.tar.bz2:
235         wget http://akaros.cs.berkeley.edu/xcc/$@
236
237 %.tar.gz:
238         wget http://akaros.cs.berkeley.edu/xcc/$@
239
240 #################################
241 ########### BINUTILS ############
242 #################################
243 binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2
244         rm -rf binutils-$(BINUTILS_VERSION);
245         tar -jxf binutils-$(BINUTILS_VERSION).tar.bz2
246         patch -p0 < binutils-$(BINUTILS_VERSION)-ros.patch
247         patch --no-backup-if-mismatch -p0 < binutils-$(BINUTILS_VERSION)-riscv.patch
248         patch -p0 < binutils-$(BINUTILS_VERSION)-objdump.patch
249
250 $(BINARY_PREFIX)binutils-builddir: binutils-$(BINUTILS_VERSION)
251         rm -rf $@
252         mkdir -p $@
253
254 native-binutils-configure:
255         cd $(BINARY_PREFIX)binutils-builddir; \
256         ../binutils-$(BINUTILS_VERSION)/configure \
257             --target=$(ARCH)-ros \
258                 --host=$(ARCH)-ros \
259             --prefix=$(INSTDIR) \
260             --disable-nls
261
262 cross-binutils-configure:
263         cd $(BINARY_PREFIX)binutils-builddir; \
264         ../binutils-$(BINUTILS_VERSION)/configure \
265             --target=$(ARCH)-ros \
266             --prefix=$(INSTDIR) \
267                 --disable-werror \
268             --disable-nls
269
270 .$(BINARY_PREFIX)binutils-configure: 
271         $(MAKE) $(BINARY_PREFIX)binutils-builddir 
272         if [ "$(NATIVE_BUILD)" = "true" ]; then \
273                 $(MAKE) native-binutils-configure; \
274         else \
275                 $(MAKE) cross-binutils-configure; \
276         fi
277         echo "MAKEINFO = :" >> $(BINARY_PREFIX)binutils-builddir/Makefile;
278         touch $@
279
280 .$(BINARY_PREFIX)binutils-make: .$(BINARY_PREFIX)binutils-configure
281         cd $(BINARY_PREFIX)binutils-builddir; \
282         make -j $(MAKE_JOBS)
283
284 .$(BINARY_PREFIX)binutils-install: .$(BINARY_PREFIX)binutils-make
285         cd $(BINARY_PREFIX)binutils-builddir; \
286         make -j $(MAKE_JOBS) install
287
288 binutils-clean:
289         cd $(BINARY_PREFIX)binutils-builddir; \
290         make clean
291
292 #################################
293 ########## GCC Stage 1 ##########
294 #################################
295 .gcc-ros-patch:
296         -cd gcc-$(GCC_VERSION); \
297         diff -ruB --unidirectional-new-file \
298              ../gcc-$(GCC_VERSION) \
299              ../gcc-$(GCC_VERSION)-ros \
300              | grep -v "Only in ../gcc-$(GCC_VERSION)" \
301              | patch -p2 
302
303 gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2
304         rm -rf gcc-$(GCC_VERSION)
305         tar -jxf gcc-$(GCC_VERSION).tar.bz2
306         $(MAKE) .gcc-ros-patch
307         patch --no-backup-if-mismatch -p0 < gcc-$(GCC_VERSION)-riscv.patch
308
309 $(BINARY_PREFIX)gcc-stage1-builddir: gcc-$(GCC_VERSION)
310         rm -rf $@
311         mkdir -p $@
312
313 .$(BINARY_PREFIX)gcc-stage1-configure: 
314         $(MAKE) $(BINARY_PREFIX)gcc-stage1-builddir
315         cd $(BINARY_PREFIX)gcc-stage1-builddir; \
316         ../gcc-$(GCC_VERSION)/configure \
317                 --target=$(ARCH)-ros \
318                 --program-prefix=$(BINARY_PREFIX) \
319                 --prefix=$(INSTDIR) \
320                 --disable-nls \
321                 --disable-shared \
322                 --enable-languages=c,c++ \
323                 --without-headers \
324                 $(GCC_BUILD_FLAGS);
325         echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage1-builddir/Makefile;
326         touch $@
327
328 .$(BINARY_PREFIX)gcc-stage1-make: .$(BINARY_PREFIX)gcc-stage1-configure
329         cd $(BINARY_PREFIX)gcc-stage1-builddir; \
330         make -j $(MAKE_JOBS) all-gcc;
331
332 .$(BINARY_PREFIX)gcc-stage1-install: .$(BINARY_PREFIX)gcc-stage1-make
333         cd $(BINARY_PREFIX)gcc-stage1-builddir; \
334         make -j $(MAKE_JOBS) install-gcc;
335
336 #################################
337 ########## GCC Stage 2 ##########
338 #################################
339 $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
340         rm -rf $@
341         mkdir -p $@
342
343 .$(BINARY_PREFIX)gcc-stage2-configure: 
344         $(MAKE) $(BINARY_PREFIX)gcc-stage2-builddir
345         cd $(BINARY_PREFIX)gcc-stage2-builddir; \
346         ../gcc-$(GCC_VERSION)/configure \
347                 --target=$(ARCH)-ros \
348                 --program-prefix=$(BINARY_PREFIX) \
349                 --prefix=$(INSTDIR) \
350                 --disable-nls \
351                 --disable-shared \
352                 --disable-multilib \
353                 --enable-languages=c \
354                 --without-headers \
355                 $(GCC_BUILD_FLAGS);
356         echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage2-builddir/Makefile;
357         touch $@
358
359 .$(BINARY_PREFIX)gcc-stage2-make: .$(BINARY_PREFIX)gcc-stage2-configure
360         cd $(BINARY_PREFIX)gcc-stage2-builddir; \
361         make -j $(MAKE_JOBS) all-gcc all-target-libgcc;
362
363 .$(BINARY_PREFIX)gcc-stage2-install: .$(BINARY_PREFIX)gcc-stage2-make
364         cd $(BINARY_PREFIX)gcc-stage2-builddir; \
365         make -j $(MAKE_JOBS) install-gcc install-target-libgcc;
366
367 #################################
368 ######### ROS Headers ###########
369 #################################
370 .$(BINARY_PREFIX)ros-headers-install: $(ROSDIR)
371         rm -rf $(INSTDIR)/$(ARCH)-ros/sys-include/*
372         mkdir -p $(INSTDIR)/$(ARCH)-ros/sys-include
373         cp -r $(ROSDIR)/kern/include/ros \
374            $(INSTDIR)/$(ARCH)-ros/sys-include/
375         rm -f $(INSTDIR)/$(ARCH)-ros/sys-include/ros/arch
376         mkdir $(INSTDIR)/$(ARCH)-ros/sys-include/ros/arch
377         cp -r $(ROSDIR)/kern/arch/$(ROS_ARCH_DIR)/ros/* \
378            $(INSTDIR)/$(ARCH)-ros/sys-include/ros/arch/
379         cp -r $(ROSDIR)/user/parlib/include/* \
380            $(INSTDIR)/$(ARCH)-ros/sys-include/
381         cp -r $(ROSDIR)/user/pthread/*.h \
382            $(INSTDIR)/$(ARCH)-ros/sys-include/
383         rm -rf $(INSTDIR)/$(ARCH)-ros/sys-include/arch
384         ln -s $(ROS_ARCH_DIR) $(INSTDIR)/$(ARCH)-ros/sys-include/arch 
385
386 #################################
387 ###### Dummy Libs Install #######
388 #################################
389 .$(BINARY_PREFIX)dummy-libs-install:
390         rm -rf $(INSTDIR)/$(ARCH)-ros/lib/libparlib.a
391         rm -rf $(INSTDIR)/$(ARCH)-ros/lib/libgcc_eh.a
392         $(ARCH)-ros-ar cr $(INSTDIR)/$(ARCH)-ros/lib/libparlib.a
393         $(ARCH)-ros-ar cr $(INSTDIR)/$(ARCH)-ros/lib/libgcc_eh.a
394
395 #################################
396 ######### Glibc Stage 1 #########
397 #################################
398 .glibc-ros-patch:
399         -cd glibc-$(GLIBC_VERSION); \
400         diff -ruB --unidirectional-new-file \
401              ../glibc-$(GLIBC_VERSION) \
402              ../glibc-$(GLIBC_VERSION)-ros \
403              | grep -v "Only in ../glibc-$(GLIBC_VERSION)" \
404              | patch -p2 
405
406 glibc-$(GLIBC_VERSION): glibc-$(GLIBC_VERSION).tar.bz2
407         rm -rf glibc-$(GLIBC_VERSION)
408         tar -jxf glibc-$(GLIBC_VERSION).tar.bz2
409         $(MAKE) .glibc-ros-patch
410         patch --no-backup-if-mismatch -p0 < glibc-$(GLIBC_VERSION)-riscv.patch
411         rm glibc-$(GLIBC_VERSION)/sysdeps/riscv/elf/start.S
412         rm glibc-$(GLIBC_VERSION)/sysdeps/i386/elf/start.S
413         rm glibc-$(GLIBC_VERSION)/sysdeps/x86_64/elf/start.S
414
415 $(BINARY_PREFIX)glibc-stage1-builddir: glibc-$(GLIBC_VERSION)
416         rm -rf $@
417         mkdir -p $@
418
419 .$(BINARY_PREFIX)glibc-stage1-configure: 
420         $(MAKE) $(BINARY_PREFIX)glibc-stage1-builddir;
421         cd $(BINARY_PREFIX)glibc-stage1-builddir; \
422         ../glibc-$(GLIBC_VERSION)/configure \
423                   --host=$(ARCH)-ros \
424                   --prefix=$(INSTDIR)/$(ARCH)-ros \
425                   --enable-hacker-mode \
426                   --disable-shared \
427               --disable-add-ons \
428                   --disable-nls \
429                   --with-headers=$(INSTDIR)/$(ARCH)-ros/sys-include \
430                   --with-elf \
431                   --with-tls \
432                   --with-__thread \
433                   $(GLIBC_CONFIGURE_FLAGS) \
434                   CFLAGS="$(ARCH_CFLAGS) -g -fpermissive -O2 -pipe";
435         touch $@
436
437 .$(BINARY_PREFIX)glibc-stage1-install: .$(BINARY_PREFIX)glibc-stage1-configure
438         cd $(BINARY_PREFIX)glibc-stage1-builddir; \
439         comma=, make -j $(MAKE_JOBS) install-headers install-bootstrap-headers=yes; \
440
441 ####################################
442 ########## Glibc Stage 2  ##########
443 ####################################
444 $(BINARY_PREFIX)glibc-stage2-builddir: glibc-$(GLIBC_VERSION)
445         rm -rf $@
446         mkdir -p $@
447
448 .$(BINARY_PREFIX)glibc-stage2-configure: 
449         $(MAKE) $(BINARY_PREFIX)glibc-stage2-builddir
450         cd $(BINARY_PREFIX)glibc-stage2-builddir; \
451         ../glibc-$(GLIBC_VERSION)/configure \
452                   --host=$(ARCH)-ros \
453                   --enable-hacker-mode \
454                   --enable-shared \
455                   --disable-nls \
456                   --with-elf \
457                   --with-tls \
458                   --with-__thread \
459                   --with-headers=$(INSTDIR)/$(ARCH)-ros/sys-include \
460                   --prefix=$(INSTDIR)/$(ARCH)-ros \
461                   libc_cv_forced_unwind=yes \
462                   libc_cv_c_cleanup=yes \
463                   $(GLIBC_CONFIGURE_FLAGS) \
464                   CFLAGS="$(ARCH_CFLAGS) -g -fpermissive -O2 -pipe";
465         touch $@
466
467 .$(BINARY_PREFIX)glibc-stage2-make: .$(BINARY_PREFIX)glibc-stage2-configure
468         cd $(BINARY_PREFIX)glibc-stage2-builddir; \
469         make -j $(MAKE_JOBS) || make -j $(MAKE_JOBS)
470
471 .$(BINARY_PREFIX)glibc-stage2-install: .$(BINARY_PREFIX)glibc-stage2-make
472         cd $(BINARY_PREFIX)glibc-stage2-builddir; \
473         make -j $(MAKE_JOBS) install
474
475 #################################
476 ####### ROS Libs Install #######
477 #################################
478 .$(BINARY_PREFIX)ros-libs-install:
479         cd $(ROSDIR); \
480         make ARCH=$(ROS_ARCH_DIR) userclean; \
481         make ARCH=$(ROS_ARCH_DIR) -j $(MAKE_JOBS) install-libs
482
483 ##################################
484 ########### Gcc Stage 3 ##########
485 ##################################
486 $(BINARY_PREFIX)gcc-stage3-builddir: gcc-$(GCC_VERSION)
487         rm -rf $@
488         mkdir -p $@
489
490 native-gcc-stage3-prep:
491         mkdir -p $(INSTDIR)/usr; \
492         cp -R $(CXXROOT)/$(ARCH)-ros/sys-include  $(INSTDIR)/usr/include; \
493         cp -R $(CXXROOT)/$(ARCH)-ros/lib* $(INSTDIR)/usr; \
494
495 native-gcc-stage3-configure: native-gcc-stage3-prep
496         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
497         ../gcc-$(GCC_VERSION)/configure \
498             --target=$(ARCH)-ros \
499             --host=$(ARCH)-ros \
500             --with-gmp=$(CXXROOT) \
501             --with-mpfr=$(CXXROOT) \
502             --with-mpc=$(CXXROOT) \
503             --prefix=$(INSTDIR) \
504             --disable-nls \
505             --disable-werror \
506             --disable-multilib \
507             --enable-shared \
508             --enable-tls \
509             --enable-libgomp \
510             --enable-languages=c,c++ \
511             --with-__thread \
512             $(GCC_BUILD_FLAGS);
513
514 cross-gcc-stage3-configure:
515         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
516         ../gcc-$(GCC_VERSION)/configure \
517             --target=$(ARCH)-ros \
518             --program-prefix=$(BINARY_PREFIX) \
519             --prefix=$(INSTDIR) \
520             --disable-nls \
521             --disable-werror \
522             --disable-multilib \
523             --enable-shared \
524             --enable-tls \
525             --enable-libgomp \
526             --enable-languages=c,c++ \
527             --with-__thread \
528             --with-headers=$(INSTDIR)/$(ARCH)-ros/include \
529             $(GCC_BUILD_FLAGS);
530
531 .$(BINARY_PREFIX)gcc-stage3-configure:
532         $(MAKE) $(BINARY_PREFIX)gcc-stage3-builddir
533         if [ "$(NATIVE_BUILD)" = "true" ]; then \
534                 $(MAKE) native-gcc-stage3-configure; \
535         else \
536                 $(MAKE) cross-gcc-stage3-configure; \
537         fi
538         echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage3-builddir/Makefile;
539         touch $@
540
541 .$(BINARY_PREFIX)gcc-stage3-make: .$(BINARY_PREFIX)gcc-stage3-configure
542         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
543         make -j $(MAKE_JOBS)
544
545 .$(BINARY_PREFIX)gcc-stage3-install: .$(BINARY_PREFIX)gcc-stage3-make
546         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
547         make -j $(MAKE_JOBS) install
548
549 ##################################
550 ######### GMP, MPFR, MPC #########
551 ##################################
552 gmp-$(GMP_VERSION): gmp-$(GMP_VERSION).tar.bz2
553         rm -rf gmp-$(GMP_VERSION)
554         tar -jxf gmp-$(GMP_VERSION).tar.bz2
555         patch -p0 < gmp-$(GMP_VERSION)-ros.patch
556
557 mpfr-$(MPFR_VERSION): mpfr-$(MPFR_VERSION).tar.bz2
558         rm -rf mpfr-$(MPFR_VERSION)
559         tar -jxf mpfr-$(MPFR_VERSION).tar.bz2
560         patch -p0 < mpfr-$(MPFR_VERSION)-ros.patch
561
562 mpc-$(MPC_VERSION): mpc-$(MPC_VERSION).tar.gz
563         rm -rf mpc-$(MPC_VERSION)
564         tar -zxf mpc-$(MPC_VERSION).tar.gz
565         patch -p0 < mpc-$(MPC_VERSION)-ros.patch
566
567 $(BINARY_PREFIX)gmp-builddir: gmp-$(GMP_VERSION)
568         rm -rf $@
569         mkdir -p $@
570
571 $(BINARY_PREFIX)mpfr-builddir: mpfr-$(MPFR_VERSION)
572         rm -rf $@
573         mkdir -p $@
574
575 $(BINARY_PREFIX)mpc-builddir: mpc-$(MPC_VERSION)
576         rm -rf $@
577         mkdir -p $@
578
579 .$(BINARY_PREFIX)gmp-configure:
580         $(MAKE) $(BINARY_PREFIX)gmp-builddir
581         cd $(BINARY_PREFIX)gmp-builddir; \
582         ../gmp-$(GMP_VERSION)/configure \
583             --disable-static \
584             --prefix=$(INSTDIR) \
585             --host=$(ARCH)-ros
586         touch $@
587
588 .$(BINARY_PREFIX)mpfr-configure:
589         $(MAKE) $(BINARY_PREFIX)mpfr-builddir
590         cd $(BINARY_PREFIX)mpfr-builddir; \
591         ../mpfr-$(MPFR_VERSION)/configure \
592             --disable-static \
593             --prefix=$(INSTDIR) \
594             --with-gmp=$(INSTDIR) \
595             --host=$(ARCH)-ros
596         touch $@
597
598 .$(BINARY_PREFIX)mpc-configure:
599         $(MAKE) $(BINARY_PREFIX)mpc-builddir
600         cd $(BINARY_PREFIX)mpc-builddir; \
601         ../mpc-$(MPC_VERSION)/configure \
602             --disable-static \
603             --prefix=$(INSTDIR) \
604             --with-gmp=$(INSTDIR) \
605             --with-mpfr=$(INSTDIR) \
606             --host=$(ARCH)-ros
607         touch $@
608
609 .$(BINARY_PREFIX)gmp-make: .$(BINARY_PREFIX)gmp-configure
610         cd $(BINARY_PREFIX)gmp-builddir; \
611         make -j $(MAKE_JOBS)
612
613 .$(BINARY_PREFIX)mpfr-make: .$(BINARY_PREFIX)mpfr-configure
614         cd $(BINARY_PREFIX)mpfr-builddir; \
615         make -j $(MAKE_JOBS)
616
617 .$(BINARY_PREFIX)mpc-make: .$(BINARY_PREFIX)mpc-configure
618         cd $(BINARY_PREFIX)mpc-builddir; \
619         make -j $(MAKE_JOBS)
620
621 .$(BINARY_PREFIX)gmp-install: .$(BINARY_PREFIX)gmp-make
622         cd $(BINARY_PREFIX)gmp-builddir; \
623         make -j $(MAKE_JOBS) install
624
625 .$(BINARY_PREFIX)mpfr-install: .$(BINARY_PREFIX)mpfr-make
626         cd $(BINARY_PREFIX)mpfr-builddir; \
627         make -j $(MAKE_JOBS) install
628
629 .$(BINARY_PREFIX)mpc-install: .$(BINARY_PREFIX)mpc-make
630         cd $(BINARY_PREFIX)mpc-builddir; \
631         make -j $(MAKE_JOBS) install
632
633 ##################################
634 ######## Clean it all up! ########
635 ##################################
636 clean:
637         rm -rf binutils-$(BINUTILS_VERSION) 
638         rm -rf gcc-$(GCC_VERSION) 
639         rm -rf glibc-$(GLIBC_VERSION) 
640         rm -rf gmp-$(GMP_VERSION)
641         rm -rf mpfr-$(MPFR_VERSION)
642         rm -rf mpc-$(MPC_VERSION)
643         rm -rf *-builddir
644         rm -rf .*-ros-*-configure
645         rm -rf *$(BINARY_PREFIX)install.bak
646