diff options
Diffstat (limited to 'reproduce/software/make/basic.mk')
| -rw-r--r-- | reproduce/software/make/basic.mk | 234 | 
1 files changed, 147 insertions, 87 deletions
diff --git a/reproduce/software/make/basic.mk b/reproduce/software/make/basic.mk index e7d00df..212c738 100644 --- a/reproduce/software/make/basic.mk +++ b/reproduce/software/make/basic.mk @@ -34,9 +34,9 @@  # Top level environment  include reproduce/software/make/build-rules.mk -include reproduce/software/config/installation/LOCAL.mk -include reproduce/software/config/installation/versions.mk -include reproduce/software/config/installation/checksums.mk +include reproduce/software/config/installation/LOCAL.conf +include reproduce/software/config/installation/versions.conf +include reproduce/software/config/installation/checksums.conf  lockdir = $(BDIR)/locks  tdir    = $(BDIR)/software/tarballs @@ -48,7 +48,7 @@ ibidir  = $(BDIR)/software/installed/version-info/proglib  # We'll need the system's PATH for making links to low-level programs we  # won't be building ourselves. -syspath         := $(PATH) +syspath := $(PATH)  # As we build more programs, we want to use this project's built programs  # and libraries, not the host's. @@ -58,7 +58,15 @@ export PKG_CONFIG_PATH := $(ildir)/pkgconfig  export PKG_CONFIG_LIBDIR := $(ildir)/pkgconfig  export CPPFLAGS := -I$(idir)/include $(CPPFLAGS)  export LDFLAGS := $(rpath_command) -L$(ildir) $(LDFLAGS) -export LD_LIBRARY_PATH := $(shell echo $(LD_LIBRARY_PATH) \ + +# This is the "basic" tools where we are relying on the host operating +# system, but are slowly populating our basic software envirnoment. To run +# (system or template) programs, `LD_LIBRARY_PATH' is necessary, so here, +# we'll first tell the programs to look into any possible pre-defined +# `LD_LIBRARY_PATH', then we'll add our own newly installed libraries.  We +# will also make sure that there is no "current directory" in it (by +# removing a starting or trailing `:' and any occurance of `::'. +export LD_LIBRARY_PATH := $(shell echo $(LD_LIBRARY_PATH):$(ildir) \                                    | sed -e's/::/:/g' -e's/^://' -e's/:$$//')  # RPATH is automatically written in macOS, so `DYLD_LIBRARY_PATH' is @@ -66,14 +74,18 @@ export LD_LIBRARY_PATH := $(shell echo $(LD_LIBRARY_PATH) \  # causes crashs (see bug #56682). So we'll just give it no value at all.  export DYLD_LIBRARY_PATH := -# Recipe startup script, see `reproduce/software/bash/bashrc.sh'. +# Recipe startup script.  export PROJECT_STATUS := configure_basic -export BASH_ENV := $(shell pwd)/reproduce/software/bash/bashrc.sh +export BASH_ENV := $(shell pwd)/reproduce/software/shell/bashrc.sh  # Define the top-level basic programs (that don't depend on any other).  top-level-programs = low-level-links gcc  all: $(foreach p, $(top-level-programs), $(ibidir)/$(p)) +# Servers to use as backup, later this should go in a file that is not +# under version control (the actual server that the tarbal comes from is +# irrelevant). +backupservers = http://akhlaghi.org/reproduce-software @@ -176,7 +188,7 @@ $(tarballs): $(tdir)/%: | $(lockdir)  	  mergenames=0; \  	  c=$(m4-checksum); \  	  w=http://akhlaghi.org/reproduce-software/m4-1.4.18-patched.tar.gz; \ -	elif [ $$n = make      ]; then c=$(make-checksum); w=https://alpha.gnu.org/gnu/make; \ +	elif [ $$n = make      ]; then c=$(make-checksum); w=https://ftp.gnu.org/gnu/make; \  	elif [ $$n = metastore ]; then c=$(metastore-checksum); w=http://akhlaghi.org/reproduce-software; \  	elif [ $$n = mpc       ]; then c=$(mpc-checksum); w=http://ftp.gnu.org/gnu/mpc; \  	elif [ $$n = mpfr      ]; then c=$(mpfr-checksum); w=http://www.mpfr.org/mpfr-current;\ @@ -228,15 +240,19 @@ $(tarballs): $(tdir)/%: | $(lockdir)  	      \  	  touch $(lockdir)/download; \  	  $(downloadwrapper) "$$downloader" $(lockdir)/download \ -	                     $$tarballurl "$@.unchecked"; \ +	                     $$tarballurl "$@.unchecked" "$(backupservers)"; \  	fi; \  	                                                \  	                                                \  	if type sha512sum > /dev/null 2>/dev/null; then \  	  checksum=$$(sha512sum "$@.unchecked" | awk '{print $$1}'); \ -	  echo "$*: should be '$$c', is '$$checksum'"; \ -	  if [ x$$checksum = x$$c ]; then mv "$@.unchecked" "$@"; \ -	  else echo "ERROR: Non-matching checksum for '$*'."; exit 1; \ +	  if [ x"$$checksum" = x"$$c" ]; then \ +	    mv "$@.unchecked" "$@"; \ +	  else \ +	    echo "ERROR: Non-matching checksum for '$*'."; \ +	    echo "Checksum should be: $$c"; \ +	    echo "Checksum is:        $$checksum"; \ +	    exit 1; \  	  fi; \  	else mv "$@.unchecked" "$@"; \  	fi; @@ -658,6 +674,66 @@ $(ibidir)/bash: $(ibidir)/readline \ +# The `-shared' flag will cause problems while building Perl on macOS, so +# we'll only use this configuration option when we are GNU/Linux +# systems. However, since the whole option must be used (which includes `=' +# and empty space), its easier to define the variable as a Make variable +# outside the recipe, not as a shell variable inside it. +ifeq ($(on_mac_os),yes) +perl-conflddlflags = +else +perl-conflddlflags = -Dlddlflags="-shared $$LDFLAGS" +endif +$(ibidir)/perl: | $(ibidir)/bash \ +                  $(tdir)/perl-$(perl-version).tar.gz +	major_version=$$(echo $(perl-version) \ +	                     | sed -e's/\./ /g' \ +	                     | awk '{printf("%d", $$1)}'); \ +	base_version=$$(echo $(perl-version) \ +	                     | sed -e's/\./ /g' \ +	                     | awk '{printf("%d.%d", $$1, $$2)}'); \ +	cd $(ddir) \ +	&& rm -rf perl-$(perl-version) \ +	&& if ! tar xf $(word 1,$(filter $(tdir)/%,$|)); then \ +	      echo; echo "Tar error"; exit 1; \ +	   fi \ +	&& cd perl-$(perl-version) \ +	&& sed -e's|\#\! /bin/sh|\#\! $(ibdir)/bash|' \ +	       -e's|\#\!/bin/sh|\#\! $(ibdir)/bash|' \ +	       Configure > Configure-tmp \ +	&& mv -f Configure-tmp Configure \ +	&& chmod +x Configure \ +	&& ./Configure -des \ +	               -Dusethreads \ +	               -Duseshrplib \ +	               -Dprefix=$(idir) \ +	               -Dvendorprefix=$(idir) \ +	               -Dprivlib=$(idir)/share/perl$$major_version/core_perl \ +	               -Darchlib=$(idir)/lib/perl$$major_version/$$base_version/core_perl \ +	               -Dsitelib=$(idir)/share/perl$$major_version/site_perl \ +	               -Dsitearch=$(idir)/lib/perl$$major_version/$$basever/site_perl \ +	               -Dvendorlib=$(idir)/share/perl$$major_version/vendor_perl \ +	               -Dvendorarch=$(idir)/lib/perl$$major_version/$$base_version/vendor_perl \ +	               -Dscriptdir=$(idir)/bin/core_perl \ +	               -Dsitescript=$(idir)/bin/site_perl \ +	               -Dvendorscript=$(idir)/bin/vendor_perl \ +	               -Dinc_version_list=none \ +	               -Dman1ext=1perl \ +	               -Dman3ext=3perl \ +	               -Dcccdlflags='-fPIC' \ +	               $(perl-conflddlflags) \ +	               -Dldflags="$$LDFLAGS" \ +	&& make SHELL=$(ibdir)/bash -j$(numthreads) \ +	&& make SHELL=$(ibdir)/bash install \ +	&& cd .. \ +	&& rm -rf perl-$(perl-version) \ +	&& cd $$topdir \ +	&& echo "Perl $(perl-version)" > $@ + + + + +  # Coreutils  # ---------  # @@ -677,8 +753,10 @@ $(ibidir)/bash: $(ibidir)/readline \  # The echo after the PatchELF loop is to avoid a crash if the last  # file that PatchELF encounters is not usable (and it returns with  # an error). +# +# Coreutils uses Perl to create man pages!  $(ibidir)/coreutils: $(ibidir)/openssl \ -	             | $(ibidir)/bash \ +	             | $(ibidir)/perl \                         $(tdir)/coreutils-$(coreutils-version).tar.xz  	cd $(ddir) \  	&& rm -rf coreutils-$(coreutils-version) \ @@ -847,17 +925,17 @@ $(ibidir)/wget: $(ibidir)/libiconv \  # there is no access to the system's PATH.  $(ibidir)/diffutils: | $(ibidir)/coreutils \                         $(tdir)/diffutils-$(diffutils-version).tar.xz -	$(call gbuild, diffutils-$(diffutils-version), static, , V=1) \ +	$(call gbuild, diffutils-$(diffutils-version), static,,V=1) \  	&& echo "GNU Diffutils $(diffutils-version)" > $@  $(ibidir)/file: | $(ibidir)/coreutils \                    $(tdir)/file-$(file-version).tar.gz -	$(call gbuild, file-$(file-version), static) \ +	$(call gbuild, file-$(file-version), static,,V=1) \  	&& echo "File $(file-version)" > $@  $(ibidir)/findutils: | $(ibidir)/coreutils \                         $(tdir)/findutils-$(findutils-version).tar.xz -	$(call gbuild, findutils-$(findutils-version), static, , V=1) \ +	$(call gbuild, findutils-$(findutils-version), static,,V=1) \  	&& echo "GNU Findutils $(findutils-version)" > $@  $(ibidir)/gawk: $(ibidir)/gmp \ @@ -910,13 +988,13 @@ $(ibidir)/gmp: | $(ibidir)/m4 \  $(ibidir)/glibtool: | $(ibidir)/m4 \                        $(tdir)/libtool-$(libtool-version).tar.xz  	$(call gbuild, libtool-$(libtool-version), static, \ -                       --program-prefix=g) \ +                       --program-prefix=g, V=1) \  	&& ln -s $(ibdir)/glibtoolize $(ibdir)/libtoolize \  	&& echo "GNU Libtool $(libtool-version)" > $@  $(ibidir)/grep: | $(ibidir)/coreutils \                    $(tdir)/grep-$(grep-version).tar.xz -	$(call gbuild, grep-$(grep-version), static) \ +	$(call gbuild, grep-$(grep-version), static,,V=1) \  	&& echo "GNU Grep $(grep-version)" > $@  $(ibidir)/libbsd: | $(ibidir)/coreutils \ @@ -927,7 +1005,7 @@ $(ibidir)/libbsd: | $(ibidir)/coreutils \  $(ibidir)/m4: | $(ibidir)/coreutils \                  $(ibidir)/texinfo \                  $(tdir)/m4-$(m4-version).tar.gz -	$(call gbuild, m4-$(m4-version), static) \ +	$(call gbuild, m4-$(m4-version), static,,V=1) \  	&& echo "GNU M4 $(m4-version)" > $@  # Metastore is used (through a Git hook) to restore the source modification @@ -997,7 +1075,7 @@ $(ibidir)/metastore: $(needlibbsd) \  	           -e's|@GROUP[@]|'$$group'|g' \  	           -e's|@BINDIR[@]|$(ibdir)|g' \  	           -e's|@TOP_PROJECT_DIR[@]|'$$current_dir'|g' \ -	           reproduce/software/bash/git-$$f > .git/hooks/$$f \ +	           reproduce/software/shell/git-$$f > .git/hooks/$$f \  	       && chmod +x .git/hooks/$$f; \  	    done; \  	  fi \ @@ -1020,63 +1098,6 @@ $(ibidir)/mpfr: $(ibidir)/gmp \  	$(call gbuild, mpfr-$(mpfr-version), static, , , make check)  \  	&& echo "GNU Multiple Precision Floating-Point Reliably $(mpfr-version)" > $@ -# The `-shared' flag will cause problems while building Perl on macOS, so -# we'll only use this configuration option when we are GNU/Linux -# systems. However, since the whole option must be used (which includes `=' -# and empty space), its easier to define the variable as a Make variable -# outside the recipe, not as a shell variable inside it. -ifeq ($(on_mac_os),yes) -perl-conflddlflags = -else -perl-conflddlflags = -Dlddlflags="-shared $$LDFLAGS" -endif -$(ibidir)/perl: | $(ibidir)/coreutils \ -                  $(tdir)/perl-$(perl-version).tar.gz -	major_version=$$(echo $(perl-version) \ -	                     | sed -e's/\./ /g' \ -	                     | awk '{printf("%d", $$1)}'); \ -	base_version=$$(echo $(perl-version) \ -	                     | sed -e's/\./ /g' \ -	                     | awk '{printf("%d.%d", $$1, $$2)}'); \ -	cd $(ddir) \ -	&& rm -rf perl-$(perl-version) \ -	&& if ! tar xf $(word 1,$(filter $(tdir)/%,$|)); then \ -	      echo; echo "Tar error"; exit 1; \ -	   fi \ -	&& cd perl-$(perl-version) \ -	&& sed -e's|\#\! /bin/sh|\#\! $(ibdir)/bash|' \ -	       -e's|\#\!/bin/sh|\#\! $(ibdir)/bash|' \ -	       Configure > Configure-tmp \ -	&& mv -f Configure-tmp Configure \ -	&& chmod +x Configure \ -	&& ./Configure -des \ -	               -Dusethreads \ -	               -Duseshrplib \ -	               -Dprefix=$(idir) \ -	               -Dvendorprefix=$(idir) \ -	               -Dprivlib=$(idir)/share/perl$$major_version/core_perl \ -	               -Darchlib=$(idir)/lib/perl$$major_version/$$base_version/core_perl \ -	               -Dsitelib=$(idir)/share/perl$$major_version/site_perl \ -	               -Dsitearch=$(idir)/lib/perl$$major_version/$$basever/site_perl \ -	               -Dvendorlib=$(idir)/share/perl$$major_version/vendor_perl \ -	               -Dvendorarch=$(idir)/lib/perl$$major_version/$$base_version/vendor_perl \ -	               -Dscriptdir=$(idir)/bin/core_perl \ -	               -Dsitescript=$(idir)/bin/site_perl \ -	               -Dvendorscript=$(idir)/bin/vendor_perl \ -	               -Dinc_version_list=none \ -	               -Dman1ext=1perl \ -	               -Dman3ext=3perl \ -	               -Dcccdlflags='-fPIC' \ -	               $(perl-conflddlflags) \ -	               -Dldflags="$$LDFLAGS" \ -	&& make SHELL=$(ibdir)/bash -j$(numthreads) \ -	&& make SHELL=$(ibdir)/bash install \ -	&& cd .. \ -	&& rm -rf perl-$(perl-version) \ -	&& cd $$topdir \ -	&& echo "Perl $(perl-version)" > $@ - -  $(ibidir)/pkg-config: | $(ibidir)/coreutils \                          $(tdir)/pkg-config-$(pkgconfig-version).tar.gz          # An existing `libiconv' can cause a conflict with `pkg-config', @@ -1101,7 +1122,7 @@ $(ibidir)/pkg-config: | $(ibidir)/coreutils \  $(ibidir)/sed: | $(ibidir)/coreutils \                   $(tdir)/sed-$(sed-version).tar.xz -	$(call gbuild, sed-$(sed-version), static) \ +	$(call gbuild, sed-$(sed-version), static,,V=1) \  	&& echo "GNU Sed $(sed-version)" > $@  $(ibidir)/texinfo: | $(ibidir)/perl \ @@ -1111,7 +1132,7 @@ $(ibidir)/texinfo: | $(ibidir)/perl \  	     $(ibdir)/patchelf --set-rpath $(ildir) $(ibdir)/info; \  	     $(ibdir)/patchelf --set-rpath $(ildir) $(ibdir)/install-info; \  	   fi \ -	&& echo "GNU Texinfo $(sed-version)" > $@ +	&& echo "GNU Texinfo $(texinfo-version)" > $@  $(ibidir)/which: | $(ibidir)/coreutils \                     $(tdir)/which-$(which-version).tar.gz @@ -1161,6 +1182,15 @@ endif  # programs (http://savannah.nongnu.org/bugs/?56294). Therefore, we'll set  # all other basic programs as Binutils prerequisite and GCC (the final  # basic target) ultimately just depends on Binutils. +# +# The `ld' linker of Binutils needs several `*crt*.o' file to run. On some +# systems these object files aren't installed in standard places. We +# defined `LIBRARY_PATH' and that fixed the problem for many +# systems. However, some software (for example ImageMagick) over-write +# `LIBRARY_PATH', therefore there is no other way than to put a link to +# these necessary files in our local build directory. IMPORTANT NOTE: +# later, when we build the GNU C Library in the project, we should remove +# this step.  $(ibidir)/binutils: | $(ibidir)/sed \                        $(ibidir)/wget \                        $(ibidir)/grep \ @@ -1174,6 +1204,7 @@ $(ibidir)/binutils: | $(ibidir)/sed \                        $(ibidir)/diffutils \                        $(ibidir)/coreutils \                        $(gcc-prerequisites) +  	if [ x$(on_mac_os) = xyes ]; then \  	  $(call makelink,as); \  	  $(call makelink,ar); \ @@ -1181,9 +1212,17 @@ $(ibidir)/binutils: | $(ibidir)/sed \  	  $(call makelink,nm); \  	  $(call makelink,ps); \  	  $(call makelink,ranlib); \ -          echo "" > $@; \ +	  echo "" > $@; \  	else \ -	  $(call gbuild, binutils-$(binutils-version), static) \ +	  $(call gbuild, binutils-$(binutils-version), static, \ +	                 --with-lib-path=$(sys_library_path), \ +	                 -j$(numthreads) ) \ +	  && if ! [ x"$(sys_library_path)" = x ]; then \ +	       for f in $(sys_library_path)/*crt*.o; do \ +	         b=$$($(ibdir)/basename $$f); \ +	         ln -s $$f $(ildir)/$$b; \ +	       done; \ +	     fi \  	  && echo "GNU Binutils $(binutils-version)" > $@; \  	fi @@ -1222,15 +1261,27 @@ $(ibidir)/gcc: | $(ibidir)/binutils \  	  ccinfo=$$(gcc --version | awk 'NR==1'); \  	  echo "C compiler (""$$ccinfo"")" > $@; \  	else \ +	  current_dir=$$(pwd); \  	  rm -f $(ibdir)/gcc* $(ibdir)/g++ $(ibdir)/gfortran $(ibdir)/gcov*;\  	  rm -rf $(ildir)/gcc $(ildir)/libcc* $(ildir)/libgcc*; \  	  rm -rf $(ildir)/libgfortran* $(ildir)/libstdc* rm $(idir)/x86_64*;\  	                                 \  	  ln -fs $(ildir) $(idir)/lib64; \ -	                                 \ -	  cd $(ddir); \ +	                       \ +	  in_ram=$$(df $(ddir) \ +	               | awk 'NR==2{print ($$4>10000000) ? "yes" : "no"}'); \ +	  if [ $$in_ram = "yes" ]; then odir=$(ddir); \ +	  else \ +	    odir=$(BDIR)/software/build-tmp-gcc; \ +	    if [ -d $$odir ]; then rm -rf $$odir; fi; \ +	    mkdir $$odir; \ +	  fi; \ +	  cd $$odir; \  	  rm -rf gcc-$(gcc-version); \ -	  tar xf $(word 1,$(filter $(tdir)/%,$|)) \ +	  tar xf $(word 1,$(filter $(tdir)/%,$|)); \ +	  if [ $$odir != $(ddir) ]; then \ +	    ln -s $$odir/gcc-$(gcc-version) $(ddir)/gcc-$(gcc-version); \ +	  fi \  	  && cd gcc-$(gcc-version) \  	  && mkdir build \  	  && cd build \ @@ -1257,15 +1308,24 @@ $(ibidir)/gcc: | $(ibidir)/binutils \  	  && make SHELL=$(ibdir)/bash -j$(numthreads) \  	  && make SHELL=$(ibdir)/bash install \  	  && cd ../.. \ -	  && rm -rf gcc-$(gcc-version) \ +	  && tempname=$$odir/gcc-$(gcc-version)/build/rpath-temp-copy \  	  && if [ "x$(on_mac_os)" != xyes ]; then \  	       patchelf --add-needed $(ildir)/libiconv.so $(ildir)/libstdc++.so; \  	       for f in $$(find $(idir)/libexec/gcc) $(ildir)/libstdc++*; do \ -	         if ldd $$f &> /dev/null; then \ -	           patchelf --set-rpath $(ildir) $$f; \ +	         isdynamic=$$(file $$f | grep "dynamically linked"); \ +	         if [ x"$$isdynamic" != x ]; then \ +	           cp $$f $$tempname; \ +	           patchelf --set-rpath $(ildir) $$tempname; \ +	           mv $$tempname $$f; echo "corrected"; \  	         fi; \  	       done; \  	     fi \ +	  && rm -rf gcc-$(gcc-version) \ +	  && cd $$current_dir \ +	  && if [ "$$odir" != "$(ddir)" ]; then \ +	       rm -rf $$odir; \ +	       rm $(ddir)/gcc-$(gcc-version); \ +	     fi \  	  && ln -sf $(ibdir)/gcc $(ibdir)/cc \  	  && echo "GNU Compiler Collection (GCC) $(gcc-version)" > $@; \  	fi  | 
