Builds the NSS in staticly (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                 --enable-static-nss \
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                 --enable-static-nss \
512                 $(GLIBC_CONFIGURE_FLAGS);
513         touch $@
514
515 .$(BINARY_PREFIX)glibc-stage2-make: .$(BINARY_PREFIX)glibc-stage2-configure
516         cd $(BINARY_PREFIX)glibc-stage2-builddir; \
517         make -j $(MAKE_JOBS)
518
519 .$(BINARY_PREFIX)glibc-stage2-install: .$(BINARY_PREFIX)glibc-stage2-make
520         cd $(BINARY_PREFIX)glibc-stage2-builddir; \
521         make -j $(MAKE_JOBS) install_root=$(SYSROOT) install
522
523 ###################################
524 ####### AKAROS Libs Install #######
525 ###################################
526 .$(BINARY_PREFIX)akaros-libs-install:
527         cd $(ROSDIR); \
528         make ARCH=$(ROS_ARCH_DIR) userclean; \
529         make ARCH=$(ROS_ARCH_DIR) -j $(MAKE_JOBS) install-libs
530
531 ##################################
532 ########### Gcc Stage 3 ##########
533 ##################################
534 $(BINARY_PREFIX)gcc-stage3-builddir: gcc-$(GCC_VERSION)
535         rm -rf $@
536         mkdir -p $@
537
538 native-gcc-stage3-prep:
539         mkdir -p $(INSTDIR)/usr; \
540
541 native-gcc-stage3-configure: native-gcc-stage3-prep
542         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
543         ../gcc-$(GCC_VERSION)/configure \
544                 --target=$(ARCH)-ucb-akaros \
545                 --host=$(ARCH)-ucb-akaros \
546                 --prefix=$(INSTDIR) \
547                 --with-gmp=$(CXXROOT) \
548                 --with-mpfr=$(CXXROOT) \
549                 --with-mpc=$(CXXROOT) \
550                 --enable-languages=c,c++ \
551                 --with-pkgversion="akaros-repo" \
552                 --disable-__cxa_atexit \
553                 --disable-mudflap \
554                 --enable-libgomp \
555                 --disable-libssp \
556                 --disable-libquadmath \
557                 --disable-libquadmath-support \
558                 --with-ppl=no \
559                 --with-isl=no \
560                 --with-cloog=no \
561                 --with-libelf=no \
562                 --enable-threads=no \
563                 --enable-tls \
564                 --disable-nls \
565                 --disable-multilib \
566                 --enable-c99 \
567                 --enable-long-long \
568                 --enable-shared \
569                 $(GCC_BUILD_FLAGS);
570
571 cross-gcc-stage3-configure:
572         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
573         CFLAGS="-O2 -g -pipe" \
574         CXXFLAGS="-O2 -g -pipe" \
575         LDFLAGS="-lstdc++ -lm" \
576         ../gcc-$(GCC_VERSION)/configure \
577                 --target=$(ARCH)-ucb-akaros \
578                 --prefix=$(INSTDIR) \
579                 --with-sysroot=$(SYSROOT) \
580                 --enable-languages=c,c++ \
581                 --with-pkgversion="akaros-repo" \
582                 --disable-__cxa_atexit \
583                 --disable-mudflap \
584                 --enable-libgomp \
585                 --disable-libssp \
586                 --disable-libquadmath \
587                 --disable-libquadmath-support \
588                 --with-ppl=no \
589                 --with-isl=no \
590                 --with-cloog=no \
591                 --with-libelf=no \
592                 --enable-threads=no \
593                 --disable-nls \
594                 --disable-multilib \
595                 --with-local-prefix=$(SYSROOT) \
596                 --enable-c99 \
597                 --enable-long-long \
598                 --enable-shared \
599                 $(GCC_BUILD_FLAGS);
600
601 .$(BINARY_PREFIX)gcc-stage3-configure:
602         $(MAKE) $(BINARY_PREFIX)gcc-stage3-builddir
603         if [ "$(NATIVE_BUILD)" = "true" ]; then \
604                 $(MAKE) native-gcc-stage3-configure; \
605         else \
606                 $(MAKE) cross-gcc-stage3-configure; \
607         fi
608         echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage3-builddir/Makefile;
609         touch $@
610
611 .$(BINARY_PREFIX)gcc-stage3-make: .$(BINARY_PREFIX)gcc-stage3-configure
612         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
613         make -j $(MAKE_JOBS)
614
615 .$(BINARY_PREFIX)gcc-stage3-install: .$(BINARY_PREFIX)gcc-stage3-make
616         cd $(BINARY_PREFIX)gcc-stage3-builddir; \
617         make -j $(MAKE_JOBS) install
618
619 ##################################
620 ######### GMP, MPFR, MPC #########
621 ##################################
622 gmp-$(GMP_VERSION): gmp-$(GMP_VERSION).tar.bz2
623         rm -rf gmp-$(GMP_VERSION)
624         tar -jxf gmp-$(GMP_VERSION).tar.bz2
625         patch -p0 < gmp-$(GMP_VERSION)-akaros.patch
626
627 mpfr-$(MPFR_VERSION): mpfr-$(MPFR_VERSION).tar.bz2
628         rm -rf mpfr-$(MPFR_VERSION)
629         tar -jxf mpfr-$(MPFR_VERSION).tar.bz2
630         patch -p0 < mpfr-$(MPFR_VERSION)-akaros.patch
631
632 mpc-$(MPC_VERSION): mpc-$(MPC_VERSION).tar.gz
633         rm -rf mpc-$(MPC_VERSION)
634         tar -zxf mpc-$(MPC_VERSION).tar.gz
635         patch -p0 < mpc-$(MPC_VERSION)-akaros.patch
636
637 $(BINARY_PREFIX)gmp-builddir: gmp-$(GMP_VERSION)
638         rm -rf $@
639         mkdir -p $@
640
641 $(BINARY_PREFIX)mpfr-builddir: mpfr-$(MPFR_VERSION)
642         rm -rf $@
643         mkdir -p $@
644
645 $(BINARY_PREFIX)mpc-builddir: mpc-$(MPC_VERSION)
646         rm -rf $@
647         mkdir -p $@
648
649 .$(BINARY_PREFIX)gmp-configure:
650         $(MAKE) $(BINARY_PREFIX)gmp-builddir
651         cd $(BINARY_PREFIX)gmp-builddir; \
652         ../gmp-$(GMP_VERSION)/configure \
653             --disable-static \
654             --prefix=$(INSTDIR) \
655             --host=$(ARCH)-ucb-akaros
656         touch $@
657
658 .$(BINARY_PREFIX)mpfr-configure:
659         $(MAKE) $(BINARY_PREFIX)mpfr-builddir
660         cd $(BINARY_PREFIX)mpfr-builddir; \
661         ../mpfr-$(MPFR_VERSION)/configure \
662             --disable-static \
663             --prefix=$(INSTDIR) \
664             --with-gmp=$(INSTDIR) \
665             --host=$(ARCH)-ucb-akaros
666         touch $@
667
668 .$(BINARY_PREFIX)mpc-configure:
669         $(MAKE) $(BINARY_PREFIX)mpc-builddir
670         cd $(BINARY_PREFIX)mpc-builddir; \
671         ../mpc-$(MPC_VERSION)/configure \
672             --disable-static \
673             --prefix=$(INSTDIR) \
674             --with-gmp=$(INSTDIR) \
675             --with-mpfr=$(INSTDIR) \
676             --host=$(ARCH)-ucb-akaros
677         touch $@
678
679 .$(BINARY_PREFIX)gmp-make: .$(BINARY_PREFIX)gmp-configure
680         cd $(BINARY_PREFIX)gmp-builddir; \
681         make -j $(MAKE_JOBS)
682
683 .$(BINARY_PREFIX)mpfr-make: .$(BINARY_PREFIX)mpfr-configure
684         cd $(BINARY_PREFIX)mpfr-builddir; \
685         make -j $(MAKE_JOBS)
686
687 .$(BINARY_PREFIX)mpc-make: .$(BINARY_PREFIX)mpc-configure
688         cd $(BINARY_PREFIX)mpc-builddir; \
689         make -j $(MAKE_JOBS)
690
691 .$(BINARY_PREFIX)gmp-install: .$(BINARY_PREFIX)gmp-make
692         cd $(BINARY_PREFIX)gmp-builddir; \
693         make -j $(MAKE_JOBS) install
694
695 .$(BINARY_PREFIX)mpfr-install: .$(BINARY_PREFIX)mpfr-make
696         cd $(BINARY_PREFIX)mpfr-builddir; \
697         make -j $(MAKE_JOBS) install
698
699 .$(BINARY_PREFIX)mpc-install: .$(BINARY_PREFIX)mpc-make
700         cd $(BINARY_PREFIX)mpc-builddir; \
701         make -j $(MAKE_JOBS) install
702
703 ##################################
704 ######## Clean it all up! ########
705 ##################################
706 clean:
707         rm -rf binutils-$(BINUTILS_VERSION) 
708         rm -rf gcc-$(GCC_VERSION) 
709         rm -rf glibc-$(GLIBC_VERSION) 
710         rm -rf gmp-$(GMP_VERSION)
711         rm -rf mpfr-$(MPFR_VERSION)
712         rm -rf mpc-$(MPC_VERSION)
713         rm -rf *-builddir
714         rm -rf .*-configure
715         rm -rf *$(BINARY_PREFIX)install.bak
716         rm -rf .glibc-$(GLIBC_VERSION)-akaros.patch
717         rm -rf .gcc-$(GCC_VERSION)-akaros.patch