logo

live-bootstrap

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

pass2.sh (5879B)


  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 zlib
  13. # intl/ Makefile is a bit broken because of new gettext
  14. sed -i 's/@USE_INCLUDED_LIBINTL@/no/' intl/Makefile.in
  15. # There is no way to add -all-static to libtool LDFLAGS (such a thing doesn't exist)
  16. # -all-static is required for static binaries with libtool
  17. sed -i 's:\(--mode=link $(CCLD)\):\1 -all-static:' {bfd,binutils,opcodes,ld,libctf,gas,gprof}/Makefile.in
  18. # Rebuild bison files
  19. touch -- */*.y
  20. rm binutils/arparse.c binutils/arparse.h binutils/defparse.c \
  21. binutils/defparse.h binutils/mcparse.c binutils/mcparse.h \
  22. binutils/rcparse.c binutils/rcparse.h binutils/sysinfo.c \
  23. binutils/sysinfo.h gas/config/bfin-parse.c gas/config/bfin-parse.h \
  24. gas/config/loongarch-parse.c gas/config/loongarch-parse.h \
  25. gas/config/m68k-parse.c gas/config/rl78-parse.c \
  26. gas/config/rl78-parse.h gas/config/rx-parse.c gas/config/rx-parse.h \
  27. gas/itbl-parse.c gas/itbl-parse.h gold/yyscript.c gold/yyscript.h \
  28. intl/plural.c ld/deffilep.c ld/deffilep.h ld/ldgram.c ld/ldgram.h
  29. # Rebuild flex generated files
  30. touch -- */*.l */*/*.l
  31. rm binutils/arlex.c binutils/deflex.c binutils/syslex.c \
  32. gas/config/bfin-lex.c gas/config/loongarch-lex.c gas/itbl-lex.c \
  33. ld/ldlex.c
  34. # Remove prebuilt docs
  35. find . -type f -name '*.info*' \
  36. -not -wholename './binutils/sysroff.info' \
  37. -delete
  38. find . -type f \( -name '*.1' -or -name '*.man' \) -delete
  39. rm libiberty/functions.texi
  40. # Remove gettext translation files
  41. find . -type f -name '*.gmo' -delete
  42. # Remove pregenerated opcodes files
  43. rm opcodes/i386-init.h opcodes/i386-tbl.h opcodes/i386-mnem.h \
  44. opcodes/ia64-asmtab.c opcodes/z8k-opc.h opcodes/aarch64-asm-2.c \
  45. opcodes/aarch64-opc-2.c opcodes/aarch64-dis-2.c \
  46. opcodes/msp430-decode.c opcodes/rl78-decode.c opcodes/rx-decode.c
  47. rm $(grep -l 'MACHINE GENERATED' opcodes/*.c opcodes/*.h)
  48. # Various other blobs/generated headers
  49. rm ld/emultempl/*.o_c
  50. rm gprof/bsd_callg_bl.c gprof/flat_bl.c gprof/fsf_callg_bl.c
  51. rm bfd/libcoff.h bfd/libbfd.h bfd/go32stub.h bfd/bfd-in2.h
  52. # Generated testsuite stuff (xz-style attack)
  53. rm libsframe/testsuite/libsframe.decode/DATA* \
  54. ld/testsuite/ld-x86-64/*.obj.bz2 ld/testsuite/ld-sh/arch/*.s \
  55. ld/testsuite/ld-sh/arch/arch_expected.txt \
  56. ld/testsuite/ld-i386/pr27193a.o.bz2 \
  57. gas/testsuite/gas/xstormy16/allinsn.sh \
  58. gas/testsuite/gas/tic4x/opcodes.s gas/testsuite/gas/sh/arch/*.s \
  59. gas/testsuite/gas/sh/arch/arch_expected.txt \
  60. binutils/testsuite/binutils-all/x86-64/pr22451.o.bz2 \
  61. binutils/testsuite/binutils-all/x86-64/pr26808.dwp.bz2 \
  62. binutils/testsuite/binutils-all/x86-64/pr27708.exe.bz2 \
  63. binutils/testsuite/binutils-all/nfp/*.nffw \
  64. binutils/testsuite/binutils-all/pr26112.o.bz2 \
  65. binutils/testsuite/binutils-all/pr26160.dwp.bz2
  66. # Regenerate crc table in libiberty/crc32.c
  67. cd libiberty
  68. sed -n '/^ #include <stdio.h>/,/^ \}$/p' crc32.c > crcgen.c
  69. gcc -o crcgen crcgen.c
  70. sed '/crc_v3\.txt/{n; q}' crc32.c > crc32.c.new
  71. ./crcgen >> crc32.c.new
  72. sed '1,/^};$/d' crc32.c >> crc32.c.new
  73. mv crc32.c.new crc32.c
  74. cd ..
  75. # bfd-in2.h is required to run autoreconf, but we don't have it yet
  76. cd bfd
  77. cp configure.ac configure.ac.bak
  78. sed -i "s/bfd-in3.h:bfd-in2.h //" configure.ac
  79. AUTOPOINT=true ACLOCAL=aclocal-1.15 AUTOMAKE=automake-1.15 autoreconf-2.69 -fi
  80. ./configure
  81. make headers
  82. mv configure.ac.bak configure.ac
  83. make distclean
  84. cd ..
  85. # Regenerate top-level (autogen + autotools)
  86. autogen Makefile.def
  87. ACLOCAL=aclocal-1.15 autoreconf-2.69 -fi
  88. # Regenerate autoconf
  89. for dir in bfd binutils gas gold gprof intl ld libctf libiberty libsframe opcodes; do
  90. cd $dir
  91. ACLOCAL=aclocal-1.15 AUTOMAKE=automake-1.15 autoreconf-2.69 -fi
  92. cd ..
  93. done
  94. cd gprofng
  95. # there is no libtool in gprofng, and libtoolize fails
  96. LIBTOOLIZE=true ACLOCAL=aclocal-1.15 AUTOMAKE=automake-1.15 autoreconf-2.69 -fi
  97. cd ..
  98. # Rebuild dependencies in libiberty/Makefile.in
  99. cd libiberty
  100. ./configure --enable-maintainer-mode
  101. make maint-deps
  102. make distclean
  103. cd ..
  104. # Regenerate MeP sections
  105. ./bfd/mep-relocs.pl
  106. }
  107. src_configure() {
  108. mkdir build
  109. cd build
  110. LDFLAGS="-static" \
  111. ../configure \
  112. --prefix="${PREFIX}" \
  113. --libdir="${LIBDIR}" \
  114. --build=i386-unknown-linux-musl \
  115. --host=i386-unknown-linux-musl \
  116. --target=i386-unknown-linux-musl \
  117. --enable-static \
  118. --disable-nls \
  119. --disable-multilib \
  120. --disable-plugins \
  121. --disable-gprofng \
  122. --enable-threads \
  123. --enable-64-bit-bfd \
  124. --enable-gold \
  125. --enable-ld=default \
  126. --enable-install-libiberty \
  127. --enable-deterministic-archives \
  128. --with-system-zlib \
  129. --program-prefix="" \
  130. --with-sysroot= \
  131. --srcdir=..
  132. }
  133. src_install() {
  134. default
  135. # Create triplet symlinks
  136. pushd "${DESTDIR}${PREFIX}/bin"
  137. for f in *; do
  138. ln -s "${PREFIX}/bin/${f}" "i386-unknown-linux-musl-${f}"
  139. done
  140. popd
  141. # FIXME: Binutils' manpages dates are not reproducible
  142. rm -r "${DESTDIR}${PREFIX}/share/man"
  143. }