pthbs

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

m4 (3036B)


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