logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

pass1.sh (5553B)


  1. # SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
  2. # SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
  3. # SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
  4. # SPDX-FileCopyrightText: 2023,2025 fosslinux <fosslinux@aussies.space>
  5. #
  6. # SPDX-License-Identifier: GPL-3.0-or-later
  7. src_prepare() {
  8. default
  9. # Remove unused generated files
  10. rm etc/Makefile.in etc/configure
  11. # Remove unused parts
  12. rm -r gprofng zlib
  13. # Rebuild bison files
  14. touch -- */*.y
  15. rm binutils/arparse.c binutils/arparse.h binutils/defparse.c \
  16. binutils/defparse.h binutils/mcparse.c binutils/mcparse.h \
  17. binutils/rcparse.c binutils/rcparse.h binutils/sysinfo.c \
  18. binutils/sysinfo.h gas/config/bfin-parse.c gas/config/bfin-parse.h \
  19. gas/config/loongarch-parse.c gas/config/loongarch-parse.h \
  20. gas/config/m68k-parse.c gas/config/rl78-parse.c \
  21. gas/config/rl78-parse.h gas/config/rx-parse.c gas/config/rx-parse.h \
  22. gas/itbl-parse.c gas/itbl-parse.h gold/yyscript.c gold/yyscript.h \
  23. intl/plural.c ld/deffilep.c ld/deffilep.h ld/ldgram.c ld/ldgram.h
  24. # Rebuild flex generated files
  25. touch -- */*.l */*/*.l
  26. rm binutils/arlex.c binutils/deflex.c binutils/syslex.c \
  27. gas/config/bfin-lex.c gas/config/loongarch-lex.c gas/itbl-lex.c \
  28. ld/ldlex.c
  29. # Remove prebuilt docs
  30. find . -type f -name '*.info*' \
  31. -not -wholename './binutils/sysroff.info' \
  32. -delete
  33. find . -type f \( -name '*.1' -or -name '*.man' \) -delete
  34. rm libiberty/functions.texi
  35. # Remove gettext translation files
  36. find . -type f -name '*.gmo' -delete
  37. # Remove pregenerated opcodes files
  38. rm opcodes/i386-init.h opcodes/i386-tbl.h opcodes/i386-mnem.h \
  39. opcodes/ia64-asmtab.c opcodes/z8k-opc.h opcodes/aarch64-asm-2.c \
  40. opcodes/aarch64-opc-2.c opcodes/aarch64-dis-2.c \
  41. opcodes/msp430-decode.c opcodes/rl78-decode.c opcodes/rx-decode.c
  42. rm $(grep -l 'MACHINE GENERATED' opcodes/*.c opcodes/*.h)
  43. # Various other blobs/generated headers
  44. rm ld/emultempl/*.o_c
  45. rm gprof/bsd_callg_bl.c gprof/flat_bl.c gprof/fsf_callg_bl.c
  46. rm bfd/libcoff.h bfd/libbfd.h bfd/go32stub.h bfd/bfd-in2.h
  47. # Generated testsuite stuff (xz-style attack)
  48. rm libsframe/testsuite/libsframe.decode/DATA* \
  49. ld/testsuite/ld-x86-64/*.obj.bz2 ld/testsuite/ld-sh/arch/*.s \
  50. ld/testsuite/ld-sh/arch/arch_expected.txt \
  51. ld/testsuite/ld-i386/pr27193a.o.bz2 \
  52. gas/testsuite/gas/xstormy16/allinsn.sh \
  53. gas/testsuite/gas/tic4x/opcodes.s gas/testsuite/gas/sh/arch/*.s \
  54. gas/testsuite/gas/sh/arch/arch_expected.txt \
  55. binutils/testsuite/binutils-all/x86-64/pr22451.o.bz2 \
  56. binutils/testsuite/binutils-all/x86-64/pr26808.dwp.bz2 \
  57. binutils/testsuite/binutils-all/x86-64/pr27708.exe.bz2 \
  58. binutils/testsuite/binutils-all/nfp/*.nffw \
  59. binutils/testsuite/binutils-all/pr26112.o.bz2 \
  60. binutils/testsuite/binutils-all/pr26160.dwp.bz2
  61. # Regenerate crc table in libiberty/crc32.c
  62. cd libiberty
  63. sed -n '/^ #include <stdio.h>/,/^ \}$/p' crc32.c > crcgen.c
  64. gcc -o crcgen crcgen.c
  65. sed '/crc_v3\.txt/{n; q}' crc32.c > crc32.c.new
  66. ./crcgen >> crc32.c.new
  67. sed '1,/^};$/d' crc32.c >> crc32.c.new
  68. mv crc32.c.new crc32.c
  69. cd ..
  70. # bfd-in2.h is required to run autoreconf, but we don't have it yet
  71. cd bfd
  72. cp configure.ac configure.ac.bak
  73. sed -i "s/bfd-in3.h:bfd-in2.h //" configure.ac
  74. AUTOPOINT=true ACLOCAL=aclocal-1.15 AUTOMAKE=automake-1.15 autoreconf-2.69 -fi
  75. ./configure
  76. make headers
  77. mv configure.ac.bak configure.ac
  78. make distclean
  79. cd ..
  80. # Regenerate autoconf
  81. for dir in bfd binutils gas gold gprof intl ld libctf libiberty libsframe opcodes; do
  82. cd $dir
  83. AUTOPOINT=true ACLOCAL=aclocal-1.15 AUTOMAKE=automake-1.15 autoreconf-2.69 -fi
  84. cd ..
  85. done
  86. rm Makefile.in # autogen
  87. ACLOCAL=aclocal-1.15 autoreconf-2.69 -fi
  88. # Rebuild dependencies in libiberty/Makefile.in
  89. cd libiberty
  90. ./configure --enable-maintainer-mode
  91. make maint-deps
  92. make distclean
  93. cd ..
  94. # Regenerate MeP sections
  95. ./bfd/mep-relocs.pl
  96. }
  97. src_configure() {
  98. for dir in intl libctf libiberty libsframe opcodes bfd binutils gas gprof ld; do
  99. cd $dir
  100. ./configure \
  101. --disable-nls \
  102. --enable-install-libiberty \
  103. --enable-deterministic-archives \
  104. --with-system-zlib \
  105. --build=i386-unknown-linux-musl \
  106. --host=i386-unknown-linux-musl \
  107. --target=i386-unknown-linux-musl \
  108. --program-prefix="" \
  109. --prefix="${PREFIX}" \
  110. --libdir="${LIBDIR}" \
  111. --with-sysroot= \
  112. --srcdir=.
  113. cd ..
  114. done
  115. }
  116. src_compile() {
  117. make -C bfd headers
  118. for dir in libiberty libsframe bfd opcodes libctf binutils gas gprof ld; do
  119. make "${MAKEJOBS}" -C $dir tooldir=${PREFIX} CFLAGS="-std=c99"
  120. done
  121. }
  122. src_install() {
  123. for dir in libiberty bfd opcodes libctf libsframe binutils gas gprof ld; do
  124. make -C $dir tooldir=${PREFIX} DESTDIR="${DESTDIR}" install
  125. done
  126. # Create triplet symlinks
  127. pushd "${DESTDIR}${PREFIX}/bin"
  128. for f in *; do
  129. ln -s "${PREFIX}/bin/${f}" "i386-unknown-linux-musl-${f}"
  130. done
  131. popd
  132. # FIXME: Binutils' manpages dates are not reproducible
  133. rm -r "${DESTDIR}${PREFIX}/share/man"
  134. }