pthbs

Packaging Through Hashed Build Scripts
git clone https://ccx.te2000.cz/git/pthbs
Log | Files | Refs | Submodules | README

musl-cross-make:bootstrap-0 (3743B)


      1 #!/usr/bin/env pthbs-build
      2 #@pragma:nosandbox
      3 #@pragma:nopath
      4 #@git:fe915821b652a7fa37b34a596f47d8e20bc72338:musl-cross-make
      5 #@sha256:ab66fc2d1c3ec0359b8e08843c9f33b63e8707efdff5e4cc5c200eae24722cbf:musl-cross-make/sources/binutils-2.33.1.tar.xz
      6 #@sha256:75d5d255a2a273b6e651f82eecfabf6cbcd8eaeae70e86b417384c8f4a58d8d3:musl-cross-make/sources/config.sub
      7 #@sha256:c95da32f440378d7751dd95533186f7fc05ceb4fb65eb5b85234e6299eb9838e:musl-cross-make/sources/gcc-9.4.0.tar.xz
      8 #@sha256:5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2:musl-cross-make/sources/gmp-6.1.2.tar.bz2
      9 #@sha256:995bc76ccf0c40d752b5ea67c022232a17eef6c9ec80ea74ea742e3c19992813:musl-cross-make/sources/linux-headers-4.19.88-1.tar.xz
     10 #@sha256:6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e:musl-cross-make/sources/mpc-1.1.0.tar.gz
     11 #@sha256:c05e3f02d09e0e9019384cdd58e0f19c64e6db1fd6f5ecf77b4b1c61ca253acc:musl-cross-make/sources/mpfr-4.0.2.tar.bz2
     12 #@sha256:7d5b0b6062521e4627e099e4c9dc8248d32a30285e959b7eecaa780cf8cfd4a4:musl-cross-make/sources/musl-1.2.3.tar.gz
     13 
     14 : ${JOBS:=1}
     15 
     16 # For validating the compiler
     17 printf '%s\n' 'int main(void) { return 0; }' >true.c
     18 
     19 printf '%s\n' >musl-cross-make/config.mak \
     20 	"OUTPUT=${pthbs_destdir%/}/versions/$pthbs_package" \
     21 	"TARGET=x86_64-linux-musl" \
     22 	'fl=-g0 -O2' \
     23 	'COMMON_CONFIG += CFLAGS="${fl}" CXXFLAGS="${fl}" FFLAGS="${fl}" LDFLAGS="-s"'
     24 
     25 touch musl-cross-make/sources/*
     26 
     27 # Patch linker path for dynamic executables
     28 make -C musl-cross-make gcc-9.4.0
     29 sed -i -e 's|/lib/ld-musl-|/versions/'"$pthbs_package"'/x86_64-linux-musl/lib/ld-musl-|' musl-cross-make/gcc-9.4.0/gcc/config/*/linux*.h
     30 
     31 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C musl-cross-make
     32 make -C musl-cross-make install
     33 
     34 # Override linker symlink
     35 for linkname in "${pthbs_destdir%/}"'/versions/'"$pthbs_package"'/x86_64-linux-musl/lib/'ld-musl-*so*; do
     36 	ln -s -f libc.so "$linkname"
     37 done
     38 
     39 # Validate the compiler
     40 "${pthbs_destdir%/}"'/versions'"/$pthbs_package/bin/"'x86_64-linux-musl-gcc' --version
     41 "${pthbs_destdir%/}"'/versions'"/$pthbs_package/bin/"'x86_64-linux-musl-gcc' -o true true.c
     42 "${pthbs_destdir%/}"'/versions'"/$pthbs_package/bin/"'x86_64-linux-musl-readelf' --string-dump=.interp true >true.linker
     43 grep -F "$pthbs_package" true.linker
     44 
     45 
     46 cd "$pthbs_destdir/versions/$pthbs_package"
     47 find -type d -o -print | awk -F/ '
     48 BEGIN {
     49 	x["./bin/x86_64-linux-musl-g++"]=1
     50 	x["./bin/x86_64-linux-musl-gcc"]=1
     51 }
     52 
     53 function r1(s) {
     54 	sub("^[.]/[^/]*", ".", s)
     55 	return s
     56 }
     57 function s1(repl, s) {
     58 	sub("^[.]/[^/]*", "./"repl, s)
     59 	return s
     60 }
     61 function link(src) {
     62 	x[$0]=0
     63 	printf "%s\t%s\n", $0, src
     64 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
     65 }
     66 $1!="."{exit 1}
     67 
     68 
     69 $2 == "bin" && $3 ~ /^x86_64-linux-musl-/ { target=$3; sub("x86_64-linux-musl-", "", target); link("./command/" target) }
     70 $2 == "command" { link($0); next }
     71 $2 == "bin" { link(s1("command", $0)); next }
     72 
     73 $2 == "library.so" { link($0); next }
     74 $2 == "library" { link($0); next }
     75 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next }
     76 $2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next }
     77 
     78 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next }
     79 
     80 $2 == "man" { link($0); next }
     81 $2 == "info" { link($0); next }
     82 $2 == "doc" { link($0); next }
     83 $2 == "icons" { link($0); next }
     84 $2 == "terminfo" { link($0); next }
     85 $2 == "data" { link($0); next }
     86 $2 == "include" { link($0); next }
     87 
     88 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
     89 
     90 END {
     91 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
     92 	for(fname in x) {
     93 		if(x[fname]) {
     94 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
     95 			exit 3
     96 		}
     97 	}
     98 }' >.install-links.new
     99 mv .install-links.new .install-links