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