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