Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor examples Makefiles #427

Merged
merged 5 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 17 additions & 85 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,85 +1,17 @@
all: audioplayer cpptest ctest dfsdemo mixertest mptest mputest rspqdemo spritemap test timers vrutest vtest ucodetest eepromfstest
clean: audioplayer-clean cpptest-clean ctest-clean dfsdemo-clean mixertest-clean mptest-clean mputest-clean rspqdemo-clean spritemap-clean test-clean timers-clean vrutest-clean vtest-clean ucodetest-clean eepromfstest-clean

audioplayer:
$(MAKE) -C audioplayer
audioplayer-clean:
$(MAKE) -C audioplayer clean

cpptest:
$(MAKE) -C cpptest
cpptest-clean:
$(MAKE) -C cpptest clean

ctest:
$(MAKE) -C ctest
ctest-clean:
$(MAKE) -C ctest clean

dfsdemo:
$(MAKE) -C dfsdemo
dfsdemo-clean:
$(MAKE) -C dfsdemo clean

eepromfstest:
$(MAKE) -C eepromfstest
eepromfstest-clean:
$(MAKE) -C eepromfstest clean

mixertest:
$(MAKE) -C mixertest
mixertest-clean:
$(MAKE) -C mixertest clean

mptest:
$(MAKE) -C mptest
mptest-clean:
$(MAKE) -C mptest clean

mputest:
$(MAKE) -C mputest
mputest-clean:
$(MAKE) -C mputest clean

rspqdemo:
$(MAKE) -C rspqdemo
rspqdemo-clean:
$(MAKE) -C rspqdemo clean

rtctest:
$(MAKE) -C rtctest
rtctest-clean:
$(MAKE) -C rtctest clean

spritemap:
$(MAKE) -C spritemap
spritemap-clean:
$(MAKE) -C spritemap clean

test:
$(MAKE) -C test
test-clean:
$(MAKE) -C test clean

timers:
$(MAKE) -C timers
timers-clean:
$(MAKE) -C timers clean

vrutest:
$(MAKE) -C vrutest
vrutest-clean:
$(MAKE) -C vrutest clean

vtest:
$(MAKE) -C vtest
vtest-clean:
$(MAKE) -C vtest clean

ucodetest:
$(MAKE) -C ucodetest
ucodetest-clean:
$(MAKE) -C ucodetest clean

.PHONY: audioplayer audioplayer-clean cpptest cpptest-clean ctest ctest-clean dfsdemo dfsdemo-clean mixertest mixertest-clean mptest mptest-clean mputest mputest-clean spritemap spritemap-clean
.PHONY: rspqdemo rspqdemo-clean test test-clean timers timers-clean vrutest vrutest-clean vtest vtest-clean ucodetest ucodetest-clean eepromfstest eepromfstest-clean
EXAMPLES = audioplayer cpptest ctest dfsdemo eepromfstest mixertest mptest mputest rspqdemo spritemap test timers vrutest vtest ucodetest

# Populated by evaluating the EXAMPLE_template macro for each example
all:
clean:

define EXAMPLE_template =
$(1):
$$(MAKE) -C $(1)
$(1)-clean:
$$(MAKE) -C $(1) clean
all: $(1)
clean: $(1)-clean
.PHONY: $(1) $(1)-clean
endef

$(foreach example,$(EXAMPLES),$(eval $(call EXAMPLE_template,$(example))))
48 changes: 15 additions & 33 deletions examples/dfsdemo/Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,21 @@
PROG_NAME = dfsdemo
all: dfsdemo.z64
.PHONY: all

ROOTDIR = $(N64_INST)
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
BUILD_DIR = build
include $(N64_INST)/include/n64.mk

CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
OBJCOPY = $(GCCN64PREFIX)objcopy
N64TOOL = $(ROOTDIR)/bin/n64tool
CHKSUM64 = $(ROOTDIR)/bin/chksum64
MKDFS = $(ROOTDIR)/bin/mkdfs
OBJS = $(BUILD_DIR)/dfsdemo.o

ASFLAGS = -mtune=vr4300 -march=vr4300
CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O2 -Wall -Werror -I$(ROOTDIR)/mips64-elf/include -I$(ROOTDIR)/include
LDFLAGS = -L$(ROOTDIR)/mips64-elf/lib -L$(ROOTDIR)/lib -ldragon -lmikmod -lc -lm -ldragonsys -Tn64.ld --gc-sections
N64TOOLFLAGS = -l 8M -h $(ROOTDIR)/mips64-elf/lib/header -t "DragonFS Demo"
dfsdemo.z64: N64_ROM_TITLE = "DragonFS Demo"
dfsdemo.z64: N64_CFLAGS += -I$(N64_ROOTDIR)/include
dfsdemo.z64: N64_LDFLAGS += -L$(N64_ROOTDIR)/lib -lmikmod
dfsdemo.z64: $(BUILD_DIR)/dfsdemo.dfs

ifeq ($(N64_BYTE_SWAP),true)
$(PROG_NAME).v64: $(PROG_NAME).z64
dd conv=swab if=$^ of=$@
endif
$(BUILD_DIR)/dfsdemo.dfs: $(wildcard filesystem/*)
$(BUILD_DIR)/dfsdemo.elf: $(OBJS)

$(PROG_NAME).z64: $(PROG_NAME).bin $(PROG_NAME).dfs
$(N64TOOL) $(N64TOOLFLAGS) -o $@ $(PROG_NAME).bin -s 1M $(PROG_NAME).dfs
$(CHKSUM64) $@

$(PROG_NAME).bin: $(PROG_NAME).elf
$(OBJCOPY) $< $@ -O binary

$(PROG_NAME).elf: $(PROG_NAME).o
$(LD) -o $@ $^ $(LDFLAGS)

$(PROG_NAME).dfs:
$(MKDFS) $@ ./filesystem/

.PHONY: clean
clean:
rm -f *.v64 *.z64 *.bin *.elf *.o *.dfs
rm -rf $(BUILD_DIR) *.z64
.PHONY: clean

-include $(wildcard $(BUILD_DIR)/*.d)
40 changes: 11 additions & 29 deletions examples/mptest/Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
PROG_NAME = mptest
all: mptest.z64
.PHONY: all

ROOTDIR = $(N64_INST)
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
BUILD_DIR = build
include $(N64_INST)/include/n64.mk

CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
OBJCOPY = $(GCCN64PREFIX)objcopy
N64TOOL = $(ROOTDIR)/bin/n64tool
CHKSUM64 = $(ROOTDIR)/bin/chksum64
OBJS = $(BUILD_DIR)/mptest.o

ASFLAGS = -mtune=vr4300 -march=vr4300
CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O2 -Wall -Werror -I$(ROOTDIR)/mips64-elf/include
LDFLAGS = -L$(ROOTDIR)/mips64-elf/lib -ldragon -lc -lm -ldragonsys -Tn64.ld --gc-sections
N64TOOLFLAGS = -l 1M -h $(ROOTDIR)/mips64-elf/lib/header -t "Mempak Test"
mptest.z64: N64_ROM_TITLE = "Mempak Test"

ifeq ($(N64_BYTE_SWAP),true)
$(PROG_NAME).v64: $(PROG_NAME).z64
dd conv=swab if=$^ of=$@
endif
$(BUILD_DIR)/mptest.elf: $(OBJS)

$(PROG_NAME).z64: $(PROG_NAME).bin
$(N64TOOL) $(N64TOOLFLAGS) -o $@ $^
$(CHKSUM64) $@

$(PROG_NAME).bin: $(PROG_NAME).elf
$(OBJCOPY) $< $@ -O binary

$(PROG_NAME).elf: $(PROG_NAME).o
$(LD) -o $@ $^ $(LDFLAGS)

.PHONY: clean
clean:
rm -f *.v64 *.z64 *.bin *.elf *.o
rm -rf $(BUILD_DIR) *.z64
.PHONY: clean

-include $(wildcard $(BUILD_DIR)/*.d)
40 changes: 11 additions & 29 deletions examples/mputest/Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
PROG_NAME = mputest
all: mputest.z64
.PHONY: all

ROOTDIR = $(N64_INST)
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
BUILD_DIR = build
include $(N64_INST)/include/n64.mk

CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
OBJCOPY = $(GCCN64PREFIX)objcopy
N64TOOL = $(ROOTDIR)/bin/n64tool
CHKSUM64 = $(ROOTDIR)/bin/chksum64
OBJS = $(BUILD_DIR)/mputest.o

ASFLAGS = -mtune=vr4300 -march=vr4300
CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O2 -Wall -Werror -I$(ROOTDIR)/mips64-elf/include
LDFLAGS = -L$(ROOTDIR)/mips64-elf/lib -ldragon -lc -lm -ldragonsys -Tn64.ld --gc-sections
N64TOOLFLAGS = -l 1M -h $(ROOTDIR)/mips64-elf/lib/header -t "Mempak Unit Test"
mputest.z64: N64_ROM_TITLE = "Mempak Unit Test"

ifeq ($(N64_BYTE_SWAP),true)
$(PROG_NAME).v64: $(PROG_NAME).z64
dd conv=swab if=$^ of=$@
endif
$(BUILD_DIR)/mputest.elf: $(OBJS)

$(PROG_NAME).z64: $(PROG_NAME).bin
$(N64TOOL) $(N64TOOLFLAGS) -o $@ $^
$(CHKSUM64) $@

$(PROG_NAME).bin: $(PROG_NAME).elf
$(OBJCOPY) $< $@ -O binary

$(PROG_NAME).elf: $(PROG_NAME).o
$(LD) -o $@ $^ $(LDFLAGS)

.PHONY: clean
clean:
rm -f *.v64 *.z64 *.bin *.elf *.o
rm -rf $(BUILD_DIR) *.z64
.PHONY: clean

-include $(wildcard $(BUILD_DIR)/*.d)
40 changes: 11 additions & 29 deletions examples/vrutest/Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
PROG_NAME = vrutest
all: vrutest.z64
.PHONY: all

ROOTDIR = $(N64_INST)
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
BUILD_DIR = build
include $(N64_INST)/include/n64.mk

CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
OBJCOPY = $(GCCN64PREFIX)objcopy
N64TOOL = $(ROOTDIR)/bin/n64tool
CHKSUM64 = $(ROOTDIR)/bin/chksum64
OBJS = $(BUILD_DIR)/vrutest.o

ASFLAGS = -mtune=vr4300 -march=vr4300
CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O2 -Wall -Werror -I$(ROOTDIR)/mips64-elf/include
LDFLAGS = -L$(ROOTDIR)/mips64-elf/lib -ldragon -lc -lm -ldragonsys -Tn64.ld --gc-sections
N64TOOLFLAGS = -l 1M -h $(ROOTDIR)/mips64-elf/lib/header -t "VRU Test"
vrutest.z64: N64_ROM_TITLE = "VRU Test"

ifeq ($(N64_BYTE_SWAP),true)
$(PROG_NAME).v64: $(PROG_NAME).z64
dd conv=swab if=$^ of=$@
endif
$(BUILD_DIR)/vrutest.elf: $(OBJS)

$(PROG_NAME).z64: $(PROG_NAME).bin
$(N64TOOL) $(N64TOOLFLAGS) -o $@ $^
$(CHKSUM64) $@

$(PROG_NAME).bin: $(PROG_NAME).elf
$(OBJCOPY) $< $@ -O binary

$(PROG_NAME).elf: $(PROG_NAME).o
$(LD) -o $@ $^ $(LDFLAGS)

.PHONY: clean
clean:
rm -f *.v64 *.z64 *.bin *.elf *.o
rm -rf $(BUILD_DIR) *.z64
.PHONY: clean

-include $(wildcard $(BUILD_DIR)/*.d)
40 changes: 11 additions & 29 deletions examples/vtest/Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
PROG_NAME = vtest
all: vtest.z64
.PHONY: all

ROOTDIR = $(N64_INST)
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
BUILD_DIR = build
include $(N64_INST)/include/n64.mk

CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
OBJCOPY = $(GCCN64PREFIX)objcopy
N64TOOL = $(ROOTDIR)/bin/n64tool
CHKSUM64 = $(ROOTDIR)/bin/chksum64
OBJS = $(BUILD_DIR)/vtest.o

ASFLAGS = -mtune=vr4300 -march=vr4300
CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -Wall -Werror -I$(ROOTDIR)/mips64-elf/include
LDFLAGS = -L$(ROOTDIR)/mips64-elf/lib -ldragon -lc -lm -ldragonsys -Tn64.ld --gc-sections
N64TOOLFLAGS = -l 1M -h $(ROOTDIR)/mips64-elf/lib/header -t "Video Res Test"
vtest.z64: N64_ROM_TITLE = "Video Res Test"

ifeq ($(N64_BYTE_SWAP),true)
$(PROG_NAME).v64: $(PROG_NAME).z64
dd conv=swab if=$^ of=$@
endif
$(BUILD_DIR)/vtest.elf: $(OBJS)

$(PROG_NAME).z64: $(PROG_NAME).bin
$(N64TOOL) $(N64TOOLFLAGS) -o $@ $^
$(CHKSUM64) $@

$(PROG_NAME).bin: $(PROG_NAME).elf
$(OBJCOPY) $< $@ -O binary

$(PROG_NAME).elf: $(PROG_NAME).o
$(LD) -o $@ $^ $(LDFLAGS)

.PHONY: clean
clean:
rm -f *.v64 *.z64 *.bin *.elf *.o
rm -rf $(BUILD_DIR) *.z64
.PHONY: clean

-include $(wildcard $(BUILD_DIR)/*.d)