mrrl

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

libmd (3130B)


      1 #!/usr/bin/env pthbs-build
      2 #+musl-cross-make.757bcca6771cad3395ae302e0fdc835ebf5b4a965c08e30d758e6149b0bacbcd
      3 #+gnu-make.529116171fecc2bdac7c70e109d28270d765379c8a52cf7c3ea7453195bbf42b
      4 #+busybox.3664b94c09ea6d35ce73985026762c142829e53fed4a38541af3afb00c37dd4a
      5 #+busybox-diffutils.a22698424a7618572314d3da6953bf6652138ec492d3a0d01c37072f74adefc4
      6 #+m4.b78d93922dc9dbf43dd31037c98271490db5d6d1919b69b12122cf55fa1fb515
      7 #@untar:-J:sha256:1bd6aa42275313af3141c7cf2e5b964e8b1fd488025caf2f971f43b00776b332:.
      8 
      9 build_env_static() {
     10 	export LD_LIBRARY_PATH="$pthbs_build_environment/library"
     11 	export CPATH="$pthbs_build_environment/include"
     12 	export LDFLAGS="-static -L$pthbs_build_environment/library $LDFLAGS"
     13 }
     14 autotools_config() {
     15 	prefix=/versions/$pthbs_package
     16 	./configure -C \
     17 		--prefix="$prefix" \
     18 		--build="$(${CC:-gcc} -dumpmachine)" \
     19 		--bindir="$prefix/command" \
     20 		--sbindir="$prefix/command" \
     21 		--infodir="$prefix/info" \
     22 		--localedir="$prefix/locale" \
     23 		--mandir="$prefix/man" \
     24 		--libdir="$prefix/library" \
     25 		--docdir="$prefix/doc/libmd" \
     26 		--datadir="$prefix/data" \
     27 		--datarootdir="$prefix/data" \
     28 		--localstatedir='/var/pthbs' \
     29 		"$@"
     30 
     31 }
     32 
     33 autotools() {
     34 	cd "$1"
     35 	shift
     36 	autotools_config "$@"
     37 	make -j${JOBS:-1} -l$((1+${JOBS:-1}))
     38 	make DESTDIR="$pthbs_destdir" install
     39 }
     40 
     41 autotools_static() {
     42 	build_env_static
     43 	autotools "$@" --enable-static --disable-shared
     44 }
     45 check_static() {
     46 	local exe || true
     47 	exe=$pthbs_destdir/'/versions'/$pthbs_package/$1
     48 	if ! test -f $exe; then
     49 		printf '%s\n' "Error: file '$1' doesn't exist!"
     50 		exit 1
     51 	fi
     52 	interp_info=$(readelf --string-dump=.interp "$exe") || exit $?
     53 	if test x '!=' "x$interp_info"; then
     54 		printf '%s\n' "Error: '$1' is a dynamic binary!"
     55 		exit 1
     56 	fi
     57 }
     58 
     59 autotools_static libmd-1.1.0
     60 
     61 
     62 cd "$pthbs_destdir/versions/$pthbs_package"
     63 find -type d -o -print | awk -F/ '
     64 BEGIN {
     65 	x["./library/libmd.a"]=1
     66 	x["./include/rmd160.h"]=1
     67 	x["./include/sha512.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