major rewrite of build.sh

- it now only updates files that were modified after the
last build, whose time is save in log.txt as number of
seconds after 1970.
- the order of execution is changed so that each file is
visited once, and we perform all we need to do on it.
more reorganization in build.sh

- fixed a bug in the previous implementation - since files were not
  traversed from the bottom to the top, some links were missing. This
  forces the parent of each file to be higher in the directory
  hierarchy, which makes the whole thing less flexible, but I'll keep it
  for now.
- made the script even shorter, now there's no duplicate code it seems.