Skip to content
Merged

32 #61

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
run: |
make deb
sudo dpkg -i ../dj64*.deb
sudo dpkg -i ../dj32*.deb

- name: Set up test environment
run: |
Expand Down
48 changes: 48 additions & 0 deletions demos/asmsimp/32/makefile
Original file line number Diff line number Diff line change
@@ -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) $@
43 changes: 43 additions & 0 deletions demos/file/32/makefile
Original file line number Diff line number Diff line change
@@ -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) $@
39 changes: 39 additions & 0 deletions demos/hello/32/makefile
Original file line number Diff line number Diff line change
@@ -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 $< $@
50 changes: 50 additions & 0 deletions demos/helloasm/32/makefile
Original file line number Diff line number Diff line change
@@ -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) $@
1 change: 1 addition & 0 deletions demos/helloasm/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
43 changes: 43 additions & 0 deletions demos/int86/32/makefile
Original file line number Diff line number Diff line change
@@ -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) $@
8 changes: 6 additions & 2 deletions demos/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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;)
Expand All @@ -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:
Expand Down
50 changes: 50 additions & 0 deletions demos/rmcb/32/makefile
Original file line number Diff line number Diff line change
@@ -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) $@
1 change: 1 addition & 0 deletions demos/rmcb/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions dj32.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dj64/plt.S.inc>" | \
$(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) -I. - | \
set -o pipefail; echo "#include <dj64/plt.S.inc>" | \
$(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
Expand Down
7 changes: 4 additions & 3 deletions dj64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dj64/plt.S.inc>" | \
$(CPP) -x assembler-with-cpp $(DJ64ASCPPFLAGS) -I. - | \
set -o pipefail; echo "#include <dj64/plt.S.inc>" | \
$(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
Expand Down
2 changes: 2 additions & 0 deletions include/dj64/thunks_c.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -88,4 +89,5 @@ STATIC UDWORD DJ64_DISPATCH_FN(int fn, UBYTE *sp, int *r_len)
#define _CFUNC(x) _##x
#include <dj64/tg_defs.h>
#include "thunk_c32.h"
#pragma pop_macro("ASMCFUNC")
#endif
3 changes: 3 additions & 0 deletions include/dj64/thunks_p.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
#include <dj64/tg_defs.h>

#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)
Expand Down
Loading