11# SPDX-FileCopyrightText: 2022 Dor Askayo <[email protected] >22# SPDX-FileCopyrightText: 2021 Andrius Štikonas <[email protected] >33# SPDX-FileCopyrightText: 2021 Paul Dersey <[email protected] >4- # SPDX-FileCopyrightText: 2023 fosslinux <[email protected] >4+ # SPDX-FileCopyrightText: 2023,2025 fosslinux <[email protected] >55#
66# SPDX-License-Identifier: GPL-3.0-or-later
77
8-
98src_prepare () {
109 default
1110
1211 # Remove unused generated files
1312 rm etc/Makefile.in etc/configure
1413
15- # Regenerate files
16- for dir in bfd binutils gas gprof intl ld libiberty opcodes zlib; do
17- (
18- cd $dir
19- AUTOPOINT=true ACLOCAL=aclocal-1.11 AUTOMAKE=automake-1.11 autoreconf-2.64 -fi
20- )
21- done
22-
23- ACLOCAL=aclocal-1.11 autoreconf-2.64 -fi
24-
2514 # Rebuild bison files
2615 touch -- * /* .y
27- rm binutils/arparse.c binutils/arparse.h
28- rm binutils/defparse.c binutils/defparse.h
29- rm binutils/mcparse.c binutils/mcparse.h
30- rm binutils/rcparse.c binutils/rcparse.h
31- rm binutils/sysinfo.c binutils/sysinfo.h
32- rm gas/bfin-parse.c gas/bfin-parse.h
33- rm gas/m68k-parse.c gas/rl78-parse.c
34- rm gas/rl78-parse.h gas/rx-parse.c
35- rm gas/rx-parse.h gas/itbl-parse.c
36- rm gas/itbl-parse.h gold/yyscript.c
37- rm gold/yyscript.h intl/plural.c
38- rm ld/deffilep.c ld/deffilep.h
39- rm ld/ldgram.c ld/ldgram.h
16+ rm binutils/arparse.c binutils/arparse.h binutils/defparse.c \
17+ binutils/defparse.h binutils/mcparse.c binutils/mcparse.h \
18+ binutils/nlmheader.c binutils/rcparse.c binutils/rcparse.h \
19+ binutils/sysinfo.c binutils/sysinfo.h gas/bfin-parse.c \
20+ gas/bfin-parse.h gas/m68k-parse.c gas/rl78-parse.c gas/rl78-parse.h \
21+ gas/rx-parse.c gas/rx-parse.h gas/itbl-parse.c gas/itbl-parse.h \
22+ gold/yyscript.c gold/yyscript.h intl/plural.c ld/deffilep.c \
23+ ld/deffilep.h ld/ldgram.c ld/ldgram.h
4024
4125 # Rebuild flex generated files
4226 touch -- * /* .l * /* /* .l
43- rm binutils/arlex.c binutils/deflex.c binutils/syslex.c
44- rm gas/bfin-lex.c gas/itbl-lex.c
45- rm ld/ldlex.c
27+ rm binutils/arlex.c binutils/deflex.c binutils/syslex.c gas/bfin-lex.c \
28+ gas/itbl-lex.c ld/ldlex.c
4629
47- # Remove prebuilt texinfo files
30+ # Remove prebuilt documentation
4831 rm bfd/doc/bfd.info binutils/doc/binutils.info
4932 rm gas/doc/as.info gprof/gprof.info ld/ld.info
33+ rm * /* .1 * /* /* .1 * /* /* .man
34+ rm libiberty/functions.texi
35+
36+ # Remove gettext translation files
37+ rm * /po/* .gmo
5038
5139 # Remove pregenerated opcodes files
52- rm opcodes/i386-init.h opcodes/i386-tbl.h
53- rm opcodes/ia64-asmtab.c
54- rm opcodes/z8k-opc.h
55- rm opcodes/aarch64-asm-2.c opcodes/aarch64-opc-2.c opcodes/aarch64-dis-2.c
40+ rm opcodes/i386-init.h opcodes/i386-tbl.h opcodes/ia64-asmtab.c \
41+ opcodes/z8k-opc.h opcodes/aarch64-asm-2.c opcodes/aarch64-opc-2.c \
42+ opcodes/aarch64-dis-2.c
5643 rm $( grep -l ' MACHINE GENERATED' opcodes/* .c opcodes/* .h)
44+ rm include/opcode/riscv-opc.h
45+
46+ # Generated headers and blobs
47+ rm bfd/go32stub.h bfd/libbfd.h bfd/bfd-in2.h bfd/libcoff.h \
48+ ld/emultempl/spu_icache.o_c ld/emultempl/spu_ovl.o_c \
49+ gprof/fsf_callg_bl.c gprof/bsd_callg_bl.c gprof/flat_bl.c
50+
51+ # Generated testdata (xz-style attack vector)
52+ rm gas/testsuite/gas/sh/arch/* .s \
53+ gas/testsuite/gas/sh/arch/arch_expected.txt \
54+ ld/testsuite/ld-sh/arch/* .s \
55+ ld/testsuite/ld-sh/arch/arch_expected.txt \
56+ ld/testsuite/ld-versados/* .ro \
57+ gas/testsuite/gas/xstormy16/allinsn.sh \
58+ gas/testsuite/gas/tic4x/opcodes.s \
59+ binutils/testsuite/binutils-all/x86-64/pr22451.o.bz2
60+
61+ # Clean out zlib/
62+ rm zlib/contrib/masmx86/* .obj \
63+ zlib/contrib/infback9/inffix9.h \
64+ zlib/contrib/blast/test.pk \
65+ zlib/contrib/puff/zeros.raw \
66+ zlib/contrib/dotzlib/DotZLib.chm \
67+ zlib/crc32.h zlib/inffixed.h
68+
69+ # Regenerate crc table in libiberty/crc32.c
70+ cd libiberty
71+ sed -n ' /^ #include <stdio.h>/,/^ \}$/p' crc32.c > crcgen.c
72+ tcc -o crcgen crcgen.c
73+ sed ' /crc_v3\.txt/{n; q}' crc32.c > crc32.c.new
74+ ./crcgen >> crc32.c.new
75+ sed ' 1,/^};$/d' crc32.c >> crc32.c.new
76+ mv crc32.c.new crc32.c
77+ cd ..
78+
79+ # bfd-in2.h is required to run autoreconf, but we don't have it yet
80+ cd bfd
81+ cp configure.ac configure.ac.bak
82+ sed -i " s/bfd-in3.h:bfd-in2.h //" configure.ac
83+ AUTOPOINT=true ACLOCAL=aclocal-1.11 AUTOMAKE=automake-1.11 autoreconf-2.64 -fi
84+ CC=tcc LD=true ./configure
85+ make headers
86+ mv configure.ac.bak configure.ac
87+ make distclean
88+ cd ..
89+
90+ # Regenerate files
91+ for dir in bfd binutils gas gprof gold intl ld libiberty opcodes zlib; do
92+ cd $dir
93+ AUTOPOINT=true ACLOCAL=aclocal-1.11 AUTOMAKE=automake-1.11 autoreconf-2.64 -fi
94+ cd ..
95+ done
96+ rm Makefile.in # autogen
97+ ACLOCAL=aclocal-1.11 autoreconf-2.64 -fi
98+
99+ # Rebuild dependencies in libiberty/Makefile.in
100+ cd libiberty
101+ CC=tcc ./configure --enable-maintainer-mode
102+ make maint-deps
103+ make distclean
104+ cd ..
57105
58106 # Regenerate MeP sections
59107 ./bfd/mep-relocs.pl
60-
61- # Manpages
62- rm * /* .1 * /* /* .1 * /* /* .man
63108}
64109
65110src_configure () {
66111 for dir in intl libiberty opcodes bfd binutils gas gprof ld zlib; do
67- (
68112 cd $dir
69113
70- LD=" true" AR=" tcc -ar" CC=" tcc" ./configure \
114+ # BUILDFIXED=1 is specifically for zlib, to avoid needing to
115+ # regenerate inffixed.h. Instead, it generates the information from
116+ # it at runtime.
117+ # Similarly, DYANMIC_CRC_TABLE=1 for crc32.h.
118+ LD=" true" AR=" tcc -ar" CC=" tcc" \
119+ CFLAGS=" -DBUILDFIXED=1 -DDYNAMIC_CRC_TABLE=1" \
120+ ./configure \
71121 --disable-nls \
72122 --enable-deterministic-archives \
73123 --enable-64-bit-bfd \
@@ -81,7 +131,7 @@ src_configure() {
81131 --srcdir=. \
82132 --enable-compressed-debug-sections=all \
83133 lt_cv_sys_max_cmd_len=32768
84- )
134+ cd ..
85135 done
86136}
87137
@@ -98,10 +148,8 @@ src_install() {
98148 done
99149
100150 # Create triplet symlinks
101- (
102- cd " ${DESTDIR}${PREFIX} /bin"
103- for f in * ; do
104- ln -s " ${PREFIX} /bin/${f} " " i386-unknown-linux-musl-${f} "
105- done
106- )
151+ cd " ${DESTDIR}${PREFIX} /bin"
152+ for f in * ; do
153+ ln -s " ${PREFIX} /bin/${f} " " i386-unknown-linux-musl-${f} "
154+ done
107155}
0 commit comments