From c4101815c2d74f5239eba4b9d848ddbf539f0380 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 20 Jun 2026 23:23:33 +0300 Subject: [PATCH 01/11] dj32: preserve ASMFUNC/ASMCFUNC macros --- include/dj64/thunks_c.inc | 2 ++ include/dj64/thunks_p.inc | 3 +++ 2 files changed, 5 insertions(+) diff --git a/include/dj64/thunks_c.inc b/include/dj64/thunks_c.inc index 24587275..a88012c8 100644 --- a/include/dj64/thunks_c.inc +++ b/include/dj64/thunks_c.inc @@ -79,6 +79,7 @@ STATIC UDWORD DJ64_DISPATCH_FN(int fn, UBYTE *sp, int *r_len) } #ifdef DJ32 +#pragma push_macro("ASMCFUNC") #undef ASMCFUNC #define ASMCFUNC extern __attribute__((cdecl)) #define _FUNC(x) _##x @@ -88,4 +89,5 @@ STATIC UDWORD DJ64_DISPATCH_FN(int fn, UBYTE *sp, int *r_len) #define _CFUNC(x) _##x #include #include "thunk_c32.h" +#pragma pop_macro("ASMCFUNC") #endif diff --git a/include/dj64/thunks_p.inc b/include/dj64/thunks_p.inc index 40dda4aa..50c9e040 100644 --- a/include/dj64/thunks_p.inc +++ b/include/dj64/thunks_p.inc @@ -22,10 +22,13 @@ #include #ifdef DJ32 +#pragma push_macro("ASMFUNC") +#undef ASMFUNC #define ASMFUNC extern __attribute__((cdecl)) #define _FUNC(x) _##x #define _CFUNC(x) x #include "thunk_p1.h" +#pragma pop_macro("ASMFUNC") #endif #ifdef _IN_DJ64 #define __CALL(n, s, l, f) dj64_asm_call(n, s, l, f) From 38cd782b2cd018db98eb97f9000273945d6b25be Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 20 Jun 2026 23:11:34 +0300 Subject: [PATCH 02/11] demos/rmcb: add 32bit build --- demos/rmcb/32/makefile | 50 ++++++++++++++++++++++++++++++++++++++++++ demos/rmcb/makefile | 1 + 2 files changed, 51 insertions(+) create mode 100644 demos/rmcb/32/makefile diff --git a/demos/rmcb/32/makefile b/demos/rmcb/32/makefile new file mode 100644 index 00000000..2b93dbd5 --- /dev/null +++ b/demos/rmcb/32/makefile @@ -0,0 +1,50 @@ +srcdir = .. +vpath %.c $(srcdir) +vpath %.S $(srcdir) + +STRIP = @true +# or use `STRIP = djstrip` for non-debug build + +SOURCES := main.c mouse.c thunks_a.c thunks_c.c +SOURCES := $(addprefix $(srcdir)/,$(SOURCES)) +AS_SOURCES := ms.S asm.S +AS_SOURCES := $(addprefix $(srcdir)/,$(AS_SOURCES)) +TGT = rmcb.exe + +# the below 4 vars must be named exactly like here +DJCFLAGS = -Wall -ggdb3 +DJCPPFLAGS = -I. -I$(srcdir) +DJASCPPFLAGS = -I$(srcdir) +DJASFLAGS = -I. -I$(srcdir) +OBJECTS = $(notdir $(SOURCES:.c=.o)) +AS_OBJECTS = $(notdir $(AS_SOURCES:.S=.o)) +PDHDR = $(srcdir)/asm.h +GLOB_ASM = $(srcdir)/glob_asm.h + +all: $(TGT) + +clean: clean_dj32 + $(RM) $(TGT) + +# display info about the built executable +info: $(TGT) + djstubify -i $< + +run: $(TGT) + dosemu -t $< + +# hook in dj64 - make sure to not do that before defining `all:` target +DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) +ifeq ($(wildcard $(DJMK)),) +ifeq ($(filter clean,$(MAKECMDGOALS)),) +$(error dj32 not installed) +endif +clean_dj32: +else +include $(DJMK) +endif + +# dj64 sets `DJ64_XOBJS`, `DJ64_XLIB`, `DJ64_XLDFLAGS` +$(TGT): $(DJ64_XLIB) + $(LINK) -d $@.dbg $^ -o $@ $(DJ64_XLDFLAGS) + $(STRIP) $@ diff --git a/demos/rmcb/makefile b/demos/rmcb/makefile index f6045db3..9408db86 100644 --- a/demos/rmcb/makefile +++ b/demos/rmcb/makefile @@ -10,6 +10,7 @@ CFLAGS = -Wall -ggdb3 OBJECTS = $(SOURCES:.c=.o) AS_OBJECTS = $(AS_SOURCES:.S=.o) PDHDR = asm.h +GLOB_ASM = glob_asm.h all: $(TGT) From 7fdd4a78fb7c5770c7ef1d26fadfb6767f5defb9 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 20 Jun 2026 23:24:44 +0300 Subject: [PATCH 03/11] demos/asmsimp: add 32bit build --- demos/asmsimp/32/makefile | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 demos/asmsimp/32/makefile diff --git a/demos/asmsimp/32/makefile b/demos/asmsimp/32/makefile new file mode 100644 index 00000000..8da0d974 --- /dev/null +++ b/demos/asmsimp/32/makefile @@ -0,0 +1,48 @@ +srcdir = .. +vpath %.c $(srcdir) +vpath %.S $(srcdir) + +STRIP = @true +# or use `STRIP = djstrip` for non-debug build + +SOURCES := hello.c thunks_p.c +SOURCES := $(addprefix $(srcdir)/,$(SOURCES)) +AS_SOURCES := h.S +AS_SOURCES := $(addprefix $(srcdir)/,$(AS_SOURCES)) +TGT = asmsimp.exe + +# the below 4 vars must be named exactly like here +DJCFLAGS = -Wall -ggdb3 +DJCPPFLAGS = -I. -I$(srcdir) +DJASFLAGS = -I. -I$(srcdir) +OBJECTS = $(notdir $(SOURCES:.c=.o)) +AS_OBJECTS = $(notdir $(AS_SOURCES:.S=.o)) +PDHDR = $(srcdir)/asm.h + +all: $(TGT) + +clean: clean_dj32 + $(RM) $(TGT) + +# display info about the built executable +info: $(TGT) + djstubify -i $< + +run: $(TGT) + dosemu -dumb $< + +# hook in dj64 - make sure to not do that before defining `all:` target +DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) +ifeq ($(wildcard $(DJMK)),) +ifeq ($(filter clean,$(MAKECMDGOALS)),) +$(error dj32 not installed) +endif +clean_dj32: +else +include $(DJMK) +endif + +# dj64 sets `DJ64_XOBJS`, `DJ64_XLIB`, `DJ64_XLDFLAGS` +$(TGT): $(DJ64_XLIB) + $(LINK) -d $@.dbg $^ -o $@ $(DJ64_XLDFLAGS) + $(STRIP) $@ From 96025673f497e7ea7e34e598ddc21e7ac19049a5 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 20 Jun 2026 23:27:50 +0300 Subject: [PATCH 04/11] demos/file: add 32bit build --- demos/file/32/makefile | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 demos/file/32/makefile diff --git a/demos/file/32/makefile b/demos/file/32/makefile new file mode 100644 index 00000000..039bb294 --- /dev/null +++ b/demos/file/32/makefile @@ -0,0 +1,43 @@ +srcdir = .. +vpath %.c $(srcdir) +vpath %.S $(srcdir) + +STRIP = @true +# or use `STRIP = djstrip` for non-debug build + +SOURCES := file.c +SOURCES := $(addprefix $(srcdir)/,$(SOURCES)) +TGT = file.exe + +# the below 4 vars must be named exactly like here +DJCFLAGS = -Wall -ggdb3 +DJCPPFLAGS = -I. -I$(srcdir) +OBJECTS = $(notdir $(SOURCES:.c=.o)) + +all: $(TGT) + +clean: clean_dj32 + $(RM) $(TGT) + +# display info about the built executable +info: $(TGT) + djstubify -i $< + +run: $(TGT) + dosemu -t $< + +# hook in dj64 - make sure to not do that before defining `all:` target +DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) +ifeq ($(wildcard $(DJMK)),) +ifeq ($(filter clean,$(MAKECMDGOALS)),) +$(error dj32 not installed) +endif +clean_dj32: +else +include $(DJMK) +endif + +# dj64 sets `DJ64_XOBJS`, `DJ64_XLIB`, `DJ64_XLDFLAGS` +$(TGT): $(DJ64_XLIB) + $(LINK) -d $@.dbg $^ -o $@ $(DJ64_XLDFLAGS) + $(STRIP) $@ From 03bcb4d95304089a6e6413f7b6a5e86de170c160 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 20 Jun 2026 23:31:47 +0300 Subject: [PATCH 05/11] demos/hello: add 32bit build --- demos/hello/32/makefile | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 demos/hello/32/makefile diff --git a/demos/hello/32/makefile b/demos/hello/32/makefile new file mode 100644 index 00000000..4a65f9e9 --- /dev/null +++ b/demos/hello/32/makefile @@ -0,0 +1,39 @@ +srcdir = .. +vpath %.c $(srcdir) +vpath %.S $(srcdir) + +SOURCES := hello.c +SOURCES := $(addprefix $(srcdir)/,$(SOURCES)) +TGT = hello + +# the below 4 vars must be named exactly like here +DJCFLAGS = -Wall -ggdb3 +DJCPPFLAGS = -I. -I$(srcdir) +OBJECTS = $(notdir $(SOURCES:.c=.o)) + +all: $(TGT) + +clean: clean_dj32 + $(RM) $(TGT) + +# display info about the built executable +info: $(TGT) + djstubify -i $< + +run: $(TGT) + dosemu -dumb -l $(realpath $<) + +# hook in dj64 - make sure to not do that before defining `all:` target +DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) +ifeq ($(wildcard $(DJMK)),) +ifeq ($(filter clean,$(MAKECMDGOALS)),) +$(error dj32 not installed) +endif +clean_dj32: +else +include $(DJMK) +endif + +# dj64 sets `DJ64_XOBJS`, `DJ64_XLIB`, `DJ64_XLDFLAGS` +$(TGT): $(DJ64_XLIB) + cp $< $@ From 05f57e7c7484e3a7bddf81678c4b885503d6b857 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 20 Jun 2026 23:37:39 +0300 Subject: [PATCH 06/11] demos/helloasm: add 32bit build --- demos/helloasm/32/makefile | 50 ++++++++++++++++++++++++++++++++++++++ demos/helloasm/makefile | 1 + 2 files changed, 51 insertions(+) create mode 100644 demos/helloasm/32/makefile diff --git a/demos/helloasm/32/makefile b/demos/helloasm/32/makefile new file mode 100644 index 00000000..b1f87e37 --- /dev/null +++ b/demos/helloasm/32/makefile @@ -0,0 +1,50 @@ +srcdir = .. +vpath %.c $(srcdir) +vpath %.S $(srcdir) + +STRIP = @true +# or use `STRIP = djstrip` for non-debug build + +SOURCES := hello.c thunks_a.c thunks_c.c thunks_p.c +SOURCES := $(addprefix $(srcdir)/,$(SOURCES)) +AS_SOURCES := h.S +AS_SOURCES := $(addprefix $(srcdir)/,$(AS_SOURCES)) +TGT = helloasm.exe + +# the below 4 vars must be named exactly like here +DJCFLAGS = -Wall -ggdb3 +DJCPPFLAGS = -I. -I$(srcdir) +DJASCPPFLAGS = -I$(srcdir) +DJASFLAGS = -I. -I$(srcdir) +OBJECTS = $(notdir $(SOURCES:.c=.o)) +AS_OBJECTS = $(notdir $(AS_SOURCES:.S=.o)) +PDHDR = $(srcdir)/asm.h +GLOB_ASM = $(srcdir)/glob_asm.h + +all: $(TGT) + +clean: clean_dj32 + $(RM) $(TGT) + +# display info about the built executable +info: $(TGT) + djstubify -i $< + +run: $(TGT) + dosemu -dumb $< + +# hook in dj64 - make sure to not do that before defining `all:` target +DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) +ifeq ($(wildcard $(DJMK)),) +ifeq ($(filter clean,$(MAKECMDGOALS)),) +$(error dj32 not installed) +endif +clean_dj32: +else +include $(DJMK) +endif + +# dj64 sets `DJ64_XOBJS`, `DJ64_XLIB`, `DJ64_XLDFLAGS` +$(TGT): $(DJ64_XLIB) + $(LINK) -d $@.dbg $^ -o $@ $(DJ64_XLDFLAGS) + $(STRIP) $@ diff --git a/demos/helloasm/makefile b/demos/helloasm/makefile index e5feb2b8..fd4ee10f 100644 --- a/demos/helloasm/makefile +++ b/demos/helloasm/makefile @@ -10,6 +10,7 @@ CFLAGS = -Wall -ggdb3 OBJECTS = $(SOURCES:.c=.o) AS_OBJECTS = $(AS_SOURCES:.S=.o) PDHDR = asm.h +GLOB_ASM = glob_asm.h all: $(TGT) From c6775a586faf0de778b85e96adbc8570d3059985 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 20 Jun 2026 23:41:59 +0300 Subject: [PATCH 07/11] demos/int86: add 32bit build --- demos/int86/32/makefile | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 demos/int86/32/makefile diff --git a/demos/int86/32/makefile b/demos/int86/32/makefile new file mode 100644 index 00000000..039bb294 --- /dev/null +++ b/demos/int86/32/makefile @@ -0,0 +1,43 @@ +srcdir = .. +vpath %.c $(srcdir) +vpath %.S $(srcdir) + +STRIP = @true +# or use `STRIP = djstrip` for non-debug build + +SOURCES := file.c +SOURCES := $(addprefix $(srcdir)/,$(SOURCES)) +TGT = file.exe + +# the below 4 vars must be named exactly like here +DJCFLAGS = -Wall -ggdb3 +DJCPPFLAGS = -I. -I$(srcdir) +OBJECTS = $(notdir $(SOURCES:.c=.o)) + +all: $(TGT) + +clean: clean_dj32 + $(RM) $(TGT) + +# display info about the built executable +info: $(TGT) + djstubify -i $< + +run: $(TGT) + dosemu -t $< + +# hook in dj64 - make sure to not do that before defining `all:` target +DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) +ifeq ($(wildcard $(DJMK)),) +ifeq ($(filter clean,$(MAKECMDGOALS)),) +$(error dj32 not installed) +endif +clean_dj32: +else +include $(DJMK) +endif + +# dj64 sets `DJ64_XOBJS`, `DJ64_XLIB`, `DJ64_XLDFLAGS` +$(TGT): $(DJ64_XLIB) + $(LINK) -d $@.dbg $^ -o $@ $(DJ64_XLDFLAGS) + $(STRIP) $@ From b777ead3b9597a64f0cdc146bd433b1a78a3a6fd Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 20 Jun 2026 23:50:56 +0300 Subject: [PATCH 08/11] demos: add 32 build --- demos/makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/demos/makefile b/demos/makefile index 3f8f50f8..ab928103 100644 --- a/demos/makefile +++ b/demos/makefile @@ -7,6 +7,7 @@ NOSTATIC = hello all: set -e; $(foreach D,$(DEMOS),$(MAKE) -C $(D);) + set -e; $(foreach D,$(DEMOS),$(MAKE) -C $(D)/32;) static: set -e; $(foreach D,$(filter-out $(NOSTATIC),$(DEMOS)),$(MAKE) -C $(D) static;) @@ -16,14 +17,17 @@ djgpp/%: clean: $(foreach D,$(DEMOS),$(MAKE) -C $(D) clean;) + $(foreach D,$(DEMOS),$(MAKE) -C $(D)/32 clean;) rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) src_install: clean djgpp/clean $(foreach D,$(DEMOS),\ $(INSTALL) -d $(DESTDIR)$(prefix)/share/doc/dj64/demos/$(D);\ - $(INSTALL) -d $(DESTDIR)$(prefix)/share/doc/dj64/demos/$(D)/djgpp;) - $(foreach F,$(filter-out %/djgpp,$(call rwildcard,$(DEMOS),*)),\ + $(INSTALL) -d $(DESTDIR)$(prefix)/share/doc/dj64/demos/$(D)/32;\ + $(INSTALL) -d $(DESTDIR)$(prefix)/share/doc/dj64/demos/$(D)/djgpp;\ + ) + $(foreach F,$(filter-out %/djgpp %/32,$(call rwildcard,$(DEMOS),*)),\ $(INSTALL) -m 0644 $(F) $(DESTDIR)$(prefix)/share/doc/dj64/demos/$(F);) src_uninstall: From a6c7b244dd2aa9d2cead71afb5d6041889537c0c Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sat, 20 Jun 2026 23:58:44 +0300 Subject: [PATCH 09/11] ci: install dj32 --- .github/workflows/ci-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 4375c713..2f4179e6 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -27,6 +27,7 @@ jobs: run: | make deb sudo dpkg -i ../dj64*.deb + sudo dpkg -i ../dj32*.deb - name: Set up test environment run: | From fe77e541740361c0ed406e30a335e18abed972e0 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sun, 21 Jun 2026 00:18:13 +0300 Subject: [PATCH 10/11] enable pipefail mode when generating plt.o --- dj32.mk | 5 +++-- dj64.mk | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dj32.mk b/dj32.mk index 20736181..1c02c472 100644 --- a/dj32.mk +++ b/dj32.mk @@ -67,11 +67,12 @@ DJ64_XLIB = $(XELF) %.o: %.c $(CC) $(DJ64CFLAGS) $(XCPPFLAGS) -I. -o $@ -c $< +SHELL := /usr/bin/env bash %.o: %.S - $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) $< | \ + set -o pipefail; $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) $< | \ $(DJ64AS) $(DJ64ASFLAGS) -o $@ - plt.o: plt.inc $(GLOB_ASM) - echo "#include " | \ + set -o pipefail; echo "#include " | \ $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) -I. - | \ $(DJ64AS) $(DJ64ASFLAGS) -o $@ - thunks_c.o: thunk_c1.h thunk_c32.h thunk_calls.h diff --git a/dj64.mk b/dj64.mk index 50a808cb..4372c843 100644 --- a/dj64.mk +++ b/dj64.mk @@ -199,11 +199,12 @@ $(DJ64_XLIB): $(OBJECTS) $(XELF) %.o: %.c $(CC) $(DJ64CFLAGS) $(XCPPFLAGS) -I. -o $@ -c $< +SHELL := /usr/bin/env bash %.o: %.S - $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) $< | \ + set -o pipefail; $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) $< | \ $(DJ64AS) $(DJ64ASFLAGS) -o $@ - plt.o: plt.inc $(GLOB_ASM) - echo "#include " | \ + set -o pipefail; echo "#include " | \ $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) -I. - | \ $(DJ64AS) $(DJ64ASFLAGS) -o $@ - thunks_c.o: thunk_calls.h From d6d9682bdac62a58ba5b9df5920384e952c39b74 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Sun, 21 Jun 2026 00:44:25 +0300 Subject: [PATCH 11/11] raise priority of cur dir in cpp --- dj32.mk | 2 +- dj64.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dj32.mk b/dj32.mk index 1c02c472..1ffd9db6 100644 --- a/dj32.mk +++ b/dj32.mk @@ -73,7 +73,7 @@ SHELL := /usr/bin/env bash $(DJ64AS) $(DJ64ASFLAGS) -o $@ - plt.o: plt.inc $(GLOB_ASM) set -o pipefail; echo "#include " | \ - $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) -I. - | \ + $(CPP) -x assembler-with-cpp -I. $(DJ64ASCPPFLAGS) - | \ $(DJ64AS) $(DJ64ASFLAGS) -o $@ - thunks_c.o: thunk_c1.h thunk_c32.h thunk_calls.h thunks_p.o: thunk_p1.h thunk_p32.h thunk_asms.h plt_asmc.h diff --git a/dj64.mk b/dj64.mk index 4372c843..734c0e73 100644 --- a/dj64.mk +++ b/dj64.mk @@ -205,7 +205,7 @@ SHELL := /usr/bin/env bash $(DJ64AS) $(DJ64ASFLAGS) -o $@ - plt.o: plt.inc $(GLOB_ASM) set -o pipefail; echo "#include " | \ - $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) -I. - | \ + $(CPP) -x assembler-with-cpp -I. $(DJ64ASCPPFLAGS) - | \ $(DJ64AS) $(DJ64ASFLAGS) -o $@ - thunks_c.o: thunk_calls.h thunks_p.o: thunk_asms.h plt_asmc.h