logo

live-bootstrap

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

pass1.sh (5562B)


  1. # SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
  2. # SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
  3. # SPDX-FileCopyrightText: 2021-23 fosslinux <fosslinux@aussies.space>
  4. # SPDX-License-Identifier: GPL-3.0-or-later
  5. src_prepare() {
  6. default
  7. # Generated using gperf
  8. rm gcc/cp/cfns.h
  9. # Regenerating top level Makefile requires GNU Autogen and hence Guile,
  10. # but it is not essential for building gcc.
  11. rm configure Makefile.in fixincludes/fixincl.x
  12. # Remove unused generated files
  13. rm libgo/aclocal.m4 libgo/configure libgo/Makefile.in
  14. # Regenerate aclocal.m4 files
  15. # grep "generated automatically by aclocal" */aclocal.m4 -l | sed -e 's#/aclocal.m4##' | tr "\n" " " | sed -e 's/ $/\n/'
  16. for dir in intl libcpp libdecnumber; do
  17. cd $dir
  18. rm aclocal.m4
  19. AUTOCONF=autoconf-2.64 AUTOM4TE=autom4te-2.64 aclocal-1.11 --acdir=../config
  20. cd ..
  21. done
  22. cd gcc
  23. rm aclocal.m4
  24. AUTOCONF=autoconf-2.64 AUTOM4TE=autom4te-2.64 aclocal-1.11 --acdir=../config
  25. cd ..
  26. cd fixincludes
  27. rm aclocal.m4
  28. AUTOCONF=autoconf-2.64 AUTOM4TE=autom4te-2.64 aclocal-1.11 --acdir=../gcc
  29. cd ..
  30. for dir in boehm-gc libffi libgfortran libgomp libitm libjava libmudflap libobjc libquadmath libssp lto-plugin zlib; do
  31. cd $dir
  32. rm aclocal.m4
  33. AUTOCONF=autoconf-2.64 AUTOM4TE=autom4te-2.64 aclocal-1.11
  34. cd ..
  35. done
  36. cd libstdc++-v3
  37. ACLOCAL=aclocal-1.11 AUTOMAKE=automake-1.11 AUTOCONF=autoconf-2.64 AUTOM4TE=autom4te-2.64 autoreconf-2.64 -fi
  38. cd ..
  39. # Regenerate configure scripts
  40. # Find all folders with configure script and rebuild them. At the moment we exclude boehm-gc folder due to
  41. # an error but we don't use that directory anyway (it's only needed for Objective C)
  42. for dir in $(find . -mindepth 2 -maxdepth 2 -name configure.ac | sed 's#/configure.ac##' | grep -v -x './libgo' | tr "\n" " " | sed -e 's/ $/\n/' -e 's/^boehm-gc //'); do
  43. pushd "$dir"
  44. rm configure
  45. autoconf-2.64 || autoconf-2.64
  46. popd
  47. done
  48. # Regenerate Makefile.in
  49. # Find all folders with Makefile.am and rebuild them. At the moment we exclude boehm-gc folder.
  50. for dir in $(find . -mindepth 2 -maxdepth 2 -name Makefile.am | sed 's#/Makefile.am##' | grep -v -x './libgo' | tr "\n" " " | sed -e 's/ $/\n/' -e 's/^boehm-gc //'); do
  51. pushd "$dir"
  52. rm Makefile.in
  53. AUTOCONF=autoconf-2.64 AUTOM4TE=autom4te-2.64 automake-1.11 --add-missing
  54. popd
  55. done
  56. for dir in libdecnumber libcpp libiberty gcc; do
  57. cd $dir
  58. rm -f config.in
  59. autoheader-2.64
  60. cd ..
  61. done
  62. # Rebuild libtool files
  63. rm config.guess config.sub ltmain.sh
  64. libtoolize
  65. cp "${PREFIX}/share/automake-1.15/config.sub" .
  66. # Workaround for bison being too new
  67. rm intl/plural.c
  68. # Rebuild flex generated files
  69. rm gcc/gengtype-lex.c
  70. # Regenerate crc table in libiberty/crc32.c
  71. pushd libiberty
  72. sed -n -e '39,66p' crc32.c > crcgen.c
  73. gcc -o crcgen crcgen.c
  74. head -n 70 crc32.c > crc32.c.new
  75. ./crcgen >> crc32.c.new
  76. tail -n +139 crc32.c >> crc32.c.new
  77. mv crc32.c.new crc32.c
  78. popd
  79. # Remove translation catalogs
  80. find . -name '*.gmo' -delete
  81. # Pre-built texinfo files
  82. find . -name '*.info' -delete
  83. }
  84. src_configure() {
  85. mkdir build
  86. cd build
  87. for dir in libiberty libcpp libdecnumber gcc libgcc libstdc++-v3; do
  88. mkdir $dir
  89. cd $dir
  90. ../../$dir/configure \
  91. --prefix="${PREFIX}" \
  92. --libdir="${LIBDIR}" \
  93. --build=i386-unknown-linux-musl \
  94. --target=i386-unknown-linux-musl \
  95. --host=i386-unknown-linux-musl \
  96. --disable-shared \
  97. --program-transform-name= \
  98. --enable-languages=c,c++ \
  99. --disable-sjlj-exceptions \
  100. --with-system-zlib
  101. cd ..
  102. done
  103. cd ..
  104. }
  105. src_compile() {
  106. ln -s . build/build-i386-unknown-linux-musl
  107. for dir in libiberty libcpp libdecnumber gcc; do
  108. # We have makeinfo now but it is not happy with gcc .info files, so skip it
  109. make "${MAKEJOBS}" -C build/$dir LIBGCC2_INCLUDES=-I"${PREFIX}/include" \
  110. STMP_FIXINC= GMPLIBS="-lmpc -lmpfr -lgmp" MAKEINFO=true
  111. done
  112. # host_subdir is necessary because we have slightly different build directory layout
  113. make "${MAKEJOBS}" -C build/libgcc PATH="${PATH}:../gcc" CC=../gcc/xgcc \
  114. host_subdir=build CFLAGS="-I../gcc/include -I/${PREFIX}/include"
  115. make "${MAKEJOBS}" -C build/libstdc++-v3 PATH="${PATH}:${PWD}/build/gcc" \
  116. CXXFLAGS="-I${PWD}/build/gcc/include -I ${PREFIX}/include"
  117. }
  118. src_install() {
  119. make -C build/gcc install STMP_FIXINC= DESTDIR="${DESTDIR}" MAKEINFO=true
  120. make -C build/libgcc install DESTDIR="${DESTDIR}" host_subdir=build
  121. make -C build/libstdc++-v3 install DESTDIR="${DESTDIR}"
  122. ln -s gcc "${DESTDIR}${PREFIX}/bin/cc"
  123. cp gcc/gsyslimits.h "${DESTDIR}${LIBDIR}/gcc/i386-unknown-linux-musl/4.7.4/include/syslimits.h"
  124. # Very strange mis-versoning error
  125. mkdir -p "${DESTDIR}${LIBDIR}/gcc/i386-unknown-linux-musl/4.7.4/include/"
  126. mv "${DESTDIR}${LIBDIR}/gcc/i386-unknown-linux-musl/4.0.4/include/"* "${DESTDIR}${LIBDIR}/gcc/i386-unknown-linux-musl/4.7.4/include/"
  127. rmdir "${DESTDIR}${LIBDIR}/gcc/i386-unknown-linux-musl/4.0.4/include"
  128. mv "${DESTDIR}${LIBDIR}/gcc/i386-unknown-linux-musl/4.0.4/"* "${DESTDIR}${LIBDIR}/gcc/i386-unknown-linux-musl/4.7.4/"
  129. }