logo

live-bootstrap

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

pass1.sh (5411B)


  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. # Rebuild bison files
  12. touch -- */*.y
  13. rm binutils/arparse.c binutils/arparse.h binutils/defparse.c \
  14. binutils/defparse.h binutils/mcparse.c binutils/mcparse.h \
  15. binutils/nlmheader.c binutils/rcparse.c binutils/rcparse.h \
  16. binutils/sysinfo.c binutils/sysinfo.h gas/bfin-parse.c \
  17. gas/bfin-parse.h gas/m68k-parse.c gas/rl78-parse.c gas/rl78-parse.h \
  18. gas/rx-parse.c gas/rx-parse.h gas/itbl-parse.c gas/itbl-parse.h \
  19. gold/yyscript.c gold/yyscript.h intl/plural.c ld/deffilep.c \
  20. ld/deffilep.h ld/ldgram.c ld/ldgram.h
  21. # Rebuild flex generated files
  22. touch -- */*.l */*/*.l
  23. rm binutils/arlex.c binutils/deflex.c binutils/syslex.c gas/bfin-lex.c \
  24. gas/itbl-lex.c ld/ldlex.c
  25. # Remove prebuilt documentation
  26. rm bfd/doc/bfd.info binutils/doc/binutils.info
  27. rm gas/doc/as.info gprof/gprof.info ld/ld.info
  28. rm */*.1 */*/*.1 */*/*.man
  29. rm libiberty/functions.texi
  30. # Remove gettext translation files
  31. rm */po/*.gmo
  32. # Remove pregenerated opcodes files
  33. rm opcodes/i386-init.h opcodes/i386-tbl.h opcodes/ia64-asmtab.c \
  34. opcodes/z8k-opc.h opcodes/aarch64-asm-2.c opcodes/aarch64-opc-2.c \
  35. opcodes/aarch64-dis-2.c
  36. rm $(grep -l 'MACHINE GENERATED' opcodes/*.c opcodes/*.h)
  37. rm include/opcode/riscv-opc.h
  38. # Generated headers and blobs
  39. rm bfd/go32stub.h bfd/libbfd.h bfd/bfd-in2.h bfd/libcoff.h \
  40. ld/emultempl/spu_icache.o_c ld/emultempl/spu_ovl.o_c \
  41. gprof/fsf_callg_bl.c gprof/bsd_callg_bl.c gprof/flat_bl.c
  42. # Generated testdata (xz-style attack vector)
  43. rm gas/testsuite/gas/sh/arch/*.s \
  44. gas/testsuite/gas/sh/arch/arch_expected.txt \
  45. ld/testsuite/ld-sh/arch/*.s \
  46. ld/testsuite/ld-sh/arch/arch_expected.txt \
  47. ld/testsuite/ld-versados/*.ro \
  48. gas/testsuite/gas/xstormy16/allinsn.sh \
  49. gas/testsuite/gas/tic4x/opcodes.s \
  50. binutils/testsuite/binutils-all/x86-64/pr22451.o.bz2
  51. # Clean out zlib/
  52. rm zlib/contrib/masmx86/*.obj \
  53. zlib/contrib/infback9/inffix9.h \
  54. zlib/contrib/blast/test.pk \
  55. zlib/contrib/puff/zeros.raw \
  56. zlib/contrib/dotzlib/DotZLib.chm \
  57. zlib/crc32.h zlib/inffixed.h
  58. # Regenerate crc table in libiberty/crc32.c
  59. cd libiberty
  60. sed -n '/^ #include <stdio.h>/,/^ \}$/p' crc32.c > crcgen.c
  61. tcc -o crcgen crcgen.c
  62. sed '/crc_v3\.txt/{n; q}' crc32.c > crc32.c.new
  63. ./crcgen >> crc32.c.new
  64. sed '1,/^};$/d' crc32.c >> crc32.c.new
  65. mv crc32.c.new crc32.c
  66. cd ..
  67. # bfd-in2.h is required to run autoreconf, but we don't have it yet
  68. cd bfd
  69. cp configure.ac configure.ac.bak
  70. sed -i "s/bfd-in3.h:bfd-in2.h //" configure.ac
  71. AUTOPOINT=true ACLOCAL=aclocal-1.11 AUTOMAKE=automake-1.11 autoreconf-2.64 -fi
  72. CC=tcc LD=true ./configure
  73. make headers
  74. mv configure.ac.bak configure.ac
  75. make clean
  76. cd ..
  77. # Regenerate files
  78. for dir in bfd binutils gas gprof gold intl ld libiberty opcodes zlib; do
  79. cd $dir
  80. AUTOPOINT=true ACLOCAL=aclocal-1.11 AUTOMAKE=automake-1.11 autoreconf-2.64 -fi
  81. cd ..
  82. done
  83. rm Makefile.in # autogen
  84. ACLOCAL=aclocal-1.11 autoreconf-2.64 -fi
  85. # Rebuild dependencies in libiberty/Makefile.in
  86. cd libiberty
  87. CC=tcc ./configure --enable-maintainer-mode
  88. make maint-deps
  89. make clean
  90. cd ..
  91. # Regenerate MeP sections
  92. ./bfd/mep-relocs.pl
  93. }
  94. src_configure() {
  95. for dir in intl libiberty opcodes bfd binutils gas gprof ld zlib; do
  96. cd $dir
  97. # BUILDFIXED=1 is specifically for zlib, to avoid needing to
  98. # regenerate inffixed.h. Instead, it generates the information from
  99. # it at runtime.
  100. # Similarly, DYANMIC_CRC_TABLE=1 for crc32.h.
  101. LD="true" AR="tcc -ar" CC="tcc" \
  102. CFLAGS="-DBUILDFIXED=1 -DDYNAMIC_CRC_TABLE=1" \
  103. ./configure \
  104. --disable-nls \
  105. --enable-deterministic-archives \
  106. --enable-64-bit-bfd \
  107. --build=i386-unknown-linux-gnu \
  108. --host=i386-unknown-linux-gnu \
  109. --target=i386-unknown-linux-gnu \
  110. --program-prefix="" \
  111. --prefix="${PREFIX}" \
  112. --libdir="${LIBDIR}" \
  113. --with-sysroot= \
  114. --srcdir=. \
  115. --enable-compressed-debug-sections=all \
  116. lt_cv_sys_max_cmd_len=32768
  117. cd ..
  118. done
  119. }
  120. src_compile() {
  121. make -C bfd headers
  122. for dir in libiberty zlib bfd opcodes binutils gas gprof ld; do
  123. make "${MAKEJOBS}" -C $dir tooldir=${PREFIX} CPPFLAGS="-DPLUGIN_LITTLE_ENDIAN" MAKEINFO=true
  124. done
  125. }
  126. src_install() {
  127. for dir in libiberty zlib bfd opcodes binutils gas gprof ld; do
  128. make -C $dir tooldir=${PREFIX} DESTDIR="${DESTDIR}" install MAKEINFO=true
  129. done
  130. # Create triplet symlinks
  131. cd "${DESTDIR}${PREFIX}/bin"
  132. for f in *; do
  133. ln -s "${PREFIX}/bin/${f}" "i386-unknown-linux-musl-${f}"
  134. done
  135. }