Fixes XCC texinfo dependency
[akaros.git] / tools / compilers / gcc-glibc / Makefile
index cddf99a..0850d5f 100644 (file)
@@ -38,7 +38,7 @@ DESTDIR ?= /
 # Configuration parameters for make-riscv
 RISCV_ARCH := riscv
 RISCV_BINARY_PREFIX := $(RISCV_ARCH)-ros-
-RISCV_GCC_BUILD_FLAGS :=
+RISCV_GCC_BUILD_FLAGS := 
 RISCV_CFLAGS :=
 
 # Configuration parameters for x86
@@ -71,7 +71,6 @@ riscv:
        $(MAKE) make-all
 
 x86:
-       $(MAKE) .glibc-patch
        export LD_LIBRARY_PATH=; \
        export DESTDIR=$(DESTDIR);\
        export INSTDIR=$(X86_INSTDIR);\
@@ -84,15 +83,15 @@ x86:
        $(MAKE) make-all
 
 make-all: 
-       $(MAKE) .glibc-patch
        $(MAKE) .$(BINARY_PREFIX)binutils-make
        $(MAKE) .$(BINARY_PREFIX)binutils-install
        $(MAKE) .$(BINARY_PREFIX)ros-headers-install
-       $(MAKE) .$(BINARY_PREFIX)glibc-headers-install
        $(MAKE) .$(BINARY_PREFIX)gcc-stage1-make
        $(MAKE) .$(BINARY_PREFIX)gcc-stage1-install
+       $(MAKE) .$(BINARY_PREFIX)ros-install-dummy-libs
        $(MAKE) .$(BINARY_PREFIX)glibc-make
        $(MAKE) .$(BINARY_PREFIX)glibc-install
+       $(MAKE) .$(BINARY_PREFIX)ros-install-libs
        $(MAKE) .$(BINARY_PREFIX)gcc-stage2-make
        $(MAKE) .$(BINARY_PREFIX)gcc-stage2-install
        mkdir -p $(ROSDIR)/fs/$(ARCH)/lib
@@ -130,7 +129,6 @@ gcc-clean:
        make clean
 
 glibc-clean:
-       cd $(BINARY_PREFIX)glibc-headers-builddir; \
        cd $(BINARY_PREFIX)glibc-builddir; \
        make clean
 
@@ -146,21 +144,31 @@ binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2
 gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2
        rm -rf gcc-$(GCC_VERSION)
        tar -jxf gcc-$(GCC_VERSION).tar.bz2
-       patch -p0 < gcc-$(GCC_VERSION)-ros.patch
+       $(MAKE) .gcc-ros-patch
        patch --no-backup-if-mismatch -p0 < gcc-$(GCC_VERSION)-riscv.patch
 
+.gcc-ros-patch:
+       -cd gcc-$(GCC_VERSION); \
+       diff -ruB --unidirectional-new-file \
+            ../gcc-$(GCC_VERSION) \
+            ../gcc-$(GCC_VERSION)-ros \
+            | grep -v "Only in ../gcc-$(GCC_VERSION)" \
+            | patch -p2 
+
 glibc-$(GLIBC_VERSION): glibc-$(GLIBC_VERSION).tar.bz2
        rm -rf glibc-$(GLIBC_VERSION)
        tar -jxf glibc-$(GLIBC_VERSION).tar.bz2
+       $(MAKE) .glibc-ros-patch
+       patch --no-backup-if-mismatch -p0 < glibc-$(GLIBC_VERSION)-riscv.patch
        rm glibc-$(GLIBC_VERSION)/sysdeps/sparc/sparc32/elf/start.S
+       rm glibc-$(GLIBC_VERSION)/sysdeps/riscv/elf/start.S
+       rm glibc-$(GLIBC_VERSION)/sysdeps/riscv/init-first.c
        rm glibc-$(GLIBC_VERSION)/sysdeps/i386/elf/start.S
        rm glibc-$(GLIBC_VERSION)/sysdeps/i386/____longjmp_chk.S
        rm glibc-$(GLIBC_VERSION)/sysdeps/i386/init-first.c
        rm glibc-$(GLIBC_VERSION)/sysdeps/i386/sysdep.h
-       $(MAKE) .glibc-patch
-       patch --no-backup-if-mismatch -p0 < glibc-$(GLIBC_VERSION)-riscv.patch
 
-.glibc-patch: glibc-$(GLIBC_VERSION)
+.glibc-ros-patch:
        -cd glibc-$(GLIBC_VERSION); \
        diff -ruB --unidirectional-new-file \
             ../glibc-$(GLIBC_VERSION) \
@@ -170,10 +178,6 @@ glibc-$(GLIBC_VERSION): glibc-$(GLIBC_VERSION).tar.bz2
 
 $(BINARY_PREFIX)binutils-builddir: binutils-$(BINUTILS_VERSION)
        rm -rf $@
-       cp -R binutils-$(BINUTILS_VERSION) $@
-
-$(BINARY_PREFIX)glibc-headers-builddir: glibc-$(GLIBC_VERSION)
-       rm -rf $@
        mkdir -p $@
 
 $(BINARY_PREFIX)gcc-stage1-builddir: gcc-$(GCC_VERSION)
@@ -191,13 +195,15 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
 .$(BINARY_PREFIX)binutils-configure: 
        $(MAKE) $(BINARY_PREFIX)binutils-builddir 
        cd $(BINARY_PREFIX)binutils-builddir; \
-       ./configure --enable-shared \
+       ../binutils-$(BINUTILS_VERSION)/configure \
+                   --enable-shared \
                    --disable-multilib \
                    --disable-nls \
                    --target=$(ARCH)-ros \
                    --prefix=$(INSTDIR) \
                    --includedir=$(INSTDIR)/include \
                    --disable-werror;
+       echo "MAKEINFO = :" >> $(BINARY_PREFIX)binutils-builddir/Makefile;
        touch $@
 
 .$(BINARY_PREFIX)binutils-make: .$(BINARY_PREFIX)binutils-configure
@@ -208,30 +214,6 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
        cd $(BINARY_PREFIX)binutils-builddir; \
        make -j $(MAKE_JOBS) install
 
-.$(BINARY_PREFIX)glibc-headers-configure:
-       $(MAKE) $(BINARY_PREFIX)glibc-headers-builddir
-       cd $(BINARY_PREFIX)glibc-headers-builddir; \
-       ../glibc-$(GLIBC_VERSION)/configure \
-                 --host=$(ARCH)-ros \
-                 --enable-hacker-mode \
-                 --enable-shared \
-                 --disable-nls \
-                 --with-elf \
-                 --with-tls \
-                 --with-__thread \
-                 --prefix=$(INSTDIR)/$(ARCH)-ros \
-                 --with-headers=$(INSTDIR)/$(ARCH)-ros/sys-include \
-                 libc_cv_forced_unwind=yes \
-                 libc_cv_c_cleanup=yes;
-       touch $@
-
-.$(BINARY_PREFIX)glibc-headers-install: .$(BINARY_PREFIX)glibc-headers-configure
-       cd $(BINARY_PREFIX)glibc-headers-builddir; \
-       make -j $(MAKE_JOBS) install-headers; \
-       mkdir -p $(INSTDIR)/$(ARCH)-ros/include/gnu; \
-       echo > $(INSTDIR)/$(ARCH)-ros/include/gnu/stubs.h; \
-       cp bits/stdio_lim.h $(INSTDIR)/$(ARCH)-ros/include/bits/
-
 .$(BINARY_PREFIX)ros-headers-install: $(ROSDIR)
        rm -rf $(INSTDIR)/$(ARCH)-ros/sys-include/*
        mkdir -p $(INSTDIR)/$(ARCH)-ros/sys-include
@@ -254,6 +236,7 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
        ../gcc-$(GCC_VERSION)/configure \
                --enable-languages=c \
                --enable-shared \
+               --enable-tls \
                --disable-checking \
                --disable-werror \
                --disable-multilib \
@@ -267,6 +250,7 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
                --prefix=$(INSTDIR) \
                --with-headers=$(INSTDIR)/$(ARCH)-ros/include \
                $(GCC_BUILD_FLAGS);
+       echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage1-builddir/Makefile;
        touch $@
 
 .$(BINARY_PREFIX)gcc-stage1-make: .$(BINARY_PREFIX)gcc-stage1-configure
@@ -283,6 +267,10 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
        #-ln -vs libgcc.a `$(BINARY_PREFIX)gcc -print-libgcc-file-name | \
        #                 sed 's/libgcc/&_eh/'`
 
+.$(BINARY_PREFIX)ros-install-dummy-libs:
+       rm -rf $(INSTDIR)/$(ARCH)-ros/lib/libparlib.a
+       $(ARCH)-ros-ar cr $(INSTDIR)/$(ARCH)-ros/lib/libparlib.a
+
 .$(BINARY_PREFIX)glibc-configure: 
        $(MAKE) $(BINARY_PREFIX)glibc-builddir
        cd $(BINARY_PREFIX)glibc-builddir; \
@@ -309,11 +297,18 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
        cd $(BINARY_PREFIX)glibc-builddir; \
        make -j $(MAKE_JOBS) install
 
+.$(BINARY_PREFIX)ros-install-libs:
+       cd $(ROSDIR); \
+       make userclean; \
+       make TARGET_ARCH=$(ARCH) -j $(MAKE_JOBS) install-libs
+
 .$(BINARY_PREFIX)gcc-stage2-configure:
        $(MAKE) $(BINARY_PREFIX)gcc-stage2-builddir
        cd $(BINARY_PREFIX)gcc-stage2-builddir; \
        ../gcc-$(GCC_VERSION)/configure \
                  --enable-shared \
+                 --enable-tls \
+                 --enable-libgomp \
                  --disable-multilib \
                  --disable-nls \
                  --program-prefix=$(BINARY_PREFIX) \
@@ -321,10 +316,11 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
                  --prefix=$(INSTDIR) \
                  --enable-languages=c,c++ \
                  $(GCC_BUILD_FLAGS) \
-                 --with-tls \
+                 --without-libffi \
                  --with-__thread \
                  --with-headers=$(INSTDIR)/$(ARCH)-ros/include \
                  --disable-werror;
+       echo "MAKEINFO = :" >> $(BINARY_PREFIX)gcc-stage2-builddir/Makefile;
        touch $@
 
 .$(BINARY_PREFIX)gcc-stage2-make: .$(BINARY_PREFIX)gcc-stage2-configure
@@ -335,7 +331,7 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
        cd $(BINARY_PREFIX)gcc-stage2-builddir; \
        make -j $(MAKE_JOBS) install
 
-patches:
+patches: gcc-$(GCC_VERSION) binutils-$(BINUTILS_VERSION)
        rm -rf orig-src
        mkdir orig-src