Debian Codegraph @

ReleaseTools/permute

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # Run through all possible configuration combinations
4 # permute [-n] [-s] [-v] [program...]
5 # -n Just display the combinations
6 # -s Just run the singles
7
8 # Needs to be run from the top of a source tree (where x3270, s3270, tcl3270
9 # and c3270 can be seen).
10
11 TD=${TD-/tmp}
12 ver=3.3
13 prog=${0##*/}
14
15 function usagescip-shell shell shell-project 0.0.0 usage().()
16 {
17 echoscip-shell system . . echo. >&2 "usage $prog [-n] [-s] [-v] [program...]"
18 exit 1
19 }
20
21 while (( $# > 0 ))
22 do case $1 in
23 -n) noop=1
24 shift
25 ;;
26 -s) singles=1
27 shift
28 ;;
29 -v) verbose=1
30 shift
31 ;;
32 -*) usagescip-shell shell shell-project 0.0.0 usage().
33 ;;
34 *) break
35 esac
36 done
37
38 if [scip-shell system . . `[`. $# -eq 0 ]
39 then progs="x3270 s3270 tcl3270 c3270 pr3287"
40 else progs="$@"
41 fi
42
43 # Run one iteration
44 # $prog program name
45 # $c configure options
46 #
47 # $TD temporary directory
48 # $noop if 1, display rather than run
49 function iteratescip-shell shell shell-project 0.0.0 iterate().()
50 {
51 typeset rc=0
52
53 if [scip-shell system . . `[`. $noop ]
54 then echoscip-shell system . . echo. $prog: $c
55 else ./configure --without-pr3287 $c >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || (echoscip-shell system . . echo. "$prog configure --without-pr3287 $c failed"; exit 1)
56 makescip-shell system . . make. clean >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
57 if mk >$TD/mk$$ 2>&1
58 then echoscip-shell system . . echo. -n "."
59 else echoscip-shell system . . echo.
60 echoscip-shell system . . echo. "$prog failed: $c"
61 [scip-shell system . . `[`. $verbose ] && catscip-shell system . . cat. $TD/mk$$
62 rc=1
63 fi
64 if grepscip-shell system . . grep. 'warning:' $TD/mk$$
65 then echoscip-shell system . . echo. "Warnings: $c"
66 fi
67 rmscip-shell system . . rm. $TD/mk$$
68 fi
69 return $rc
70 }
71
72 # Compute the options for the given iteration.
73 # $1 iteration
74 #
75 # $n_opts number of possible options for this program
76 # $masks[] bit mask for each option
77 # $opts[] name of each option
78 # $nixpr --without-pr3287 option, if applicable
79 function config_optsscip-shell shell shell-project 0.0.0 config_opts().()
80 {
81 typeset -i x=$1
82 typeset c=""
83 typeset -i j=0
84
85 while (( j < n_opts ))
86 do if (( x & ${masks[$j]} ))
87 then c="$c --${opts[$j]}"
88 fi
89 j=j+1
90 done
91 echoscip-shell system . . echo. $c $nixpr
92 }
93
94 # Count the bits in $1.
95 # $1 integer to evaluate
96 function cobscip-shell shell shell-project 0.0.0 cob().()
97 {
98 typeset -i n=$1 b=1 r=0
99 while (( $b <= $n ))
100 do if (( $n & $b ))
101 then r=r+1
102 fi
103 b=b*2
104 done
105 echoscip-shell system . . echo. $r
106 }
107
108 for prog in $progs
109 do echoscip-shell system . . echo. "Trying $prog."
110 rmscip-shell system . . rm. -rf $TD/$prog-$ver/
111 p=$PWD
112 cd $prog
113 makescip-shell system . . make. -f Makefile.aux $prog-src.tgz
114 cd $TD/
115 tarscip-shell system . . tar. -xzf ~-/$prog-src.tgz
116 cd $prog-$ver/
117 [scip-shell system . . `[`. -f $p/$prog/.mk ] && cpscip-shell system . . cp. $p/$prog/.mk .
118
119 typeset -i b=1
120 unset opts[@]
121 if [scip-shell system . . `[`. $prog = x3270 -o $prog = c3270 ]
122 then nixpr=--without-pr3287
123 else unset nixpr
124 fi
125 typeset -a opts masks
126 typeset -i n_opts=0
127 for opt in disable-ansi disable-apl disable-local-process disable-printer disable-script disable-tn3270e disable-trace disable-menus disable-keypad disable-ft disable-ssl disable-dbcs with-iconv disable-ipv6
128 do unset ok
129 case $opt in
130 disable-dbcs|disable-ssl|with-iconv|disable-ipv6)
131 # apply to all
132 ok=1
133 ;;
134 disable-ansi|disable-apl|disable-local-process|disable-tn3270e|disable-trace|disable-ft)
135 # apply to all except pr3287
136 if [scip-shell system . . `[`. $prog != pr3287 ]
137 then ok=1
138 fi
139 ;;
140 disable-printer|disable-menus)
141 # only apply to x3270 and c3270
142 if [scip-shell system . . `[`. $prog = x3270 -o $prog = c3270 ]
143 then ok=1
144 fi
145 ;;
146 disable-script)
147 # required for s3270 and tcl3270
148 if [scip-shell system . . `[`. $prog != s3270 -a $prog != tcl3270 -a $prog != pr3287 ]
149 then ok=1
150 fi
151 ;;
152 disable-keypad)
153 # apply only to x3270
154 if [scip-shell system . . `[`. $prog = x3270 ]
155 then ok=1
156 fi
157 ;;
158 esac
159 if [scip-shell system . . `[`. "$ok" ]
160 then opts[$n_opts]=$opt
161 masks[$n_opts]=$b
162 b=b*2
163 n_opts=n_opts+1
164 fi
165 done
166 echoscip-shell system . . echo. "$prog: possible options are [${opts[@]}]: $b combinations"
167
168 # Loop through the singles.
169 typeset -i x=0
170 while (( x < b ))
171 do c=$(config_optsscip-shell shell shell-project 0.0.0 config_opts(). $x)
172 iteratescip-shell shell shell-project 0.0.0 iterate(). || exit 1
173 if (( $x == 0 ))
174 then x=1
175 else x=x*2
176 fi
177 done
178
179 # Loop through everything else.
180 if [scip-shell system . . `[`. ! "$singles" ]
181 then
182 typeset -i x=0
183 while (( x < b ))
184 do c=$(config_optsscip-shell shell shell-project 0.0.0 config_opts(). $x)
185 typeset nb=$(cobscip-shell shell shell-project 0.0.0 cob(). $x)
186 if (( nb > 1 ))
187 then iteratescip-shell shell shell-project 0.0.0 iterate().
188 fi
189 x=x+1
190 done
191 fi
192
193 echoscip-shell system . . echo.
194
195 cd ..
196 rmscip-shell system . . rm. -rf $prog-$ver/
197 cd $p
198 done