From e2736b794a772a1ec9b2997ee4da646e7e2c7da3 Mon Sep 17 00:00:00 2001 From: Damian Yerrick Date: Sun, 31 Mar 2024 19:45:36 -0400 Subject: [PATCH] gba: default to Wonderful Toolchain makefile --- gameboy/makefile | 2 +- gba/Makefile | 195 +------------------------------------ gba/dkaMakefile | 194 ++++++++++++++++++++++++++++++++++++ gba/tools/paginate_help.py | 4 +- gba/wfMakefile | 11 ++- nes/makefile | 2 +- 6 files changed, 206 insertions(+), 202 deletions(-) create mode 100644 gba/dkaMakefile diff --git a/gameboy/makefile b/gameboy/makefile index 5c4892d..779372d 100644 --- a/gameboy/makefile +++ b/gameboy/makefile @@ -215,7 +215,7 @@ obj/gb/localvars.z80: tools/savescan.py $(sort $(wildcard src/*.z80)) # Print the commit tag obj/gb/last-commit-now: - git describe --tags | tr -d '\r\n' > $@ + (git describe --tags || echo non-Git) | tr -d '\r\n' > $@ # Update last-commit only if it has changed obj/gb/last-commit: obj/gb/last-commit-now if test -f $@; then true; else touch $@; fi diff --git a/gba/Makefile b/gba/Makefile index 2ff5991..bf7e691 100644 --- a/gba/Makefile +++ b/gba/Makefile @@ -1,194 +1 @@ -#!make -f -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/gba_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# INCLUDES is a list of directories containing extra header files -# DATA is a list of directories containing binary data -# GRAPHICS is a list of directories containing files to be processed by grit -# -# All directories are specified relative to the project directory where -# the makefile is found -# -#--------------------------------------------------------------------------------- -TARGET := 240pee_mb -BUILD := build -SOURCES := src -INCLUDES := -DATA := -MUSIC := -GRAPHICS := tilesets ../common/tilesets - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -DEFINES := -D__GBA__ -ARCH := -mthumb -mthumb-interwork - -CFLAGS := -g -Wall -O2 -fno-common\ - -mcpu=arm7tdmi -mtune=arm7tdmi\ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions - -ASFLAGS := -g $(ARCH) $(DEFINES) -x assembler-with-cpp -LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project -#--------------------------------------------------------------------------------- -LIBS := -ltonc - - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBTONC := $(DEVKITPRO)/libtonc -LIBDIRS := $(LIBTONC) - -#--------------------------------------------------------------------------------- -# Python executable name depends on operating system. -# COMSPEC is present on Windows, not UNIX -#--------------------------------------------------------------------------------- -ifdef COMSPEC - PY := py -3 -else - PY := python3 -endif - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- - - -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ - $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) - -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := \ - main.c help.c \ - placeholder.c stills.c overscan.c scrolltest.c motionblur.c \ - shadowsprite.c stopwatch.c soundtest.c audiosync.c backlight.c megaton.c \ - pads.c ppuclear.c vwfdraw.c vwflabels.c undte.c rand.c 4bcanvas.c -CPPFILES := -S_H_SFILES := \ - bggfx_chr.s spritegfx_chr.s monoscope_chr.s sharpness_chr.s \ - stopwatchface_chr.s stopwatchhand_chr.s stopwatchdigits_chr.s \ - kikimap_chr.s kikitiles_chr.s greenhillzone_chr.s hepsie_chr.s \ - Gus_portrait_chr.s convergence_chr.s pluge_shark_6color_chr.s \ - helpbgtiles_chr.s helpsprites_chr.s Donna_chr.s vwf7.s helppages.s -SFILES := posprintf.s - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) $(S_H_SFILES:.s=.o) - -export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) $(subst .s,.h,$(S_H_SFILES)) - -export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -# This sets up the dependencies for the first build if the user runs -# make 240pee_mb.gba -# instead of running -# make -#--------------------------------------------------------------------------------- -$(TARGET).gba $(TARGET).elf: $(BUILD) - echo hello... - -#--------------------------------------------------------------------------------- -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba - - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- - -$(OUTPUT).gba : $(OUTPUT).elf - -$(OUTPUT).elf : $(OFILES) - -$(OFILES_SOURCES) : $(HFILES) - -#--------------------------------------------------------------------------------- -# This rule creates assembly source files using grit -# grit takes an image file and a .grit describing how the file is to be processed -# add additional rules like this for each image extension -# you use in the graphics folders -#--------------------------------------------------------------------------------- -%_chr.s %_chr.h : %.png %.grit -#--------------------------------------------------------------------------------- - grit $< -ff$(word 2,$^) -fts -o$*_chr - -# Convert a proportional font -vwf7.s vwf7.h: vwf7_cp144p.png ../tools/vwfbuild.py last-commit - $(PY) ../tools/vwfbuild.py $< $(basename $@).s $(basename $@).h - -# Update last-commit if it has changed -last-commit-now: - git describe --tags | tr -d '\r\n' > $@ -last-commit: last-commit-now - if test -f $@; then true; else touch $@; fi - cmp $< $@ || cp $< $@ - -# Convert help files -helppages.s helppages.h: helppages.txt last-commit ../tools/paginate_help.py - $(PY) ../tools/paginate_help.py -DCOMMIT="$$(cat last-commit)" $< -o $(basename $@).s -oh $(basename $@).h - --include $(DEPSDIR)/*.d -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include wfMakefile diff --git a/gba/dkaMakefile b/gba/dkaMakefile new file mode 100644 index 0000000..3400275 --- /dev/null +++ b/gba/dkaMakefile @@ -0,0 +1,194 @@ +#!make -f +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") +endif + +include $(DEVKITARM)/gba_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# INCLUDES is a list of directories containing extra header files +# DATA is a list of directories containing binary data +# GRAPHICS is a list of directories containing files to be processed by grit +# +# All directories are specified relative to the project directory where +# the makefile is found +# +#--------------------------------------------------------------------------------- +TARGET := 240pee_mb +BUILD := build +SOURCES := src +INCLUDES := +DATA := +MUSIC := +GRAPHICS := tilesets ../common/tilesets + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +DEFINES := -D__GBA__ +ARCH := -mthumb -mthumb-interwork + +CFLAGS := -g -Wall -O2 -fno-common\ + -mcpu=arm7tdmi -mtune=arm7tdmi\ + $(ARCH) $(DEFINES) + +CFLAGS += $(INCLUDE) + +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions + +ASFLAGS := -g $(ARCH) $(DEFINES) -x assembler-with-cpp +LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := -ltonc + + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBTONC := $(DEVKITPRO)/libtonc +LIBDIRS := $(LIBTONC) + +#--------------------------------------------------------------------------------- +# Python executable name depends on operating system. +# COMSPEC is present on Windows, not UNIX +#--------------------------------------------------------------------------------- +ifdef COMSPEC + PY := py -3 +else + PY := python3 +endif + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- + + +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ + $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := \ + main.c help.c \ + placeholder.c stills.c overscan.c scrolltest.c motionblur.c \ + shadowsprite.c stopwatch.c soundtest.c audiosync.c backlight.c megaton.c \ + pads.c ppuclear.c vwfdraw.c vwflabels.c undte.c rand.c 4bcanvas.c +CPPFILES := +S_H_SFILES := \ + bggfx_chr.s spritegfx_chr.s monoscope_chr.s sharpness_chr.s \ + stopwatchface_chr.s stopwatchhand_chr.s stopwatchdigits_chr.s \ + kikimap_chr.s kikitiles_chr.s greenhillzone_chr.s hepsie_chr.s \ + Gus_portrait_chr.s convergence_chr.s pluge_shark_6color_chr.s \ + helpbgtiles_chr.s helpsprites_chr.s Donna_chr.s vwf7.s helppages.s +SFILES := posprintf.s + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) $(S_H_SFILES:.s=.o) + +export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) $(subst .s,.h,$(S_H_SFILES)) + +export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +# This sets up the dependencies for the first build if the user runs +# make 240pee_mb.gba +# instead of running +# make +#--------------------------------------------------------------------------------- +$(TARGET).gba $(TARGET).elf: $(BUILD) + echo hello... + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba + + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- + +$(OUTPUT).gba : $(OUTPUT).elf + +$(OUTPUT).elf : $(OFILES) + +$(OFILES_SOURCES) : $(HFILES) + +#--------------------------------------------------------------------------------- +# This rule creates assembly source files using grit +# grit takes an image file and a .grit describing how the file is to be processed +# add additional rules like this for each image extension +# you use in the graphics folders +#--------------------------------------------------------------------------------- +%_chr.s %_chr.h : %.png %.grit +#--------------------------------------------------------------------------------- + grit $< -ff$(word 2,$^) -fts -o$*_chr + +# Convert a proportional font +vwf7.s vwf7.h: vwf7_cp144p.png ../tools/vwfbuild.py last-commit + $(PY) ../tools/vwfbuild.py $< $(basename $@).s $(basename $@).h + +# Update last-commit if it has changed +last-commit-now: + (git describe --tags || echo non-Git) | tr -d '\r\n' > $@ +last-commit: last-commit-now + if test -f $@; then true; else touch $@; fi + cmp $< $@ || cp $< $@ + +# Convert help files +helppages.s helppages.h: helppages.txt last-commit ../tools/paginate_help.py + $(PY) ../tools/paginate_help.py -DCOMMIT="$$(cat last-commit)" $< -o $(basename $@).s -oh $(basename $@).h + +-include $(DEPSDIR)/*.d +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/gba/tools/paginate_help.py b/gba/tools/paginate_help.py index 40edca0..1ea9aeb 100755 --- a/gba/tools/paginate_help.py +++ b/gba/tools/paginate_help.py @@ -67,8 +67,8 @@ def render_help(docs, defines=None): lines.extend(' .word helptitle_%s' % doc[1] for doc in docs) # ensure files end with newline - lines.extend("") - lines_header.extend("") + lines.append("") + lines_header.append("") return ["\n".join(lines), "\n".join(lines_header)] def parse_define(s): diff --git a/gba/wfMakefile b/gba/wfMakefile index ac08dc4..213a031 100644 --- a/gba/wfMakefile +++ b/gba/wfMakefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 # # SPDX-FileContributor: Adrian "asie" Siekierka, 2023 -# SPDX-FileContributor: Damian Yerrick, 2023 +# SPDX-FileContributor: Damian Yerrick, 2024 export WONDERFUL_TOOLCHAIN ?= /opt/wonderful TARGET = gba/multiboot @@ -125,7 +125,7 @@ DEPS := $(OBJS:.o=.d) # Targets # ------- -.PHONY: all clean +.PHONY: all clean $(BUILDDIR)/last-commit-now all: $(ROM) compile_commands.json @@ -194,8 +194,11 @@ $(BUILDDIR)/%pages.txt.o $(BUILDDIR)/%pages.h : %pages.txt $(BUILDDIR)/last-comm # times in separate processes, once for each output file. # If using old Make, change `&:` to `:` and use `make -j1`. -$(BUILDDIR)/last-commit: - echo -n "non-Git" >> $@ +$(BUILDDIR)/last-commit-now: + (git describe --tags || echo non-Git) | tr -d '\r\n' > $@ +$(BUILDDIR)/last-commit: $(BUILDDIR)/last-commit-now + if test -f $@; then true; else touch $@; fi + cmp $< $@ || cp $< $@ # Convert a proportional font $(BUILDDIR)/tilesets/vwf7_cp144p.o $(BUILDDIR)/tilesets/vwf7.h &: ../common/tilesets/vwf7_cp144p.png tools/vwfbuild.py diff --git a/nes/makefile b/nes/makefile index 1b5f104..dc0d02f 100644 --- a/nes/makefile +++ b/nes/makefile @@ -274,7 +274,7 @@ $(objdir)/%.hlp.s: $(srcdir)/%.txt tools/paginate_help.py \ # Print the commit tag $(objdir)/last-commit-now: - git describe --tags | tr -d '\r\n' > $@ + (git describe --tags || echo non-Git) | tr -d '\r\n' > $@ # Update last-commit only if it has changed $(objdir)/last-commit: $(objdir)/last-commit-now if test -f $@; then true; else touch $@; fi