Skip to content

Commit

Permalink
Add debug target that uses libmd-debug for SGDK samples
Browse files Browse the repository at this point in the history
  • Loading branch information
andwn committed Jun 4, 2020
1 parent a03f4c9 commit 0126687
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
11 changes: 8 additions & 3 deletions examples/sgdk-skeleton/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ INCS += -I$(MARSDEV)/m68k-elf/lib/gcc/m68k-elf/$(GCC_VER)/include
INCS += -I$(MARSDEV)/m68k-elf/include
INCS += -I$(MARSDEV)/m68k-elf/m68k-elf/include

# Libraries: GCC + SGDK + Newlib
# Libraries: GCC + Newlib (SGDK libs are with release/debug targets)
# If you plan on using Newlib, uncomment the line with -lnosys
LIBS = -L$(MARSDEV)/m68k-elf/lib/gcc/m68k-elf/$(GCC_VER) -lgcc
LIBS += -L$(MARSDEV)/m68k-elf/lib -lmd
#LIBS += -L$(MARSDEV)/m68k-elf/m68k-elf/lib -lnosys

# Force libgcc math routines to be available at link time
LIBS += -u __modsi3 -u __divsi3 -u __mulsi3 -u __umodsi3 -u __udivsi3 -u __umulsi3

# Any C or C++ standard should be fine here as long as GCC support it
CCFLAGS = -m68000 -Wall -Wextra -std=c99 -ffreestanding
CXXFLAGS = -m68000 -Wall -Wextra -std=c++17 -ffreestanding
Expand Down Expand Up @@ -77,14 +79,17 @@ all: release

release: OPTIONS = -O3 -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer
release: OPTIONS += -fshort-enums -flto -fuse-linker-plugin
release: LIBS += -L$(MARSDEV)/m68k-elf/lib -lmd
release: out.bin symbol.txt

asm: OPTIONS = -O3 -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer
asm: OPTIONS += -fshort-enums
asm: LIBS += -L$(MARSDEV)/m68k-elf/lib -lmd
asm: asm-dir $(ASMO)

# Gens-KMod, BlastEm and UMDK support GDB tracing, enabled by this target
debug: OPTIONS = -g -Og -DDEBUG -DKDEBUG
debug: OPTIONS = -g -Og -DDEBUG -DKDEBUG -fno-web -fno-gcse -fno-unit-at-a-time -fshort-enums
debug: LIBS += -L$(MARSDEV)/m68k-elf/lib -lmd-debug
debug: out.bin symbol.txt

# This generates a symbol table that is very helpful in debugging crashes,
Expand Down
7 changes: 6 additions & 1 deletion examples/sgdk-ssfmapper/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ INCS += -I$(MARSDEV)/m68k-elf/m68k-elf/include
# Libraries: GCC + SGDK + Newlib
# If you plan on using Newlib, uncomment the line with -lnosys
LIBS = -L$(MARSDEV)/m68k-elf/lib/gcc/m68k-elf/$(GCC_VER) -lgcc
LIBS += -L$(MARSDEV)/m68k-elf/lib -lmd-far
#LIBS += -L$(MARSDEV)/m68k-elf/m68k-elf/lib -lnosys

# Force libgcc math routines to be available at link time
LIBS += -u __modsi3 -u __divsi3 -u __mulsi3 -u __umodsi3 -u __udivsi3 -u __umulsi3

# Any C or C++ standard should be fine here as long as GCC support it
CCFLAGS = -m68000 -Wall -Wextra -std=c99 -ffreestanding
CXXFLAGS = -m68000 -Wall -Wextra -std=c++17 -ffreestanding
Expand Down Expand Up @@ -71,14 +73,17 @@ all: release

release: OPTIONS = -O3 -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer
release: OPTIONS += -fshort-enums -flto -fuse-linker-plugin
release: LIBS += -L$(MARSDEV)/m68k-elf/lib -lmd-far
release: out.bin symbol.txt

asm: OPTIONS = -O3 -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer
asm: OPTIONS += -fshort-enums
asm: LIBS += -L$(MARSDEV)/m68k-elf/lib -lmd-far
asm: asm-dir $(ASMO)

# Gens-KMod, BlastEm and UMDK support GDB tracing, enabled by this target
debug: OPTIONS = -g -Og -DDEBUG -DKDEBUG
debug: LIBS += -L$(MARSDEV)/m68k-elf/lib -lmd-far-debug
debug: out.bin symbol.txt

# This generates a symbol table that is very helpful in debugging crashes,
Expand Down
17 changes: 10 additions & 7 deletions sgdk/Makefile.libmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ ifeq ($(OS),Windows_NT)
endif

INCS = -Iinc -Ires
FLAGS = -m68000 -fomit-frame-pointer -fno-web -fno-gcse -fno-unit-at-a-time \
-fshort-enums -fno-builtin
FLAGS = -m68000 -fno-web -fno-gcse -fno-unit-at-a-time -fshort-enums -fno-builtin
LIBS = -L$(MARSDEV)/m68k-elf/lib/gcc/m68k-elf/$(GCC_VER) -lgcc
FLAGSZ80 = -isrc -iinc
OPTIONS = -O3 -flto -fuse-linker-plugin
OPTIONS =

CS = $(wildcard src/*.c)
SS = $(wildcard src/*.s)
Expand All @@ -47,9 +47,12 @@ RESOURCES += $(CS:.c=.o)
RESOURCES += $(SS:.s=.o)
RESOURCES += $(S80S:.s80=.o)

.PHONY: all clean
.PHONY: all release debug clean

all: $(RESOURCES) libmd.a
all: release

release: OPTIONS = -O3 -flto -fuse-linker-plugin -fomit-frame-pointer
release: $(RESOURCES) libmd.a

debug: OPTIONS = -DDEBUG -Og -g
debug: $(RESOURCES) libmd-debug.a
Expand All @@ -64,10 +67,10 @@ debug: $(RESOURCES) libmd-debug.a
$(BINTOS) $<

%.o: %.c
$(CC) $(OPTIONS) $(FLAGS) $(INCS) -c $< -o $@
$(CC) $(OPTIONS) $(FLAGS) $(INCS) -c $< -o $@ $(LIBS)

%.o: %.s
$(CC) $(OPTIONS) $(FLAGS) $(INCS) -c $< -o $@
$(CC) $(OPTIONS) $(FLAGS) $(INCS) -c $< -o $@ $(LIBS)

%.s: %.res
$(RESCOMP) $< $@
Expand Down

0 comments on commit 0126687

Please sign in to comment.