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