From c27c3ad87eb909fcec97be77875a4fc83aceb67e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Fri, 5 May 2023 16:10:08 -0400
Subject: [PATCH] Fix win32 builds, symbols need to be mangled appropriately.

Note, the CI job is needs to be updated with AS=mingw32-as... need
to find where that lives.
---
 src/conio/GNUmakefile  |  2 +-
 src/conio/genmap.c     | 19 +++++++++++--------
 src/syncterm/COMPILING |  4 ++--
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/conio/GNUmakefile b/src/conio/GNUmakefile
index e14fb74d39..82e045acbc 100644
--- a/src/conio/GNUmakefile
+++ b/src/conio/GNUmakefile
@@ -71,7 +71,7 @@ $(EXEODIR)$(DIRSEP)genmap$(EXEFILE): $(EXEODIR)
 
 rgbmap.s: $(EXEODIR)$(DIRSEP)genmap$(EXEFILE)
 	@echo Creating $@...
-	$(QUIET)$(EXEODIR)$(DIRSEP)genmap$(EXEFILE)
+	$(QUIET)$(EXEODIR)$(DIRSEP)genmap$(EXEFILE) $(os)
 
 rgbmap.h: rgbmap.s
 
diff --git a/src/conio/genmap.c b/src/conio/genmap.c
index 96916e8c11..ef71103749 100644
--- a/src/conio/genmap.c
+++ b/src/conio/genmap.c
@@ -1,5 +1,7 @@
 #include <stdio.h>
+#include <string.h>
 #include <inttypes.h>
+
 uint32_t r2y[16777216];
 uint32_t y2r[16777216];
 
@@ -58,20 +60,21 @@ main(int argc, char **argv)
 	FILE *h = fopen("rgbmap.h", "w");
 	FILE *r = fopen("r2y.bin", "wb");
 	FILE *y = fopen("y2r.bin", "wb");
+	char *mangle = "";
+
 	init_r2y();
+	if (argc > 1 && strcmp(argv[1], "win32") == 0)
+		mangle = "_";
 
 	fprintf(s,
 	    ".section .rodata\n"
-	    ".global r2y\n"
-	    ".type   r2y, @object\n"
+	    ".global %sr2y\n"
+	    ".global %sy2r\n"
 	    ".align  4\n"
-	    "r2y:\n"
+	    "%sr2y:\n"
 	    "	.incbin \"r2y.bin\"\n"
-	    ".global y2r\n"
-	    ".type   y2r, @object\n"
-	    ".align  4\n"
-	    "y2r:\n"
-	    "	.incbin \"y2r.bin\"\n");
+	    "%sy2r:\n"
+	    "	.incbin \"y2r.bin\"\n", mangle, mangle, mangle, mangle);
 	fprintf(h,
 	    "#ifndef RGBMAP_H\n"
 	    "#define RGBMAP_H\n"
diff --git a/src/syncterm/COMPILING b/src/syncterm/COMPILING
index 3c4cb0b958..581b7bf8c1 100644
--- a/src/syncterm/COMPILING
+++ b/src/syncterm/COMPILING
@@ -46,7 +46,7 @@ with the following command:
 hdiutil convert ~/Desktop/SyncTERM.dmg -format UDRO -o /Volumes/Synchronet/sbbs/web/root/syncterm.bbsdev.net/SyncTERM.dmg -ov
 
 Release builds for Win32 using MinGW32 use the following command line:
-gmake CC=mingw32-gcc VERBOSE=please AR=mingw32-ar RANLIB=mingw32-ranlib RELEASE=1 CXX=mingw32-g++ WINDRES=mingw32-windres
+gmake CC=mingw32-gcc VERBOSE=please AR=mingw32-ar AS=mingw32-as RANLIB=mingw32-ranlib RELEASE=1 CXX=mingw32-g++ WINDRES=mingw32-windres
 
 Release builds of jsdoor (not related at all)
-gmake jsdoor NO_LD_RUN_PATH=dumbass CC=mingw32-gcc VERBOSE=please AR=mingw32-ar RANLIB=mingw32-ranlib RELEASE=1 CXX=mingw32-g++ WINDRES=mingw32-windres JSLIBDIR=../../3rdp/win32.release/mozjs/bin/ JSINCLUDE=../../3rdp/win32.release/mozjs/include/ JSLIB=mozjs
+gmake jsdoor NO_LD_RUN_PATH=dumbass CC=mingw32-gcc VERBOSE=please AR=mingw32-ar AS=mingw32-as RANLIB=mingw32-ranlib RELEASE=1 CXX=mingw32-g++ WINDRES=mingw32-windres JSLIBDIR=../../3rdp/win32.release/mozjs/bin/ JSINCLUDE=../../3rdp/win32.release/mozjs/include/ JSLIB=mozjs
-- 
GitLab