Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
139 lines (110 sloc) 4.12 KB
#!/usr/bin/make -f
#
# Makefile for Pently music engine
# Copyright 2012-2015 Damian Yerrick
#
# Copying and distribution of this file, with or without
# modification, are permitted in any medium without royalty
# provided the copyright notice and this notice are preserved.
# This file is offered as-is, without any warranty.
#
# These are used in the title of the NES program and the zip file.
title := pently
version := 0.05wip9
# Name of Pently score for main targets "pently.nes" and "pently.nsf"
# is src/$(scorename).pently, such as src/musicseq.pently.
# To make a ROM or NSF based on a different score, such as
# src/pino-a53.pently, use "make pino-a53.nsf".
scorename := musicseq
# Space-separated list of asm files that make up the ROM,
# whether source code or generated
objlist := main \
pads ppuclear paldetect math bpmmath profiler vis \
pentlysound pentlymusic
objlistnsf := nsfshell \
pentlysound pentlymusic
# List of documents included in zipfile
docs_md := usage bytecode pentlyas famitracker
AS65 := ca65
ASFLAGS65 :=
LD65 := ld65
objdir := obj/nes
srcdir := src
imgdir := tilesets
#EMU := "/C/Program Files/Nintendulator/Nintendulator.exe"
EMU := fceux --input1 GamePad.0
DEBUGEMU := ~/.wine/drive_c/Program\ Files\ \(x86\)/FCEUX/fceux.exe
# other options for EMU are start (Windows) or gnome-open (GNOME)
# Work around a quirk of how the Python 3 for Windows installer
# sets up the PATH
ifdef COMSPEC
PY:=py
else
PY:=
endif
.PHONY: run debug clean dist zip all zip.in
run: $(title).nes
$(EMU) $<
debug: $(title).nes
$(DEBUGEMU) $<
clean:
-rm $(objdir)/*.o $(objdir)/*.s $(objdir)/*.chr $(objdir)/*.inc
# Rule to create or update the distribution zipfile by adding all
# files listed in zip.in. Actually the zipfile depends on every
# single file in zip.in, but currently we use changes to the compiled
# program, makefile, and README as a heuristic for when something was
# changed. It won't see changes to docs or tools, but usually when
# docs changes, README also changes, and when tools changes, the
# makefile changes.
dist: zip
zip: $(title)-$(version).zip
$(title)-$(version).zip: zip.in all CHANGES.txt \
README.md CHANGES.txt $(foreach o,$(docs_md),docs/$(o).md) \
$(objdir)/index.txt
zip -9 -u $@ -@ < $<
# Build zip.in from the list of files in the Git tree
zip.in:
git ls-files | grep -e "^[^.]" > $@
echo pently.nes >> $@
echo pently.nsf >> $@
echo zip.in >> $@
$(objdir)/index.txt: makefile
echo "This file forces the creation of the folder for object files. You may delete it." > $@
# Rules for PRG ROM
objlisto := $(foreach o,$(objlist),$(objdir)/$(o).o)
objlistnsf := $(foreach o,$(objlistnsf),$(objdir)/$(o).o)
all: $(title).nes $(title).nsf
# These two build the main binary target
map.txt $(title).nes: nrom128.cfg $(objlisto) $(objdir)/$(scorename)-rmarks.o
$(LD65) -o $(title).nes -C $^ -m map.txt
nsfmap.txt $(title).nsf: nsf.cfg $(objlistnsf) $(objdir)/$(scorename).o
$(LD65) -o $(title).nsf -C $^ -m nsfmap.txt
# These two are for "make pino-a53.nsf" functionality
%.nes: nrom128.cfg $(objlisto) $(objdir)/%-rmarks.o
$(LD65) -o $@ -C $^
%.nsf: nsf.cfg $(objlistnsf) $(objdir)/%.o
$(LD65) -o $@ -C $^
$(objdir)/%.o: \
$(srcdir)/%.s $(srcdir)/nes.inc $(srcdir)/shell.inc $(srcdir)/pently.inc
$(AS65) $(ASFLAGS65) $< -o $@
$(objdir)/%.o: $(objdir)/%.s
$(AS65) $(ASFLAGS65) $< -o $@
# Files that depend on additional headers
$(objdir)/musicseq.o $(objdir)/pentlymusic.o: $(srcdir)/pentlyseq.inc
$(objdir)/pentlysound.o $(objdir)/pentlymusic.o \
$(objdir)/bpmmath.o $(objdir)/nsfshell.o $(objdir)/vis.o $(objdir)/main.o: \
$(srcdir)/pentlyconfig.inc
$(objdir)/pentlymusic.o: $(objdir)/pentlybss.inc
# Files that depend on .incbin'd files
$(objdir)/main.o: tracknames.txt $(objdir)/bggfx.chr $(objdir)/spritegfx.chr
# Build RAM map
$(objdir)/pentlybss.inc: tools/pentlybss.py $(srcdir)/pentlyconfig.inc
$(PY) $^ pentlymusicbase -o $@
# Translate music project
$(objdir)/%.s: tools/pentlyas.py src/%.pently
$(PY) $^ -o $@ --periods 76
$(objdir)/%-rmarks.s: tools/pentlyas.py src/%.pently
$(PY) $^ -o $@ --periods 76 --rehearse
# Rules for CHR ROM
$(objdir)/%.chr: $(imgdir)/%.png
$(PY) tools/pilbmp2nes.py $< $@