pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


make_numtree1.ksh93 - build makefile to generate number sequence
Posted by Anonymous on Fri 19th Jul 2024 00:01
raw | new post
view followups (newest first): make_numtree1.ksh93 - build makefile to generate number sequence by Anonymous
modification of post by Anonymous (view diff)

  1. #!/bin/ksh93
  2.  
  3. #
  4. # make_numtree1.ksh93 - build makefile to generate number sequence
  5. # The resulting Makefile is intended to be used with $ make -j128 all #
  6. # as filesystem test
  7. #
  8. # Written by Roland Mainz <roland.mainz@nrubsig.org>
  9. #
  10.  
  11. function make_number_seq
  12. {
  13. #       set -o nounset
  14.  
  15.         nameref out_maketarget=$1
  16.         integer start_i=$2
  17.         integer stop_i=$3
  18.         integer i
  19.         typeset -a make_targets
  20.  
  21.         if (( (stop_i - start_i) > 100 ; then
  22.                 (( i=(stop_i - start_i)/2 ))
  23.                 make_number_seq make_targets[0] $start_i $(( start_i+i ))
  24.                 make_number_seq make_targets[1] $(( start_i+i+1 )) $stop_i
  25.         else
  26.                 for ((i=start_i ; i < stop_i ; i++ )) ; do
  27.                         printf 'i_%d:\n' i
  28.                         printf '\tprintf "%d\\n" >"i_%d"\n' i i
  29.                         make_targets+=( "i_$i" )
  30.                 done
  31.         fi
  32.  
  33.         out_maketarget="i_${start_i}_${stop_i}"
  34.         printf 'i_%d_%d: %s\n' start_i stop_i "${make_targets[*]}"
  35.  
  36.         printf '\tcat '
  37.         printf '%q ' "${make_targets[@]}"
  38.         printf ' >"%s"\n' "$out_maketarget"
  39.  
  40.         return 0
  41. }
  42.  
  43. typeset make_target
  44.  
  45. make_number_seq make_target 0 100
  46.  
  47. printf 'all: %s\n' "$make_target"
  48. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at