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