2022-01-20 07:17:45 +03:00
|
|
|
#! /bin/sh
|
2022-01-16 08:09:36 +03:00
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
2022-01-22 05:10:25 +03:00
|
|
|
srcdir="$(dirname "$0")"
|
2022-01-16 08:09:36 +03:00
|
|
|
test -z "$srcdir" && srcdir=.
|
|
|
|
|
2024-04-05 15:41:32 +03:00
|
|
|
: "${AUTORECONF:=autoreconf}"
|
|
|
|
: "${AUTOMAKE:=automake}"
|
|
|
|
|
2022-01-16 08:09:36 +03:00
|
|
|
cd "$srcdir"
|
|
|
|
|
2024-01-25 03:46:47 +03:00
|
|
|
FREESTANDING_TOOLCHAIN_COMMIT_HASH=18a5e52483344e117d45738c9afb2b34792cbced
|
2024-01-13 21:59:39 +03:00
|
|
|
FREESTANDING_HEADERS_COMMIT_HASH=dd3abd2d7147efc4170dff478d3b7730bed14147
|
2024-06-12 04:06:04 +03:00
|
|
|
CC_RUNTIME_COMMIT_HASH=aa5854cebb4a5a561f35252cdda741919fc9c3f6
|
2024-06-08 18:02:45 +03:00
|
|
|
LIMINE_EFI_COMMIT_HASH=d8257094947b0edefe9fa4dcb15255235e3c5193
|
2024-01-13 21:59:39 +03:00
|
|
|
TINF_COMMIT_HASH=57ffa1f1d5e3dde19011b2127bd26d01689b694b
|
2024-06-12 03:39:25 +03:00
|
|
|
FLANTERM_COMMIT_HASH=ef07a10cc38b34aa003d17be97a9f3542e275069
|
2024-06-12 03:51:43 +03:00
|
|
|
STB_COMMIT_HASH=013ac3beddff3dbffafd5177e7972067cd2b5083
|
2024-05-31 01:35:00 +03:00
|
|
|
DTC_COMMIT_HASH=039a99414e778332d8f9c04cbd3072e1dcc62798
|
2024-01-13 21:59:39 +03:00
|
|
|
|
2024-02-11 08:51:01 +03:00
|
|
|
AUXFILES="config.guess config.sub install-sh"
|
|
|
|
|
2024-01-13 21:59:39 +03:00
|
|
|
clone_repo_commit() {
|
2024-07-05 03:24:10 +03:00
|
|
|
if test -d $2/.git; then
|
2024-02-01 02:51:29 +03:00
|
|
|
git -C $2 reset --hard
|
|
|
|
git -C $2 clean -fd
|
|
|
|
if ! git -C $2 checkout $3; then
|
|
|
|
rm -rf $2
|
2024-01-13 22:04:18 +03:00
|
|
|
fi
|
2024-02-11 08:04:15 +03:00
|
|
|
else
|
2024-07-05 03:24:10 +03:00
|
|
|
if test -d $2; then
|
2024-02-11 08:04:15 +03:00
|
|
|
echo "error: '$2' is not a Git repository"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-02-01 02:51:29 +03:00
|
|
|
fi
|
2024-07-05 03:24:10 +03:00
|
|
|
if ! test -d $2; then
|
2024-01-13 21:59:39 +03:00
|
|
|
git clone $1 $2
|
|
|
|
git -C $2 checkout $3
|
2024-02-01 02:51:29 +03:00
|
|
|
fi
|
2024-01-13 21:59:39 +03:00
|
|
|
}
|
|
|
|
|
2024-07-05 03:24:10 +03:00
|
|
|
if test -d .git; then
|
2024-06-28 01:01:30 +03:00
|
|
|
clone_repo_commit https://github.com/osdev0/freestanding-toolchain.git build-aux/freestanding-toolchain $FREESTANDING_TOOLCHAIN_COMMIT_HASH
|
|
|
|
clone_repo_commit https://github.com/osdev0/freestanding-headers.git freestanding-headers $FREESTANDING_HEADERS_COMMIT_HASH
|
2024-01-26 03:13:18 +03:00
|
|
|
|
2024-06-28 01:01:30 +03:00
|
|
|
clone_repo_commit https://github.com/osdev0/cc-runtime.git decompressor/cc-runtime $CC_RUNTIME_COMMIT_HASH
|
2024-02-11 08:04:15 +03:00
|
|
|
rm -rf common/cc-runtime
|
|
|
|
cp -rp decompressor/cc-runtime common/
|
|
|
|
for f in common/cc-runtime/*.c; do
|
|
|
|
mv "$f" "$(echo "$f" | sed 's/\.c/.s2.c/g')"
|
|
|
|
done
|
2024-01-13 21:59:39 +03:00
|
|
|
|
2024-02-11 08:04:15 +03:00
|
|
|
clone_repo_commit https://github.com/limine-bootloader/limine-efi.git limine-efi $LIMINE_EFI_COMMIT_HASH
|
2024-01-13 21:59:39 +03:00
|
|
|
|
2024-02-11 08:04:15 +03:00
|
|
|
clone_repo_commit https://github.com/jibsen/tinf.git tinf $TINF_COMMIT_HASH
|
|
|
|
mkdir -p decompressor/tinf
|
|
|
|
cp tinf/src/tinf.h tinf/src/tinflate.c tinf/src/tinfgzip.c decompressor/tinf/
|
|
|
|
patch -p0 < decompressor/tinf.patch
|
|
|
|
rm -f tinf/src/tinf.h.orig tinf/src/tinflate.c.orig tinf/src/tinfgzip.c.orig
|
2024-01-13 21:59:39 +03:00
|
|
|
|
2024-02-11 08:04:15 +03:00
|
|
|
clone_repo_commit https://github.com/mintsuki/flanterm.git common/flanterm $FLANTERM_COMMIT_HASH
|
2024-02-01 01:46:15 +03:00
|
|
|
|
2024-02-11 08:04:15 +03:00
|
|
|
clone_repo_commit https://github.com/nothings/stb.git stb $STB_COMMIT_HASH
|
|
|
|
cp stb/stb_image.h common/lib/
|
|
|
|
patch -p0 < common/stb_image.patch
|
|
|
|
rm -f common/lib/stb_image.h.orig
|
2024-05-30 18:41:45 +03:00
|
|
|
|
2024-05-31 01:35:00 +03:00
|
|
|
clone_repo_commit https://git.kernel.org/pub/scm/utils/dtc/dtc.git dtc $DTC_COMMIT_HASH
|
|
|
|
rm -rf common/libfdt
|
|
|
|
cp -rp dtc/libfdt common/
|
2024-05-30 18:41:45 +03:00
|
|
|
find common/libfdt/ -type f -not -name '*.c' -not -name '*.h' -delete
|
|
|
|
patch -p1 < common/libfdt.patch
|
2024-05-31 22:54:03 +03:00
|
|
|
rm -f common/libfdt/*.orig
|
2024-02-11 08:04:15 +03:00
|
|
|
fi
|
2023-03-16 06:38:59 +03:00
|
|
|
|
2024-04-15 00:41:45 +03:00
|
|
|
# Create timestamps file
|
2024-07-05 03:24:10 +03:00
|
|
|
if test -d .git && git log -1 >/dev/null 2>&1; then
|
2024-04-08 12:43:39 +03:00
|
|
|
cat >timestamps <<EOF
|
|
|
|
REGEN_DATE="$(git log -1 --pretty=%cd --date='format:%B %Y')"
|
|
|
|
SOURCE_DATE_EPOCH="$(git log -1 --pretty=%ct)"
|
2024-05-02 00:37:53 +03:00
|
|
|
SOURCE_DATE_EPOCH_TOUCH="$(git log -1 --pretty=%cI | head -c 16 | sed 's/-//g;s/T//g;s/://g')"
|
2024-04-08 12:43:39 +03:00
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! test -f timestamps; then
|
|
|
|
echo "error: Not a Git repository and 'timestamps' file missing."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-02-11 08:51:01 +03:00
|
|
|
for auxfile in $AUXFILES; do
|
|
|
|
rm -f build-aux/$auxfile
|
|
|
|
done
|
2024-02-11 08:41:05 +03:00
|
|
|
|
2024-04-05 15:41:32 +03:00
|
|
|
$AUTORECONF -fvi -Wall
|
2023-12-26 18:26:29 +03:00
|
|
|
|
|
|
|
# Older versions of autoreconf have a bug where they do not
|
|
|
|
# install auxiliary files, sometimes... Check if that is the
|
|
|
|
# case and work around...
|
2024-02-11 08:51:01 +03:00
|
|
|
for auxfile in $AUXFILES; do
|
2024-07-05 03:24:10 +03:00
|
|
|
if ! test -f build-aux/$auxfile; then
|
2024-04-05 15:41:32 +03:00
|
|
|
if ! $AUTOMAKE --print-libdir >/dev/null 2>&1; then
|
2024-02-11 08:04:15 +03:00
|
|
|
echo "error: Broken autoreconf detected, but missing or broken automake."
|
|
|
|
echo " Please make sure automake is installed and working."
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-04-05 15:41:32 +03:00
|
|
|
AUTOMAKE_LIBDIR="$($AUTOMAKE --print-libdir)"
|
2024-07-05 03:24:10 +03:00
|
|
|
if test -z "$AUTOMAKE_LIBDIR"; then
|
2024-04-05 15:41:32 +03:00
|
|
|
# Assume `true` was passed as $AUTOMAKE
|
|
|
|
continue
|
|
|
|
fi
|
2023-12-26 18:26:29 +03:00
|
|
|
mkdir -p build-aux
|
2024-04-05 15:41:32 +03:00
|
|
|
cp -v "$AUTOMAKE_LIBDIR/$auxfile" build-aux/
|
2024-02-11 08:04:15 +03:00
|
|
|
chmod +x build-aux/$auxfile
|
2023-12-26 18:26:29 +03:00
|
|
|
fi
|
|
|
|
done
|