Skip to content

Commit

Permalink
make: switch to dj64.mk
Browse files Browse the repository at this point in the history
  • Loading branch information
stsp committed Jun 7, 2024
1 parent 9ff566f commit 1ca66d5
Showing 1 changed file with 16 additions and 62 deletions.
78 changes: 16 additions & 62 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,16 @@
GAS = $(CROSS_PREFIX)as
CROSS_PREFIX := i686-linux-gnu-
ifeq ($(shell $(GAS) --version 2>/dev/null),)
CROSS_PREFIX := x86_64-linux-gnu-
endif
ifeq ($(shell $(GAS) --version 2>/dev/null),)
ifeq ($(shell uname -m),x86_64)
CROSS_PREFIX :=
else
$(error cross-binutils not installed)
endif
endif
XAS = $(CPP) $(CPPFLAGS) -x assembler-with-cpp $< | $(GAS) --32

LD = gcc
XLD = $(CROSS_PREFIX)ld
XSTRIP = $(CROSS_PREFIX)strip --strip-debug
PREFIX ?= /usr/local
DATADIR ?= $(PREFIX)/share/comcom64
CFLAGS = -Wall -Og -Wmissing-declarations -Wwrite-strings \
-ggdb3 -Wunused -Wmissing-prototypes
LDFLAGS = $(shell pkg-config --libs dj64) \
-Wl,-rpath=/usr/local/i386-pc-dj64/lib64 \
-Wl,-rpath=/usr/i386-pc-dj64/lib64
XLDFLAGS = $(shell pkg-config --static --libs dj64static) -melf_i386 -static
CPPFLAGS = -I. $(shell pkg-config --variable=cppflags dj64)
SOURCES = command.c cmdbuf.c ms.c env.c psp.c umb.c ae0x.c compl.c \
thunks_a.c thunks_c.c
HEADERS = ae0x.h cmdbuf.h compl.h psp.h command.h env.h ms.h umb.h \
glob_asm.h asm.h
PDHDR = asm.h
OBJECTS = $(SOURCES:.c=.o)
AS_SOURCES = int23.S int0.S asm.S mouse.S
AS_OBJECTS = $(AS_SOURCES:.S=.o)
LIB = libcomcom64.so
CMD = comcom64.exe
ELF = comcom64.elf
DBG = dosemu_$(CMD).dbg
REVISIONID := $(shell git describe --dirty=+)
CFLAGS += -DREV_ID=\"$(REVISIONID)\"
Expand All @@ -42,46 +19,10 @@ CFLAGS += -DREV_ID=\"$(REVISIONID)\"

all: $(CMD)

clean:
$(RM) $(CMD) $(LIB) $(ELF) *.dbg *.o version
$(RM) plt.inc *.tmp thunk_calls.h thunk_asms.h
clean: clean_dj64
$(RM) $(CMD)

$(OBJECTS): $(HEADERS)
$(LIB): $(OBJECTS)
$(LD) $^ $(LDFLAGS) -o $@

$(ELF): $(AS_OBJECTS) plt.o
$(XLD) $^ $(XLDFLAGS) -o $@
$(XSTRIP) $@

$(CMD): $(LIB) $(ELF)
./link.sh djlink objdump $(ELF) $(LIB) $(DBG) $@ $(CMD)

#.INTERMEDIATE: $(LIB)

# Common rules
%.o: %.c
dj64-gcc $(CFLAGS) -I. -o $@ -c $<

%.o: %.S
$(XAS) -o $@

%.o: %.s
$(XAS) -o $@

plt.o: plt.s plt.inc glob_asm.h

thunks_c.o: thunk_calls.h

TGMK = $(shell pkg-config --variable=makeinc thunk_gen)
ifeq ($(TGMK),)
ifeq ($(filter clean,$(MAKECMDGOALS)),)
$(error thunk_gen not installed)
endif
endif
TFLAGS = -a 4 -p 4
PDHDR = asm.h
include $(TGMK)

ifeq (,$(wildcard $(CMD)))
install:
Expand All @@ -95,3 +36,16 @@ endif

uninstall:
rm -rf $(DATADIR)

# hook in dj64 - make sure to not do that before defining `all:` target
DJMK = $(shell pkg-config --variable=makeinc dj64)
ifeq ($(DJMK),)
ifeq ($(filter clean,$(MAKECMDGOALS)),)
$(error dj64 not installed)
endif
else
include $(DJMK)
endif

$(CMD): $(DJ64_XOBJS)
./link.sh djlink objdump $(DJ64_XELF) $(DJ64_XLIB) $(DBG) $@ $(CMD)

0 comments on commit 1ca66d5

Please sign in to comment.