Add support for a crossed-native compiler build (XCC)
[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-nls
268
269 .$(BINARY_PREFIX)binutils-configure: 
270         $(MAKE) $(BINARY_PREFIX)binutils-builddir 
271         if [ "$(NATIVE_BUILD)" = "true" ]; then \
272                 $(MAKE) native-binutils-configure; \
273         else \
274                 $(MAKE) cross-binutils-configure; \
275         fi
276         echo "MAKEINFO = :" >> $(BINARY_PREFIX)binutils-builddir/Makefile;
277         touch $@
278
279 .$(BINARY_PREFIX)binutils-make: .$(BINARY_PREFIX)binutils-configure
280         cd $(BINARY_PREFIX)binutils-builddir; \
281         make -j $(MAKE_JOBS)
282
283 .$(BINARY_PREFIX)binutils-install: .$(BINARY_PREFIX)binutils-make
284         cd $(BINARY_PREFIX)binutils-builddir; \
285         make -j $(MAKE_JOBS) install
286
287 binutils-clean:
288         cd $(BINARY_PREFIX)binutils-builddir; \
289         make clean
290
291 #################################
292 ########## GCC Stage 1 ##########
293 #################################
294 .gcc-ros-patch:
295         -cd gcc-$(GCC_VERSION); \
296         diff -ruB --unidirectional-new-file \
297              ../gcc-$(GCC_VERSION) \
298              ../gcc-$(GCC_VERSION)-ros \
299              | grep -v "Only in ../gcc-$(GCC_VERSION)" \
300              | patch -p2 
301
302 gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2
303         rm -rf gcc-$(GCC_VERSION)
304         tar -jxf gcc-$(GCC_VERSION).tar.bz2
305         $(MAKE) .gcc-ros-patch
306         patch --no-backup-if-mismatch -p0 < gcc-$(GCC_VERSION)-riscv.patch
307
308 $(BINARY_PREFIX)gcc-stage1-builddir: gcc-$(GCC_VERSION)
309         rm -rf $@
310         mkdir -p $@
311
312 .$(BINARY_PREFIX)gcc-stage1-configure: 
313         $(MAKE) $(BINARY_PREFIX)gcc-stage1-builddir
314         cd $(BINARY_PREFIX)gcc-stage1-builddir; \
315         ../gcc-$(GCC_VERSION)/configure \
316                 --target=$(ARCH)-ros \
317                 --program-prefix=$(BINARY_PREFIX) \
318                 --prefix=$(INSTDIR) \
319                 --disable-nls \
320                 --disable-shared \
321                 --enable-languages=c,c++ \
322                 --without-headers \
323                 $(GCC_BUILD_FLAGS);
324         echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage1-builddir/Makefile;
325         touch $@
326
327 .$(BINARY_PREFIX)gcc-stage1-make: .$(BINARY_PREFIX)gcc-stage1-configure
328         cd $(BINARY_PREFIX)gcc-stage1-builddir; \
329         make -j $(MAKE_JOBS) all-gcc;
330
331 .$(BINARY_PREFIX)gcc-stage1-install: .$(BINARY_PREFIX)gcc-stage1-make
332         cd $(BINARY_PREFIX)gcc-stage1-builddir; \
333         make -j $(MAKE_JOBS) install-gcc;
334
335 #################################
336 ########## GCC Stage 2 ##########
337 #################################
338 $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
339         rm -rf $@
340         mkdir -p $@
341
342 .$(BINARY_PREFIX)gcc-stage2-configure: 
343         $(MAKE) $(BINARY_PREFIX)gcc-stage2-builddir
344         cd $(BINARY_PREFIX)gcc-stage2-builddir; \
345         ../gcc-$(GCC_VERSION)/configure \
346                 --target=$(ARCH)-ros \
347                 --program-prefix=$(BINARY_PREFIX) \
348                 --prefix=$(INSTDIR) \
349                 --disable-nls \
350                 --disable-shared \
351                 --disable-multilib \
352                 --enable-languages=c \
353                 --without-headers \
354                 $(GCC_BUILD_FLAGS);
355         echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage2-builddir/Makefile;
356         touch $@
357
358 .$(BINARY_PREFIX)gcc-stage2-make: .$(BINARY_PREFIX)gcc-stage2-configure
359         cd $(BINARY_PREFIX)gcc-stage2-builddir; \
360         make -j $(MAKE_JOBS) all-gcc all-target-libgcc;
361
362 .$(BINARY_PREFIX)gcc-stage2-install: .$(BINARY_PREFIX)gcc-stage2-make
363         cd $(BINARY_PREFIX)gcc-stage2-builddir; \
364         make -j $(MAKE_JOBS) install-gcc install-target-libgcc;
365
366 #################################
367 ######### ROS Headers ###########
368 #################################
369 .$(BINARY_PREFIX)ros-headers-install: $(ROSDIR)
370         rm -rf $(INSTDIR)/$(ARCH)-ros/sys-include/*
371         mkdir -p $(INSTDIR)/$(ARCH)-ros/sys-include
372         cp -r $(ROSDIR)/kern/include/ros \
373            $(INSTDIR)/$(ARCH)-ros/sys-include/
374         rm -f $(INSTDIR)/$(ARCH)-ros/sys-include/ros/arch
375         mkdir $(INSTDIR)/$(ARCH)-ros/sys-include/ros/arch
376         cp -r $(ROSDIR)/kern/arch/$(ROS_ARCH_DIR)/ros/* \
377            $(INSTDIR)/$(ARCH)-ros/sys-include/ros/arch/
378         cp -r $(ROSDIR)/user/parlib/include/* \
379            $(INSTDIR)/$(ARCH)-ros/sys-include/
380         cp -r $(ROSDIR)/user/pthread/*.h \
381            $(INSTDIR)/$(ARCH)-ros/sys-include/
382         rm -rf $(INSTDIR)/$(ARCH)-ros/sys-include/arch
383         ln -s $(ROS_ARCH_DIR) $(INSTDIR)/$(ARCH)-ros/sys-include/arch 
384
385 #################################
386 ###### Dummy Libs Install #######
387 #################################
388 .$(BINARY_PREFIX)dummy-libs-install:
389         rm -rf $(INSTDIR)/$(ARCH)-ros/lib/libparlib.a
390         rm -rf $(INSTDIR)/$(ARCH)-ros/lib/libgcc_eh.a
391         $(ARCH)-ros-ar cr $(INSTDIR)/$(ARCH)-ros/lib/libparlib.a
392         $(ARCH)-ros-ar cr $(INSTDIR)/$(ARCH)-ros/lib/libgcc_eh.a
393
394 #################################
395 ######### Glibc Stage 1 #########
396 #################################
397 .glibc-ros-patch:
398         -cd glibc-$(GLIBC_VERSION); \
399         diff -ruB --unidirectional-new-file \
400              ../glibc-$(GLIBC_VERSION) \
401              ../glibc-$(GLIBC_VERSION)-ros \
402              | grep -v "Only in ../glibc-$(GLIBC_VERSION)" \
403              | patch -p2 
404
405 glibc-$(GLIBC_VERSION): glibc-$(GLIBC_VERSION).tar.bz2
406         rm -rf glibc-$(GLIBC_VERSION)
407         tar -jxf glibc-$(GLIBC_VERSION).tar.bz2
408         $(MAKE) .glibc-ros-patch
409         patch --no-backup-if-mismatch -p0 < glibc-$(GLIBC_VERSION)-riscv.patch
410         rm glibc-$(GLIBC_VERSION)/sysdeps/riscv/elf/start.S
411         rm glibc-$(GLIBC_VERSION)/sysdeps/i386/elf/start.S
412         rm glibc-$(GLIBC_VERSION)/sysdeps/x86_64/elf/start.S
413
414 $(BINARY_PREFIX)glibc-stage1-builddir: glibc-$(GLIBC_VERSION)
415         rm -rf $@
416         mkdir -p $@
417
418 .$(BINARY_PREFIX)glibc-stage1-configure: 
419         $(MAKE) $(BINARY_PREFIX)glibc-stage1-builddir;
420         cd $(BINARY_PREFIX)glibc-stage1-builddir; \
421         ../glibc-$(GLIBC_VERSION)/configure \
422                   --host=$(ARCH)-ros \
423                   --prefix=$(INSTDIR)/$(ARCH)-ros \
424                   --enable-hacker-mode \
425                   --disable-shared \
426               --disable-add-ons \
427                   --disable-nls \
428                   --with-headers=$(INSTDIR)/$(ARCH)-ros/sys-include \
429                   --with-elf \
430                   --with-tls \
431                   --with-__thread \
432                   $(GLIBC_CONFIGURE_FLAGS) \
433                   CFLAGS="$(ARCH_CFLAGS) -g -fpermissive -O2 -pipe";
434         touch $@
435
436 .$(BINARY_PREFIX)glibc-stage1-install: .$(BINARY_PREFIX)glibc-stage1-configure
437         cd $(BINARY_PREFIX)glibc-stage1-builddir; \
438         comma=, make -j $(MAKE_JOBS) install-headers install-bootstrap-headers=yes; \
439
440 ####################################
441 ########## Glibc Stage 2  ##########
442 ####################################
443 $(BINARY_PREFIX)glibc-stage2-builddir: glibc-$(GLIBC_VERSION)
444         rm -rf $@
445         mkdir -p $@
446
447 .$(BINARY_PREFIX)glibc-stage2-configure: 
448         $(MAKE) $(BINARY_PREFIX)glibc-stage2-builddir
449         cd $(BINARY_PREFIX)glibc-stage2-builddir; \
450         ../glibc-$(GLIBC_VERSION)/configure \
451                   --host=$(ARCH)-ros \
452                   --enable-hacker-mode \
453                   --enable-shared \
454                   --disable-nls \
455                   --with-elf \
456                   --with-tls \
457                   --with-__thread \
458                   --with-headers=$(INSTDIR)/$(ARCH)-ros/sys-include \
459                   --prefix=$(INSTDIR)/$(ARCH)-ros \
460                   libc_cv_forced_unwind=yes \
461                   libc_cv_c_cleanup=yes \
462                   $(GLIBC_CONFIGURE_FLAGS) \
463                   CFLAGS="$(ARCH_CFLAGS) -g -fpermissive -O2 -pipe";
464         touch $@
465
466 .$(BINARY_PREFIX)glibc-stage2-make: .$(BINARY_PREFIX)glibc-stage2-configure
467         cd $(BINARY_PREFIX)glibc-stage2-builddir; \
468         make -j $(MAKE_JOBS) || make -j $(MAKE_JOBS)
469
470 .$(BINARY_PREFIX)glibc-stage2-install: .$(BINARY_PREFIX)glibc-stage2-make
471         cd $(BINARY_PREFIX)glibc-stage2-builddir; \
472         make -j $(MAKE_JOBS) install
473
474 #################################
475 ####### ROS Libs Install #######
476 #################################
477 .$(BINARY_PREFIX)ros-libs-install:
478         cd $(ROSDIR); \
479         make ARCH=$(ROS_ARCH_DIR) userclean; \
480         make ARCH=$(ROS_ARCH_DIR) -j $(MAKE_JOBS) install-libs
481
482 ##################################
483 ########### Gcc Stage 3 ##########
484 ##################################
485 $(BINARY_PREFIX)gcc-stage3-builddir: gcc-$(GCC_VERSION)
486         rm -rf $@
487         mkdir -p $@
488
489 native-gcc-stage3-prep:
490         mkdir -p $(INSTDIR)/usr; \
491         cp -R $(CXXROOT)/$(ARCH)-ros/sys-include  $(INSTDIR)/usr/include; \
492         cp -R $(CXXROOT)/$(ARCH)-ros/lib* $(INSTDIR)/usr; \
493
494 native-gcc-stage3-configure: native-gcc-stage3-prep
495         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
496         ../gcc-$(GCC_VERSION)/configure \
497             --target=$(ARCH)-ros \
498             --host=$(ARCH)-ros \
499             --with-gmp=$(CXXROOT) \
500             --with-mpfr=$(CXXROOT) \
501             --with-mpc=$(CXXROOT) \
502             --prefix=$(INSTDIR) \
503             --disable-nls \
504             --disable-werror \
505             --disable-multilib \
506             --enable-shared \
507             --enable-tls \
508             --enable-libgomp \
509             --enable-languages=c,c++ \
510             --with-__thread \
511             $(GCC_BUILD_FLAGS);
512
513 cross-gcc-stage3-configure:
514         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
515         ../gcc-$(GCC_VERSION)/configure \
516             --target=$(ARCH)-ros \
517             --program-prefix=$(BINARY_PREFIX) \
518             --prefix=$(INSTDIR) \
519             --disable-nls \
520             --disable-werror \
521             --disable-multilib \
522             --enable-shared \
523             --enable-tls \
524             --enable-libgomp \
525             --enable-languages=c,c++ \
526             --with-__thread \
527             --with-headers=$(INSTDIR)/$(ARCH)-ros/include \
528             $(GCC_BUILD_FLAGS);
529
530 .$(BINARY_PREFIX)gcc-stage3-configure:
531         $(MAKE) $(BINARY_PREFIX)gcc-stage3-builddir
532         if [ "$(NATIVE_BUILD)" = "true" ]; then \
533                 $(MAKE) native-gcc-stage3-configure; \
534         else \
535                 $(MAKE) cross-gcc-stage3-configure; \
536         fi
537         echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage3-builddir/Makefile;
538         touch $@
539
540 .$(BINARY_PREFIX)gcc-stage3-make: .$(BINARY_PREFIX)gcc-stage3-configure
541         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
542         make -j $(MAKE_JOBS)
543
544 .$(BINARY_PREFIX)gcc-stage3-install: .$(BINARY_PREFIX)gcc-stage3-make
545         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
546         make -j $(MAKE_JOBS) install
547
548 ##################################
549 ######### GMP, MPFR, MPC #########
550 ##################################
551 gmp-$(GMP_VERSION): gmp-$(GMP_VERSION).tar.bz2
552         rm -rf gmp-$(GMP_VERSION)
553         tar -jxf gmp-$(GMP_VERSION).tar.bz2
554         patch -p0 < gmp-$(GMP_VERSION)-ros.patch
555
556 mpfr-$(MPFR_VERSION): mpfr-$(MPFR_VERSION).tar.bz2
557         rm -rf mpfr-$(MPFR_VERSION)
558         tar -jxf mpfr-$(MPFR_VERSION).tar.bz2
559         patch -p0 < mpfr-$(MPFR_VERSION)-ros.patch
560
561 mpc-$(MPC_VERSION): mpc-$(MPC_VERSION).tar.gz
562         rm -rf mpc-$(MPC_VERSION)
563         tar -zxf mpc-$(MPC_VERSION).tar.gz
564         patch -p0 < mpc-$(MPC_VERSION)-ros.patch
565
566 $(BINARY_PREFIX)gmp-builddir: gmp-$(GMP_VERSION)
567         rm -rf $@
568         mkdir -p $@
569
570 $(BINARY_PREFIX)mpfr-builddir: mpfr-$(MPFR_VERSION)
571         rm -rf $@
572         mkdir -p $@
573
574 $(BINARY_PREFIX)mpc-builddir: mpc-$(MPC_VERSION)
575         rm -rf $@
576         mkdir -p $@
577
578 .$(BINARY_PREFIX)gmp-configure:
579         $(MAKE) $(BINARY_PREFIX)gmp-builddir
580         cd $(BINARY_PREFIX)gmp-builddir; \
581         ../gmp-$(GMP_VERSION)/configure \
582             --disable-static \
583             --prefix=$(INSTDIR) \
584             --host=$(ARCH)-ros
585         touch $@
586
587 .$(BINARY_PREFIX)mpfr-configure:
588         $(MAKE) $(BINARY_PREFIX)mpfr-builddir
589         cd $(BINARY_PREFIX)mpfr-builddir; \
590         ../mpfr-$(MPFR_VERSION)/configure \
591             --disable-static \
592             --prefix=$(INSTDIR) \
593             --with-gmp=$(INSTDIR) \
594             --host=$(ARCH)-ros
595         touch $@
596
597 .$(BINARY_PREFIX)mpc-configure:
598         $(MAKE) $(BINARY_PREFIX)mpc-builddir
599         cd $(BINARY_PREFIX)mpc-builddir; \
600         ../mpc-$(MPC_VERSION)/configure \
601             --disable-static \
602             --prefix=$(INSTDIR) \
603             --with-gmp=$(INSTDIR) \
604             --with-mpfr=$(INSTDIR) \
605             --host=$(ARCH)-ros
606         touch $@
607
608 .$(BINARY_PREFIX)gmp-make: .$(BINARY_PREFIX)gmp-configure
609         cd $(BINARY_PREFIX)gmp-builddir; \
610         make -j $(MAKE_JOBS)
611
612 .$(BINARY_PREFIX)mpfr-make: .$(BINARY_PREFIX)mpfr-configure
613         cd $(BINARY_PREFIX)mpfr-builddir; \
614         make -j $(MAKE_JOBS)
615
616 .$(BINARY_PREFIX)mpc-make: .$(BINARY_PREFIX)mpc-configure
617         cd $(BINARY_PREFIX)mpc-builddir; \
618         make -j $(MAKE_JOBS)
619
620 .$(BINARY_PREFIX)gmp-install: .$(BINARY_PREFIX)gmp-make
621         cd $(BINARY_PREFIX)gmp-builddir; \
622         make -j $(MAKE_JOBS) install
623
624 .$(BINARY_PREFIX)mpfr-install: .$(BINARY_PREFIX)mpfr-make
625         cd $(BINARY_PREFIX)mpfr-builddir; \
626         make -j $(MAKE_JOBS) install
627
628 .$(BINARY_PREFIX)mpc-install: .$(BINARY_PREFIX)mpc-make
629         cd $(BINARY_PREFIX)mpc-builddir; \
630         make -j $(MAKE_JOBS) install
631
632 ##################################
633 ######## Clean it all up! ########
634 ##################################
635 clean:
636         rm -rf binutils-$(BINUTILS_VERSION) 
637         rm -rf gcc-$(GCC_VERSION) 
638         rm -rf glibc-$(GLIBC_VERSION) 
639         rm -rf gmp-$(GMP_VERSION)
640         rm -rf mpfr-$(MPFR_VERSION)
641         rm -rf mpc-$(MPC_VERSION)
642         rm -rf *-builddir
643         rm -rf .*-ros-*-configure
644         rm -rf *$(BINARY_PREFIX)install.bak
645