mrrl

Minimal Reliable Reproducible Linux
git clone https://ccx.te2000.cz/git/mrrl
Log | Files | Refs | Submodules | README

libbsd (3181B)


      1 #!/usr/bin/env pthbs-build
      2 #+musl-cross-make.675bc960d97b88b341ba4c64ea1b10f6afd9c9f0394ed84ca848768c5e1b646c
      3 #+gnu-make.152d99fd58e3130b4bd4d23833643ca418555a0560e88962cd8a28ffcd9a9ab7
      4 #+busybox.7818e9d6df97d97317c8fcdf404811731aa0c5c3ab7eb6aec00c9652b6da511c
      5 #+busybox-diffutils.3579038707d7520c09339ee4fc3b67ef03caeeaf8fff3b6f93c51ace141a4393
      6 #+m4.9943b16e3463f08c59487393409dc10df95173d9d015f907948a44a96e7fd8ee
      7 #+libmd.a99fe1b71bd36f593d01ab819134b9fd790626e489dbc2b4c59cac12cb84522a
      8 #@untar:-J:sha256:55fdfa2696fb4d55a592fa9ad14a9df897c7b0008ddb3b30c419914841f85f33:.
      9 
     10 build_env_static() {
     11 	export LD_LIBRARY_PATH="$pthbs_build_environment/library"
     12 	export CPATH="$pthbs_build_environment/include"
     13 	export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS"
     14 }
     15 autotools_config() {
     16 	prefix=/versions/$pthbs_package
     17 	./configure -C \
     18 		--prefix="$prefix" \
     19 		--build="$(${CC:-gcc} -dumpmachine)" \
     20 		--bindir="$prefix/command" \
     21 		--sbindir="$prefix/command" \
     22 		--infodir="$prefix/info" \
     23 		--localedir="$prefix/locale" \
     24 		--mandir="$prefix/man" \
     25 		--libdir="$prefix/library" \
     26 		--docdir="$prefix/doc/libbsd" \
     27 		--datadir="$prefix/data" \
     28 		--datarootdir="$prefix/data" \
     29 		--localstatedir='/var/pthbs' \
     30 		"$@"
     31 
     32 }
     33 
     34 autotools() {
     35 	cd "$1"
     36 	shift
     37 	autotools_config "$@"
     38 	make -j${JOBS:-1} -l$((1+${JOBS:-1}))
     39 	make DESTDIR="$pthbs_destdir" install
     40 }
     41 
     42 autotools_static() {
     43 	build_env_static
     44 	autotools "$@" --enable-static --disable-shared
     45 }
     46 check_static() {
     47 	local exe || true
     48 	exe=$pthbs_destdir/'/versions'/$pthbs_package/$1
     49 	if ! test -f $exe; then
     50 		printf '%s\n' "Error: file '$1' doesn't exist!"
     51 		exit 1
     52 	fi
     53 	interp_info=$(readelf --string-dump=.interp "$exe") || exit $?
     54 	if test x '!=' "x$interp_info"; then
     55 		printf '%s\n' "Error: '$1' is a dynamic binary!"
     56 		exit 1
     57 	fi
     58 }
     59 
     60 autotools_static libbsd-0.11.8
     61 
     62 
     63 cd "$pthbs_destdir/versions/$pthbs_package"
     64 find -type d -o -print | awk -F/ '
     65 BEGIN {
     66 	x["./library/libbsd.a"]=1
     67 	x["./include/bsd/bsd.h"]=1
     68 }
     69 
     70 function r1(s) {
     71 	sub("^[.]/[^/]*", ".", s)
     72 	return s
     73 }
     74 function s1(repl, s) {
     75 	sub("^[.]/[^/]*", "./"repl, s)
     76 	return s
     77 }
     78 function link(src) {
     79 	x[$0]=0
     80 	printf "%s\t%s\n", $0, src
     81 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
     82 }
     83 $1!="."{exit 1}
     84 
     85 
     86 $2 == "command" { link($0); next }
     87 $2 == "bin" { link(s1("command", $0)); next }
     88 
     89 $2 == "library.so" { link($0); next }
     90 $2 == "library" { link($0); next }
     91 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next }
     92 $2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next }
     93 
     94 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next }
     95 
     96 $2 == "man" { link($0); next }
     97 $2 == "info" { link($0); next }
     98 $2 == "doc" { link($0); next }
     99 $2 == "icons" { link($0); next }
    100 $2 == "terminfo" { link($0); next }
    101 $2 == "data" { link($0); next }
    102 $2 == "include" { link($0); next }
    103 
    104 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
    105 
    106 END {
    107 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
    108 	for(fname in x) {
    109 		if(x[fname]) {
    110 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
    111 			exit 3
    112 		}
    113 	}
    114 }' >.install-links.new
    115 mv .install-links.new .install-links