]> git.draconx.ca Git - dxcommon.git/blob - t/ccw32.sh
DX_C_ALIGNAS: Work around bash-5 parsing bug.
[dxcommon.git] / t / ccw32.sh
1 #!/bin/sh
2 #
3 # Copyright © 2022 Nick Bowler
4 #
5 # Fake C compiler for testing PE subsystem probes.
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 mode=link
12 outfile=
13 infile=
14
15 : "${TEST_SUBSYS=3}"
16 : "${TEST_GUI_FLAG=-mwindows}"
17
18 for arg; do
19   shift
20
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
28
29 test x"$infile" != x || exit
30 filebase=`expr "$infile" : '\(.*\).c$'`
31
32 case $mode in
33 link)
34   : "${outfile:=a.exe}"
35   ;;
36 compile)
37   : "${outfile:=$filebase.obj}"
38   ;;
39 esac
40
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"