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 network.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)
27 for f in $components; do
29 component_mod=$(stat -c %Y $f 2>/dev/null)
32 elif [ $component_mod -lt $target_mod ]; then
38 if $update_required; then
39 echo "$0 - update $f from $target"
40 sanity=$(egrep "(+++ $f +++)|(--- $f ---)" $target | wc -l)
41 if [ $sanity -ne 2 ]; then
42 $(echo "$0 - $target does not have markers for $f in it!") 1>&2
46 new_contents=$(nawk "/+++ $f +++/, /--- $f ---/" $target | grep -v "+++ $f +++" | grep -v "\--- $f ---")
48 echo "$new_contents" > $f
50 echo "$0 - $f is newer than $target"
58 # If any components were modified more recently than the target, merge the components into the target
59 if $merge_required; then
60 echo $header > $target
61 for f in $components; do
62 echo "$0 - merge $f into $target"
63 echo "# +++ $f +++ #" >> $target
65 echo "# --- $f --- #" >> $target
68 echo $footer >> $target