summaryrefslogtreecommitdiff
path: root/nacl/cpuid/do
blob: 8a3a6f7b3564abac54fc13188b9bc34a4563164d (plain)
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
#!/bin/sh -e

mkdir include

(
  echo x86
  echo unknown
) | (
  while read n
  do
    okabi | (
      while read abi
      do
        okc-$abi | (
          while read c
          do
            echo "=== `date` === Trying $n.c with $c..." >&2
            rm -f cpuid.c
	    cp $n.c cpuid.c || continue
            $c -o cpuid cpuid.c || continue
            $c -o cbytes cbytes.c || continue
	    ./cpuid > cpuid.out || continue
	    echo 'static const char cpuid[] = {' > cpuid.h || continue
	    ./cbytes < cpuid.out >> cpuid.h || continue
	    echo '} ;' >> cpuid.h || continue
	    cp cpuid.h include/cpuid.h || continue
	    cat cpuid.out
            exit 0
          done
          exit 111
        ) && exit 0
      done
      exit 111
    ) && exit 0
  done
  exit 111
)