summaryrefslogtreecommitdiff
path: root/move.sh
diff options
context:
space:
mode:
Diffstat (limited to 'move.sh')
-rwxr-xr-xmove.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/move.sh b/move.sh
new file mode 100755
index 0000000000..0312b2d36f
--- /dev/null
+++ b/move.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+in_array() {
+ local needle=$1; shift
+ local item
+ for item in "$@"; do
+ [[ $item = $needle ]] && return 0 # Found
+ done
+ return 1 # Not Found
+}
+
+(
+ set -e
+ find . \( -name Makefile -o -name '*.mk' \) -delete
+
+ touch .tmp.move.all
+ files=(.tmp.move.all)
+ file=/dev/null
+ IFS=''
+ while read -r line; do
+ if [[ $line = '#@'* ]]; then
+ file="${line#'#@'}"
+ file="${file%% *}"
+ elif [[ $file = all ]]; then
+ printf '%s\n' "$line" | tee -a "${files[@]}" >/dev/null
+ else
+ if ! in_array "$file" "${files[@]}"; then
+ cat .tmp.move.all > "$file"
+ files+=("$file")
+ fi
+ printf '%s\n' "$line" >> "$file"
+ fi
+ done < Makefile.am
+ rm .tmp.move.all
+)