aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMatt Borgerson <contact@mborgerson.com>2019-12-17 19:45:49 -0700
committerMatt Borgerson <contact@mborgerson.com>2019-12-17 19:45:49 -0700
commitaf1a586beb952808238834a4d65531936a97f0de (patch)
treec221a14ce6f6ba176929c21ec3f263504a0ea7f6 /Makefile
parent12c212b99255d0984a2e39239395403900959024 (diff)
downloadgdbstub-af1a586beb952808238834a4d65531936a97f0de.tar.gz
Add a demo and instructions on how to run with QEMU
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile14
1 files changed, 12 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index cd8189a..c447411 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,9 @@
ARCH := x86
+# Include a simple demo that can be debugged
+INCLUDE_DEMO = 1
+
CC = gcc
CFLAGS = -Werror -ansi -Os -g -ffunction-sections -fno-stack-protector -I$(ARCH) -I$(PWD)
LD = ld
@@ -43,6 +46,10 @@ else
$(error Please specify a supported architecture)
endif
+ifeq ($(INCLUDE_DEMO),1)
+OBJECTS += demo.o
+endif
+
all: $(TARGET)
.PRECIOUS: %.elf
@@ -52,8 +59,11 @@ all: $(TARGET)
%.elf: $(OBJECTS) gdbstub.ld
$(LD) $(LDFLAGS) -o $@ $(OBJECTS)
-gdbstub.ld: gdbstub.ld.in
- $(shell sed -e "s/\$$BASE_ADDRESS/$(BASE_ADDRESS)/" gdbstub.ld.in > gdbstub.ld)
+gdbstub.ld: gdbstub.ld.in Makefile
+ $(CC) -o $@ -x c -P -E \
+ -DBASE_ADDRESS=$(BASE_ADDRESS) \
+ -DINCLUDE_DEMO=$(INCLUDE_DEMO) \
+ $<
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<