aboutsummaryrefslogtreecommitdiff
path: root/reproduce/software/make/basic.mk
diff options
context:
space:
mode:
Diffstat (limited to 'reproduce/software/make/basic.mk')
-rw-r--r--reproduce/software/make/basic.mk344
1 files changed, 251 insertions, 93 deletions
diff --git a/reproduce/software/make/basic.mk b/reproduce/software/make/basic.mk
index d90d945..4b18c29 100644
--- a/reproduce/software/make/basic.mk
+++ b/reproduce/software/make/basic.mk
@@ -21,9 +21,9 @@
#
# ------------------------------------------------------------------------
#
-# Copyright (C) 2018-2022 Mohammad Akhlaghi <mohammad@akhlaghi.org>
-# Copyright (C) 2019-2022 Raul Infante-Sainz <infantesainz@gmail.com>
-# Copyright (C) 2022 Pedram Ashofteh Ardakani <pedramardakani@pm.me>
+# Copyright (C) 2018-2025 Mohammad Akhlaghi <mohammad@akhlaghi.org>
+# Copyright (C) 2019-2025 Raul Infante-Sainz <infantesainz@gmail.com>
+# Copyright (C) 2022-2025 Pedram Ashofteh Ardakani <pedramardakani@pm.me>
#
# This Makefile is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
# along with this Makefile. If not, see <http://www.gnu.org/licenses/>.
# Top level environment
-include reproduce/software/config/LOCAL.conf
+include .build/software/config/LOCAL.conf
include reproduce/software/make/build-rules.mk
include reproduce/software/config/versions.conf
include reproduce/software/config/checksums.conf
@@ -49,22 +49,27 @@ include reproduce/software/config/checksums.conf
include reproduce/software/config/urls.conf
# Basic directories
-lockdir = $(BDIR)/software/locks
-tdir = $(BDIR)/software/tarballs
-ddir = $(BDIR)/software/build-tmp
-idir = $(BDIR)/software/installed
-ibdir = $(BDIR)/software/installed/bin
-ildir = $(BDIR)/software/installed/lib
-ibidir = $(BDIR)/software/installed/version-info/proglib
+lockdir = $(BDIR)/software/locks
+tdir = $(BDIR)/software/tarballs
+ddir = $(BDIR)/software/build-tmp
+idir = $(BDIR)/software/installed
+ibdir = $(BDIR)/software/installed/bin
+ildir = $(BDIR)/software/installed/lib
+iidir = $(BDIR)/software/installed/include
+shsrcdir = "$(shell pwd)"/reproduce/software/shell
+ibidir = $(BDIR)/software/installed/version-info/proglib
# Ultimate Makefile target. GNU Nano (a simple and very light-weight text
# editor) is installed by default, it is recommended to have it in the
# 'basic.mk', so Maneaged projects can be edited on any system (even when
# there is no command-line text editor available).
+#
+# The recipe is '@echo > /dev/null' so Make does not print "make: Nothing
+# to be done for 'all'."
targets-proglib = low-level-links \
gcc-$(gcc-version) \
nano-$(nano-version)
-all: $(foreach p, $(targets-proglib), $(ibidir)/$(p))
+all: $(foreach p, $(targets-proglib), $(ibidir)/$(p)); @echo > /dev/null
# Define the shell environment
# ----------------------------
@@ -87,13 +92,18 @@ export SHELL := $(ibdir)/dash
export PATH := $(ibdir):$(PATH)
export PKG_CONFIG_PATH := $(ildir)/pkgconfig
export PKG_CONFIG_LIBDIR := $(ildir)/pkgconfig
-export CPPFLAGS := -I$(idir)/include $(CPPFLAGS) \
- -Wno-nullability-completeness
export LDFLAGS := $(rpath_command) -L$(ildir) $(LDFLAGS)
# Disable built-in rules (which are not needed here!)
.SUFFIXES:
+# See description of '-Wno-nullability-completeness' in
+# 'reproduce/software/shell/configure.sh'.
+ifeq ($(on_mac_os),yes)
+ noccwarnings=-Wno-nullability-completeness
+endif
+export CPPFLAGS := -I$(idir)/include $(CPPFLAGS) $(noccwarnings)
+
# 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,
@@ -101,6 +111,15 @@ export LDFLAGS := $(rpath_command) -L$(ildir) $(LDFLAGS)
# '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 '::'.
+#
+# But first: in case LD_LIBRARY_PATH is empty, give it the default value of
+# $(sys_library_sh_path) (which was the location of the libraries needed by
+# the host's shell). This is because after we add the Maneage's library
+# path, on some systems, no other libraries will be checked except those
+# that are in 'LD_LIBRARY_PATH'.
+ifeq ($(strip $(LD_LIBRARY_PATH)),)
+export LD_LIBRARY_PATH=$(sys_library_sh_path)
+endif
export LD_LIBRARY_PATH := $(shell echo $(LD_LIBRARY_PATH):$(ildir) \
| sed -e's/::/:/g' -e's/^://' -e's/:$$//')
@@ -121,17 +140,24 @@ export DYLD_LIBRARY_PATH :=
# Afer putting everything together, we use the first server as the
# reference for all software if their '-url' variable isn't defined (in
# 'reproduce/software/config/urls.conf').
-downloadwrapper = ./reproduce/analysis/bash/download-multi-try
+downloadwrapper = ./reproduce/analysis/bash/download-multi-try.sh
maneage_backup_urls := $(shell awk '!/^#/{printf "%s ", $$1}' \
reproduce/software/config/servers-backup.conf)
backupservers_all = $(user_backup_urls) $(maneage_backup_urls)
topbackupserver = $(word 1, $(backupservers_all))
backupservers = $(filter-out $(topbackupserver),$(backupservers_all))
-
-
-
-
+# When building in Apptainer containers, as of 2025-04-18, we need to
+# configure Maneage as root (within the container). In such cases, we need
+# to activate the 'FORCE_UNSAFE_CONFIGURE' environment variable to build
+# some of the software. The 'if' statement is here to make sure we are in
+# Apptainer: in other situations, the "unsafe" configure script shouldn't
+# be activated. Note that this doesn't happen in Docker (where the Maneage
+# source is in the same directory) because we build a non-root ('maneager'
+# user there who executes the configure command.
+unsafe-config = if [ $$(pwd) = "/home/maneager/source" ] \
+ && [ $$(whoami) = root ]; then \
+ export FORCE_UNSAFE_CONFIGURE=1; fi
@@ -202,6 +228,7 @@ $(ibidir)/low-level-links: $(ibidir)/grep-$(grep-version) \
$(call makelink,xcrun)
$(call makelink,sysctl)
$(call makelink,sw_vers)
+ $(call makelink,codesign)
$(call makelink,dsymutil)
$(call makelink,install_name_tool)
@@ -222,6 +249,10 @@ $(ibidir)/low-level-links: $(ibidir)/grep-$(grep-version) \
fi
done
+# Useful tools: 'ldd' (list libraries linked by binary on GNU
+# systems)
+ $(call makelink,ldd)
+
# We want this to be empty (so it doesn't interefere with the other
# files in 'ibidir'.
touch $@
@@ -240,11 +271,8 @@ $(ibidir)/low-level-links: $(ibidir)/grep-$(grep-version) \
#
# The first set of programs to be built are those that we need to unpack
# the source code tarballs of each program. We have already installed Lzip
-# before calling 'basic.mk', so it is present and working. Hence we first
-# build the Lzipped tarball of Gzip, then use our own Gzip to unpack the
-# tarballs of the other compression programs. Once all the compression
-# programs/libraries are complete, we build our own GNU Tar and continue
-# with other software.
+# before calling 'basic.mk', so it is present and working. So the only
+# prerequisites of these (until reaching Tar) is the necessary directories.
$(lockdir): | $(BDIR); mkdir $@
$(ibidir)/gzip-$(gzip-version): | $(ibdir) $(ildir) $(lockdir)
tarball=gzip-$(gzip-version).tar.lz
@@ -252,13 +280,13 @@ $(ibidir)/gzip-$(gzip-version): | $(ibdir) $(ildir) $(lockdir)
$(call gbuild, gzip-$(gzip-version), static, , V=1)
echo "GNU Gzip $(gzip-version)" > $@
-$(ibidir)/xz-$(xz-version): $(ibidir)/gzip-$(gzip-version)
+$(ibidir)/xz-$(xz-version): | $(ibdir) $(ildir) $(lockdir)
tarball=xz-$(xz-version).tar.lz
$(call import-source, $(xz-url), $(xz-checksum))
$(call gbuild, xz-$(xz-version), static)
echo "XZ Utils $(xz-version)" > $@
-$(ibidir)/bzip2-$(bzip2-version): $(ibidir)/gzip-$(gzip-version)
+$(ibidir)/bzip2-$(bzip2-version): | $(ibdir) $(ildir) $(lockdir)
# Download the tarball.
tarball=bzip2-$(bzip2-version).tar.lz
@@ -287,8 +315,9 @@ $(ibidir)/bzip2-$(bzip2-version): $(ibidir)/gzip-$(gzip-version)
fi
cd $(ddir)
rm -rf $$tdir
- tar -xf $(tdir)/$$tarball
+ tar -xf $(tdir)/$$tarball --no-same-owner --no-same-permissions
cd $$tdir
+ $(shsrcdir)/prep-source.sh $(ibdir)
sed -e 's@\(ln -s -f \)$$(PREFIX)/bin/@\1@' Makefile \
> Makefile.sed
mv Makefile.sed Makefile
@@ -303,32 +332,12 @@ $(ibidir)/bzip2-$(bzip2-version): $(ibidir)/gzip-$(gzip-version)
ln -fs libbz2.so.$(bzip2-version) libbz2.so
echo "Bzip2 $(bzip2-version)" > $@
-$(ibidir)/unzip-$(unzip-version): $(ibidir)/gzip-$(gzip-version)
- tarball=unzip-$(unzip-version).tar.lz
- $(call import-source, $(unzip-url), $(unzip-checksum))
- $(call gbuild, unzip-$(unzip-version), static,, \
- -f unix/Makefile generic \
- CFLAGS="-DBIG_MEM -DMMAP",,pwd, \
- -f unix/Makefile generic \
- BINDIR=$(ibdir) MANDIR=$(idir)/man/man1 )
- echo "Unzip $(unzip-version)" > $@
-
-$(ibidir)/zip-$(zip-version): $(ibidir)/gzip-$(gzip-version)
- tarball=zip-$(zip-version).tar.lz
- $(call import-source, $(zip-url), $(zip-checksum))
- $(call gbuild, zip-$(zip-version), static,, \
- -f unix/Makefile generic \
- CFLAGS="-DBIG_MEM -DMMAP",,pwd, \
- -f unix/Makefile generic \
- BINDIR=$(ibdir) MANDIR=$(idir)/man/man1 )
- echo "Zip $(zip-version)" > $@
-
# Some programs (like Wget and CMake) that use zlib need it to be dynamic
# so they use our custom build. So we won't force a static-only build.
#
# Note for a static-only build: Zlib's './configure' doesn't use Autoconf's
# configure script, it just accepts a direct '--static' option.
-$(ibidir)/zlib-$(zlib-version): $(ibidir)/gzip-$(gzip-version)
+$(ibidir)/zlib-$(zlib-version): | $(ibdir) $(ildir) $(lockdir)
tarball=zlib-$(zlib-version).tar.lz
$(call import-source, $(zlib-url), $(zlib-checksum))
$(call gbuild, zlib-$(zlib-version))
@@ -341,16 +350,15 @@ $(ibidir)/zlib-$(zlib-version): $(ibidir)/gzip-$(gzip-version)
# software to be built).
$(ibidir)/tar-$(tar-version): \
$(ibidir)/xz-$(xz-version) \
- $(ibidir)/zip-$(zip-version) \
$(ibidir)/gzip-$(gzip-version) \
$(ibidir)/zlib-$(zlib-version) \
- $(ibidir)/bzip2-$(bzip2-version) \
- $(ibidir)/unzip-$(unzip-version)
+ $(ibidir)/bzip2-$(bzip2-version)
# Since all later programs depend on Tar, the configuration will hit
# a bottleneck here: only making Tar. So its more efficient to built
# it on multiple threads (even when the user's Make doesn't pass down
# the number of threads).
+ $(call unsafe-config)
tarball=tar-$(tar-version).tar.lz
$(call import-source, $(tar-url), $(tar-checksum))
$(call gbuild, tar-$(tar-version), , , -j$(numthreads) V=1)
@@ -418,6 +426,7 @@ $(ibidir)/ncurses-$(ncurses-version): $(ibidir)/patchelf-$(patchelf-version)
rm -f $(ibdir)/bash* $(ibdir)/awk* $(ibdir)/gawk*
# Standard build process.
+ export CFLAGS="-std=gnu17 $$CFLAGS"
$(call gbuild, ncurses-$(ncurses-version), static, \
--with-shared --enable-rpath --without-normal \
--without-debug --with-cxx-binding \
@@ -461,6 +470,9 @@ $(ibidir)/ncurses-$(ncurses-version): $(ibidir)/patchelf-$(patchelf-version)
#
# 5. A link is made to also be able to include files from the
# 'ncurses' headers.
+#
+# 6. Top-level symbolic links are made for the 'include' (.h) files.
+#
if [ x$(on_mac_os) = xyes ]; then so="dylib"; else so="so"; fi
if [ -f $(ildir)/libncursesw.$$so ]; then
@@ -485,6 +497,11 @@ $(ibidir)/ncurses-$(ncurses-version): $(ibidir)/patchelf-$(patchelf-version)
ln -fs $(ildir)/pkgconfig/ncursesw.pc pkgconfig/cursesw.pc
ln -fs $(idir)/include/ncursesw $(idir)/include/ncurses
+
+# Add symbolic links for the ncursesw/*.h 'include' files
+# so that they can be found in the top-level include/ directory.
+ cd "$(iidir)"
+ ln -fsv $(idir)/include/ncursesw/*.h .
echo "GNU NCURSES $(ncurses-version)" > $@
else
exit 1
@@ -548,7 +565,7 @@ $(ibidir)/bash-$(bash-version): \
if [ "x$(static_build)" = xyes ]; then stopt="--enable-static-link"
else stopt=""
fi;
- export CFLAGS="$$CFLAGS \
+ export CFLAGS="$$CFLAGS -std=gnu17 \
-DDEFAULT_PATH_VALUE='\"$(ibdir)\"' \
-DSTANDARD_UTILS_PATH='\"$(ibdir)\"' \
-DSYS_BASHRC='\"$(BASH_ENV)\"' "
@@ -607,8 +624,9 @@ $(ibidir)/perl-$(perl-version): $(ibidir)/patchelf-$(patchelf-version)
| awk '{printf("%d.%d", $$1, $$2)}')
cd $(ddir)
rm -rf perl-$(perl-version)
- tar -xf $(tdir)/$$tarball
+ tar -xf $(tdir)/$$tarball --no-same-owner --no-same-permissions
cd perl-$(perl-version)
+ $(shsrcdir)/prep-source.sh $(ibdir)
./Configure -des \
-Dusethreads \
-Duseshrplib \
@@ -629,7 +647,7 @@ $(ibidir)/perl-$(perl-version): $(ibidir)/patchelf-$(patchelf-version)
-Dcccdlflags='-fPIC' \
$(perl-conflddlflags) \
-Dldflags="$$LDFLAGS"
- make -j$(numthreads)
+ make -j$(numthreads) V=1
make install
cd ..
rm -rf perl-$(perl-version)
@@ -667,20 +685,16 @@ $(ibidir)/coreutils-$(coreutils-version): \
$(ibidir)/openssl-$(openssl-version)
# Import, unpack and enter the source directory.
+ $(call unsafe-config)
tarball=coreutils-$(coreutils-version).tar.lz
$(call import-source, $(coreutils-url), $(coreutils-checksum))
+
+# Unpack and enter the source.
cd $(ddir)
rm -rf coreutils-$(coreutils-version)
- tar -xf $(tdir)/$$tarball
+ tar -xf $(tdir)/$$tarball --no-same-owner --no-same-permissions
cd coreutils-$(coreutils-version)
-
-# Set the configure script to use our shell, note that we can't
-# assume GNU SED here yet (it installs after Coreutils).
- sed -e's|\#\! /bin/sh|\#\! $(ibdir)/bash|' \
- -e's|\#\!/bin/sh|\#\! $(ibdir)/bash|' \
- configure > configure-tmp
- mv configure-tmp configure
- chmod +x configure
+ $(shsrcdir)/prep-source.sh $(ibdir)
# Configure, build and install Coreutils.
./configure --prefix=$(idir) SHELL=$(ibdir)/bash \
@@ -692,7 +706,7 @@ $(ibidir)/coreutils-$(coreutils-version): \
# Fix RPATH if necessary.
if [ -f $(ibdir)/patchelf ]; then
make SHELL=$(ibdir)/bash install DESTDIR=junkinst
- unalias ls || true # avoid decorated 'ls' commands with extra characters
+ unalias ls || true # Not decorated 'ls' (with extra characters).
instprogs=$$(ls junkinst/$(ibdir))
for f in $$instprogs; do
$(ibdir)/patchelf --set-rpath $(ildir) $(ibdir)/$$f
@@ -717,8 +731,9 @@ $(ibidir)/podlators-$(podlators-version): $(ibidir)/perl-$(perl-version)
$(call import-source, $(podlators-url), $(podlators-checksum))
cd $(ddir)
rm -rf podlators-$(podlators-version)
- tar -xf $(tdir)/$$tarball
+ tar -xf $(tdir)/$$tarball --no-same-owner --no-same-permissions
cd podlators-$(podlators-version)
+ $(shsrcdir)/prep-source.sh $(ibdir)
perl Makefile.PL
make
make install
@@ -741,7 +756,7 @@ $(ibidir)/openssl-$(openssl-version): $(ibidir)/podlators-$(podlators-version) \
# First download the certificates and copy them into the
# installation directory.
tarball=cert.pem-$(certpem-version)
- $(call import-source, $(cert-url), $(cert-checksum))
+ $(call import-source, $(certpem-url), $(certpem-checksum))
cp $(tdir)/cert.pem-$(certpem-version) $(idir)/etc/ssl/cert.pem
# Now download the OpenSSL tarball.
@@ -807,6 +822,8 @@ $(ibidir)/curl-$(curl-version): $(ibidir)/coreutils-$(coreutils-version)
--without-librtmp \
--without-libidn2 \
--without-wolfssl \
+ --without-nghttp2 \
+ --without-nghttp3 \
--without-brotli \
--without-gnutls \
--without-cyassl \
@@ -814,6 +831,7 @@ $(ibidir)/curl-$(curl-version): $(ibidir)/coreutils-$(coreutils-version)
--without-axtls \
--disable-ldaps \
--disable-ldap \
+ --without-zstd \
--without-nss, V=1)
if [ -f $(ibdir)/patchelf ]; then
@@ -875,6 +893,12 @@ $(ibidir)/wget-$(wget-version): \
# process of the higher-level programs and libraries. Note that during the
# building of those higher-level programs (after this Makefile finishes),
# there is no access to the system's PATH.
+$(ibidir)/bison-$(bison-version): $(ibidir)/help2man-$(help2man-version)
+ tarball=bison-$(bison-version).tar.lz
+ $(call import-source, $(bison-url), $(bison-checksum))
+ $(call gbuild, bison-$(bison-version), static, ,V=1 -j$(numthreads))
+ echo "GNU Bison $(bison-version)" > $@
+
$(ibidir)/diffutils-$(diffutils-version): \
$(ibidir)/coreutils-$(coreutils-version)
tarball=diffutils-$(diffutils-version).tar.lz
@@ -928,6 +952,13 @@ $(ibidir)/gawk-$(gawk-version): \
# Build final target.
echo "GNU AWK $(gawk-version)" > $@
+$(ibidir)/help2man-$(help2man-version): \
+ $(ibidir)/coreutils-$(coreutils-version)
+ tarball=help2man-$(help2man-version).tar.lz
+ $(call import-source, $(help2man-url), $(help2man-checksum))
+ $(call gbuild, help2man-$(help2man-version), static, ,V=1)
+ echo "Help2man $(Help2man-version)" > $@
+
$(ibidir)/libiconv-$(libiconv-version): \
$(ibidir)/pkg-config-$(pkgconfig-version)
tarball=libiconv-$(libiconv-version).tar.lz
@@ -987,9 +1018,10 @@ $(ibidir)/gmp-$(gmp-version): \
$(ibidir)/coreutils-$(coreutils-version)
tarball=gmp-$(gmp-version).tar.lz
$(call import-source, $(gmp-url), $(gmp-checksum))
+ export CFLAGS="-std=gnu17 $$CFLAGS"
$(call gbuild, gmp-$(gmp-version), static, \
--enable-cxx --enable-fat, \
- -j$(numthreads) ,make check)
+ -j$(numthreads))
echo "GNU Multiple Precision Arithmetic Library $(gmp-version)" > $@
# Less is useful with Git (to view the diffs within a minimal container)
@@ -998,7 +1030,19 @@ $(ibidir)/gmp-$(gmp-version): \
$(ibidir)/less-$(less-version): $(ibidir)/ncurses-$(ncurses-version)
tarball=less-$(less-version).tar.lz
$(call import-source, $(less-url), $(less-checksum))
- $(call gbuild, less-$(less-version), static,,-j$(numthreads))
+
+# Without the '--with-regex=posix' option, the build will depend on
+# PCRE (perl compatible regular expressions) which are not available
+# on some systems/compilers and can cause a crash. Maneage was
+# successfully built with the POSIX regular expression (regex), and
+# 'less' is generally, an interactive software, not a batch-mode
+# software (it is just added in 'basic.mk' because Git uses it to
+# display things. Again, this is an interactive meta-operation in
+# maneage (operations you only do when you are developing Maneage
+# within Maneage interactively, and will not affect into the actual
+# reproducible analysis!)
+ $(call gbuild, less-$(less-version), static, \
+ --with-regex=posix,-j$(numthreads))
if [ -f $(ibdir)/patchelf ]; then
$(ibdir)/patchelf --set-rpath $(ildir) $(ibdir)/less;
fi
@@ -1017,22 +1061,34 @@ $(ibidir)/libtool-$(libtool-version): $(ibidir)/m4-$(m4-version)
$(ibidir)/grep-$(grep-version): $(ibidir)/coreutils-$(coreutils-version)
tarball=grep-$(grep-version).tar.lz
$(call import-source, $(grep-url), $(grep-checksum))
- $(call gbuild, grep-$(grep-version), static,,V=1)
+ $(call gbuild, grep-$(grep-version), static,, \
+ -j$(numthreads) V=1)
echo "GNU Grep $(grep-version)" > $@
# M4 doesn't depend on PatchELF, but just to be consistent with the
# levels/phases introduced here (where the compressors are level 1,
# PatchELF is level 2, and ...), we'll set it as a dependency.
+#
+# The '--with-syscmd-shell' is used as the default shell and if not given,
+# 'm4' will use '/bin/sh' (which is not under Maneage control and can cause
+# problems in 'high-level.mk' because it closes off the system's
+# LD_LIBRARY_PATH and if the system's '/bin/sh' needs a special system
+# library, the high-level programs will not be built). We are setting this
+# default shell to Dash because M4 is built before our own Bash. Recall
+# that Dash is built before we enter this Makefile.
$(ibidir)/m4-$(m4-version): $(ibidir)/patchelf-$(patchelf-version)
tarball=m4-$(m4-version).tar.lz
$(call import-source, $(m4-url), $(m4-checksum))
- $(call gbuild, m4-$(m4-version), static,,V=1)
+ export CFLAGS="-std=gnu17 $$CFLAGS"
+ $(call gbuild, m4-$(m4-version), static, \
+ --with-syscmd-shell=$(ibdir)/dash, \
+ -j$(numthreads) V=1)
echo "GNU M4 $(m4-version)" > $@
$(ibidir)/mpfr-$(mpfr-version): $(ibidir)/gmp-$(gmp-version)
tarball=mpfr-$(mpfr-version).tar.lz
$(call import-source, $(mpfr-url), $(mpfr-checksum))
- $(call gbuild, mpfr-$(mpfr-version), static, , , make check)
+ $(call gbuild, mpfr-$(mpfr-version), static)
echo "GNU Multiple Precision Floating-Point Reliably $(mpfr-version)" > $@
$(ibidir)/pkg-config-$(pkgconfig-version): $(ibidir)/patchelf-$(patchelf-version)
@@ -1056,6 +1112,7 @@ $(ibidir)/pkg-config-$(pkgconfig-version): $(ibidir)/patchelf-$(patchelf-version
if [ x$(on_mac_os) = xyes ]; then export compiler="CC=clang"
else export compiler=""
fi
+ export CFLAGS="-std=gnu17 $$CFLAGS"
$(call gbuild, pkg-config-$(pkgconfig-version), static, \
$$compiler --with-internal-glib \
--with-pc-path=$(ildir)/pkgconfig, V=1)
@@ -1070,6 +1127,17 @@ $(ibidir)/sed-$(sed-version): $(ibidir)/coreutils-$(coreutils-version)
$(ibidir)/texinfo-$(texinfo-version): \
$(ibidir)/perl-$(perl-version) \
$(ibidir)/gettext-$(gettext-version)
+
+# Setting for the XS sub-package. "This is because in theory, the XS
+# module could be built with a different compiler to the rest of the
+# project, needing completely different flags" (part of [1])
+#
+# [1] https://lists.gnu.org/archive/html/bug-texinfo/2022-08/msg00068.html
+ export PERL="$(ibdir)/perl"
+ export PERL_EXT_LDFLAGS="-L$(ildir)"
+ export PERL_EXT_CPPFLAGS="-I$(iidir)"
+
+# Basic build commands.
tarball=texinfo-$(texinfo-version).tar.lz
$(call import-source, $(texinfo-url), $(texinfo-checksum))
$(call gbuild, texinfo-$(texinfo-version), static)
@@ -1105,7 +1173,7 @@ $(ibidir)/mpc-$(mpc-version): $(ibidir)/mpfr-$(mpfr-version)
echo "" > $@
else
$(call gbuild, mpc-$(mpc-version), static, , \
- -j$(numthreads), make check)
+ -j$(numthreads))
echo "GNU Multiple Precision Complex library" > $@
fi
@@ -1136,6 +1204,7 @@ $(ibidir)/binutils-$(binutils-version): \
$(ibidir)/gawk-$(gawk-version) \
$(ibidir)/grep-$(grep-version) \
$(ibidir)/wget-$(wget-version) \
+ $(ibidir)/bison-$(bison-version) \
$(ibidir)/which-$(which-version) \
$(ibidir)/libtool-$(libtool-version) \
$(ibidir)/texinfo-$(texinfo-version) \
@@ -1163,8 +1232,9 @@ $(ibidir)/binutils-$(binutils-version): \
# Build binutils with the standard 'gbuild' function.
$(call gbuild, binutils-$(binutils-version), static, \
- --with-lib-path=$(sys_library_path), \
- -j$(numthreads) )
+ --with-lib-path=$(sys_library_path) \
+ --enable-gprofng=no, \
+ -j$(numthreads) V=1)
# The 'ld' linker of Binutils needs several '*crt*.o' files from
# the host's GNU C Library to run. On some systems these object
@@ -1287,20 +1357,49 @@ $(ibidir)/gcc-$(gcc-version): $(ibidir)/binutils-$(binutils-version)
current_dir=$$(pwd)
# By default 'ddir' (where GCC is decompressed and built) is in the
-# RAM (on systems that support '/dev/shm'). This is done to avoid
-# building so many small/temporary files and possibly harming the
-# hard-drive or SSD. But if the RAM doesn't have enough space, we
-# should use the hard-drive or SSD. During its build GCC's build
-# directory will become about 7GB (multiple of 1024 bytes, for GCC
-# 11.2.0). So at this step, we are making sure we have more than
-# 7.5GiB (multiple of 1000 bytes, which corresponds to 7.32GB)
-# before GCC starts to build. Note that the 4th column of 'df' is
-# the "available" space at the time of running, not the full
-# space. So the background RAM that the OS will be using during
-# Maneage is accounted for. Also consider that GCC is built alone
-# (no other Maneage software is built at the same time as GCC).
- in_ram=$$(df $(ddir) \
- | awk 'NR==2{print ($$4>7500000) ? "yes" : "no"}'); \
+# RAM (on systems that support a '/dev/shm' RAM disk). This is done
+# to avoid building so many small/temporary files and possibly
+# harming the hard-drive or SSD. But if the RAM doesn't have enough
+# space, we should use the hard-drive or SSD. During its build,
+# GCC's build directory will become several gigabytes and the build
+# also needs RAM. You can track the RAM usage of the system with a
+# 1-second resolution (if no other RAM consuming program is running
+# while building GCC) with the command below (example outputs can
+# be seen in https://savannah.nongnu.org/task/index.php?16623).
+#
+# c=1; while true; do POSIXLY_CORRECT=1 df -P /dev/shm/maneage-* | awk 'NR==2{print '$c', $3}'; c=$((c+1)); sleep 1; done > mem-usage.txt
+# asttable mem-usage.txt -c1,'arith $2 512 x 1024 / 1024 / 1024 /' -o mem.fits
+#
+# For POSIX portability and longevity (default sizes might change),
+# we use the '-P' option, and we use the environment variable
+# POSIXLY_CORRECT=1, so the 'block size' is 512 bytes. In this way,
+# to get the actual GiB amount, multiply the value returned above
+# by 512 (B/block), then divide by 1024^3 (B/GiB).
+#
+# To get the final value to use here, get the maximum used value
+# after GCC is fully built and you have stopped the 'while true'
+# command above. You can do this with the command below (assumes
+# you have Gnuastro).
+#
+# aststatistics mem-usage.txt -c2 --maximum | asttable -c'arith $1 7000000 +' -Afixed -B0
+#
+# The extra space is because we will assume an extra 3 GiB = 3GiB *
+# 1024^3 (B/GiB) / 512 (B/block) = 6291456 blocks are necessary for
+# the building (let's round it to 7000000!).
+#
+# Therefore, we need to make sure that the running system more than
+# the necessary amount of space in the RAM. To do this, we use 'df'
+# below.
+#
+# The 4th column of 'df' is the "available" space at the time of
+# running, not the full space. So the 'RAM disk' that the OS
+# will be using as "pretend" disk space (e.g. using 'tmpfs'; this
+# is physically RAM, but appears as if it is disk space)
+# during this stage of Maneage is accounted for. GCC is built
+# alone - no other Maneage software is built at the same time as
+# GCC - so this amount of RAM should be enough.
+ in_ram=$$(POSIXLY_CORRECT=1 df -P $(ddir) \
+ | awk 'NR==2{print ($$4>26613216) ? "yes" : "no"}'); \
if [ $$in_ram = "yes" ]; then odir=$(ddir)
else
odir=$(BDIR)/software/build-tmp-gcc-due-to-lack-of-space
@@ -1308,15 +1407,46 @@ $(ibidir)/gcc-$(gcc-version): $(ibidir)/binutils-$(binutils-version)
mkdir $$odir
fi
-# Go into the proper directory, unpack GCC and prepare the 'build'
-# directory inside it for all the built files.
+# Go into the directory to uncompress GCC.
cd $$odir
+
+# Unpack GCC and prepare the 'build' directory inside it for all
+# the built files.
rm -rf gcc-$(gcc-version)
- tar -xf $(tdir)/$$tarball
+ tar -xf $(tdir)/$$tarball --no-same-owner --no-same-permissions
if [ $$odir != $(ddir) ]; then
ln -s $$odir/gcc-$(gcc-version) $(ddir)/gcc-$(gcc-version)
fi
cd gcc-$(gcc-version)
+ $(shsrcdir)/prep-source.sh $(ibdir)
+
+# Unfortunately binutils installs headers like 'ansidecl.h' that
+# have been seen to conflict with GCC's internal versions of those
+# headers. For example in the 'ansidecl.h' of Binutils 2.39, the
+# 'PTR' macro isn't defined, while the same file in GCC 12.1.0 has
+# defined it. Therefore, without this change, GCC will include the
+# file installed from Binutils, not find what it needs and crash!
+# Therefore, with the 'CPPFLAGS' modification below, we tell GCC to
+# first look into its own 'include' directory before anything else.
+ export CPPFLAGS="-I$$(pwd)/include $(CPPFLAGS)"
+
+# In the GNU C Library 2.36 (which is more recent than GCC 12.1.0),
+# the 'linux/mount.h' (loaded by 'linux/fs.h', which is loaded by
+# 'libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp'
+# in GCC) conflicts with 'sys/mount.h' which is directly loaded by
+# the same file! This is a known conflict in glibc 2.36 (see
+# [1]). As described in [1], one solution is the final job done in
+# [2]. We therefore do this process here: 1) Not loading
+# 'linux/fs.h', and adding the necessary macros directly.
+#
+# [1] https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
+# [2] https://reviews.llvm.org/D129471
+ sed -e's|\#include <linux/fs.h>||' \
+ -e"s|FS_IOC_GETFLAGS;|_IOR('f', 1, long);|" \
+ -e"s|FS_IOC_GETVERSION;|_IOR('v', 1, long);|" \
+ -e"s|FS_IOC_SETFLAGS;|_IOW('f', 2, long);|" \
+ -e"s|FS_IOC_SETVERSION;|_IOW('v', 2, long);|" \
+ -i libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
# Set the build directory for the processing.
mkdir build
@@ -1396,12 +1526,39 @@ $(ibidir)/gcc-$(gcc-version): $(ibidir)/binutils-$(binutils-version)
+# Level 6: need re-compilation
+# ----------------------------
+#
+# The initial build of these was done with the host's settings, which will
+# cause problems later when we completely close-off the host environment.
+$(ibidir)/make-$(make-version): $(ibidir)/gcc-$(gcc-version)
+ tarball=make-$(make-version).tar.lz
+ $(call import-source, $(make-url), $(make-checksum))
+ $(call gbuild, make-$(make-version), static, \
+ --disable-dependency-tracking --without-guile)
+ echo "GNU Make $(make-version)" > $@
+
+$(ibidir)/lzip-$(lzip-version): $(ibidir)/gcc-$(gcc-version)
+ tarball=lzip-$(lzip-version).tar
+ unpackdir=lzip-$(lzip-version)
+ cd $(ddir)
+ rm -rf $$unpackdir
+ tar -xf $(tdir)/$$tarball --no-same-owner --no-same-permissions
+ cd $$unpackdir
+ $(shsrcdir)/prep-source.sh $(ibdir)
+ ./configure --build --check --installdir="$(ibdir)"
+ if [ -f $(ibdir)/patchelf ]; then
+ $(ibdir)/patchelf --set-rpath $(ildir) $(ibdir)/lzip;
+ fi
+ cd ..
+ rm -rf $$unpackdir
+ echo "Lzip $(lzip-version)" > $@
-# Level 6: Basic text editor
+# Level 7: Basic text editor
# --------------------------
#
# If the project is built in a minimal environment, there is no text
@@ -1418,7 +1575,8 @@ $(ibidir)/gcc-$(gcc-version): $(ibidir)/binutils-$(binutils-version)
# nano (and use their own optional high-level text editor). To do this, you
# can just have to manually remove 'nano' from 'targets-proglib' above and
# add their optional text editor in 'TARGETS.conf'.
-$(ibidir)/nano-$(nano-version): $(ibidir)/gcc-$(gcc-version)
+$(ibidir)/nano-$(nano-version): $(ibidir)/lzip-$(lzip-version) \
+ $(ibidir)/make-$(make-version)
tarball=nano-$(nano-version).tar.lz
$(call import-source, $(nano-url), $(nano-checksum))
$(call gbuild, nano-$(nano-version), static)