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