From 834a6084c308c5691c1853a52f62deabca07ef8d Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Wed, 28 May 2025 14:03:13 -0700 Subject: [PATCH] WIP. Moving to WSL1 environment --- bin/makefile-cygwin.x86_64-sdl | 2 +- bin/makefile-wsl1.x86_64-sdl | 25 +++++++++++++++++++++++++ bin/makefile-wsl1.x86_64-x | 28 ++++++++++++++++++++++++++++ bin/osversion | 7 ++++++- inc/maiko/platform.h | 12 +++++++++++- 5 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 bin/makefile-wsl1.x86_64-sdl create mode 100644 bin/makefile-wsl1.x86_64-x diff --git a/bin/makefile-cygwin.x86_64-sdl b/bin/makefile-cygwin.x86_64-sdl index 28531eb..6538071 100644 --- a/bin/makefile-cygwin.x86_64-sdl +++ b/bin/makefile-cygwin.x86_64-sdl @@ -15,7 +15,7 @@ XFLAGS = -DSDL=2 # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ LDFLAGS = -lm -L/usr/local/lib -lSDL2 # diff --git a/bin/makefile-wsl1.x86_64-sdl b/bin/makefile-wsl1.x86_64-sdl new file mode 100644 index 0000000..ccf98c3 --- /dev/null +++ b/bin/makefile-wsl1.x86_64-sdl @@ -0,0 +1,25 @@ +# Options for Linux, Intel x86_64 and SDL + +CC = gcc -m64 $(GCC_CFLAGS) +# CC = clang -m64 $(CLANG_CFLAGS) + +XFILES = $(OBJECTDIR)sdl.o + +# +# For SDL version 2 +# -DSDL=2 in XFLAGS and -lSDL2 in LDFLAGS +# For SDL version 3 +# -DSDL=3 in XFLAGS and -lSDL3 in LDFLAGS +# +XFLAGS = -DSDL=2 + +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 -g3 +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) + +LDFLAGS = -lm -lSDL2 +LDELDFLAGS = + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl diff --git a/bin/makefile-wsl1.x86_64-x b/bin/makefile-wsl1.x86_64-x new file mode 100644 index 0000000..4e80252 --- /dev/null +++ b/bin/makefile-wsl1.x86_64-x @@ -0,0 +1,28 @@ +# Options for Linux, Intel x86_64 and X-Window + +CC = gcc -m64 $(GCC_CFLAGS) +# CC = clang -m64 $(CLANG_CFLAGS) + +XFILES = $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)xinit.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xwinman.o + + +XFLAGS = -DXWINDOW + +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 -g3 +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ + +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex diff --git a/bin/osversion b/bin/osversion index 80bf6bd..6d6cf21 100755 --- a/bin/osversion +++ b/bin/osversion @@ -8,7 +8,12 @@ case "$os" in *-*-solaris2*) echo sunos5 ;; alpha-dec-osf1) echo osf1 ;; *-apple-darwin*) echo darwin ;; - *-*-linux*) echo linux ;; + *-*-linux*) + echo d"${WSL_DISTRO_NAME}"d + echo i"${WSL_INTEROP}"i + + if [ -n "${WSL_DISTRO_NAME}" ] && [ -z "${WSL_INTEROP}" ]; + then echo wsl1; else echo linux; fi ;; *-*-openbsd*) echo openbsd ;; *-*-freebsd*) echo freebsd ;; *-*-cygwin*) echo cygwin ;; diff --git a/inc/maiko/platform.h b/inc/maiko/platform.h index 725db07..8769731 100644 --- a/inc/maiko/platform.h +++ b/inc/maiko/platform.h @@ -38,13 +38,23 @@ # define MAIKO_OS_DETECTED 1 #endif -#ifdef __linux__ +#if defined(__linux__) && !defined(__wsl1__) # define MAIKO_OS_LINUX 1 # define MAIKO_OS_NAME "Linux" # define MAIKO_OS_UNIX_LIKE 1 # define MAIKO_OS_DETECTED 1 #endif +#if defined(__linux__) && defined(__wsl1__) +# define MAIKO_OS_LINUX 1 +# define MAIKO_OS_WSL1 1 +# define MAIKO_OS_NAME "Windows System for Linux v1" +# define MAIKO_OS_UNIX_LIKE 1 +# define MAIKO_EMULATE_TIMER_INTERRUPTS 1 +# define MAIKO_EMULATE_ASYNC_INTERRUPTS 1 +# define MAIKO_OS_DETECTED 1 +#endif + #ifdef __NetBSD__ # define MAIKO_OS_NETBSD 1 # define MAIKO_OS_NAME "NetBSD"