]> git.draconx.ca Git - dxcommon.git/blobdiff - t/ccw32.sh
Add a macro to probe -mwindows on MinGW.
[dxcommon.git] / t / ccw32.sh
diff --git a/t/ccw32.sh b/t/ccw32.sh
new file mode 100755 (executable)
index 0000000..9a0fe7c
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Copyright © 2022 Nick Bowler
+#
+# Fake C compiler for testing PE subsystem probes.
+#
+# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+# This is free software: you are free to do what the fuck you want to.
+# There is NO WARRANTY, to the extent permitted by law.
+
+mode=link
+outfile=
+infile=
+
+: "${TEST_SUBSYS=3}"
+: "${TEST_GUI_FLAG=-mwindows}"
+
+for arg; do
+  shift
+
+  case $arg in
+  -o) outfile=$1; ;;
+  -c) mode=compile ;;
+  *.c) infile=$arg ;;
+  $TEST_GUI_FLAG) TEST_SUBSYS=2 ;;
+  esac
+done
+
+test x"$infile" != x || exit
+filebase=`expr "$infile" : '\(.*\).c$'`
+
+case $mode in
+link)
+  : "${outfile:=a.exe}"
+  ;;
+compile)
+  : "${outfile:=$filebase.obj}"
+  ;;
+esac
+
+:; {
+  printf '%-60s' MZ
+  printf '\101\1\0\0%257s' ''
+  printf 'PE\0\0%20s' ''
+  printf '\13\1%66s' ''
+  printf "\\$TEST_SUBSYS\\0"
+} >"$outfile"