kconfig: use pkg-config for ncurses detection
[akaros.git] / tools / compilers / gcc-glibc / Makefile
index 41f4f8b..736499b 100644 (file)
@@ -1,15 +1,21 @@
 # Number of make jobs to spawn.  Define it in Makelocal
 MAKE_JOBS ?= $(shell expr `cat /proc/cpuinfo | grep processor | wc -l` - 1)
 
-BINUTILS_VERSION := 2.24
+BINUTILS_VERSION := 2.30
 GCC_VERSION := 4.9.2
 GLIBC_VERSION := 2.19
 GMP_VERSION := 5.1.3
 MPFR_VERSION := 3.1.2
 MPC_VERSION := 1.0.2
 
+ifndef AKAROS_TOOLCHAINS
+    $(error AKAROS_TOOLCHAINS is empty!  You must set it!)
+endif
+
 # Defines where to install the toolchain
--include Makelocal
+RISCV_INSTDIR         := $(AKAROS_TOOLCHAINS)/riscv-ucb-akaros-gcc/
+X86_64_INSTDIR        := $(AKAROS_TOOLCHAINS)/x86_64-ucb-akaros-gcc/
+X86_64_NATIVE_INSTDIR := $(AKAROS_TOOLCHAINS)/x86_64-ucb-akaros-gcc-native/
 
 define print-usage
        @echo "Usage: make <arch> [ <config> ] [ <subcmd> ] "
@@ -105,7 +111,7 @@ endif
 ifeq ($(ARCH),riscv)
     AKAROS_ARCH_DIR := riscv
     ARCH_CFLAGS :=
-    GLIBC_CONFIGURE_FLAGS := 
+    GLIBC_CONFIGURE_FLAGS :=
     GCC_BUILD_FLAGS :=
 endif
 ifeq ($(CONFIG),cross)
@@ -168,7 +174,7 @@ define BUILD_ERROR
     for this variable in there.
 endef
 BUILD_ERRORS := $(call add_error, $(BUILD_ERROR))
-endif 
+endif
 
 ifeq ($(CONFIG),native)
 ifeq ($(shell which $(ARCH)-ucb-akaros-gcc 2>/dev/null),)
@@ -234,25 +240,32 @@ unexport LD_LIBRARY_PATH
 check-env-real:
        @echo "    Your environment checks out. Build away!"
 
+define make_and_log
+       $(MAKE) $(1) > build_logs/$(2).log 2>&1
+       @echo "make $(2) succeeded"
+endef
+
 ifeq ($(CONFIG),cross)
 build-real:
-       $(MAKE) .$(BINARY_PREFIX)binutils-install
-       $(MAKE) .$(BINARY_PREFIX)gcc-stage1-install
-       $(MAKE) .$(BINARY_PREFIX)headers-clean
-       $(MAKE) .$(BINARY_PREFIX)akaros-headers-install
-       $(MAKE) .$(BINARY_PREFIX)dummy-libs-install
-       $(MAKE) .$(BINARY_PREFIX)glibc-stage1-install
-       $(MAKE) .$(BINARY_PREFIX)gcc-stage2-install
-       $(MAKE) .$(BINARY_PREFIX)glibc-stage2-install
-       $(MAKE) .$(BINARY_PREFIX)akaros-libs-install
-       $(MAKE) .$(BINARY_PREFIX)gcc-stage3-install
-       $(MAKE) .$(BINARY_PREFIX)gmp-install
-       $(MAKE) .$(BINARY_PREFIX)mpfr-install
-       $(MAKE) .$(BINARY_PREFIX)mpc-install
+       $(shell mkdir -p build_logs)
+       $(call make_and_log,.$(BINARY_PREFIX)binutils-install,$(BINARY_PREFIX)binutils-install)
+       $(call make_and_log,.$(BINARY_PREFIX)gcc-stage1-install,$(BINARY_PREFIX)gcc-stage1-install)
+       $(call make_and_log,.$(BINARY_PREFIX)headers-clean,$(BINARY_PREFIX)headers-clean)
+       $(call make_and_log,.$(BINARY_PREFIX)akaros-headers-install,$(BINARY_PREFIX)akaros-headers-install)
+       $(call make_and_log,.$(BINARY_PREFIX)dummy-libs-install,$(BINARY_PREFIX)dummy-libs-install)
+       $(call make_and_log,.$(BINARY_PREFIX)glibc-stage1-install,$(BINARY_PREFIX)glibc-stage1-install)
+       $(call make_and_log,.$(BINARY_PREFIX)gcc-stage2-install,$(BINARY_PREFIX)gcc-stage2-install)
+       $(call make_and_log,.$(BINARY_PREFIX)glibc-stage2-install,$(BINARY_PREFIX)glibc-stage2-install)
+       $(call make_and_log,.$(BINARY_PREFIX)akaros-libs-install,$(BINARY_PREFIX)akaros-libs-install)
+       $(call make_and_log,.$(BINARY_PREFIX)gcc-stage3-install,$(BINARY_PREFIX)gcc-stage3-install)
+       $(call make_and_log,.$(BINARY_PREFIX)gmp-install,$(BINARY_PREFIX)gmp-install)
+       $(call make_and_log,.$(BINARY_PREFIX)mpfr-install,$(BINARY_PREFIX)mpfr-install)
+       $(call make_and_log,.$(BINARY_PREFIX)mpc-install,$(BINARY_PREFIX)mpc-install)
 else
 build-real:
-       $(MAKE) .$(BINARY_PREFIX)binutils-install
-       $(MAKE) .$(BINARY_PREFIX)gcc-stage3-install
+       $(shell mkdir -p build_logs)
+       $(call make_and_log,.$(BINARY_PREFIX)binutils-install,$(BINARY_PREFIX)binutils-install)
+       $(call make_and_log,.$(BINARY_PREFIX)gcc-stage3-install,$(BINARY_PREFIX)gcc-stage3-install)
 endif
 
 uninstall-real:
@@ -277,7 +290,6 @@ binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2
        rm -rf binutils-$(BINUTILS_VERSION);
        tar -jxf binutils-$(BINUTILS_VERSION).tar.bz2
        patch -p0 < binutils-$(BINUTILS_VERSION)-akaros.patch
-       patch --no-backup-if-mismatch -p0 < binutils-$(BINUTILS_VERSION)-riscv.patch
 
 $(BINARY_PREFIX)binutils-builddir: binutils-$(BINUTILS_VERSION)
        rm -rf $@
@@ -317,8 +329,8 @@ cross-binutils-configure:
                --disable-nls \
                --with-sysroot=$(SYSROOT)
 
-.$(BINARY_PREFIX)binutils-configure: 
-       $(MAKE) $(BINARY_PREFIX)binutils-builddir 
+.$(BINARY_PREFIX)binutils-configure:
+       $(MAKE) $(BINARY_PREFIX)binutils-builddir
        if [ "$(CONFIG)" = "native" ]; then \
                $(MAKE) native-binutils-configure; \
        else \
@@ -342,14 +354,14 @@ binutils-clean:
 #################################
 ########## GCC Stage 1 ##########
 #################################
-.gcc-akaros-patch:
+.gcc-akaros-directory-patch:
        -cd gcc-$(GCC_VERSION); \
        diff -ruB --unidirectional-new-file \
             ../gcc-$(GCC_VERSION) \
             ../gcc-$(GCC_VERSION)-akaros \
             | grep -v "Only in ../gcc-$(GCC_VERSION)" \
-            > ../.gcc-$(GCC_VERSION)-akaros.patch; \
-            patch -p2 < ../.gcc-$(GCC_VERSION)-akaros.patch
+            > ../.gcc-$(GCC_VERSION)-akaros-directory.patch; \
+            patch -p2 < ../.gcc-$(GCC_VERSION)-akaros-directory.patch
 
 gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2 \
                    gmp-$(GMP_VERSION) \
@@ -357,8 +369,10 @@ gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2 \
                    mpc-$(MPC_VERSION)
        rm -rf gcc-$(GCC_VERSION)
        tar -jxf gcc-$(GCC_VERSION).tar.bz2
-       $(MAKE) .gcc-akaros-patch
+       $(MAKE) .gcc-akaros-directory-patch
+       patch --no-backup-if-mismatch -p0 < gcc-$(GCC_VERSION)-r233572.patch
        patch --no-backup-if-mismatch -p0 < gcc-$(GCC_VERSION)-riscv.patch
+       patch --no-backup-if-mismatch -p0 < gcc-$(GCC_VERSION)-existing.patch
        (cd gcc-$(GCC_VERSION) && \
         ln -s ../gmp-$(GMP_VERSION) gmp && \
         ln -s ../mpfr-$(MPFR_VERSION) mpfr && \
@@ -368,7 +382,7 @@ $(BINARY_PREFIX)gcc-stage1-builddir: gcc-$(GCC_VERSION)
        rm -rf $@
        mkdir -p $@
 
-.$(BINARY_PREFIX)gcc-stage1-configure: 
+.$(BINARY_PREFIX)gcc-stage1-configure:
        $(MAKE) $(BINARY_PREFIX)gcc-stage1-builddir
        cd $(BINARY_PREFIX)gcc-stage1-builddir; \
        CFLAGS="-O2 -g -pipe" \
@@ -396,6 +410,7 @@ $(BINARY_PREFIX)gcc-stage1-builddir: gcc-$(GCC_VERSION)
                --disable-nls \
                --disable-multilib \
                --enable-languages=c \
+               --enable-linker-build-id \
                $(GCC_BUILD_FLAGS);
        echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage1-builddir/Makefile;
        touch $@
@@ -415,7 +430,7 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
        rm -rf $@
        mkdir -p $@
 
-.$(BINARY_PREFIX)gcc-stage2-configure: 
+.$(BINARY_PREFIX)gcc-stage2-configure:
        $(MAKE) $(BINARY_PREFIX)gcc-stage2-builddir
        cd $(BINARY_PREFIX)gcc-stage2-builddir; \
        CFLAGS="-O2 -g -pipe" \
@@ -443,6 +458,7 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
                --disable-nls \
                --enable-languages=c,c++,fortran \
                --disable-multilib \
+               --enable-linker-build-id \
                $(GCC_BUILD_FLAGS);
        echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage2-builddir/Makefile;
        touch $@
@@ -488,14 +504,14 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
 #################################
 ######### Glibc Stage 1 #########
 #################################
-.glibc-akaros-patch:
+.glibc-akaros-directory-patch:
        -cd glibc-$(GLIBC_VERSION); \
        diff -ruB --unidirectional-new-file \
             ../glibc-$(GLIBC_VERSION) \
             ../glibc-$(GLIBC_VERSION)-akaros \
             | grep -v "Only in ../glibc-$(GLIBC_VERSION)" \
-            > ../.glibc-$(GLIBC_VERSION)-akaros.patch; \
-            patch -p2 < ../.glibc-$(GLIBC_VERSION)-akaros.patch
+            > ../.glibc-$(GLIBC_VERSION)-akaros-directory.patch; \
+            patch -p2 < ../.glibc-$(GLIBC_VERSION)-akaros-directory.patch
 
 # On occasion, include/pthread.h was getting installed in stage 2, clobbering
 # parlib's pthread.h.
@@ -503,14 +519,15 @@ glibc-$(GLIBC_VERSION): glibc-$(GLIBC_VERSION).tar.bz2
        rm -rf glibc-$(GLIBC_VERSION)
        tar -jxf glibc-$(GLIBC_VERSION).tar.bz2
        rm glibc-$(GLIBC_VERSION)/include/pthread.h
-       $(MAKE) .glibc-akaros-patch
+       $(MAKE) .glibc-akaros-directory-patch
        patch --no-backup-if-mismatch -p0 < glibc-$(GLIBC_VERSION)-riscv.patch
+       patch --no-backup-if-mismatch -p0 < glibc-$(GLIBC_VERSION)-existing.patch
 
 $(BINARY_PREFIX)glibc-stage1-builddir: glibc-$(GLIBC_VERSION)
        rm -rf $@
        mkdir -p $@
 
-.$(BINARY_PREFIX)glibc-stage1-configure: 
+.$(BINARY_PREFIX)glibc-stage1-configure:
        $(MAKE) $(BINARY_PREFIX)glibc-stage1-builddir;
        cd $(BINARY_PREFIX)glibc-stage1-builddir; \
        CFLAGS="$(ARCH_CFLAGS) -U_FORTIFY_SOURCE -g -O2 -pipe" \
@@ -562,7 +579,7 @@ $(BINARY_PREFIX)glibc-stage2-builddir: glibc-$(GLIBC_VERSION)
        rm -rf $@
        mkdir -p $@
 
-.$(BINARY_PREFIX)glibc-stage2-configure: 
+.$(BINARY_PREFIX)glibc-stage2-configure:
        $(MAKE) $(BINARY_PREFIX)glibc-stage2-builddir
        cd $(BINARY_PREFIX)glibc-stage2-builddir; \
        CFLAGS="$(ARCH_CFLAGS) -U_FORTIFY_SOURCE -g -O2 -pipe" \
@@ -610,7 +627,7 @@ $(BINARY_PREFIX)glibc-stage2-builddir: glibc-$(GLIBC_VERSION)
 .$(BINARY_PREFIX)akaros-libs-install:
        cd $(AKAROSDIR); \
        make ARCH=$(AKAROS_ARCH_DIR) userclean; \
-       make ARCH=$(AKAROS_ARCH_DIR) -j $(MAKE_JOBS) install-libs
+       make ARCH=$(AKAROS_ARCH_DIR) -j $(MAKE_JOBS) install-base-libs
 
 ##################################
 ########### Gcc Stage 3 ##########
@@ -643,7 +660,7 @@ native-gcc-stage3-configure: native-gcc-stage3-prep
                --with-isl=no \
                --with-cloog=no \
                --with-libelf=no \
-               --enable-threads=no \
+               --enable-threads=akaros \
                --enable-tls \
                --disable-nls \
                --disable-multilib \
@@ -652,6 +669,7 @@ native-gcc-stage3-configure: native-gcc-stage3-prep
                --enable-shared \
                --disable-canonical-prefixes \
                --disable-canonical-system-headers \
+               --enable-linker-build-id \
                $(GCC_BUILD_FLAGS);
 
 cross-gcc-stage3-configure:
@@ -675,7 +693,7 @@ cross-gcc-stage3-configure:
                --with-isl=no \
                --with-cloog=no \
                --with-libelf=no \
-               --enable-threads=no \
+               --enable-threads=akaros \
                --disable-nls \
                --disable-multilib \
                --with-local-prefix=$(SYSROOT) \
@@ -684,6 +702,7 @@ cross-gcc-stage3-configure:
                --enable-shared \
                --disable-canonical-prefixes \
                --disable-canonical-system-headers \
+               --enable-linker-build-id \
                $(GCC_BUILD_FLAGS);
 
 .$(BINARY_PREFIX)gcc-stage3-configure: