| 1 | #! /bin/sh |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | srcdir="$(dirname "$0")" |
| 6 | test -z "$srcdir" && srcdir=. |
| 7 | |
| 8 | : "${AUTORECONF:=autoreconf}" |
| 9 | : "${AUTOMAKE:=automake}" |
| 10 | |
| 11 | cd "$srcdir" |
| 12 | |
| 13 | AUXFILES="config.guess config.sub install-sh" |
| 14 | |
| 15 | clone_repo_commit() { |
| 16 | if test -d "$2/.git"; then |
| 17 | git -C "$2" reset --hard |
| 18 | git -C "$2" clean -fd |
| 19 | if ! git -C "$2" -c advice.detachedHead=false checkout $3; then |
| 20 | rm -rf "$2" |
| 21 | fi |
| 22 | else |
| 23 | if test -d "$2"; then |
| 24 | set +x |
| 25 | echo "error: '$2' is not a Git repository" 1>&2 |
| 26 | exit 1 |
| 27 | fi |
| 28 | fi |
| 29 | if ! test -d "$2"; then |
| 30 | git clone $1 "$2" |
| 31 | if ! git -C "$2" -c advice.detachedHead=false checkout $3; then |
| 32 | rm -rf "$2" |
| 33 | exit 1 |
| 34 | fi |
| 35 | fi |
| 36 | } |
| 37 | |
| 38 | if ! test -f version; then |
| 39 | clone_repo_commit \ |
| 40 | https://github.com/osdev0/freestnd-c-hdrs-0bsd.git \ |
| 41 | freestnd-c-hdrs \ |
| 42 | 097259a899d30f0a4b7a694de2de5fdda942e923 |
| 43 | |
| 44 | clone_repo_commit \ |
| 45 | https://github.com/osdev0/cc-runtime.git \ |
| 46 | cc-runtime \ |
| 47 | dae79833b57a01b9fd3e359ee31def69f5ae899b |
| 48 | cp cc-runtime/src/cc-runtime.c common/cc-runtime.s2.c |
| 49 | |
| 50 | clone_repo_commit \ |
| 51 | https://github.com/iczelia/pdgzip.git \ |
| 52 | pdgzip \ |
| 53 | ce578d3f815bf591b78d1689c09b05acf173c095 |
| 54 | cp pdgzip/pdgzip.c common/compress/pdgzip.c |
| 55 | cp pdgzip/pdgzip.h common/compress/pdgzip.h |
| 56 | |
| 57 | clone_repo_commit \ |
| 58 | https://github.com/Limine-Bootloader/limine-protocol.git \ |
| 59 | limine-protocol \ |
| 60 | 5b9d13e557590d8eab93fa7449bdd1d7ed72ba8c |
| 61 | |
| 62 | clone_repo_commit \ |
| 63 | https://github.com/PicoEFI/PicoEFI.git \ |
| 64 | picoefi \ |
| 65 | af14129ec21ba482873289e36311ec02f1e19964 |
| 66 | |
| 67 | clone_repo_commit \ |
| 68 | https://github.com/Mintsuki/Flanterm.git \ |
| 69 | flanterm \ |
| 70 | dfa1922c0749faf64c4423a81b233a20c08a7db7 |
| 71 | |
| 72 | clone_repo_commit \ |
| 73 | https://github.com/Mintsuki/stbi-hardened.git \ |
| 74 | stbi-hardened \ |
| 75 | b85b7e87f6f87300f32f7de3d94e1ed083a71263 |
| 76 | cp stbi-hardened/include/stb_image.h common/lib/stb_image.h |
| 77 | patch -p0 < common/stb_image.patch |
| 78 | rm -f common/lib/stb_image.h.orig |
| 79 | |
| 80 | clone_repo_commit \ |
| 81 | https://github.com/osdev0/libfdt.git \ |
| 82 | libfdt \ |
| 83 | 7bf94e6347129d17eca263112296ad170dec28a9 |
| 84 | fi |
| 85 | |
| 86 | # Create timestamps file |
| 87 | if test -d .git && git log -1 >/dev/null 2>&1; then |
| 88 | cat >timestamps <<EOF |
| 89 | REGEN_DATE="$(git log -1 --pretty=%cd --date='format:%B %Y')" |
| 90 | SOURCE_DATE_EPOCH="$(git log -1 --pretty=%ct)" |
| 91 | SOURCE_DATE_EPOCH_TOUCH="$(git log -1 --pretty=%cI | head -c 16 | sed 's/-//g;s/T//g;s/://g')" |
| 92 | EOF |
| 93 | else |
| 94 | if ! test -f timestamps; then |
| 95 | cat >timestamps <<EOF |
| 96 | REGEN_DATE="UNVERSIONED" |
| 97 | SOURCE_DATE_EPOCH="1546297200" |
| 98 | SOURCE_DATE_EPOCH_TOUCH="201901010000" |
| 99 | EOF |
| 100 | fi |
| 101 | fi |
| 102 | |
| 103 | for auxfile in $AUXFILES; do |
| 104 | rm -f build-aux/$auxfile |
| 105 | done |
| 106 | |
| 107 | $AUTORECONF -fvi -Wall |
| 108 | |
| 109 | # Older versions of autoreconf have a bug where they do not |
| 110 | # install auxiliary files, sometimes... Check if that is the |
| 111 | # case and work around... |
| 112 | for auxfile in $AUXFILES; do |
| 113 | if ! test -f build-aux/$auxfile; then |
| 114 | if ! $AUTOMAKE --print-libdir >/dev/null 2>&1; then |
| 115 | set +x |
| 116 | echo "error: Broken autoreconf detected, but missing or broken automake." 1>&2 |
| 117 | echo " Please make sure automake is installed and working." 1>&2 |
| 118 | exit 1 |
| 119 | fi |
| 120 | AUTOMAKE_LIBDIR="$($AUTOMAKE --print-libdir)" |
| 121 | if test -z "$AUTOMAKE_LIBDIR"; then |
| 122 | # Assume `true` was passed as $AUTOMAKE |
| 123 | continue |
| 124 | fi |
| 125 | mkdir -p build-aux |
| 126 | cp -v "$AUTOMAKE_LIBDIR/$auxfile" build-aux/ |
| 127 | chmod +x build-aux/$auxfile |
| 128 | fi |
| 129 | done |
| 130 | |
| 131 | set +x |
| 132 | |
| 133 | printf "\nSource tree bootstrapped successfully!\n" |