3 # I still can't believe I am doing this
5 # (This can't be done with gnu make, because of circular dependency issues)
8 components="piece.py board.py player.py thread_util.py game.py graphics.py main.py"
9 # The below seems nicer, but doesn't work because things need to be imported in the right order :(
10 #components=$(ls *.py | tr '\t' '\n' | grep -v $target)
12 header="#!/usr/bin/python -u"
13 footer="# EOF - created from update.sh on $(date)"
17 # If the target was modified more recently than any of the components, update the component file
18 target_mod=$(stat -c %Y $target 2>/dev/null)
25 for f in $components; do
27 component_mod=$(stat -c %Y $f 2>/dev/null)
30 elif [ $component_mod -lt $target_mod ]; then
36 if $update_required; then
37 echo "$0 - update $f from $target"
38 sanity=$(egrep "(+++ $f +++)|(--- $f ---)" $target | wc -l)
39 if [ $sanity -ne 2 ]; then
40 $(echo "$0 - $target does not have markers for $f in it!") 1>&2
44 new_contents=$(nawk "/+++ $f +++/, /--- $f ---/" $target | grep -v "+++ $f +++" | grep -v "\--- $f ---")
46 echo "$new_contents" > $f
48 echo "$0 - $f is newer than $target"
54 # If any components were modified more recently than the target, merge the components into the target
55 if $merge_required; then
56 echo $header > $target
57 for f in $components; do
58 echo "$0 - merge $f into $target"
59 echo "# +++ $f +++ #" >> $target
61 echo "# --- $f --- #" >> $target
64 echo $footer >> $target