Avoid using variables for directories that cannot be moved
In theory, `src/` could be moved, but that can be done using `make -f path/to/Makefile` instead, so getting rid of some complexity is worth it. Also, I doubt there is a use case for this :P
This commit is contained in:
24
Makefile
24
Makefile
@@ -7,12 +7,12 @@
|
||||
# #
|
||||
################################################
|
||||
|
||||
# Directory constants
|
||||
SRCDIR := src
|
||||
## Directory constants
|
||||
# These directories can be placed elsewhere if you want; directories whose placement
|
||||
# must be fixed lest this Makefile breaks are hardcoded throughout this Makefile
|
||||
BINDIR := bin
|
||||
OBJDIR := obj
|
||||
DEPDIR := dep
|
||||
RESDIR := res
|
||||
|
||||
# Program constants
|
||||
ifneq ($(OS),Windows_NT)
|
||||
@@ -34,14 +34,14 @@ RGBFIX := $(RGBDS)rgbfix
|
||||
ROM = $(BINDIR)/$(ROMNAME).$(ROMEXT)
|
||||
|
||||
# Argument constants
|
||||
INCDIRS = $(SRCDIR)/ $(SRCDIR)/include/
|
||||
INCDIRS = src/ src/include/
|
||||
WARNINGS = all extra
|
||||
ASFLAGS = -p $(PADVALUE) $(addprefix -i,$(INCDIRS)) $(addprefix -W,$(WARNINGS))
|
||||
LDFLAGS = -p $(PADVALUE)
|
||||
FIXFLAGS = -p $(PADVALUE) -v -i "$(GAMEID)" -k "$(LICENSEE)" -l $(OLDLIC) -m $(MBC) -n $(VERSION) -r $(SRAMSIZE) -t $(TITLE)
|
||||
|
||||
# The list of "root" ASM files that RGBASM will be invoked on
|
||||
SRCS = $(wildcard $(SRCDIR)/*.asm)
|
||||
SRCS = $(wildcard src/*.asm)
|
||||
|
||||
## Project-specific configuration
|
||||
# Use this to override the above
|
||||
@@ -62,7 +62,7 @@ clean:
|
||||
$(RM_RF) $(BINDIR)
|
||||
$(RM_RF) $(OBJDIR)
|
||||
$(RM_RF) $(DEPDIR)
|
||||
$(RM_RF) $(RESDIR)
|
||||
$(RM_RF) res
|
||||
.PHONY: clean
|
||||
|
||||
# `rebuild`: Build everything from scratch
|
||||
@@ -79,9 +79,9 @@ rebuild:
|
||||
###############################################
|
||||
|
||||
# How to build a ROM
|
||||
$(BINDIR)/%.$(ROMEXT) $(BINDIR)/%.sym $(BINDIR)/%.map: $(patsubst $(SRCDIR)/%.asm,$(OBJDIR)/%.o,$(SRCS))
|
||||
$(BINDIR)/%.$(ROMEXT) $(BINDIR)/%.sym $(BINDIR)/%.map: $(patsubst src/%.asm,$(OBJDIR)/%.o,$(SRCS))
|
||||
@$(MKDIR_P) $(@D)
|
||||
$(RGBASM) $(ASFLAGS) -o $(OBJDIR)/build_date.o $(SRCDIR)/res/build_date.asm
|
||||
$(RGBASM) $(ASFLAGS) -o $(OBJDIR)/build_date.o src/res/build_date.asm
|
||||
$(RGBLINK) $(LDFLAGS) -m $(BINDIR)/$*.map -n $(BINDIR)/$*.sym -o $(BINDIR)/$*.$(ROMEXT) $^ $(OBJDIR)/build_date.o \
|
||||
&& $(RGBFIX) -v $(FIXFLAGS) $(BINDIR)/$*.$(ROMEXT)
|
||||
|
||||
@@ -89,12 +89,12 @@ $(BINDIR)/%.$(ROMEXT) $(BINDIR)/%.sym $(BINDIR)/%.map: $(patsubst $(SRCDIR)/%.as
|
||||
# Also add all obj dependencies to the dep file too, so Make knows to remake it
|
||||
# Caution: some of these flags were added in RGBDS 0.4.0, using an earlier version WILL NOT WORK
|
||||
# (and produce weird errors)
|
||||
$(OBJDIR)/%.o $(DEPDIR)/%.mk: $(SRCDIR)/%.asm
|
||||
$(OBJDIR)/%.o $(DEPDIR)/%.mk: src/%.asm
|
||||
@$(MKDIR_P) $(patsubst %/,%,$(dir $(OBJDIR)/$* $(DEPDIR)/$*))
|
||||
$(RGBASM) $(ASFLAGS) -M $(DEPDIR)/$*.mk -MG -MP -MQ $(OBJDIR)/$*.o -MQ $(DEPDIR)/$*.mk -o $(OBJDIR)/$*.o $<
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(patsubst $(SRCDIR)/%.asm,$(DEPDIR)/%.mk,$(SRCS))
|
||||
-include $(patsubst src/%.asm,$(DEPDIR)/%.mk,$(SRCS))
|
||||
endif
|
||||
|
||||
################################################
|
||||
@@ -107,11 +107,11 @@ endif
|
||||
# By default, asset recipes convert files in `res/` into other files in `res/`
|
||||
# This line causes assets not found in `res/` to be also looked for in `src/res/`
|
||||
# "Source" assets can thus be safely stored there without `make clean` removing them
|
||||
VPATH := $(SRCDIR)
|
||||
VPATH := src
|
||||
|
||||
# Define how to compress files using the PackBits16 codec
|
||||
# Compressor script requires Python 3
|
||||
$(RESDIR)/%.pb16: $(SRCDIR)/tools/pb16.py $(RESDIR)/%
|
||||
res/%.pb16: src/tools/pb16.py res/%
|
||||
@$(MKDIR_P) $(@D)
|
||||
$^ $@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user