Thanks to the help of @Keesver and @pmcgee I now have quickjs-ng building with MINGW in WSL for Win32 and Win64.
It would have been nice to get them building with native windows tooling but alas that's just too hard due to how the project is setup (ifdef hell). My next challenge will be to get his automated on our CI servers (server 2019) which currently do not have wsl installed.
I added a windows resource file (winver.rc) so I can set the version number.
#include <windows.h>
1 VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "QuickJS NG"
VALUE "FileVersion", "1.0.0.0"
VALUE "ProductName", "QuickJS NG"
VALUE "Comment", "Compiled by VSoft Technologies Pty Ltd"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
FWIW - this is the makefile I ended up with - just provide the ARCH on the command line, e.g
make -f Makefile_win ARCH=64
Makefile_win
ARCH ?= 32
ifeq ($(ARCH),32)
CC = i686-w64-mingw32-gcc
CFLAGS = -O2 -fPIC -Wall -D_GNU_SOURCE -DCONFIG_VERSION=\"V16\"
LDFLAGS = -static -shared
RC_COMPILER = i686-w64-mingw32-windres --preprocessor=i686-w64-mingw32-gcc --preprocessor-arg=-E --preprocessor-arg=-xc-header --preprocessor-arg=-DRC_INVOKED
RC_FLAGS = --target=pe-i386
else
CC = x86_64-w64-mingw32-gcc
CFLAGS = -O2 -fPIC -Wall -D_GNU_SOURCE -DCONFIG_VERSION=\"V16\"
LDFLAGS = -static -shared
RC_COMPILER = x86_64-w64-mingw32-windres
RC_FLAGS =
endif
OUT_DIR = Win$(ARCH)
RC_FILE = winver.rc
RES_FILE = $(OUT_DIR)/winver.o
SRC = quickjs.c libunicode.c libregexp.c cutils.c libbf.c quickjs-libc.c
OBJS = $(patsubst %.c,$(OUT_DIR)/%.o,$(SRC))
TARGET = $(OUT_DIR)/quickjs-ng$(ARCH).dll
all: $(OUT_DIR) $(TARGET)
$(OUT_DIR):
mkdir -p $(OUT_DIR)
$(OUT_DIR)/%.o: %.c | $(OUT_DIR)
$(CC) $(CFLAGS) -c $< -o $@
$(RES_FILE): $(RC_FILE) | $(OUT_DIR)
$(RC_COMPILER)$(RC_FLAGS) -i $(RC_FILE) -o $(RES_FILE)
$(TARGET): $(OBJS) $(RES_FILE)
$(CC) $(LDFLAGS) -o $@ $^
clean:
rm -rf win$(ARCH)
Thanks again for all the help.