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