ftpiiu_plugin/Makefile.nds

207 lines
7.9 KiB
Makefile
Raw Normal View History

2020-04-17 22:32:39 +02:00
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary files embedded using bin2o
# GRAPHICS is a list of directories containing image files to be converted with grit
# AUDIO is a list of directories containing audio to be converted by maxmod
# ICON is the image used to create the game icon, leave blank to use default rule
# NITRO is a directory that will be accessible via NitroFS
#---------------------------------------------------------------------------------
TARGET := nds/ftpd
BUILD := nds/build
SOURCES := source source/nds
INCLUDES := include
DATA :=
GRAPHICS :=
AUDIO :=
ICON :=
# specify a directory which contains the nitro filesystem
# this is relative to the Makefile
NITRO :=
# These set the information text in the nds file
GAME_TITLE := ftpd classic
GAME_SUBTITLE1 := v$(VERSION)
2023-03-11 14:02:43 +01:00
GAME_SUBTITLE2 := (c) 2023 mtheall
2020-04-17 22:32:39 +02:00
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
2020-04-23 00:16:21 +02:00
OPTIMIZE := -Og
2020-04-17 22:32:39 +02:00
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
2020-04-23 00:16:21 +02:00
CFLAGS := -g -Wall $(OPTIMIZE) \
2020-04-17 22:32:39 +02:00
$(ARCH) $(INCLUDE) -DARM9 -DNDS \
-DSTATUS_STRING="\"ftpd v$(VERSION)\"" \
2020-04-24 22:51:43 +02:00
-DNO_IPV6 -DCLASSIC -DFTPDCONFIG="\"/config/ftpd/ftpd.cfg\""
2022-10-04 04:52:19 +02:00
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++2a
2020-04-17 22:32:39 +02:00
ASFLAGS := -g $(ARCH)
2020-04-23 00:16:21 +02:00
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) $(OPTIMIZE)
2020-04-17 22:32:39 +02:00
2020-04-23 08:01:11 +02:00
CC := `which ccache 2>/dev/null` $(CC)
CXX := `which ccache 2>/dev/null` $(CXX)
2020-04-17 22:32:39 +02:00
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project (order is important)
#---------------------------------------------------------------------------------
LIBS := -lfat -ldswifi9 -lnds9
# automatigically add libraries for NitroFS
ifneq ($(strip $(NITRO)),)
LIBS := -lfilesystem -lfat $(LIBS)
endif
# automagically add maxmod library
ifneq ($(strip $(AUDIO)),)
LIBS := -lmm9 $(LIBS)
endif
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
2020-05-09 20:23:54 +02:00
LIBDIRS := $(LIBNDS)
2020-04-17 22:32:39 +02:00
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(TOPDIR)/$(BUILD),$(CURDIR))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
# prepare NitroFS directory
ifneq ($(strip $(NITRO)),)
export NITRO_FILES := $(CURDIR)/$(NITRO)
endif
# get audio list for maxmod
ifneq ($(strip $(AUDIO)),)
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
# place the soundbank file in NitroFS if using it
ifneq ($(strip $(NITRO)),)
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
# otherwise, needs to be loaded from memory
else
export SOUNDBANK := soundbank.bin
BINFILES += $(SOUNDBANK)
endif
endif
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES))\
$(PNGFILES:.png=.o)\
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
2020-04-27 03:45:26 +02:00
icons := $(wildcard $(dir $(TARGET))*.bmp)
2020-04-17 22:32:39 +02:00
2020-04-27 03:45:26 +02:00
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
2020-04-17 22:32:39 +02:00
else
2020-04-27 03:45:26 +02:00
ifneq (,$(findstring $(dir $(TARGET))icon.bmp,$(icons)))
export GAME_ICON := $(CURDIR)/$(dir $(TARGET))icon.bmp
2020-04-17 22:32:39 +02:00
endif
endif
.PHONY: $(BUILD) clean dslink
#---------------------------------------------------------------------------------
$(BUILD):
@mkdir -p $@
@$(MAKE) -C $(BUILD) -f $(CURDIR)/Makefile.nds
dslink: $(BUILD)
@dslink $(OUTPUT).nds
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
2020-04-27 03:45:26 +02:00
$(OUTPUT).nds: $(OUTPUT).elf
2020-04-17 22:32:39 +02:00
$(OUTPUT).elf: $(OFILES)
# need to build soundbank first
2020-05-09 20:23:54 +02:00
$(OFILES): $(SOUNDBANK) $(TOPDIR)/Makefile $(TOPDIR)/Makefile.nds
2020-04-17 22:32:39 +02:00
#---------------------------------------------------------------------------------
# rule to build solution from music files
#---------------------------------------------------------------------------------
$(SOUNDBANK) : $(MODFILES)
#---------------------------------------------------------------------------------
mmutil $^ -d -o$@ -hsoundbank.h
#---------------------------------------------------------------------------------
%.bin.o: %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
#---------------------------------------------------------------------------------
# This rule creates assembly source files using grit
# grit takes an image file and a .grit describing how the file is to be processed
# add additional rules like this for each image extension
# you use in the graphics folders
#---------------------------------------------------------------------------------
%.s %.h: %.png %.grit
#---------------------------------------------------------------------------------
grit $< -fts -o$*
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------