diff --git a/Makefile b/Makefile index 7868a6e1e..1cb59fece 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ ROM := pokeemerald.gba OBJ_DIR := build/emerald LIBPATH := -L ../../tools/agbcc/lib else -CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) -quiet +CC1 := $(shell $(CC) --print-prog-name=cc1) -quiet override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast ROM := pokeemerald_modern.gba OBJ_DIR := build/modern @@ -78,6 +78,12 @@ FIX := tools/gbafix/gbafix$(EXE) MAPJSON := tools/mapjson/mapjson$(EXE) JSONPROC := tools/jsonproc/jsonproc$(EXE) +TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) +TOOLBASE = $(TOOLDIRS:tools/%=%) +TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE)) + +MAKEFLAGS += --no-print-directory + # Clear the default suffixes .SUFFIXES: # Don't delete intermediate files @@ -88,7 +94,17 @@ JSONPROC := tools/jsonproc/jsonproc$(EXE) # Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: -.PHONY: rom clean compare tidy tools mostlyclean clean-tools +.PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) + +infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line)))) + +# Build tools when building the rom +# Disable dependency scanning for clean/tidy/tools +ifeq (,$(filter-out all compare,$(MAKECMDGOALS))) +$(call infoshell, $(MAKE) tools) +else +NODEP := 1 +endif C_SRCS := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c) C_OBJS := $(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(C_SRCS)) @@ -112,18 +128,14 @@ SUBDIRS := $(sort $(dir $(OBJS))) AUTO_GEN_TARGETS := -TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) -TOOLBASE = $(TOOLDIRS:tools/%=%) -TOOLS = $(foreach tool,$(TOOLBASE),tools/%(tool)/$(tool)$(EXE)) - $(shell mkdir -p $(SUBDIRS)) -all: tools rom +all: rom -tools: $(TOOLS) +tools: $(TOOLDIRS) -$(TOOLS): - @$(foreach tooldir,$(TOOLDIRS),$(MAKE) -C $(tooldir);) +$(TOOLDIRS): + @$(MAKE) -C $@ rom: $(ROM) diff --git a/src/bg.c b/src/bg.c index 43570f5eb..1678f4023 100644 --- a/src/bg.c +++ b/src/bg.c @@ -220,7 +220,7 @@ static void ShowBgInternal(u8 bg) (sGpuBgConfigs.configs[bg].wraparound << 13) | (sGpuBgConfigs.configs[bg].screenSize << 14); - SetGpuReg((bg << 1) + 0x8, value); + SetGpuReg((bg << 1) + REG_OFFSET_BG0CNT, value); sGpuBgConfigs.bgVisibilityAndMode |= 1 << (bg + 8); sGpuBgConfigs.bgVisibilityAndMode &= DISPCNT_ALL_BG_AND_MODE_BITS; diff --git a/tools/aif2pcm/Makefile b/tools/aif2pcm/Makefile index e5cb6ad31..af7d19fe9 100644 --- a/tools/aif2pcm/Makefile +++ b/tools/aif2pcm/Makefile @@ -6,7 +6,10 @@ LIBS = -lm SRCS = main.c extended.c -.PHONY: clean +.PHONY: all clean + +all: aif2pcm + @: aif2pcm: $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) diff --git a/tools/bin2c/Makefile b/tools/bin2c/Makefile index 73f78980e..ab11e1b61 100644 --- a/tools/bin2c/Makefile +++ b/tools/bin2c/Makefile @@ -2,10 +2,13 @@ CC = gcc CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 -.PHONY: clean +.PHONY: all clean SRCS = bin2c.c +all: bin2c + @: + bin2c: $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) diff --git a/tools/gbafix/Makefile b/tools/gbafix/Makefile index f12c8cc4f..5b410da08 100644 --- a/tools/gbafix/Makefile +++ b/tools/gbafix/Makefile @@ -1,8 +1,11 @@ CC = gcc -.PHONY: clean +.PHONY: all clean SRCS = gbafix.c +all: gbafix + @: + gbafix: $(SRCS) $(CC) $(SRCS) -o $@ $(LDFLAGS) diff --git a/tools/jsonproc/Makefile b/tools/jsonproc/Makefile index 69093a216..721da1025 100755 --- a/tools/jsonproc/Makefile +++ b/tools/jsonproc/Makefile @@ -8,7 +8,10 @@ SRCS := jsonproc.cpp HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp -.PHONY: clean +.PHONY: all clean + +all: jsonproc + @: jsonproc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS) diff --git a/tools/mapjson/Makefile b/tools/mapjson/Makefile index d09acad50..9a49be506 100644 --- a/tools/mapjson/Makefile +++ b/tools/mapjson/Makefile @@ -6,7 +6,10 @@ SRCS := json11.cpp mapjson.cpp HEADERS := mapjson.h -.PHONY: clean +.PHONY: all clean + +all: mapjson + @: mapjson: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) diff --git a/tools/preproc/Makefile b/tools/preproc/Makefile index 3d3275819..63dedda1f 100644 --- a/tools/preproc/Makefile +++ b/tools/preproc/Makefile @@ -8,7 +8,10 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \ HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \ utf8.h -.PHONY: clean +.PHONY: all clean + +all: preproc + @: preproc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) diff --git a/tools/ramscrgen/Makefile b/tools/ramscrgen/Makefile index 9aa309aa1..858db1a77 100644 --- a/tools/ramscrgen/Makefile +++ b/tools/ramscrgen/Makefile @@ -6,7 +6,10 @@ SRCS := main.cpp sym_file.cpp elf.cpp HEADERS := ramscrgen.h sym_file.h elf.h char_util.h -.PHONY: clean +.PHONY: all clean + +all: ramscrgen + @: ramscrgen: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) diff --git a/tools/rsfont/Makefile b/tools/rsfont/Makefile index 582be7b88..abe1cab51 100644 --- a/tools/rsfont/Makefile +++ b/tools/rsfont/Makefile @@ -6,7 +6,10 @@ LIBS = -lpng -lz SRCS = main.c convert_png.c util.c font.c -.PHONY: clean +.PHONY: all clean + +all: rsfont + @: rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile index 53c9d0060..1516f159c 100644 --- a/tools/scaninc/Makefile +++ b/tools/scaninc/Makefile @@ -6,7 +6,10 @@ SRCS = scaninc.cpp c_file.cpp asm_file.cpp source_file.cpp HEADERS := scaninc.h asm_file.h c_file.h source_file.h -.PHONY: clean +.PHONY: all clean + +all: scaninc + @: scaninc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)