File: configure.nacl

package info (click to toggle)
curvedns 0.87-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,964 kB
  • sloc: asm: 19,669; ansic: 11,907; cpp: 1,066; sh: 954; makefile: 57
file content (420 lines) | stat: -rwxr-xr-x 11,400 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
#!/bin/sh

# nacl/do
# D. J. Bernstein
#  Edited by H.A. van Tilborg for release with CurveDNS
# Public domain.

project=nacl
version=`cat "$project"/version`
shorthostname=`hostname | sed 's/\..*//' | tr -cd '[a-z][A-Z][0-9]'`

top="`pwd`/$project/build"
bin="$top/bin"
lib="$top/lib"
include="$top/include"
work="$top/work"

PATH="/usr/local/bin:$PATH"
PATH="/usr/sfw/bin:$PATH"
PATH="$bin:$PATH"
export PATH

LD_LIBRARY_PATH="/usr/local/lib/sparcv9:/usr/local/lib:$LD_LIBRARY_PATH"
LD_LIBRARY_PATH="/usr/sfw/lib/sparcv9:/usr/sfw/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH

# and wacky MacOS X
DYLD_LIBRARY_PATH="/usr/local/lib/sparcv9:/usr/local/lib:$DYLD_LIBRARY_PATH"
DYLD_LIBRARY_PATH="/usr/sfw/lib/sparcv9:/usr/sfw/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH

# and work around bug in GNU sort
LANG=C
export LANG

rm -rf "$top"
cd "$project"
mkdir -p "$top"
mkdir -p "$bin"
mkdir -p "$lib"
mkdir -p "$include"

exec >"$top/log"
exec 2>&1
exec 5>"$top/data"
exec </dev/null

echo "=== `date` === starting"

echo "=== `date` === hostname"
hostname || :
echo "=== `date` === uname -a"
uname -a || :
echo "=== `date` === uname -M"
uname -M || :
echo "=== `date` === uname -F"
uname -F || :
echo "=== `date` === /usr/sbin/lscfg | grep proc"
/usr/sbin/lscfg | grep proc || :
echo "=== `date` === /usr/sbin/lsattr -El proc0"
/usr/sbin/lsattr -El proc0 || :
echo "=== `date` === cat /proc/cpuinfo"
cat /proc/cpuinfo || :
echo "=== `date` === cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq || :
echo "=== `date` === cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq || :
echo "=== `date` === cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq || :
echo "=== `date` === cat /sys/devices/system/cpu/cpu0/clock_tick"
cat /sys/devices/system/cpu/cpu0/clock_tick || :
echo "=== `date` === sysctl hw.model"
sysctl hw.model || :
echo "=== `date` === sysctl machdep.tsc_freq"
sysctl machdep.tsc_freq || :
echo "=== `date` === /usr/sbin/psrinfo -v"
/usr/sbin/psrinfo -v || :

echo "=== `date` === building okcompilers"
rm -rf "$work"
mkdir -p "$work"
cp -pr okcompilers/* "$work"
( cd "$work" && sh do )
cp -p "$work"/bin/* "$bin"

echo "=== `date` === building cpuid"
rm -rf "$work"
mkdir -p "$work"
cp -pr cpuid/* "$work"
( cd "$work" && sh do )
cp -pr "$work"/include/* "$include"

echo "=== `date` === building inttypes"
rm -rf "$work"
mkdir -p "$work"
cp -pr inttypes/* "$work"
( cd "$work" && sh do )
cp -pr "$work"/include/* "$include"

echo "=== `date` === building cpucycles"
rm -rf "$work"
mkdir -p "$work"
cp -pr cpucycles/* "$work"
( cd "$work" && sh do )
cp -pr "$work"/lib/* "$lib"
cp -pr "$work"/include/* "$include"

echo "=== `date` === building randombytes"
rm -rf "$work"
mkdir -p "$work"
cp -pr randombytes/* "$work"
( cd "$work" && sh do )
cp -pr "$work"/lib/* "$lib"
cp -pr "$work"/include/* "$include"

okabi \
| while read abi
do
  rm -rf "$work"
  mkdir -p "$work"
  echo 'void crypto_'"$project"'_base(void) { ; }' > "$work/${project}_base.c"
  okc-$abi \
  | while read compiler
  do
    ( cd "$work" && $compiler -c ${project}_base.c ) && break
  done
  okar-$abi cr "$lib/$abi/lib${project}.a" "$work/${project}_base.o"
  ( ranlib "$lib/$abi/lib${project}.a" || exit 0 )
done

# loop over operations
cat OPERATIONS \
| while read o
do
  [ -d "$o" ] || continue

  selected=''
  [ -f "$o/selected" ] && selected=`cat "$o/selected"`

  # for each operation, loop over primitives
  ls "$o" \
  | sort \
  | while read p
  do
    [ -d "$o/$p" ] || continue
    expectedchecksum=''
    [ -f "$o/$p/checksum" ] && expectedchecksum=`cat "$o/$p/checksum"`
    op="${o}_${p}"

    startdate=`date +%Y%m%d`

    # for each operation primitive, loop over abis
    okabi \
    | while read abi
    do
      echo "=== `date` === $abi $o/$p"
      libs=`"oklibs-$abi"`
      libs="$lib/$abi/cpucycles.o $libs"
      [ -f "$lib/$abi/lib${project}.a" ] && libs="$lib/$abi/lib${project}.a $libs"

      rm -rf "$work"
      mkdir -p "$work"
      mkdir -p "$work/best"

      # for each operation primitive abi, loop over implementations
      find "$o/$p" -follow -name "api.h" \
      | sort \
      | while read doth
      do
        implementationdir=`dirname $doth`
	opi=`echo "$implementationdir" | tr ./- ___`

	echo "=== `date` === $abi $implementationdir"

	rm -rf "$work/compile"
	mkdir -p "$work/compile"
  
	cfiles=`ls "$implementationdir" | grep '\.c$' || :`
	sfiles=`ls "$implementationdir" | grep '\.[sS]$' || :`
	cppfiles=`ls "$o" | grep '\.cpp$' || :`
  
	cp -p "$o"/*.c "$work/compile/"
	cp -p "$o"/*.cpp "$work/compile/"

	cp -pr "$implementationdir"/* "$work/compile"

	cp -p "try-anything.c" "$work/compile/try-anything.c"
	cp -p "measure-anything.c" "$work/compile/measure-anything.c"

	cp -p MACROS "$work/compile/MACROS"
	cp -p PROTOTYPES.c "$work/compile/PROTOTYPES.c"
	cp -p PROTOTYPES.cpp "$work/compile/PROTOTYPES.cpp"

	(
	  cd "$work/compile"
	  (
	    echo "#ifndef ${o}_H"
	    echo "#define ${o}_H"
	    echo ""
	    echo "#include \"${op}.h\""
	    echo ""
	    egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < MACROS \
	    | sed "s/$o/$op/" | while read mop
	    do
	      echo "#define ${mop} ${mop}" | sed "s/$op/$o/"
	    done
	    echo "#define ${o}_PRIMITIVE \"${p}\""
	    echo "#define ${o}_IMPLEMENTATION ${op}_IMPLEMENTATION"
	    echo "#define ${o}_VERSION ${op}_VERSION"
	    echo ""
	    echo "#endif"
	  ) > "$o.h"
	  (
	    echo "#ifndef ${op}_H"
	    echo "#define ${op}_H"
	    echo ""
	    sed 's/[ 	]CRYPTO_/ '"${opi}"'_/g' < api.h
	    echo '#ifdef __cplusplus'
	    echo '#include <string>'
	    egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < PROTOTYPES.cpp \
	    | sed "s/$o/$opi/"
	    echo 'extern "C" {'
	    echo '#endif'
	    egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < PROTOTYPES.c \
	    | sed "s/$o/$opi/"
	    echo '#ifdef __cplusplus'
	    echo '}'
	    echo '#endif'
	    echo ""
	    egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < MACROS \
	    | sed "s/$o/$opi/" | while read mopi
	    do
	      echo "#define ${mopi} ${mopi}" | sed "s/$opi/$op/"
	    done
	    echo "#define ${op}_IMPLEMENTATION \"${implementationdir}\""
	    echo "#ifndef ${opi}_VERSION"
	    echo "#define ${opi}_VERSION \"-\""
	    echo "#endif"
	    echo "#define ${op}_VERSION ${opi}_VERSION"
	    echo ""
	    echo "#endif"
	  ) > "$op.h"

	  okc-$abi \
	  | while read compiler
	  do
	    echo "=== `date` === $abi $implementationdir $compiler"
	    compilerword=`echo "$compiler" | tr ' ' '_'`
	    ok=1
	    for f in $cfiles $sfiles
	    do
	      if [ "$ok" = 1 ]
	      then
		$compiler \
		  -I. -I"$include" -I"$include/$abi" \
		  -c "$f" >../errors 2>&1 || ok=0
		( if [ `wc -l < ../errors` -lt 25 ]
		  then
		    cat ../errors
		  else
		    head ../errors
		    echo ...
		    tail ../errors
		  fi
		) \
		| while read err
		do
		  echo "$version $shorthostname $abi $startdate $o $p fromcompiler $implementationdir $compilerword $f $err" >&5
		done
	      fi
	    done

	    [ "$ok" = 1 ] || continue
	    okar-$abi cr "$op.a" *.o || continue
	    ranlib "$op.a"

	    $compiler \
	      -I. -I"$include" -I"$include/$abi" \
	      -o try try.c try-anything.c \
	      "$op.a" $libs >../errors 2>&1 || ok=0
	    cat ../errors \
	    | while read err
	    do
	      echo "$version $shorthostname $abi $startdate $o $p fromcompiler $implementationdir $compilerword try.c $err" >&5
	    done
	    [ "$ok" = 1 ] || continue

	    if sh -c './try || exit $?' >../outputs 2>../errors
	    then
	      checksum=`awk '{print $1}' < ../outputs`
	      cycles=`awk '{print $2}' < ../outputs`
	      checksumcycles=`awk '{print $3}' < ../outputs`
	      cyclespersecond=`awk '{print $4}' < ../outputs`
	      impl=`awk '{print $5}' < ../outputs`
	    else
	      echo "$version $shorthostname $abi $startdate $o $p tryfails $implementationdir $compilerword error $?" >&5
	      cat ../outputs ../errors \
	      | while read err
	      do
	        echo "$version $shorthostname $abi $startdate $o $p tryfails $implementationdir $compilerword $err" >&5
	      done
	      continue
	    fi

	    checksumok=fails
	    [ "x$expectedchecksum" = "x$checksum" ] && checksumok=ok
	    [ "x$expectedchecksum" = "x" ] && checksumok=unknown
	    echo "$version $shorthostname $abi $startdate $o $p try $checksum $checksumok $cycles $checksumcycles $cyclespersecond $impl $compilerword" >&5
	    [ "$checksumok" = fails ] && continue

	    [ -s ../bestmedian ] && [ `cat ../bestmedian` -le $cycles ] && continue
	    echo "$cycles" > ../bestmedian

	    $compiler -D'COMPILER="'"$compiler"'"' \
	      -DLOOPS=1 \
	      -I. -I"$include" -I"$include/$abi" \
	      -o measure measure.c measure-anything.c \
	      "$op.a" $libs >../errors 2>&1 || ok=0
	    cat ../errors \
	    | while read err
	    do
	      echo "$version $shorthostname $abi $startdate $o $p fromcompiler $implementationdir $compilerword measure.c $err" >&5
	    done
	    [ "$ok" = 1 ] || continue

	    for f in $cppfiles
	    do
	      okcpp-$abi \
	      | while read cppcompiler
	      do
	        echo "=== `date` === $abi $implementationdir $cppcompiler"
	        $cppcompiler \
		  -I. -I"$include" -I"$include/$abi" \
		  -c "$f" && break
	      done
	    done

	    rm -f ../best/*.o ../best/measure || continue
	    for f in *.o
	    do
	      cp -p "$f" "../best/${opi}-$f"
	    done
	    cp -p "$op.h" "../$op.h"
	    cp -p "$o.h" "../$o.h"
	    cp -p measure ../best/measure
	  done
	)
      done

      echo "=== `date` === $abi $o/$p measuring"

      "$work/best/measure" \
      | while read measurement
      do
	echo "$version $shorthostname $abi $startdate $o $p $measurement" >&5
      done

      [ -f "$o/$p/used" ] \
      && okar-$abi cr "$lib/$abi/lib${project}.a" "$work/best"/*.o \
      && ( ranlib "$lib/$abi/lib${project}.a" || exit 0 ) \
      && cp -p "$work/$op.h" "$include/$abi/$op.h" \
      && [ -f "$o/$p/selected" ] \
      && cp -p "$work/$o.h" "$include/$abi/$o.h" \
      || :
    done
  done
done

for language in c cpp
do
  for bintype in commandline tests
  do
    ls $bintype \
    | sed -n 's/\.'$language'$//p' \
    | sort \
    | while read cmd
    do
      echo "=== `date` === starting $bintype/$cmd"
    
      rm -rf "$work"
      mkdir -p "$work/compile"
    
      cp "$bintype/$cmd.$language" "$work/compile/$cmd.$language"
      [ "$bintype" = tests ] && cp -p "$bintype/$cmd.out" "$work/compile/$cmd.out"
    
      okabi \
      | while read abi
      do
        [ -x "$bin/$cmd" ] && break
    
        libs=`"oklibs-$abi"`
        libs="$lib/$abi/cpucycles.o $libs"
        libs="$libs $lib/$abi/randombytes.o"
    
        ok${language}-$abi \
        | while read compiler
        do
          [ -x "$bin/$cmd" ] && break
    
          echo "=== `date` === $bintype/$cmd $abi $compiler"
          (
            cd "$work/compile"
            if $compiler \
              -I"$include" -I"$include/$abi" \
              -o "$cmd" "$cmd.${language}" \
              "$lib/$abi/lib${project}.a" $libs
	    then
	      case "$bintype" in
	        commandline) cp -p "$cmd" "$bin/$cmd" ;;
		tests) "./$cmd" | cmp - "$cmd.out" || "./$cmd" ;;
	      esac
	    fi
          )
        done
      done
    done
  done
done

echo "=== `date` === finishing"