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: | 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) $@ 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) $@ 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 $< $@ 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) 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) $@ 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: 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) diff --git a/dj32.mk b/dj32.mk index 20736181..1ffd9db6 100644 --- a/dj32.mk +++ b/dj32.mk @@ -67,12 +67,13 @@ 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 " | \ - $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) -I. - | \ + set -o pipefail; echo "#include " | \ + $(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 50a808cb..734c0e73 100644 --- a/dj64.mk +++ b/dj64.mk @@ -199,12 +199,13 @@ $(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 " | \ - $(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) -I. - | \ + set -o pipefail; echo "#include " | \ + $(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 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)