NESpire/testing/Makefile

61 lines
1.2 KiB
Makefile
Raw Normal View History

2024-05-20 21:32:41 +01:00
DEBUG = FALSE
BLD_FILE ?= .buildver
# Initiate BLD_FILE if not exists
buildver_create := $(shell if ! test -f $(BLD_FILE); then echo 0 > $(BLD_FILE); fi)
# Prepare callable function. This function updates BLD_FILE
buildver = $(shell echo $$(($$(cat $(BLD_FILE)) + 1)) > $(BLD_FILE))
VER = buildver
GCC = nspire-gcc
AS = nspire-as
GXX = nspire-g++
LD = nspire-ld
GENZEHN = genzehn
EXE = nespire_mod_$(shell cat $(BLD_FILE))
GCCFLAGS = -Wall -W -marm
LDFLAGS =
ZEHNFLAGS = --name "$(EXE)"
ifeq ($(DEBUG),FALSE)
GCCFLAGS += -Os
else
GCCFLAGS += -O0 -g
endif
OBJS = $(patsubst %.c, %.o, $(shell find . -name \*.c))
OBJS += $(patsubst %.cpp, %.o, $(shell find . -name \*.cpp))
OBJS += $(patsubst %.S, %.o, $(shell find . -name \*.S))
2024-05-20 23:42:37 +01:00
DISTDIR = builds
2024-05-20 21:32:41 +01:00
2024-05-20 23:42:37 +01:00
all:$(DISTDIR)/$(EXE).tns
2024-05-20 21:32:41 +01:00
%.o: %.c
$(GCC) $(GCCFLAGS) -c $< -o $@
%.o: %.cpp
$(GXX) $(GCCFLAGS) -c $< -o $@
%.o: %.S
$(AS) -c $< -o $@
2024-05-20 23:42:37 +01:00
$(DISTDIR)/$(EXE).elf: $(OBJS)
2024-05-20 21:32:41 +01:00
mkdir -p $(DISTDIR)
$(LD) $^ -o $@ $(LDFLAGS)
2024-05-20 23:42:37 +01:00
$(DISTDIR)/$(EXE).tns: $(DISTDIR)/$(EXE).elf
2024-05-20 21:32:41 +01:00
$(GENZEHN) --input $^ --output $@.zehn $(ZEHNFLAGS)
$(call buildver)
make-prg $@.zehn $@
rm $@.zehn
clean:
2024-05-20 23:42:37 +01:00
rm -f $(OBJS)