51 lines
1006 B
Makefile
51 lines
1006 B
Makefile
PORT := 1234
|
|
CHECK := diff -q
|
|
MKDIR_P := mkdir -p
|
|
|
|
CC := lcc
|
|
CFLAGS := -nostdlib
|
|
|
|
QEMU := qemu-e2k
|
|
QEMU_ARGS :=
|
|
|
|
GDB := e2k-linux-gdb
|
|
GDB_ARGS := -q --batch --nx --nw -ix gdbinit
|
|
GDB_BPS := -ex 'b _start' -ex 'b _stop'
|
|
|
|
ifndef EMU
|
|
GDB_SERVER := gdbserver
|
|
GDB_SERVER_ARGS := :$(PORT)
|
|
else
|
|
GDB_SERVER := $(QEMU)
|
|
GDB_SERVER_ARGS := -g $(PORT) $(QEMU_ARGS)
|
|
endif
|
|
|
|
tests := $(subst .s,,$(notdir $(wildcard src/*.s)))
|
|
executables := $(addprefix build/,$(tests))
|
|
logs := $(addprefix build/,$(addsuffix .log,$(tests)))
|
|
checks := $(addprefix check-,$(tests))
|
|
|
|
.PHONY: all test mkdirs clean $(checks)
|
|
|
|
all: mkdirs $(logs)
|
|
|
|
test: mkdirs $(checks)
|
|
|
|
mkdirs:
|
|
$(MKDIR_P) build
|
|
|
|
clean:
|
|
$(RM) $(executables)
|
|
$(RM) $(logs)
|
|
|
|
$(executables): build/%: src/%.s
|
|
$(CC) $(CFLAGS) -o $@ $<
|
|
|
|
$(logs): build/%.log: build/% src/%.gdb
|
|
$(GDB_SERVER) $(GDB_SERVER_ARGS) $< &
|
|
$(GDB) $(GDB_ARGS) -ex 'file $<' $(GDB_BPS) \
|
|
-ex 'target remote :$(PORT)' -x src/$*.gdb > $@
|
|
|
|
$(checks): check-%: build/%.log src/%.log
|
|
$(CHECK) $^
|