Move vfprintf.c out from sysdeps (XCC)
[akaros.git] / tools / compilers / gcc-glibc / Makefile
index 350d290..5d8ef20 100644 (file)
@@ -1,5 +1,5 @@
 # Number of make jobs to spawn.  Define it in Makelocal
-MAKE_JOBS :=
+MAKE_JOBS ?= $(shell expr `cat /proc/cpuinfo | grep processor | wc -l` - 1)
 
 BINUTILS_VERSION := 2.24
 GCC_VERSION := 4.9.2
@@ -15,7 +15,7 @@ define print-usage
        @echo "Usage: make <arch> [ <config> ] [ <subcmd> ] "
        @echo "    Valid archs are: 'x86_64', 'riscv'"
        @echo "    Valid configs are: 'cross', 'native'"
-       @echo "    Valid subcommands are: 'build', 'uninstall', check-env'"
+       @echo "    Valid subcommands are: 'build', 'uninstall', check-env' 'install-headers'"
        @echo "    If no config is specified, the 'cross' config is assumed by default."
        @echo "    If no subcommand is specified, the 'build' subcommand is assumed by default."
        @echo ""
@@ -30,7 +30,7 @@ endef
 ifndef AKAROS_COMPILER_REAL_BUILD
 VALID_ARCHS := x86_64 riscv
 VALID_CONFIGS := cross native
-VALID_SUBCMDS := build uninstall check-env
+VALID_SUBCMDS := build uninstall check-env install-headers
 VALID_CLEANS := clean inst-clean
 VALID_TARGETS := $(VALID_ARCHS) $(VALID_CONFIGS) \
                  $(VALID_SUBCMDS) $(VALID_CLEANS)
@@ -135,6 +135,31 @@ define BUILD_ERROR
 endef
 BUILD_ERRORS := $(call add_error, $(BUILD_ERROR))
 endif
+
+GPPEXISTS := $(shell which g++ > /dev/null 2>&1 ; echo $$?)
+ifneq ($(GPPEXISTS),0)
+define BUILD_ERROR
+    You need to have 'g++' installed on your system before proceeding!"
+endef
+BUILD_ERRORS := $(call add_error, $(BUILD_ERROR))
+endif
+
+FLEXEXISTS := $(shell which flex > /dev/null 2>&1 ; echo $$?)
+ifneq ($(FLEXEXISTS),0)
+define BUILD_ERROR
+    You need to have 'flex' installed on your system before proceeding!"
+endef
+BUILD_ERRORS := $(call add_error, $(BUILD_ERROR))
+endif
+
+BISONEXISTS := $(shell which bison > /dev/null 2>&1 ; echo $$?)
+ifneq ($(BISONEXISTS),0)
+define BUILD_ERROR
+    You need to have 'bison' installed on your system before proceeding!"
+endef
+BUILD_ERRORS := $(call add_error, $(BUILD_ERROR))
+endif
+
 ifeq ($(INSTDIR),)
 define BUILD_ERROR
     You need to setup $(INSTDIR_STRING), to point to where you
@@ -144,6 +169,7 @@ define BUILD_ERROR
 endef
 BUILD_ERRORS := $(call add_error, $(BUILD_ERROR))
 endif 
+
 ifeq ($(CONFIG),native)
 ifeq ($(shell which $(ARCH)-ucb-akaros-gcc 2>/dev/null),)
 define BUILD_ERROR
@@ -165,6 +191,7 @@ endef
 BUILD_ERRORS := $(call add_error, $(BUILD_ERROR))
 endif
 endif
+
 ifeq ($(ARCH),x86_64)
 ifeq ($(shell grep "CONFIG_X86_64=y" $(AKAROSDIR)/.config),)
 define BUILD_ERROR
@@ -191,7 +218,7 @@ $(MAKECMDGOALS): make-real
 make-real:
        @echo "$${BUILD_ERRORS}" |\
        awk '\
-               BEGIN { RS="<##>"; FS="<##>"; }\
+               BEGIN { RS="$(BUILD_ERROR_DELIMITER)"; FS="$(BUILD_ERROR_DELIMITER)"; }\
                { str[NR] = $$i; }\
                END { for (i = 1; i < NR; i++) {\
                                print "Error Detected:";\
@@ -201,6 +228,9 @@ make-real:
 
 else # BUILD_ERROR
 
+# Make sure that LD_LIBRARY_PATH is not set during the build process
+unexport LD_LIBRARY_PATH
+
 check-env-real:
        @echo "    Your environment checks out. Build away!"
 
@@ -208,6 +238,7 @@ 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
@@ -231,6 +262,8 @@ uninstall-real:
                echo "    Removed $${dir} ($(ARCH)-$(CONFIG)-inst)";\
        fi
 
+install-headers-real: .$(BINARY_PREFIX)akaros-headers-install
+
 %.tar.bz2:
        wget http://akaros.cs.berkeley.edu/xcc/$@
 
@@ -325,6 +358,7 @@ gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2 \
        rm -rf gcc-$(GCC_VERSION)
        tar -jxf gcc-$(GCC_VERSION).tar.bz2
        $(MAKE) .gcc-akaros-patch
+       patch --no-backup-if-mismatch -p0 < gcc-$(GCC_VERSION)-r233572.patch
        patch --no-backup-if-mismatch -p0 < gcc-$(GCC_VERSION)-riscv.patch
        (cd gcc-$(GCC_VERSION) && \
         ln -s ../gmp-$(GMP_VERSION) gmp && \
@@ -363,6 +397,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 $@
@@ -410,6 +445,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 $@
@@ -424,21 +460,23 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
        cd $(BINARY_PREFIX)gcc-stage2-builddir; \
        make -j $(MAKE_JOBS) install-gcc install-target-libgcc;
 
-####################################
-######### AKAROS Headers ###########
-####################################
-.$(BINARY_PREFIX)akaros-headers-install: $(AKAROSDIR)
+#################################
+############ Headers ############
+#################################
+.$(BINARY_PREFIX)headers-clean:
        rm -rf $(SYSROOT)/usr/include/*
+
+.$(BINARY_PREFIX)akaros-headers-install: $(AKAROSDIR)
        mkdir -p $(SYSROOT)/usr/include
+       rm -rf $(SYSROOT)/usr/include/ros
        cp -r $(AKAROSDIR)/kern/include/ros \
            $(SYSROOT)/usr/include/
-       rm -f $(SYSROOT)/usr/include/ros/arch
-       mkdir $(SYSROOT)/usr/include/ros/arch
+       rm -rf $(SYSROOT)/usr/include/ros/arch
+       mkdir -p $(SYSROOT)/usr/include/ros/arch
        cp -r $(AKAROSDIR)/kern/arch/$(AKAROS_ARCH_DIR)/ros/* \
            $(SYSROOT)/usr/include/ros/arch/
-       mkdir -p $(SYSROOT)/usr/include/parlib
        cp -r $(AKAROSDIR)/user/parlib/include/* \
-           $(SYSROOT)/usr/include/parlib/
+           $(SYSROOT)/usr/include/
        cp -r $(AKAROSDIR)/user/pthread/*.h \
            $(SYSROOT)/usr/include/
 
@@ -608,13 +646,16 @@ native-gcc-stage3-configure: native-gcc-stage3-prep
                --with-isl=no \
                --with-cloog=no \
                --with-libelf=no \
-               --enable-threads=no \
+               --enable-threads=posix \
                --enable-tls \
                --disable-nls \
                --disable-multilib \
                --enable-c99 \
                --enable-long-long \
                --enable-shared \
+               --disable-canonical-prefixes \
+               --disable-canonical-system-headers \
+               --enable-linker-build-id \
                $(GCC_BUILD_FLAGS);
 
 cross-gcc-stage3-configure:
@@ -638,13 +679,16 @@ cross-gcc-stage3-configure:
                --with-isl=no \
                --with-cloog=no \
                --with-libelf=no \
-               --enable-threads=no \
+               --enable-threads=posix \
                --disable-nls \
                --disable-multilib \
                --with-local-prefix=$(SYSROOT) \
                --enable-c99 \
                --enable-long-long \
                --enable-shared \
+               --disable-canonical-prefixes \
+               --disable-canonical-system-headers \
+               --enable-linker-build-id \
                $(GCC_BUILD_FLAGS);
 
 .$(BINARY_PREFIX)gcc-stage3-configure: