at-compat: Add diff workaround for DOS/Windows hosts.
[dxcommon.git] / t / ccw32.sh
blob9a0fe7c95aba9f63f25a6280e8806893e58ba5cf
1 #!/bin/sh
3 # Copyright © 2022 Nick Bowler
5 # Fake C compiler for testing PE subsystem probes.
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.
11 mode=link
12 outfile=
13 infile=
15 : "${TEST_SUBSYS=3}"
16 : "${TEST_GUI_FLAG=-mwindows}"
18 for arg; do
19 shift
21 case $arg in
22 -o) outfile=$1; ;;
23 -c) mode=compile ;;
24 *.c) infile=$arg ;;
25 $TEST_GUI_FLAG) TEST_SUBSYS=2 ;;
26 esac
27 done
29 test x"$infile" != x || exit
30 filebase=`expr "$infile" : '\(.*\).c$'`
32 case $mode in
33 link)
34 : "${outfile:=a.exe}"
36 compile)
37 : "${outfile:=$filebase.obj}"
39 esac
41 :; {
42 printf '%-60s' MZ
43 printf '\101\1\0\0%257s' ''
44 printf 'PE\0\0%20s' ''
45 printf '\13\1%66s' ''
46 printf "\\$TEST_SUBSYS\\0"
47 } >"$outfile"