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
|
## Directory constants
|
||||||
SRCDIR := src
|
# 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
|
BINDIR := bin
|
||||||
OBJDIR := obj
|
OBJDIR := obj
|
||||||
DEPDIR := dep
|
DEPDIR := dep
|
||||||
RESDIR := res
|
|
||||||
|
|
||||||
# Program constants
|
# Program constants
|
||||||
ifneq ($(OS),Windows_NT)
|
ifneq ($(OS),Windows_NT)
|
||||||
@@ -34,14 +34,14 @@ RGBFIX := $(RGBDS)rgbfix
|
|||||||
ROM = $(BINDIR)/$(ROMNAME).$(ROMEXT)
|
ROM = $(BINDIR)/$(ROMNAME).$(ROMEXT)
|
||||||
|
|
||||||
# Argument constants
|
# Argument constants
|
||||||
INCDIRS = $(SRCDIR)/ $(SRCDIR)/include/
|
INCDIRS = src/ src/include/
|
||||||
WARNINGS = all extra
|
WARNINGS = all extra
|
||||||
ASFLAGS = -p $(PADVALUE) $(addprefix -i,$(INCDIRS)) $(addprefix -W,$(WARNINGS))
|
ASFLAGS = -p $(PADVALUE) $(addprefix -i,$(INCDIRS)) $(addprefix -W,$(WARNINGS))
|
||||||
LDFLAGS = -p $(PADVALUE)
|
LDFLAGS = -p $(PADVALUE)
|
||||||
FIXFLAGS = -p $(PADVALUE) -v -i "$(GAMEID)" -k "$(LICENSEE)" -l $(OLDLIC) -m $(MBC) -n $(VERSION) -r $(SRAMSIZE) -t $(TITLE)
|
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
|
# The list of "root" ASM files that RGBASM will be invoked on
|
||||||
SRCS = $(wildcard $(SRCDIR)/*.asm)
|
SRCS = $(wildcard src/*.asm)
|
||||||
|
|
||||||
## Project-specific configuration
|
## Project-specific configuration
|
||||||
# Use this to override the above
|
# Use this to override the above
|
||||||
@@ -62,7 +62,7 @@ clean:
|
|||||||
$(RM_RF) $(BINDIR)
|
$(RM_RF) $(BINDIR)
|
||||||
$(RM_RF) $(OBJDIR)
|
$(RM_RF) $(OBJDIR)
|
||||||
$(RM_RF) $(DEPDIR)
|
$(RM_RF) $(DEPDIR)
|
||||||
$(RM_RF) $(RESDIR)
|
$(RM_RF) res
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
# `rebuild`: Build everything from scratch
|
# `rebuild`: Build everything from scratch
|
||||||
@@ -79,9 +79,9 @@ rebuild:
|
|||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
# How to build a ROM
|
# 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)
|
@$(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 \
|
$(RGBLINK) $(LDFLAGS) -m $(BINDIR)/$*.map -n $(BINDIR)/$*.sym -o $(BINDIR)/$*.$(ROMEXT) $^ $(OBJDIR)/build_date.o \
|
||||||
&& $(RGBFIX) -v $(FIXFLAGS) $(BINDIR)/$*.$(ROMEXT)
|
&& $(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
|
# 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
|
# Caution: some of these flags were added in RGBDS 0.4.0, using an earlier version WILL NOT WORK
|
||||||
# (and produce weird errors)
|
# (and produce weird errors)
|
||||||
$(OBJDIR)/%.o $(DEPDIR)/%.mk: $(SRCDIR)/%.asm
|
$(OBJDIR)/%.o $(DEPDIR)/%.mk: src/%.asm
|
||||||
@$(MKDIR_P) $(patsubst %/,%,$(dir $(OBJDIR)/$* $(DEPDIR)/$*))
|
@$(MKDIR_P) $(patsubst %/,%,$(dir $(OBJDIR)/$* $(DEPDIR)/$*))
|
||||||
$(RGBASM) $(ASFLAGS) -M $(DEPDIR)/$*.mk -MG -MP -MQ $(OBJDIR)/$*.o -MQ $(DEPDIR)/$*.mk -o $(OBJDIR)/$*.o $<
|
$(RGBASM) $(ASFLAGS) -M $(DEPDIR)/$*.mk -MG -MP -MQ $(OBJDIR)/$*.o -MQ $(DEPDIR)/$*.mk -o $(OBJDIR)/$*.o $<
|
||||||
|
|
||||||
ifneq ($(MAKECMDGOALS),clean)
|
ifneq ($(MAKECMDGOALS),clean)
|
||||||
-include $(patsubst $(SRCDIR)/%.asm,$(DEPDIR)/%.mk,$(SRCS))
|
-include $(patsubst src/%.asm,$(DEPDIR)/%.mk,$(SRCS))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
@@ -107,11 +107,11 @@ endif
|
|||||||
# By default, asset recipes convert files in `res/` into other files in `res/`
|
# 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/`
|
# 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
|
# "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
|
# Define how to compress files using the PackBits16 codec
|
||||||
# Compressor script requires Python 3
|
# Compressor script requires Python 3
|
||||||
$(RESDIR)/%.pb16: $(SRCDIR)/tools/pb16.py $(RESDIR)/%
|
res/%.pb16: src/tools/pb16.py res/%
|
||||||
@$(MKDIR_P) $(@D)
|
@$(MKDIR_P) $(@D)
|
||||||
$^ $@
|
$^ $@
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user