Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 45 lines 1.2 kB view raw
1# Wrap the given `aclocal' program, appending extra `-I' flags 2# corresponding to the directories listed in $ACLOCAL_PATH. (Note 3# that `wrapProgram' can't be used for that purpose since it can only 4# prepend flags, not append them.) 5wrapAclocal() { 6 local program="$1" 7 local wrapped="$(dirname $program)/.$(basename $program)-wrapped" 8 9 mv "$program" "$wrapped" 10 cat > "$program"<<EOF 11#! $SHELL -e 12 13unset extraFlagsArray 14declare -a extraFlagsArray 15 16oldIFS=\$IFS 17IFS=: 18for dir in \$ACLOCAL_PATH; do 19 if test -n "\$dir" -a -d "\$dir"; then 20 extraFlagsArray=("\${extraFlagsArray[@]}" "-I" "\$dir") 21 fi 22done 23IFS=\$oldIFS 24 25exec "$wrapped" "\$@" "\${extraFlagsArray[@]}" 26EOF 27 chmod +x "$program" 28} 29 30postInstall() { 31 # Create a wrapper around `aclocal' that converts every element in 32 # `ACLOCAL_PATH' into a `-I dir' option. This way `aclocal' 33 # becomes modular; M4 macros do not need to be stored in a single 34 # global directory, while callers of `aclocal' do not need to pass 35 # `-I' options explicitly. 36 37 for prog in $out/bin/aclocal*; do 38 wrapAclocal "$prog" 39 done 40 41 ln -s aclocal-1.11 $out/share/aclocal 42 ln -s automake-1.11 $out/share/automake 43} 44 45genericBuild