title: elapsed time for each rule
body: <p>I have this bash code:</p>
  
  <p>(At the start of the script:)</p>
  
  <pre><code>function timer()
  {
      if [[ $# -eq 0 ]]; then
          echo $(date '+%s')
      else
          local  stime=$1
          etime=$(date '+%s')
  
          if [[ -z "$stime" ]]; then stime=$etime; fi
  
          dt=$((etime - stime))
          ds=$((dt % 60))
          dm=$(((dt / 60) % 60))
          dh=$((dt / 3600))
          printf '%d:%02d:%02d' $dh $dm $ds
      fi
  }
  
  t=$(timer)
  </code></pre>
  
  <p>(and, at the end of the script:)</p>
  
  <pre><code>printf 'Elapsed time: %s\n' $(timer $t)
  </code></pre>
  
  <p>to calculate the total time elapsed by the script. This code works fine in a bash (shell) script. So, I want to put this code in a makefile for each rule.</p>
  
  <p>How can I put this function in Makefile? And how can call'em in each rule?</p>
  
  <p>I made something like this:</p>
  
  <pre><code>define TIME
       stime=$(1)
       etime=$(date '+%s')
       dt=$((etime - stime)) \
       ds=$((dt % 60)) \
       ...
  endef
  </code></pre>
  
  <p>and in each rule:</p>
  
  <pre><code>rule1: dep1 dep2 dep3
      ...SOME STUFF
      @$(call TIME, starttime)
  
  rule2: depx depD rule1
      ...SOME STUFF
      @$(call TIME, starttime)
  </code></pre>
  
  <p>but the math operation does not work. I tried a lot of things but I can't do works</p>