]> git.draconx.ca Git - dxcommon.git/blob - t/gob2.sh
DX_C_ALIGNAS: Work around bash-5 parsing bug.
[dxcommon.git] / t / gob2.sh
1 #!/bin/sh
2 #
3 # Copyright © 2020 Nick Bowler
4 #
5 # Fake gob2 program for testing the gob2 detection macro.
6 #
7 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
8 # This is free software: you are free to do what the fuck you want to.
9 # There is NO WARRANTY, to the extent permitted by law.
10
11 : "${FAKE_GOB2_VERSION=2.0.0}"
12
13 argv0=$0
14
15 infile=
16 for arg
17 do
18   case $arg in
19   *.gob)
20     infile=$arg
21   esac
22 done
23
24 if test x"$infile" = x""; then
25   printf '%s: error: no input file\n' "$argv0" 1>&2
26   exit 1
27 fi
28
29 exec 3<"$infile"
30 save_IFS=$IFS
31 while IFS=$IFS. read a b c d e <&3; do
32   case $a in
33   requires)
34     IFS=$IFS.
35     set x $FAKE_GOB2_VERSION; shift
36     IFS=$save_IFS
37
38     { test "${1:-0}" -gt "${b:-0}" ||
39       { test "${1:-0}" -eq "${b:-0}" &&
40         { test "${2:-0}" -gt "${c:-0}" ||
41           { test "${2:-0}" -eq "${c:-0}" && test "${3:-0}" -ge "${d:-}"
42             }; }; }; } ||
43     { printf '%s: error: minimum version not met\n' "$argv0"; exit; }
44     ;;
45   esac
46 done
47
48 cat >conftest.c <<'EOF'
49 int conftest_get_type(void) { }
50 EOF