From 3ba35ba48eadee35f67b1dc8da51f1f0b0f81bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Sun, 2 Jun 2024 17:27:10 +0100 Subject: [PATCH] docs: build: library: examples: Set BlocksDS as main toolchain Until now the main makefiles of Nitro Engine have been the ones of devkitPro, forcing users to go through extra steps to build everything under BlocksDS. Now, the easy makefiles are the BlocksDS ones, and additional notes have been added to warn about the limitations of devkitPro: - No GRF support in libnds. - NitroFS doesn't work in melonDS. --- Makefile | 289 +++++++----- Makefile.blocksds | 204 -------- Makefile.dkp | 139 ++++++ examples/2d_system/Makefile | 26 +- examples/2d_system/Makefile.blocksds | 25 - examples/2d_system/gui/Makefile | 222 +-------- examples/2d_system/gui/Makefile.blocksds | 6 - examples/2d_system/gui/Makefile.dkp | 220 +++++++++ .../2d_system/quad_texture_sizes/Makefile | 222 +-------- .../quad_texture_sizes/Makefile.blocksds | 6 - .../2d_system/quad_texture_sizes/Makefile.dkp | 220 +++++++++ examples/2d_system/quads/Makefile | 222 +-------- examples/2d_system/quads/Makefile.blocksds | 4 - examples/2d_system/quads/Makefile.dkp | 220 +++++++++ examples/2d_system/sprites/Makefile | 222 +-------- examples/2d_system/sprites/Makefile.blocksds | 6 - examples/2d_system/sprites/Makefile.dkp | 220 +++++++++ examples/Makefile | 36 +- examples/Makefile.blocksds | 25 - ...file.example.blocksds => Makefile.example} | 1 + examples/effects/Makefile | 26 +- examples/effects/Makefile.blocksds | 25 - examples/effects/fog/Makefile | 223 +-------- examples/effects/fog/Makefile.blocksds | 7 - examples/effects/fog/Makefile.dkp | 220 +++++++++ examples/effects/screen_effects/Makefile | 222 +-------- .../effects/screen_effects/Makefile.blocksds | 6 - examples/effects/screen_effects/Makefile.dkp | 220 +++++++++ .../screen_effects_dual_3d_dma/Makefile | 222 +-------- .../Makefile.blocksds | 6 - .../screen_effects_dual_3d_dma/Makefile.dkp | 220 +++++++++ .../effects/shading_alpha_outlining/Makefile | 223 +-------- .../shading_alpha_outlining/Makefile.blocksds | 7 - .../shading_alpha_outlining/Makefile.dkp | 220 +++++++++ examples/effects/specular_material/Makefile | 223 +-------- .../specular_material/Makefile.blocksds | 7 - .../effects/specular_material/Makefile.dkp | 220 +++++++++ examples/effects/volumetric_shadow/Makefile | 223 +-------- .../volumetric_shadow/Makefile.blocksds | 7 - .../effects/volumetric_shadow/Makefile.dkp | 220 +++++++++ examples/loading/Makefile | 26 +- examples/loading/Makefile.blocksds | 25 - examples/loading/animated_model/Makefile | 223 +-------- .../loading/animated_model/Makefile.blocksds | 7 - examples/loading/animated_model/Makefile.dkp | 220 +++++++++ examples/loading/clone_models/Makefile | 222 +-------- .../loading/clone_models/Makefile.blocksds | 6 - examples/loading/clone_models/Makefile.dkp | 220 +++++++++ examples/loading/compressed_texture/Makefile | 222 +-------- .../compressed_texture/Makefile.blocksds | 6 - .../loading/compressed_texture/Makefile.dkp | 220 +++++++++ .../filesystem_animated_model/Makefile | 222 +-------- .../filesystem_animated_model/Makefile.dkp | 220 +++++++++ .../filesystem_multiple_textures/Makefile | 222 +-------- .../Makefile.blocksds | 6 - .../filesystem_multiple_textures/Makefile.dkp | 220 +++++++++ .../loading/filesystem_simple_model/Makefile | 222 +-------- .../filesystem_simple_model/Makefile.blocksds | 7 - .../filesystem_simple_model/Makefile.dkp | 220 +++++++++ .../Makefile} | 2 +- .../filesystem_textures_grf/Makefile.blocksds | 6 - examples/loading/incomplete_texture/Makefile | 222 +-------- .../incomplete_texture/Makefile.blocksds | 6 - .../loading/incomplete_texture/Makefile.dkp | 220 +++++++++ .../loading/model_with_vertex_color/Makefile | 223 +-------- .../model_with_vertex_color/Makefile.blocksds | 7 - .../model_with_vertex_color/Makefile.dkp | 220 +++++++++ examples/loading/multiple_models/Makefile | 222 +-------- .../loading/multiple_models/Makefile.blocksds | 6 - examples/loading/multiple_models/Makefile.dkp | 220 +++++++++ examples/loading/paletted_texture/Makefile | 222 +-------- .../paletted_texture/Makefile.blocksds | 6 - .../loading/paletted_texture/Makefile.dkp | 220 +++++++++ examples/loading/simple_model/Makefile | 223 +-------- .../loading/simple_model/Makefile.blocksds | 7 - examples/loading/simple_model/Makefile.dkp | 220 +++++++++ examples/other/Makefile | 26 +- examples/other/Makefile.blocksds | 25 - examples/other/blended_animations/Makefile | 223 +-------- .../blended_animations/Makefile.blocksds | 7 - .../other/blended_animations/Makefile.dkp | 220 +++++++++ examples/other/clear_bmp/Makefile | 223 +-------- examples/other/clear_bmp/Makefile.blocksds | 7 - examples/other/clear_bmp/Makefile.dkp | 220 +++++++++ .../other/dual_3d_dma_low_framerate/Makefile | 222 +-------- .../Makefile.blocksds | 6 - .../dual_3d_dma_low_framerate/Makefile.dkp | 220 +++++++++ examples/other/dual_3d_modes/Makefile | 222 +-------- .../other/dual_3d_modes/Makefile.blocksds | 6 - examples/other/dual_3d_modes/Makefile.dkp | 220 +++++++++ examples/other/dual_3d_modes_args/Makefile | 222 +-------- .../dual_3d_modes_args/Makefile.blocksds | 6 - .../other/dual_3d_modes_args/Makefile.dkp | 220 +++++++++ examples/other/error_handling/Makefile | 228 +-------- .../other/error_handling/Makefile.blocksds | 7 - examples/other/error_handling/Makefile.dkp | 225 +++++++++ examples/other/fps_counter/Makefile | 223 +-------- examples/other/fps_counter/Makefile.blocksds | 7 - examples/other/fps_counter/Makefile.dkp | 220 +++++++++ examples/other/free_camera/Makefile | 223 +-------- examples/other/free_camera/Makefile.blocksds | 7 - examples/other/free_camera/Makefile.dkp | 220 +++++++++ examples/other/polygon_colored/Makefile | 222 +-------- .../other/polygon_colored/Makefile.blocksds | 4 - examples/other/polygon_colored/Makefile.dkp | 220 +++++++++ examples/other/polygon_textured/Makefile | 222 +-------- .../other/polygon_textured/Makefile.blocksds | 6 - examples/other/polygon_textured/Makefile.dkp | 220 +++++++++ .../stylus_texture_drawing_rgb256/Makefile | 222 +-------- .../Makefile.blocksds | 6 - .../Makefile.dkp | 220 +++++++++ .../stylus_texture_drawing_rgba/Makefile | 222 +-------- .../Makefile.blocksds | 6 - .../stylus_texture_drawing_rgba/Makefile.dkp | 220 +++++++++ examples/other/swap_3d_dual_screen/Makefile | 222 +-------- .../swap_3d_dual_screen/Makefile.blocksds | 6 - .../other/swap_3d_dual_screen/Makefile.dkp | 220 +++++++++ examples/other/swap_3d_single_screen/Makefile | 222 +-------- .../swap_3d_single_screen/Makefile.blocksds | 6 - .../other/swap_3d_single_screen/Makefile.dkp | 220 +++++++++ examples/other/touch_test/Makefile | 222 +-------- examples/other/touch_test/Makefile.blocksds | 6 - examples/other/touch_test/Makefile.dkp | 220 +++++++++ examples/physics/Makefile | 26 +- examples/physics/Makefile.blocksds | 25 - examples/physics/basic/Makefile | 222 +-------- examples/physics/basic/Makefile.blocksds | 6 - examples/physics/basic/Makefile.dkp | 220 +++++++++ examples/physics/box_tower/Makefile | 222 +-------- examples/physics/box_tower/Makefile.blocksds | 6 - examples/physics/box_tower/Makefile.dkp | 220 +++++++++ examples/physics/collision_actions/Makefile | 222 +-------- .../collision_actions/Makefile.blocksds | 6 - .../physics/collision_actions/Makefile.dkp | 220 +++++++++ examples/templates/3d_dual_screen/Makefile | 436 ++++++++++------- .../3d_dual_screen/Makefile.blocksds | 296 ------------ .../templates/3d_dual_screen/Makefile.dkp | 220 +++++++++ examples/templates/3d_single_screen/Makefile | 436 ++++++++++------- .../3d_single_screen/Makefile.blocksds | 296 ------------ .../templates/3d_single_screen/Makefile.dkp | 220 +++++++++ examples/templates/Makefile | 26 +- examples/templates/Makefile.blocksds | 25 - examples/templates/using_nflib/Makefile | 439 ++++++++++-------- .../templates/using_nflib/Makefile.blocksds | 297 ------------ examples/templates/using_nflib/Makefile.dkp | 222 +++++++++ examples/text/Makefile | 25 + examples/text/font_from_ram/Makefile | 223 +-------- examples/text/font_from_ram/Makefile.blocksds | 7 - examples/text/font_from_ram/Makefile.dkp | 220 +++++++++ examples/text/monospaced_text/Makefile | 222 +-------- .../text/monospaced_text/Makefile.blocksds | 6 - examples/text/monospaced_text/Makefile.dkp | 220 +++++++++ readme.rst | 83 ++-- tests/3d_modes_lcd_depth/Makefile | 221 +-------- tests/3d_modes_lcd_depth/Makefile.blocksds | 3 - tests/allocator/Makefile | 225 +-------- tests/allocator/Makefile.blocksds | 1 - tests/clone_materials/Makefile | 222 +-------- tests/clone_materials/Makefile.blocksds | 6 - 159 files changed, 11185 insertions(+), 11866 deletions(-) delete mode 100644 Makefile.blocksds create mode 100644 Makefile.dkp delete mode 100644 examples/2d_system/Makefile.blocksds delete mode 100644 examples/2d_system/gui/Makefile.blocksds create mode 100644 examples/2d_system/gui/Makefile.dkp delete mode 100644 examples/2d_system/quad_texture_sizes/Makefile.blocksds create mode 100644 examples/2d_system/quad_texture_sizes/Makefile.dkp delete mode 100644 examples/2d_system/quads/Makefile.blocksds create mode 100644 examples/2d_system/quads/Makefile.dkp delete mode 100644 examples/2d_system/sprites/Makefile.blocksds create mode 100644 examples/2d_system/sprites/Makefile.dkp delete mode 100644 examples/Makefile.blocksds rename examples/{Makefile.example.blocksds => Makefile.example} (99%) delete mode 100644 examples/effects/Makefile.blocksds delete mode 100644 examples/effects/fog/Makefile.blocksds create mode 100644 examples/effects/fog/Makefile.dkp delete mode 100644 examples/effects/screen_effects/Makefile.blocksds create mode 100644 examples/effects/screen_effects/Makefile.dkp delete mode 100644 examples/effects/screen_effects_dual_3d_dma/Makefile.blocksds create mode 100644 examples/effects/screen_effects_dual_3d_dma/Makefile.dkp delete mode 100644 examples/effects/shading_alpha_outlining/Makefile.blocksds create mode 100644 examples/effects/shading_alpha_outlining/Makefile.dkp delete mode 100644 examples/effects/specular_material/Makefile.blocksds create mode 100644 examples/effects/specular_material/Makefile.dkp delete mode 100644 examples/effects/volumetric_shadow/Makefile.blocksds create mode 100644 examples/effects/volumetric_shadow/Makefile.dkp delete mode 100644 examples/loading/Makefile.blocksds delete mode 100644 examples/loading/animated_model/Makefile.blocksds create mode 100644 examples/loading/animated_model/Makefile.dkp delete mode 100644 examples/loading/clone_models/Makefile.blocksds create mode 100644 examples/loading/clone_models/Makefile.dkp delete mode 100644 examples/loading/compressed_texture/Makefile.blocksds create mode 100644 examples/loading/compressed_texture/Makefile.dkp create mode 100644 examples/loading/filesystem_animated_model/Makefile.dkp delete mode 100644 examples/loading/filesystem_multiple_textures/Makefile.blocksds create mode 100644 examples/loading/filesystem_multiple_textures/Makefile.dkp delete mode 100644 examples/loading/filesystem_simple_model/Makefile.blocksds create mode 100644 examples/loading/filesystem_simple_model/Makefile.dkp rename examples/loading/{filesystem_animated_model/Makefile.blocksds => filesystem_textures_grf/Makefile} (81%) delete mode 100644 examples/loading/filesystem_textures_grf/Makefile.blocksds delete mode 100644 examples/loading/incomplete_texture/Makefile.blocksds create mode 100644 examples/loading/incomplete_texture/Makefile.dkp delete mode 100644 examples/loading/model_with_vertex_color/Makefile.blocksds create mode 100644 examples/loading/model_with_vertex_color/Makefile.dkp delete mode 100644 examples/loading/multiple_models/Makefile.blocksds create mode 100644 examples/loading/multiple_models/Makefile.dkp delete mode 100644 examples/loading/paletted_texture/Makefile.blocksds create mode 100644 examples/loading/paletted_texture/Makefile.dkp delete mode 100644 examples/loading/simple_model/Makefile.blocksds create mode 100644 examples/loading/simple_model/Makefile.dkp delete mode 100644 examples/other/Makefile.blocksds delete mode 100644 examples/other/blended_animations/Makefile.blocksds create mode 100644 examples/other/blended_animations/Makefile.dkp delete mode 100644 examples/other/clear_bmp/Makefile.blocksds create mode 100644 examples/other/clear_bmp/Makefile.dkp delete mode 100644 examples/other/dual_3d_dma_low_framerate/Makefile.blocksds create mode 100644 examples/other/dual_3d_dma_low_framerate/Makefile.dkp delete mode 100644 examples/other/dual_3d_modes/Makefile.blocksds create mode 100644 examples/other/dual_3d_modes/Makefile.dkp delete mode 100644 examples/other/dual_3d_modes_args/Makefile.blocksds create mode 100644 examples/other/dual_3d_modes_args/Makefile.dkp delete mode 100644 examples/other/error_handling/Makefile.blocksds create mode 100644 examples/other/error_handling/Makefile.dkp delete mode 100644 examples/other/fps_counter/Makefile.blocksds create mode 100644 examples/other/fps_counter/Makefile.dkp delete mode 100644 examples/other/free_camera/Makefile.blocksds create mode 100644 examples/other/free_camera/Makefile.dkp delete mode 100644 examples/other/polygon_colored/Makefile.blocksds create mode 100644 examples/other/polygon_colored/Makefile.dkp delete mode 100644 examples/other/polygon_textured/Makefile.blocksds create mode 100644 examples/other/polygon_textured/Makefile.dkp delete mode 100644 examples/other/stylus_texture_drawing_rgb256/Makefile.blocksds create mode 100644 examples/other/stylus_texture_drawing_rgb256/Makefile.dkp delete mode 100644 examples/other/stylus_texture_drawing_rgba/Makefile.blocksds create mode 100644 examples/other/stylus_texture_drawing_rgba/Makefile.dkp delete mode 100644 examples/other/swap_3d_dual_screen/Makefile.blocksds create mode 100644 examples/other/swap_3d_dual_screen/Makefile.dkp delete mode 100644 examples/other/swap_3d_single_screen/Makefile.blocksds create mode 100644 examples/other/swap_3d_single_screen/Makefile.dkp delete mode 100644 examples/other/touch_test/Makefile.blocksds create mode 100644 examples/other/touch_test/Makefile.dkp delete mode 100644 examples/physics/Makefile.blocksds delete mode 100644 examples/physics/basic/Makefile.blocksds create mode 100644 examples/physics/basic/Makefile.dkp delete mode 100644 examples/physics/box_tower/Makefile.blocksds create mode 100644 examples/physics/box_tower/Makefile.dkp delete mode 100644 examples/physics/collision_actions/Makefile.blocksds create mode 100644 examples/physics/collision_actions/Makefile.dkp delete mode 100644 examples/templates/3d_dual_screen/Makefile.blocksds create mode 100644 examples/templates/3d_dual_screen/Makefile.dkp delete mode 100644 examples/templates/3d_single_screen/Makefile.blocksds create mode 100644 examples/templates/3d_single_screen/Makefile.dkp delete mode 100644 examples/templates/Makefile.blocksds delete mode 100644 examples/templates/using_nflib/Makefile.blocksds create mode 100644 examples/templates/using_nflib/Makefile.dkp create mode 100644 examples/text/Makefile delete mode 100644 examples/text/font_from_ram/Makefile.blocksds create mode 100644 examples/text/font_from_ram/Makefile.dkp delete mode 100644 examples/text/monospaced_text/Makefile.blocksds create mode 100644 examples/text/monospaced_text/Makefile.dkp delete mode 100644 tests/3d_modes_lcd_depth/Makefile.blocksds delete mode 100644 tests/allocator/Makefile.blocksds delete mode 100644 tests/clone_materials/Makefile.blocksds diff --git a/Makefile b/Makefile index 459a396..b6339b2 100644 --- a/Makefile +++ b/Makefile @@ -1,139 +1,204 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023 -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BLOCKSDS ?= /opt/blocksds/core +BLOCKSDSEXT ?= /opt/blocksds/external -include $(DEVKITARM)/ds_rules +WONDERFUL_TOOLCHAIN ?= /opt/wonderful +ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/ -#--------------------------------------------------------------------------------- -# 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 -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -#--------------------------------------------------------------------------------- -SOURCES := source source/dsma source/libdsf -DATA := data -INCLUDES := include source/libdsf +# Source code paths +# ----------------- + +SOURCEDIRS := source +INCLUDEDIRS := include source/libdsf +GFXDIRS := +BINDIRS := + +# Defines passed to all files +# --------------------------- ifeq ($(NE_DEBUG),1) - TARGET := NE_debug - BUILD := build_debug +DEFINES := -DNE_DEBUG -DNE_BLOCKSDS else - TARGET := NE - BUILD := build_release +DEFINES := -DNE_BLOCKSDS endif -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb -mthumb-interwork +# Libraries +# --------- -CFLAGS := -g -Wall -O2\ - -march=armv5te -mtune=arm946e-s \ - -fomit-frame-pointer -ffast-math \ - $(ARCH) -Wno-address-of-packed-member +LIBDIRS := $(BLOCKSDS)/libs/libnds + +# Build artifacts +# --------------- ifeq ($(NE_DEBUG),1) - CFLAGS += -DNE_DEBUG -endif - -CFLAGS += $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions - -ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project -#--------------------------------------------------------------------------------- -LIBS := - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(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))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- + NAME := NE_debug + BUILDDIR := build_debug else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- + NAME := NE + BUILDDIR := build_release endif -#--------------------------------------------------------------------------------- +INSTALLNAME := nitro-engine +ARCHIVE := lib/lib$(NAME).a -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +# Tools +# ----- -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) +PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi- +CC := $(PREFIX)gcc +CXX := $(PREFIX)g++ +AR := ar +MKDIR := mkdir +RM := rm -rf +CP := cp +INSTALL := install -.PHONY: $(BUILD) clean all +# Verbose flag +# ------------ -#--------------------------------------------------------------------------------- -all: $(BUILD) +ifeq ($(VERBOSE),1) +V := +else +V := @ +endif -lib: - @[ -d $@ ] || mkdir -p $@ - -$(BUILD): lib - @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile +# Source files +# ------------ + +ifneq ($(BINDIRS),) + SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS)) +endif +ifneq ($(GFXDIRS),) + SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS)) +endif + +SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s") +SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c") +SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp") + +# Compiler and linker flags +# ------------------------- + +DEFINES += -D__NDS__ -DARM9 + +ARCH := -march=armv5te -mtune=arm946e-s + +WARNFLAGS := -Wall -Wno-address-of-packed-member + +INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \ + $(foreach path,$(LIBDIRS),-I$(path)/include) + +ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) \ + -ffunction-sections -fdata-sections + +CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ + -ffunction-sections -fdata-sections \ + -fomit-frame-pointer + +CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ + -ffunction-sections -fdata-sections \ + -fno-exceptions -fno-rtti \ + -fomit-frame-pointer + +# Intermediate build files +# ------------------------ + +OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) + +HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ + $(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) + +OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP))) + +OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES) + +DEPS := $(OBJS:.o=.d) + +# Targets +# ------- + +.PHONY: all clean install + +all: $(ARCHIVE) + +$(ARCHIVE): $(OBJS) + @echo " AR $@" + @$(MKDIR) -p $(@D) + $(V)$(AR) rcs $@ $(OBJS) + +install: all + @echo " INSTALL $(BLOCKSDSEXT)/$(INSTALLNAME)/" + $(V)$(RM) $(BLOCKSDSEXT)/$(INSTALLNAME)/ + $(V)$(INSTALL) -d $(BLOCKSDSEXT)/$(INSTALLNAME)/ \ + $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/img2ds \ + $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/md5_to_dsma \ + $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/obj2dl + $(V)$(CP) -r include lib $(BLOCKSDSEXT)/$(INSTALLNAME)/ + $(V)$(CP) -r tools/img2ds/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/img2ds + $(V)$(CP) -r tools/md5_to_dsma/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/md5_to_dsma + $(V)$(CP) -r tools/obj2dl/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/obj2dl -#--------------------------------------------------------------------------------- clean: - @echo clean ... - @rm -fr build_debug build_release lib + @echo " CLEAN" + $(V)$(RM) $(ARCHIVE) build_debug build_release -#--------------------------------------------------------------------------------- -else +# Rules +# ----- -DEPENDS := $(OFILES:.o=.d) +$(BUILDDIR)/%.s.o : %.s + @echo " AS $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT) : $(OFILES) +$(BUILDDIR)/%.c.o : %.c + @echo " CC $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -%.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) +$(BUILDDIR)/%.arm.c.o : %.arm.c + @echo " CC $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< +$(BUILDDIR)/%.cpp.o : %.cpp + @echo " CXX $<" + @$(MKDIR) -p $(@D) + $(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $< --include $(DEPENDS) +$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp + @echo " CXX $<" + @$(MKDIR) -p $(@D) + $(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin + @echo " BIN2C $<" + @$(MKDIR) -p $(@D) + $(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c + +$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit + @echo " GRIT $<" + @$(MKDIR) -p $(@D) + $(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$* + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c + $(V)touch $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.h + +# All assets must be built before the source code +# ----------------------------------------------- + +$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS) + +# Include dependency files if they exist +# -------------------------------------- + +-include $(DEPS) diff --git a/Makefile.blocksds b/Makefile.blocksds deleted file mode 100644 index b6339b2..0000000 --- a/Makefile.blocksds +++ /dev/null @@ -1,204 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023 - -BLOCKSDS ?= /opt/blocksds/core -BLOCKSDSEXT ?= /opt/blocksds/external - -WONDERFUL_TOOLCHAIN ?= /opt/wonderful -ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/ - -# Source code paths -# ----------------- - -SOURCEDIRS := source -INCLUDEDIRS := include source/libdsf -GFXDIRS := -BINDIRS := - -# Defines passed to all files -# --------------------------- - -ifeq ($(NE_DEBUG),1) -DEFINES := -DNE_DEBUG -DNE_BLOCKSDS -else -DEFINES := -DNE_BLOCKSDS -endif - -# Libraries -# --------- - -LIBDIRS := $(BLOCKSDS)/libs/libnds - -# Build artifacts -# --------------- - -ifeq ($(NE_DEBUG),1) - NAME := NE_debug - BUILDDIR := build_debug -else - NAME := NE - BUILDDIR := build_release -endif -INSTALLNAME := nitro-engine -ARCHIVE := lib/lib$(NAME).a - -# Tools -# ----- - -PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi- -CC := $(PREFIX)gcc -CXX := $(PREFIX)g++ -AR := ar -MKDIR := mkdir -RM := rm -rf -CP := cp -INSTALL := install - -# Verbose flag -# ------------ - -ifeq ($(VERBOSE),1) -V := -else -V := @ -endif - -# Source files -# ------------ - -ifneq ($(BINDIRS),) - SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin") - INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS)) -endif -ifneq ($(GFXDIRS),) - SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png") - INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS)) -endif - -SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s") -SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c") -SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp") - -# Compiler and linker flags -# ------------------------- - -DEFINES += -D__NDS__ -DARM9 - -ARCH := -march=armv5te -mtune=arm946e-s - -WARNFLAGS := -Wall -Wno-address-of-packed-member - -INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \ - $(foreach path,$(LIBDIRS),-I$(path)/include) - -ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) \ - -ffunction-sections -fdata-sections - -CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ - -ffunction-sections -fdata-sections \ - -fomit-frame-pointer - -CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ - -ffunction-sections -fdata-sections \ - -fno-exceptions -fno-rtti \ - -fomit-frame-pointer - -# Intermediate build files -# ------------------------ - -OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) - -HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ - $(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) - -OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP))) - -OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES) - -DEPS := $(OBJS:.o=.d) - -# Targets -# ------- - -.PHONY: all clean install - -all: $(ARCHIVE) - -$(ARCHIVE): $(OBJS) - @echo " AR $@" - @$(MKDIR) -p $(@D) - $(V)$(AR) rcs $@ $(OBJS) - -install: all - @echo " INSTALL $(BLOCKSDSEXT)/$(INSTALLNAME)/" - $(V)$(RM) $(BLOCKSDSEXT)/$(INSTALLNAME)/ - $(V)$(INSTALL) -d $(BLOCKSDSEXT)/$(INSTALLNAME)/ \ - $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/img2ds \ - $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/md5_to_dsma \ - $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/obj2dl - $(V)$(CP) -r include lib $(BLOCKSDSEXT)/$(INSTALLNAME)/ - $(V)$(CP) -r tools/img2ds/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/img2ds - $(V)$(CP) -r tools/md5_to_dsma/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/md5_to_dsma - $(V)$(CP) -r tools/obj2dl/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/obj2dl - -clean: - @echo " CLEAN" - $(V)$(RM) $(ARCHIVE) build_debug build_release - -# Rules -# ----- - -$(BUILDDIR)/%.s.o : %.s - @echo " AS $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.c.o : %.c - @echo " CC $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.arm.c.o : %.arm.c - @echo " CC $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< - -$(BUILDDIR)/%.cpp.o : %.cpp - @echo " CXX $<" - @$(MKDIR) -p $(@D) - $(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp - @echo " CXX $<" - @$(MKDIR) -p $(@D) - $(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< - -$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin - @echo " BIN2C $<" - @$(MKDIR) -p $(@D) - $(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c - -$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit - @echo " GRIT $<" - @$(MKDIR) -p $(@D) - $(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$* - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c - $(V)touch $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.h - -# All assets must be built before the source code -# ----------------------------------------------- - -$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS) - -# Include dependency files if they exist -# -------------------------------------- - --include $(DEPS) diff --git a/Makefile.dkp b/Makefile.dkp new file mode 100644 index 0000000..d954dd0 --- /dev/null +++ b/Makefile.dkp @@ -0,0 +1,139 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +#--------------------------------------------------------------------------------- +SOURCES := source source/dsma source/libdsf +DATA := data +INCLUDES := include source/libdsf + +ifeq ($(NE_DEBUG),1) + TARGET := NE_debug + BUILD := build_debug +else + TARGET := NE + BUILD := build_release +endif + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -mthumb -mthumb-interwork + +CFLAGS := -g -Wall -O2\ + -march=armv5te -mtune=arm946e-s \ + -fomit-frame-pointer -ffast-math \ + $(ARCH) -Wno-address-of-packed-member + +ifeq ($(NE_DEBUG),1) + CFLAGS += -DNE_DEBUG +endif + +CFLAGS += $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions + +ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(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))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# 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)) \ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +.PHONY: $(BUILD) clean all + +#--------------------------------------------------------------------------------- +all: $(BUILD) + +lib: + @[ -d $@ ] || mkdir -p $@ + +$(BUILD): lib + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr build_debug build_release lib + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT) : $(OFILES) + +#--------------------------------------------------------------------------------- +%.bin.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/2d_system/Makefile b/examples/2d_system/Makefile index 6c369fd..4cafacf 100644 --- a/examples/2d_system/Makefile +++ b/examples/2d_system/Makefile @@ -1,5 +1,25 @@ -SUBDIRS:= `ls` +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 + +.PHONY: all clean + +MAKE := make + all: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; + clean: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) clean --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; diff --git a/examples/2d_system/Makefile.blocksds b/examples/2d_system/Makefile.blocksds deleted file mode 100644 index 766b751..0000000 --- a/examples/2d_system/Makefile.blocksds +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023 - -.PHONY: all clean - -MAKE := make - -all: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; - -clean: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; diff --git a/examples/2d_system/gui/Makefile b/examples/2d_system/gui/Makefile index 6a54f39..94c5ed0 100644 --- a/examples/2d_system/gui/Makefile +++ b/examples/2d_system/gui/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/2d_system/gui/Makefile.blocksds b/examples/2d_system/gui/Makefile.blocksds deleted file mode 100644 index 4726605..0000000 --- a/examples/2d_system/gui/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/2d_system/gui/Makefile.dkp b/examples/2d_system/gui/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/2d_system/gui/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/2d_system/quad_texture_sizes/Makefile b/examples/2d_system/quad_texture_sizes/Makefile index 6a54f39..94c5ed0 100644 --- a/examples/2d_system/quad_texture_sizes/Makefile +++ b/examples/2d_system/quad_texture_sizes/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/2d_system/quad_texture_sizes/Makefile.blocksds b/examples/2d_system/quad_texture_sizes/Makefile.blocksds deleted file mode 100644 index 4726605..0000000 --- a/examples/2d_system/quad_texture_sizes/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/2d_system/quad_texture_sizes/Makefile.dkp b/examples/2d_system/quad_texture_sizes/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/2d_system/quad_texture_sizes/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/2d_system/quads/Makefile b/examples/2d_system/quads/Makefile index 133ddc5..91b554d 100644 --- a/examples/2d_system/quads/Makefile +++ b/examples/2d_system/quads/Makefile @@ -1,220 +1,4 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/2d_system/quads/Makefile.blocksds b/examples/2d_system/quads/Makefile.blocksds deleted file mode 100644 index 32a0b8d..0000000 --- a/examples/2d_system/quads/Makefile.blocksds +++ /dev/null @@ -1,4 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -include ../../Makefile.example.blocksds diff --git a/examples/2d_system/quads/Makefile.dkp b/examples/2d_system/quads/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/2d_system/quads/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/2d_system/sprites/Makefile b/examples/2d_system/sprites/Makefile index 6a54f39..461477c 100644 --- a/examples/2d_system/sprites/Makefile +++ b/examples/2d_system/sprites/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/2d_system/sprites/Makefile.blocksds b/examples/2d_system/sprites/Makefile.blocksds deleted file mode 100644 index 1c2569f..0000000 --- a/examples/2d_system/sprites/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/2d_system/sprites/Makefile.dkp b/examples/2d_system/sprites/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/2d_system/sprites/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/Makefile b/examples/Makefile index 2f98c1b..d7e420c 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,20 +1,28 @@ -SUBDIRS:= $(shell ls) +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 -#------------------------------------------------------------------------------- -all: examples -#------------------------------------------------------------------------------- - @rm -fr build-all +.PHONY: all clean + +MAKE := make + +all: + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; @mkdir -p build-all @find . -name "*.nds" -not -path build-all -exec cp -fv {} build-all \; -# TODO: The previous target tries to copy the files from build-all into -# themselves. Exclude them correctly. - -examples: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; - -#------------------------------------------------------------------------------- clean: -#------------------------------------------------------------------------------- + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) clean --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; @rm -fr build-all - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; diff --git a/examples/Makefile.blocksds b/examples/Makefile.blocksds deleted file mode 100644 index 2265382..0000000 --- a/examples/Makefile.blocksds +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023 - -.PHONY: all clean - -MAKE := make - -all: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - $(MAKE) -C $$i -f Makefile.blocksds --no-print-directory || { exit 1;} \ - fi; \ - done; - @rm -fr build-all - @mkdir -p build-all - @find . -name "*.nds" -not -path build-all -exec cp -fv {} build-all \; - -clean: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - $(MAKE) -C $$i -f Makefile.blocksds clean --no-print-directory || { exit 1;} \ - fi; \ - done; - @rm -fr build-all diff --git a/examples/Makefile.example.blocksds b/examples/Makefile.example similarity index 99% rename from examples/Makefile.example.blocksds rename to examples/Makefile.example index bb4e378..10111f6 100644 --- a/examples/Makefile.example.blocksds +++ b/examples/Makefile.example @@ -259,6 +259,7 @@ $(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit @$(MKDIR) -p $(@D) $(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$* $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c + $(V)touch $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.h ifneq ($(SOURCES_AUDIO),) diff --git a/examples/effects/Makefile b/examples/effects/Makefile index 6c369fd..4cafacf 100644 --- a/examples/effects/Makefile +++ b/examples/effects/Makefile @@ -1,5 +1,25 @@ -SUBDIRS:= `ls` +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 + +.PHONY: all clean + +MAKE := make + all: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; + clean: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) clean --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; diff --git a/examples/effects/Makefile.blocksds b/examples/effects/Makefile.blocksds deleted file mode 100644 index 766b751..0000000 --- a/examples/effects/Makefile.blocksds +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023 - -.PHONY: all clean - -MAKE := make - -all: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; - -clean: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; diff --git a/examples/effects/fog/Makefile b/examples/effects/fog/Makefile index 6006f41..25146a3 100644 --- a/examples/effects/fog/Makefile +++ b/examples/effects/fog/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/effects/fog/Makefile.blocksds b/examples/effects/fog/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/effects/fog/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/effects/fog/Makefile.dkp b/examples/effects/fog/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/effects/fog/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/effects/screen_effects/Makefile b/examples/effects/screen_effects/Makefile index 133ddc5..108ae50 100644 --- a/examples/effects/screen_effects/Makefile +++ b/examples/effects/screen_effects/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/effects/screen_effects/Makefile.blocksds b/examples/effects/screen_effects/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/effects/screen_effects/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/effects/screen_effects/Makefile.dkp b/examples/effects/screen_effects/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/effects/screen_effects/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/effects/screen_effects_dual_3d_dma/Makefile b/examples/effects/screen_effects_dual_3d_dma/Makefile index 133ddc5..108ae50 100644 --- a/examples/effects/screen_effects_dual_3d_dma/Makefile +++ b/examples/effects/screen_effects_dual_3d_dma/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/effects/screen_effects_dual_3d_dma/Makefile.blocksds b/examples/effects/screen_effects_dual_3d_dma/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/effects/screen_effects_dual_3d_dma/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/effects/screen_effects_dual_3d_dma/Makefile.dkp b/examples/effects/screen_effects_dual_3d_dma/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/effects/screen_effects_dual_3d_dma/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/effects/shading_alpha_outlining/Makefile b/examples/effects/shading_alpha_outlining/Makefile index 6006f41..25146a3 100644 --- a/examples/effects/shading_alpha_outlining/Makefile +++ b/examples/effects/shading_alpha_outlining/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/effects/shading_alpha_outlining/Makefile.blocksds b/examples/effects/shading_alpha_outlining/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/effects/shading_alpha_outlining/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/effects/shading_alpha_outlining/Makefile.dkp b/examples/effects/shading_alpha_outlining/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/effects/shading_alpha_outlining/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/effects/specular_material/Makefile b/examples/effects/specular_material/Makefile index 6006f41..25146a3 100644 --- a/examples/effects/specular_material/Makefile +++ b/examples/effects/specular_material/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/effects/specular_material/Makefile.blocksds b/examples/effects/specular_material/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/effects/specular_material/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/effects/specular_material/Makefile.dkp b/examples/effects/specular_material/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/effects/specular_material/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/effects/volumetric_shadow/Makefile b/examples/effects/volumetric_shadow/Makefile index 6006f41..25146a3 100644 --- a/examples/effects/volumetric_shadow/Makefile +++ b/examples/effects/volumetric_shadow/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/effects/volumetric_shadow/Makefile.blocksds b/examples/effects/volumetric_shadow/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/effects/volumetric_shadow/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/effects/volumetric_shadow/Makefile.dkp b/examples/effects/volumetric_shadow/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/effects/volumetric_shadow/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/Makefile b/examples/loading/Makefile index 6c369fd..4cafacf 100644 --- a/examples/loading/Makefile +++ b/examples/loading/Makefile @@ -1,5 +1,25 @@ -SUBDIRS:= `ls` +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 + +.PHONY: all clean + +MAKE := make + all: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; + clean: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) clean --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; diff --git a/examples/loading/Makefile.blocksds b/examples/loading/Makefile.blocksds deleted file mode 100644 index 766b751..0000000 --- a/examples/loading/Makefile.blocksds +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023 - -.PHONY: all clean - -MAKE := make - -all: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; - -clean: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; diff --git a/examples/loading/animated_model/Makefile b/examples/loading/animated_model/Makefile index 6006f41..25146a3 100644 --- a/examples/loading/animated_model/Makefile +++ b/examples/loading/animated_model/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/animated_model/Makefile.blocksds b/examples/loading/animated_model/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/loading/animated_model/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/loading/animated_model/Makefile.dkp b/examples/loading/animated_model/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/animated_model/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/clone_models/Makefile b/examples/loading/clone_models/Makefile index 133ddc5..108ae50 100644 --- a/examples/loading/clone_models/Makefile +++ b/examples/loading/clone_models/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/clone_models/Makefile.blocksds b/examples/loading/clone_models/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/loading/clone_models/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/loading/clone_models/Makefile.dkp b/examples/loading/clone_models/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/clone_models/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/compressed_texture/Makefile b/examples/loading/compressed_texture/Makefile index 133ddc5..108ae50 100644 --- a/examples/loading/compressed_texture/Makefile +++ b/examples/loading/compressed_texture/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/compressed_texture/Makefile.blocksds b/examples/loading/compressed_texture/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/loading/compressed_texture/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/loading/compressed_texture/Makefile.dkp b/examples/loading/compressed_texture/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/compressed_texture/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/filesystem_animated_model/Makefile b/examples/loading/filesystem_animated_model/Makefile index 1f06ed9..e99b7b1 100644 --- a/examples/loading/filesystem_animated_model/Makefile +++ b/examples/loading/filesystem_animated_model/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +NITROFSDIR := nitrofiles -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := -AUDIO := -ICON := - -# specify a directory which contains the nitro filesystem -# this is relative to the Makefile -NITRO := nitrofiles - -# These set the information text in the nds file -GAME_TITLE := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/filesystem_animated_model/Makefile.dkp b/examples/loading/filesystem_animated_model/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/filesystem_animated_model/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/filesystem_multiple_textures/Makefile b/examples/loading/filesystem_multiple_textures/Makefile index 1f06ed9..e99b7b1 100644 --- a/examples/loading/filesystem_multiple_textures/Makefile +++ b/examples/loading/filesystem_multiple_textures/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +NITROFSDIR := nitrofiles -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := -AUDIO := -ICON := - -# specify a directory which contains the nitro filesystem -# this is relative to the Makefile -NITRO := nitrofiles - -# These set the information text in the nds file -GAME_TITLE := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/filesystem_multiple_textures/Makefile.blocksds b/examples/loading/filesystem_multiple_textures/Makefile.blocksds deleted file mode 100644 index 1221ba5..0000000 --- a/examples/loading/filesystem_multiple_textures/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -NITROFSDIR := nitrofiles - -include ../../Makefile.example.blocksds diff --git a/examples/loading/filesystem_multiple_textures/Makefile.dkp b/examples/loading/filesystem_multiple_textures/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/filesystem_multiple_textures/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/filesystem_simple_model/Makefile b/examples/loading/filesystem_simple_model/Makefile index 9fb7bb8..e99b7b1 100644 --- a/examples/loading/filesystem_simple_model/Makefile +++ b/examples/loading/filesystem_simple_model/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +NITROFSDIR := nitrofiles -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := -AUDIO := -ICON := - -# specify a directory which contains the nitro filesystem -# this is relative to the Makefile -NITRO := nitrofiles - -# These set the information text in the nds file -GAME_TITLE := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/filesystem_simple_model/Makefile.blocksds b/examples/loading/filesystem_simple_model/Makefile.blocksds deleted file mode 100644 index 3996658..0000000 --- a/examples/loading/filesystem_simple_model/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -NITROFSDIR := nitrofiles - -include ../../Makefile.example.blocksds diff --git a/examples/loading/filesystem_simple_model/Makefile.dkp b/examples/loading/filesystem_simple_model/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/filesystem_simple_model/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/filesystem_animated_model/Makefile.blocksds b/examples/loading/filesystem_textures_grf/Makefile similarity index 81% rename from examples/loading/filesystem_animated_model/Makefile.blocksds rename to examples/loading/filesystem_textures_grf/Makefile index 1221ba5..e99b7b1 100644 --- a/examples/loading/filesystem_animated_model/Makefile.blocksds +++ b/examples/loading/filesystem_textures_grf/Makefile @@ -3,4 +3,4 @@ NITROFSDIR := nitrofiles -include ../../Makefile.example.blocksds +include ../../Makefile.example diff --git a/examples/loading/filesystem_textures_grf/Makefile.blocksds b/examples/loading/filesystem_textures_grf/Makefile.blocksds deleted file mode 100644 index 1221ba5..0000000 --- a/examples/loading/filesystem_textures_grf/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -NITROFSDIR := nitrofiles - -include ../../Makefile.example.blocksds diff --git a/examples/loading/incomplete_texture/Makefile b/examples/loading/incomplete_texture/Makefile index 6a54f39..94c5ed0 100644 --- a/examples/loading/incomplete_texture/Makefile +++ b/examples/loading/incomplete_texture/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/incomplete_texture/Makefile.blocksds b/examples/loading/incomplete_texture/Makefile.blocksds deleted file mode 100644 index 4726605..0000000 --- a/examples/loading/incomplete_texture/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/loading/incomplete_texture/Makefile.dkp b/examples/loading/incomplete_texture/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/incomplete_texture/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/model_with_vertex_color/Makefile b/examples/loading/model_with_vertex_color/Makefile index 6006f41..25146a3 100644 --- a/examples/loading/model_with_vertex_color/Makefile +++ b/examples/loading/model_with_vertex_color/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/model_with_vertex_color/Makefile.blocksds b/examples/loading/model_with_vertex_color/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/loading/model_with_vertex_color/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/loading/model_with_vertex_color/Makefile.dkp b/examples/loading/model_with_vertex_color/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/model_with_vertex_color/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/multiple_models/Makefile b/examples/loading/multiple_models/Makefile index 133ddc5..108ae50 100644 --- a/examples/loading/multiple_models/Makefile +++ b/examples/loading/multiple_models/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/multiple_models/Makefile.blocksds b/examples/loading/multiple_models/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/loading/multiple_models/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/loading/multiple_models/Makefile.dkp b/examples/loading/multiple_models/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/multiple_models/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/paletted_texture/Makefile b/examples/loading/paletted_texture/Makefile index 6a54f39..94c5ed0 100644 --- a/examples/loading/paletted_texture/Makefile +++ b/examples/loading/paletted_texture/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/paletted_texture/Makefile.blocksds b/examples/loading/paletted_texture/Makefile.blocksds deleted file mode 100644 index 4726605..0000000 --- a/examples/loading/paletted_texture/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/loading/paletted_texture/Makefile.dkp b/examples/loading/paletted_texture/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/paletted_texture/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/loading/simple_model/Makefile b/examples/loading/simple_model/Makefile index 6006f41..25146a3 100644 --- a/examples/loading/simple_model/Makefile +++ b/examples/loading/simple_model/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/loading/simple_model/Makefile.blocksds b/examples/loading/simple_model/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/loading/simple_model/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/loading/simple_model/Makefile.dkp b/examples/loading/simple_model/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/loading/simple_model/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/Makefile b/examples/other/Makefile index 6c369fd..4cafacf 100644 --- a/examples/other/Makefile +++ b/examples/other/Makefile @@ -1,5 +1,25 @@ -SUBDIRS:= `ls` +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 + +.PHONY: all clean + +MAKE := make + all: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; + clean: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) clean --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; diff --git a/examples/other/Makefile.blocksds b/examples/other/Makefile.blocksds deleted file mode 100644 index 766b751..0000000 --- a/examples/other/Makefile.blocksds +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023 - -.PHONY: all clean - -MAKE := make - -all: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; - -clean: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; diff --git a/examples/other/blended_animations/Makefile b/examples/other/blended_animations/Makefile index 6006f41..25146a3 100644 --- a/examples/other/blended_animations/Makefile +++ b/examples/other/blended_animations/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/blended_animations/Makefile.blocksds b/examples/other/blended_animations/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/other/blended_animations/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/other/blended_animations/Makefile.dkp b/examples/other/blended_animations/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/blended_animations/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/clear_bmp/Makefile b/examples/other/clear_bmp/Makefile index 6006f41..25146a3 100644 --- a/examples/other/clear_bmp/Makefile +++ b/examples/other/clear_bmp/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/clear_bmp/Makefile.blocksds b/examples/other/clear_bmp/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/other/clear_bmp/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/other/clear_bmp/Makefile.dkp b/examples/other/clear_bmp/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/clear_bmp/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/dual_3d_dma_low_framerate/Makefile b/examples/other/dual_3d_dma_low_framerate/Makefile index 133ddc5..108ae50 100644 --- a/examples/other/dual_3d_dma_low_framerate/Makefile +++ b/examples/other/dual_3d_dma_low_framerate/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/dual_3d_dma_low_framerate/Makefile.blocksds b/examples/other/dual_3d_dma_low_framerate/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/other/dual_3d_dma_low_framerate/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/other/dual_3d_dma_low_framerate/Makefile.dkp b/examples/other/dual_3d_dma_low_framerate/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/dual_3d_dma_low_framerate/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/dual_3d_modes/Makefile b/examples/other/dual_3d_modes/Makefile index 133ddc5..108ae50 100644 --- a/examples/other/dual_3d_modes/Makefile +++ b/examples/other/dual_3d_modes/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/dual_3d_modes/Makefile.blocksds b/examples/other/dual_3d_modes/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/other/dual_3d_modes/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/other/dual_3d_modes/Makefile.dkp b/examples/other/dual_3d_modes/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/dual_3d_modes/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/dual_3d_modes_args/Makefile b/examples/other/dual_3d_modes_args/Makefile index 133ddc5..108ae50 100644 --- a/examples/other/dual_3d_modes_args/Makefile +++ b/examples/other/dual_3d_modes_args/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/dual_3d_modes_args/Makefile.blocksds b/examples/other/dual_3d_modes_args/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/other/dual_3d_modes_args/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/other/dual_3d_modes_args/Makefile.dkp b/examples/other/dual_3d_modes_args/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/dual_3d_modes_args/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/error_handling/Makefile b/examples/other/error_handling/Makefile index 626fbca..3a732dc 100644 --- a/examples/other/error_handling/Makefile +++ b/examples/other/error_handling/Makefile @@ -1,225 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +DEFINES := -DNE_DEBUG +LIBS := -lNE_debug -lnds9 -lc -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 - -# Enable debug mode of Nitro Engine -CFLAGS += -DNE_DEBUG - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -# Use debug version of Nitro Engine -LIBS := -lNE_debug -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/error_handling/Makefile.blocksds b/examples/other/error_handling/Makefile.blocksds deleted file mode 100644 index 6ea2714..0000000 --- a/examples/other/error_handling/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -DEFINES := -DNE_DEBUG -LIBS := -lNE_debug -lnds9 -lc - -include ../../Makefile.example.blocksds diff --git a/examples/other/error_handling/Makefile.dkp b/examples/other/error_handling/Makefile.dkp new file mode 100644 index 0000000..de89d8c --- /dev/null +++ b/examples/other/error_handling/Makefile.dkp @@ -0,0 +1,225 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 + +# Enable debug mode of Nitro Engine +CFLAGS += -DNE_DEBUG + +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +# Use debug version of Nitro Engine +LIBS := -lNE_debug -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/fps_counter/Makefile b/examples/other/fps_counter/Makefile index 6006f41..25146a3 100644 --- a/examples/other/fps_counter/Makefile +++ b/examples/other/fps_counter/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/fps_counter/Makefile.blocksds b/examples/other/fps_counter/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/other/fps_counter/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/other/fps_counter/Makefile.dkp b/examples/other/fps_counter/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/fps_counter/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/free_camera/Makefile b/examples/other/free_camera/Makefile index 6006f41..25146a3 100644 --- a/examples/other/free_camera/Makefile +++ b/examples/other/free_camera/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/free_camera/Makefile.blocksds b/examples/other/free_camera/Makefile.blocksds deleted file mode 100644 index b5f7196..0000000 --- a/examples/other/free_camera/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/other/free_camera/Makefile.dkp b/examples/other/free_camera/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/free_camera/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/polygon_colored/Makefile b/examples/other/polygon_colored/Makefile index 133ddc5..91b554d 100644 --- a/examples/other/polygon_colored/Makefile +++ b/examples/other/polygon_colored/Makefile @@ -1,220 +1,4 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/polygon_colored/Makefile.blocksds b/examples/other/polygon_colored/Makefile.blocksds deleted file mode 100644 index 32a0b8d..0000000 --- a/examples/other/polygon_colored/Makefile.blocksds +++ /dev/null @@ -1,4 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -include ../../Makefile.example.blocksds diff --git a/examples/other/polygon_colored/Makefile.dkp b/examples/other/polygon_colored/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/polygon_colored/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/polygon_textured/Makefile b/examples/other/polygon_textured/Makefile index 6006f41..461477c 100644 --- a/examples/other/polygon_textured/Makefile +++ b/examples/other/polygon_textured/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/polygon_textured/Makefile.blocksds b/examples/other/polygon_textured/Makefile.blocksds deleted file mode 100644 index 1c2569f..0000000 --- a/examples/other/polygon_textured/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/other/polygon_textured/Makefile.dkp b/examples/other/polygon_textured/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/polygon_textured/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/stylus_texture_drawing_rgb256/Makefile b/examples/other/stylus_texture_drawing_rgb256/Makefile index 6006f41..461477c 100644 --- a/examples/other/stylus_texture_drawing_rgb256/Makefile +++ b/examples/other/stylus_texture_drawing_rgb256/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/stylus_texture_drawing_rgb256/Makefile.blocksds b/examples/other/stylus_texture_drawing_rgb256/Makefile.blocksds deleted file mode 100644 index 1c2569f..0000000 --- a/examples/other/stylus_texture_drawing_rgb256/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/other/stylus_texture_drawing_rgb256/Makefile.dkp b/examples/other/stylus_texture_drawing_rgb256/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/stylus_texture_drawing_rgb256/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/stylus_texture_drawing_rgba/Makefile b/examples/other/stylus_texture_drawing_rgba/Makefile index 6006f41..461477c 100644 --- a/examples/other/stylus_texture_drawing_rgba/Makefile +++ b/examples/other/stylus_texture_drawing_rgba/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/stylus_texture_drawing_rgba/Makefile.blocksds b/examples/other/stylus_texture_drawing_rgba/Makefile.blocksds deleted file mode 100644 index 1c2569f..0000000 --- a/examples/other/stylus_texture_drawing_rgba/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/other/stylus_texture_drawing_rgba/Makefile.dkp b/examples/other/stylus_texture_drawing_rgba/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/stylus_texture_drawing_rgba/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/swap_3d_dual_screen/Makefile b/examples/other/swap_3d_dual_screen/Makefile index 6a54f39..94c5ed0 100644 --- a/examples/other/swap_3d_dual_screen/Makefile +++ b/examples/other/swap_3d_dual_screen/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/swap_3d_dual_screen/Makefile.blocksds b/examples/other/swap_3d_dual_screen/Makefile.blocksds deleted file mode 100644 index 4726605..0000000 --- a/examples/other/swap_3d_dual_screen/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/other/swap_3d_dual_screen/Makefile.dkp b/examples/other/swap_3d_dual_screen/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/swap_3d_dual_screen/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/swap_3d_single_screen/Makefile b/examples/other/swap_3d_single_screen/Makefile index 6a54f39..94c5ed0 100644 --- a/examples/other/swap_3d_single_screen/Makefile +++ b/examples/other/swap_3d_single_screen/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/swap_3d_single_screen/Makefile.blocksds b/examples/other/swap_3d_single_screen/Makefile.blocksds deleted file mode 100644 index 4726605..0000000 --- a/examples/other/swap_3d_single_screen/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/other/swap_3d_single_screen/Makefile.dkp b/examples/other/swap_3d_single_screen/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/swap_3d_single_screen/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/other/touch_test/Makefile b/examples/other/touch_test/Makefile index 133ddc5..108ae50 100644 --- a/examples/other/touch_test/Makefile +++ b/examples/other/touch_test/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/other/touch_test/Makefile.blocksds b/examples/other/touch_test/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/other/touch_test/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/other/touch_test/Makefile.dkp b/examples/other/touch_test/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/other/touch_test/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/physics/Makefile b/examples/physics/Makefile index 6c369fd..4cafacf 100644 --- a/examples/physics/Makefile +++ b/examples/physics/Makefile @@ -1,5 +1,25 @@ -SUBDIRS:= `ls` +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 + +.PHONY: all clean + +MAKE := make + all: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; + clean: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) clean --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; diff --git a/examples/physics/Makefile.blocksds b/examples/physics/Makefile.blocksds deleted file mode 100644 index 766b751..0000000 --- a/examples/physics/Makefile.blocksds +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023 - -.PHONY: all clean - -MAKE := make - -all: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; - -clean: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; diff --git a/examples/physics/basic/Makefile b/examples/physics/basic/Makefile index 133ddc5..108ae50 100644 --- a/examples/physics/basic/Makefile +++ b/examples/physics/basic/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/physics/basic/Makefile.blocksds b/examples/physics/basic/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/physics/basic/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/physics/basic/Makefile.dkp b/examples/physics/basic/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/physics/basic/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/physics/box_tower/Makefile b/examples/physics/box_tower/Makefile index 133ddc5..108ae50 100644 --- a/examples/physics/box_tower/Makefile +++ b/examples/physics/box_tower/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/physics/box_tower/Makefile.blocksds b/examples/physics/box_tower/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/physics/box_tower/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/physics/box_tower/Makefile.dkp b/examples/physics/box_tower/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/physics/box_tower/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/physics/collision_actions/Makefile b/examples/physics/collision_actions/Makefile index 133ddc5..108ae50 100644 --- a/examples/physics/collision_actions/Makefile +++ b/examples/physics/collision_actions/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/physics/collision_actions/Makefile.blocksds b/examples/physics/collision_actions/Makefile.blocksds deleted file mode 100644 index c6e3cbb..0000000 --- a/examples/physics/collision_actions/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/physics/collision_actions/Makefile.dkp b/examples/physics/collision_actions/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/physics/collision_actions/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/templates/3d_dual_screen/Makefile b/examples/templates/3d_dual_screen/Makefile index 133ddc5..977bb77 100644 --- a/examples/templates/3d_dual_screen/Makefile +++ b/examples/templates/3d_dual_screen/Makefile @@ -1,220 +1,296 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BLOCKSDS ?= /opt/blocksds/core +BLOCKSDSEXT ?= /opt/blocksds/external -include $(DEVKITARM)/ds_rules +WONDERFUL_TOOLCHAIN ?= /opt/wonderful +ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/ -#--------------------------------------------------------------------------------- -# 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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := -AUDIO := -ICON := +# User config +# =========== -# specify a directory which contains the nitro filesystem -# this is relative to the Makefile -NITRO := +NAME := $(shell basename $(CURDIR)) +GAME_TITLE := 3D dual screen template +GAME_SUBTITLE := Nitro Engine example +GAME_AUTHOR := github.com/AntonioND/nitro-engine +GAME_ICON := $(BLOCKSDS)/sys/icon.bmp -# These set the information text in the nds file -GAME_TITLE := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine +# DLDI and internal SD slot of DSi +# -------------------------------- -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s +# Root folder of the SD image +SDROOT := sdroot +# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode +SDIMAGE := image.bin -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) +# Source code paths +# ----------------- -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -lnds9 +SOURCEDIRS := source +INCLUDEDIRS := +GFXDIRS := +BINDIRS := +AUDIODIRS := +NITROFSDIR := -# automatigically add libraries for NitroFS -ifneq ($(strip $(NITRO)),) -LIBS := -lfilesystem -lfat $(LIBS) -endif -# automagically add maxmod library -ifneq ($(strip $(AUDIO)),) -LIBS := -lmm9 $(LIBS) -endif +# Defines passed to all files +# --------------------------- -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine +DEFINES := -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- +# Libraries +# --------- -export OUTPUT := $(CURDIR)/$(TARGET) +LIBS := -lNE -lnds9 -lc +LIBDIRS := $(BLOCKSDSEXT)/nitro-engine \ + $(BLOCKSDS)/libs/libnds -export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\ - $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\ - $(foreach dir,$(DATA),$(CURDIR)/$(dir))\ - $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) +# Build artifacts +# --------------- -export DEPSDIR := $(CURDIR)/$(BUILD) +BUILDDIR := build +ELF := build/$(NAME).elf +DUMP := build/$(NAME).dump +MAP := build/$(NAME).map +ROM := $(NAME).nds -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) -#--------------------------------------------------------------------------------- +# If NITROFSDIR is set, the output of mmutil will be placed in that directory +SOUNDBANKINFODIR := $(BUILDDIR)/maxmod +ifeq ($(strip $(NITROFSDIR)),) + SOUNDBANKDIR := $(BUILDDIR)/maxmod else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- + SOUNDBANKDIR := $(NITROFSDIR) endif -#--------------------------------------------------------------------------------- -export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +# Tools +# ----- -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi- +CC := $(PREFIX)gcc +CXX := $(PREFIX)g++ +LD := $(PREFIX)gcc +OBJDUMP := $(PREFIX)objdump +MKDIR := mkdir +RM := rm -rf -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) +# Verbose flag +# ------------ -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) +ifeq ($(VERBOSE),1) +V := +else +V := @ +endif -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) +# Source files +# ------------ -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp +ifneq ($(BINDIRS),) + SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS)) +endif +ifneq ($(GFXDIRS),) + SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS)) +endif +ifneq ($(AUDIODIRS),) + SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)') + ifneq ($(SOURCES_AUDIO),) + INCLUDEDIRS += $(SOUNDBANKINFODIR) endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif endif -.PHONY: $(BUILD) clean +SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s") +SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c") +SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp") -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile +# Compiler and linker flags +# ------------------------- + +DEFINES += -D__NDS__ -DARM9 + +ARCH := -march=armv5te -mtune=arm946e-s + +WARNFLAGS := -Wall + +ifeq ($(SOURCES_CPP),) + LIBS += -lc +else + LIBS += -lstdc++ -lc +endif + +INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \ + $(foreach path,$(LIBDIRS),-I$(path)/include) + +LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib) + +ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) \ + -ffunction-sections -fdata-sections + +CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ + -ffunction-sections -fdata-sections \ + -fomit-frame-pointer + +CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ + -ffunction-sections -fdata-sections \ + -fno-exceptions -fno-rtti \ + -fomit-frame-pointer + +LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \ + -Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \ + -T$(BLOCKSDS)/sys/crts/ds_arm9.mem \ + -T$(BLOCKSDS)/sys/crts/ds_arm9.ld \ + -Wl,--no-warn-rwx-segments \ + -Wl,--start-group $(LIBS) -lgcc -Wl,--end-group + +# Intermediate build files +# ------------------------ + +OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) + +HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ + $(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) + +ifneq ($(SOURCES_AUDIO),) + ifeq ($(strip $(NITROFSDIR)),) + OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o + endif + HEADERS_ASSETS += $(SOUNDBANKINFODIR)/soundbank.h +endif + +OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP))) + +OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES) + +DEPS := $(OBJS:.o=.d) + +# Targets +# ------- + +.PHONY: all clean dump dldipatch sdimage + +all: $(ROM) + +ifneq ($(strip $(NITROFSDIR)),) +# Additional arguments for ndstool +NDSTOOL_ARGS := -d $(NITROFSDIR) + +# Make the NDS ROM depend on the filesystem only if it is needed +$(ROM): $(NITROFSDIR) +endif + +# Combine the title strings +ifeq ($(strip $(GAME_SUBTITLE)),) + GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR) +else + GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR) +endif + +$(ROM): $(ELF) + @echo " NDSTOOL $@" + $(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \ + -7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \ + -b $(GAME_ICON) "$(GAME_FULL_TITLE)" \ + $(NDSTOOL_ARGS) + +$(ELF): $(OBJS) + @echo " LD $@" + $(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS) + +$(DUMP): $(ELF) + @echo " OBJDUMP $@" + $(V)$(OBJDUMP) -h -C -S $< > $@ + +dump: $(DUMP) -#--------------------------------------------------------------------------------- clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + @echo " CLEAN" + $(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE) \ + $(SOUNDBANKDIR)/soundbank.bin -#--------------------------------------------------------------------------------- -else +sdimage: + @echo " MKFATIMG $(SDIMAGE) $(SDROOT)" + $(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) +dldipatch: $(ROM) + @echo " DLDIPATCH $(ROM)" + $(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch \ + $(BLOCKSDS)/sys/dldi_r4/r4tf.dldi $(ROM) -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) +# Rules +# ----- -# need to build soundbank first -$(OFILES): $(SOUNDBANK) +$(BUILDDIR)/%.s.o : %.s + @echo " AS $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h +$(BUILDDIR)/%.c.o : %.c + @echo " CC $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) +$(BUILDDIR)/%.arm.c.o : %.arm.c + @echo " CC $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< -#--------------------------------------------------------------------------------- -# 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$* +$(BUILDDIR)/%.cpp.o : %.cpp + @echo " CXX $<" + @$(MKDIR) -p $(@D) + $(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr +$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp + @echo " CXX $<" + @$(MKDIR) -p $(@D) + $(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< --include $(DEPSDIR)/*.d +$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin + @echo " BIN2C $<" + @$(MKDIR) -p $(@D) + $(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c -#--------------------------------------------------------------------------------------- +$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit + @echo " GRIT $<" + @$(MKDIR) -p $(@D) + $(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$* + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c + +ifneq ($(SOURCES_AUDIO),) + +$(SOUNDBANKINFODIR)/soundbank.h: $(SOURCES_AUDIO) + @echo " MMUTIL $^" + @$(MKDIR) -p $(@D) + @$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \ + -o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKINFODIR)/soundbank.h + +ifeq ($(strip $(NITROFSDIR)),) +$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKINFODIR)/soundbank.h + @echo " BIN2C soundbank.bin" + $(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \ + $(SOUNDBANKDIR) + @echo " CC.9 soundbank_bin.c" + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \ + $(SOUNDBANKDIR)/soundbank_bin.c endif -#--------------------------------------------------------------------------------------- + +endif + +# All assets must be built before the source code +# ----------------------------------------------- + +$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS) + +# Include dependency files if they exist +# -------------------------------------- + +-include $(DEPS) diff --git a/examples/templates/3d_dual_screen/Makefile.blocksds b/examples/templates/3d_dual_screen/Makefile.blocksds deleted file mode 100644 index 977bb77..0000000 --- a/examples/templates/3d_dual_screen/Makefile.blocksds +++ /dev/null @@ -1,296 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 - -BLOCKSDS ?= /opt/blocksds/core -BLOCKSDSEXT ?= /opt/blocksds/external - -WONDERFUL_TOOLCHAIN ?= /opt/wonderful -ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/ - -# User config -# =========== - -NAME := $(shell basename $(CURDIR)) -GAME_TITLE := 3D dual screen template -GAME_SUBTITLE := Nitro Engine example -GAME_AUTHOR := github.com/AntonioND/nitro-engine -GAME_ICON := $(BLOCKSDS)/sys/icon.bmp - -# DLDI and internal SD slot of DSi -# -------------------------------- - -# Root folder of the SD image -SDROOT := sdroot -# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode -SDIMAGE := image.bin - -# Source code paths -# ----------------- - -SOURCEDIRS := source -INCLUDEDIRS := -GFXDIRS := -BINDIRS := -AUDIODIRS := -NITROFSDIR := - -# Defines passed to all files -# --------------------------- - -DEFINES := - -# Libraries -# --------- - -LIBS := -lNE -lnds9 -lc -LIBDIRS := $(BLOCKSDSEXT)/nitro-engine \ - $(BLOCKSDS)/libs/libnds - -# Build artifacts -# --------------- - -BUILDDIR := build -ELF := build/$(NAME).elf -DUMP := build/$(NAME).dump -MAP := build/$(NAME).map -ROM := $(NAME).nds - -# If NITROFSDIR is set, the output of mmutil will be placed in that directory -SOUNDBANKINFODIR := $(BUILDDIR)/maxmod -ifeq ($(strip $(NITROFSDIR)),) - SOUNDBANKDIR := $(BUILDDIR)/maxmod -else - SOUNDBANKDIR := $(NITROFSDIR) -endif - -# Tools -# ----- - -PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi- -CC := $(PREFIX)gcc -CXX := $(PREFIX)g++ -LD := $(PREFIX)gcc -OBJDUMP := $(PREFIX)objdump -MKDIR := mkdir -RM := rm -rf - -# Verbose flag -# ------------ - -ifeq ($(VERBOSE),1) -V := -else -V := @ -endif - -# Source files -# ------------ - -ifneq ($(BINDIRS),) - SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin") - INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS)) -endif -ifneq ($(GFXDIRS),) - SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png") - INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS)) -endif -ifneq ($(AUDIODIRS),) - SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)') - ifneq ($(SOURCES_AUDIO),) - INCLUDEDIRS += $(SOUNDBANKINFODIR) - endif -endif - -SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s") -SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c") -SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp") - -# Compiler and linker flags -# ------------------------- - -DEFINES += -D__NDS__ -DARM9 - -ARCH := -march=armv5te -mtune=arm946e-s - -WARNFLAGS := -Wall - -ifeq ($(SOURCES_CPP),) - LIBS += -lc -else - LIBS += -lstdc++ -lc -endif - -INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \ - $(foreach path,$(LIBDIRS),-I$(path)/include) - -LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib) - -ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) \ - -ffunction-sections -fdata-sections - -CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ - -ffunction-sections -fdata-sections \ - -fomit-frame-pointer - -CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ - -ffunction-sections -fdata-sections \ - -fno-exceptions -fno-rtti \ - -fomit-frame-pointer - -LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \ - -Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \ - -T$(BLOCKSDS)/sys/crts/ds_arm9.mem \ - -T$(BLOCKSDS)/sys/crts/ds_arm9.ld \ - -Wl,--no-warn-rwx-segments \ - -Wl,--start-group $(LIBS) -lgcc -Wl,--end-group - -# Intermediate build files -# ------------------------ - -OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) - -HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ - $(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) - -ifneq ($(SOURCES_AUDIO),) - ifeq ($(strip $(NITROFSDIR)),) - OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o - endif - HEADERS_ASSETS += $(SOUNDBANKINFODIR)/soundbank.h -endif - -OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP))) - -OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES) - -DEPS := $(OBJS:.o=.d) - -# Targets -# ------- - -.PHONY: all clean dump dldipatch sdimage - -all: $(ROM) - -ifneq ($(strip $(NITROFSDIR)),) -# Additional arguments for ndstool -NDSTOOL_ARGS := -d $(NITROFSDIR) - -# Make the NDS ROM depend on the filesystem only if it is needed -$(ROM): $(NITROFSDIR) -endif - -# Combine the title strings -ifeq ($(strip $(GAME_SUBTITLE)),) - GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR) -else - GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR) -endif - -$(ROM): $(ELF) - @echo " NDSTOOL $@" - $(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \ - -7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \ - -b $(GAME_ICON) "$(GAME_FULL_TITLE)" \ - $(NDSTOOL_ARGS) - -$(ELF): $(OBJS) - @echo " LD $@" - $(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS) - -$(DUMP): $(ELF) - @echo " OBJDUMP $@" - $(V)$(OBJDUMP) -h -C -S $< > $@ - -dump: $(DUMP) - -clean: - @echo " CLEAN" - $(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE) \ - $(SOUNDBANKDIR)/soundbank.bin - -sdimage: - @echo " MKFATIMG $(SDIMAGE) $(SDROOT)" - $(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) - -dldipatch: $(ROM) - @echo " DLDIPATCH $(ROM)" - $(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch \ - $(BLOCKSDS)/sys/dldi_r4/r4tf.dldi $(ROM) - -# Rules -# ----- - -$(BUILDDIR)/%.s.o : %.s - @echo " AS $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.c.o : %.c - @echo " CC $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.arm.c.o : %.arm.c - @echo " CC $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< - -$(BUILDDIR)/%.cpp.o : %.cpp - @echo " CXX $<" - @$(MKDIR) -p $(@D) - $(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp - @echo " CXX $<" - @$(MKDIR) -p $(@D) - $(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< - -$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin - @echo " BIN2C $<" - @$(MKDIR) -p $(@D) - $(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c - -$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit - @echo " GRIT $<" - @$(MKDIR) -p $(@D) - $(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$* - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c - -ifneq ($(SOURCES_AUDIO),) - -$(SOUNDBANKINFODIR)/soundbank.h: $(SOURCES_AUDIO) - @echo " MMUTIL $^" - @$(MKDIR) -p $(@D) - @$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \ - -o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKINFODIR)/soundbank.h - -ifeq ($(strip $(NITROFSDIR)),) -$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKINFODIR)/soundbank.h - @echo " BIN2C soundbank.bin" - $(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \ - $(SOUNDBANKDIR) - @echo " CC.9 soundbank_bin.c" - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \ - $(SOUNDBANKDIR)/soundbank_bin.c -endif - -endif - -# All assets must be built before the source code -# ----------------------------------------------- - -$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS) - -# Include dependency files if they exist -# -------------------------------------- - --include $(DEPS) diff --git a/examples/templates/3d_dual_screen/Makefile.dkp b/examples/templates/3d_dual_screen/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/templates/3d_dual_screen/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/templates/3d_single_screen/Makefile b/examples/templates/3d_single_screen/Makefile index 133ddc5..33fc30a 100644 --- a/examples/templates/3d_single_screen/Makefile +++ b/examples/templates/3d_single_screen/Makefile @@ -1,220 +1,296 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BLOCKSDS ?= /opt/blocksds/core +BLOCKSDSEXT ?= /opt/blocksds/external -include $(DEVKITARM)/ds_rules +WONDERFUL_TOOLCHAIN ?= /opt/wonderful +ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/ -#--------------------------------------------------------------------------------- -# 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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := -AUDIO := -ICON := +# User config +# =========== -# specify a directory which contains the nitro filesystem -# this is relative to the Makefile -NITRO := +NAME := $(shell basename $(CURDIR)) +GAME_TITLE := 3D template +GAME_SUBTITLE := Nitro Engine example +GAME_AUTHOR := github.com/AntonioND/nitro-engine +GAME_ICON := $(BLOCKSDS)/sys/icon.bmp -# These set the information text in the nds file -GAME_TITLE := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine +# DLDI and internal SD slot of DSi +# -------------------------------- -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s +# Root folder of the SD image +SDROOT := sdroot +# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode +SDIMAGE := image.bin -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) +# Source code paths +# ----------------- -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -lnds9 +SOURCEDIRS := source +INCLUDEDIRS := +GFXDIRS := +BINDIRS := +AUDIODIRS := +NITROFSDIR := -# automatigically add libraries for NitroFS -ifneq ($(strip $(NITRO)),) -LIBS := -lfilesystem -lfat $(LIBS) -endif -# automagically add maxmod library -ifneq ($(strip $(AUDIO)),) -LIBS := -lmm9 $(LIBS) -endif +# Defines passed to all files +# --------------------------- -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine +DEFINES := -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- +# Libraries +# --------- -export OUTPUT := $(CURDIR)/$(TARGET) +LIBS := -lNE -lnds9 -lc +LIBDIRS := $(BLOCKSDSEXT)/nitro-engine \ + $(BLOCKSDS)/libs/libnds -export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\ - $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\ - $(foreach dir,$(DATA),$(CURDIR)/$(dir))\ - $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) +# Build artifacts +# --------------- -export DEPSDIR := $(CURDIR)/$(BUILD) +BUILDDIR := build +ELF := build/$(NAME).elf +DUMP := build/$(NAME).dump +MAP := build/$(NAME).map +ROM := $(NAME).nds -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) -#--------------------------------------------------------------------------------- +# If NITROFSDIR is set, the output of mmutil will be placed in that directory +SOUNDBANKINFODIR := $(BUILDDIR)/maxmod +ifeq ($(strip $(NITROFSDIR)),) + SOUNDBANKDIR := $(BUILDDIR)/maxmod else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- + SOUNDBANKDIR := $(NITROFSDIR) endif -#--------------------------------------------------------------------------------- -export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +# Tools +# ----- -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi- +CC := $(PREFIX)gcc +CXX := $(PREFIX)g++ +LD := $(PREFIX)gcc +OBJDUMP := $(PREFIX)objdump +MKDIR := mkdir +RM := rm -rf -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) +# Verbose flag +# ------------ -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) +ifeq ($(VERBOSE),1) +V := +else +V := @ +endif -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) +# Source files +# ------------ -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp +ifneq ($(BINDIRS),) + SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS)) +endif +ifneq ($(GFXDIRS),) + SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS)) +endif +ifneq ($(AUDIODIRS),) + SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)') + ifneq ($(SOURCES_AUDIO),) + INCLUDEDIRS += $(SOUNDBANKINFODIR) endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif endif -.PHONY: $(BUILD) clean +SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s") +SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c") +SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp") -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile +# Compiler and linker flags +# ------------------------- + +DEFINES += -D__NDS__ -DARM9 + +ARCH := -march=armv5te -mtune=arm946e-s + +WARNFLAGS := -Wall + +ifeq ($(SOURCES_CPP),) + LIBS += -lc +else + LIBS += -lstdc++ -lc +endif + +INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \ + $(foreach path,$(LIBDIRS),-I$(path)/include) + +LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib) + +ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) \ + -ffunction-sections -fdata-sections + +CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ + -ffunction-sections -fdata-sections \ + -fomit-frame-pointer + +CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ + -ffunction-sections -fdata-sections \ + -fno-exceptions -fno-rtti \ + -fomit-frame-pointer + +LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \ + -Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \ + -T$(BLOCKSDS)/sys/crts/ds_arm9.mem \ + -T$(BLOCKSDS)/sys/crts/ds_arm9.ld \ + -Wl,--no-warn-rwx-segments \ + -Wl,--start-group $(LIBS) -lgcc -Wl,--end-group + +# Intermediate build files +# ------------------------ + +OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) + +HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ + $(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) + +ifneq ($(SOURCES_AUDIO),) + ifeq ($(strip $(NITROFSDIR)),) + OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o + endif + HEADERS_ASSETS += $(SOUNDBANKINFODIR)/soundbank.h +endif + +OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP))) + +OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES) + +DEPS := $(OBJS:.o=.d) + +# Targets +# ------- + +.PHONY: all clean dump dldipatch sdimage + +all: $(ROM) + +ifneq ($(strip $(NITROFSDIR)),) +# Additional arguments for ndstool +NDSTOOL_ARGS := -d $(NITROFSDIR) + +# Make the NDS ROM depend on the filesystem only if it is needed +$(ROM): $(NITROFSDIR) +endif + +# Combine the title strings +ifeq ($(strip $(GAME_SUBTITLE)),) + GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR) +else + GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR) +endif + +$(ROM): $(ELF) + @echo " NDSTOOL $@" + $(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \ + -7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \ + -b $(GAME_ICON) "$(GAME_FULL_TITLE)" \ + $(NDSTOOL_ARGS) + +$(ELF): $(OBJS) + @echo " LD $@" + $(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS) + +$(DUMP): $(ELF) + @echo " OBJDUMP $@" + $(V)$(OBJDUMP) -h -C -S $< > $@ + +dump: $(DUMP) -#--------------------------------------------------------------------------------- clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + @echo " CLEAN" + $(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE) \ + $(SOUNDBANKDIR)/soundbank.bin -#--------------------------------------------------------------------------------- -else +sdimage: + @echo " MKFATIMG $(SDIMAGE) $(SDROOT)" + $(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) +dldipatch: $(ROM) + @echo " DLDIPATCH $(ROM)" + $(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch \ + $(BLOCKSDS)/sys/dldi_r4/r4tf.dldi $(ROM) -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) +# Rules +# ----- -# need to build soundbank first -$(OFILES): $(SOUNDBANK) +$(BUILDDIR)/%.s.o : %.s + @echo " AS $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h +$(BUILDDIR)/%.c.o : %.c + @echo " CC $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) +$(BUILDDIR)/%.arm.c.o : %.arm.c + @echo " CC $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< -#--------------------------------------------------------------------------------- -# 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$* +$(BUILDDIR)/%.cpp.o : %.cpp + @echo " CXX $<" + @$(MKDIR) -p $(@D) + $(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr +$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp + @echo " CXX $<" + @$(MKDIR) -p $(@D) + $(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< --include $(DEPSDIR)/*.d +$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin + @echo " BIN2C $<" + @$(MKDIR) -p $(@D) + $(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c -#--------------------------------------------------------------------------------------- +$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit + @echo " GRIT $<" + @$(MKDIR) -p $(@D) + $(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$* + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c + +ifneq ($(SOURCES_AUDIO),) + +$(SOUNDBANKINFODIR)/soundbank.h: $(SOURCES_AUDIO) + @echo " MMUTIL $^" + @$(MKDIR) -p $(@D) + @$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \ + -o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKINFODIR)/soundbank.h + +ifeq ($(strip $(NITROFSDIR)),) +$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKINFODIR)/soundbank.h + @echo " BIN2C soundbank.bin" + $(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \ + $(SOUNDBANKDIR) + @echo " CC.9 soundbank_bin.c" + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \ + $(SOUNDBANKDIR)/soundbank_bin.c endif -#--------------------------------------------------------------------------------------- + +endif + +# All assets must be built before the source code +# ----------------------------------------------- + +$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS) + +# Include dependency files if they exist +# -------------------------------------- + +-include $(DEPS) diff --git a/examples/templates/3d_single_screen/Makefile.blocksds b/examples/templates/3d_single_screen/Makefile.blocksds deleted file mode 100644 index 33fc30a..0000000 --- a/examples/templates/3d_single_screen/Makefile.blocksds +++ /dev/null @@ -1,296 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 - -BLOCKSDS ?= /opt/blocksds/core -BLOCKSDSEXT ?= /opt/blocksds/external - -WONDERFUL_TOOLCHAIN ?= /opt/wonderful -ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/ - -# User config -# =========== - -NAME := $(shell basename $(CURDIR)) -GAME_TITLE := 3D template -GAME_SUBTITLE := Nitro Engine example -GAME_AUTHOR := github.com/AntonioND/nitro-engine -GAME_ICON := $(BLOCKSDS)/sys/icon.bmp - -# DLDI and internal SD slot of DSi -# -------------------------------- - -# Root folder of the SD image -SDROOT := sdroot -# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode -SDIMAGE := image.bin - -# Source code paths -# ----------------- - -SOURCEDIRS := source -INCLUDEDIRS := -GFXDIRS := -BINDIRS := -AUDIODIRS := -NITROFSDIR := - -# Defines passed to all files -# --------------------------- - -DEFINES := - -# Libraries -# --------- - -LIBS := -lNE -lnds9 -lc -LIBDIRS := $(BLOCKSDSEXT)/nitro-engine \ - $(BLOCKSDS)/libs/libnds - -# Build artifacts -# --------------- - -BUILDDIR := build -ELF := build/$(NAME).elf -DUMP := build/$(NAME).dump -MAP := build/$(NAME).map -ROM := $(NAME).nds - -# If NITROFSDIR is set, the output of mmutil will be placed in that directory -SOUNDBANKINFODIR := $(BUILDDIR)/maxmod -ifeq ($(strip $(NITROFSDIR)),) - SOUNDBANKDIR := $(BUILDDIR)/maxmod -else - SOUNDBANKDIR := $(NITROFSDIR) -endif - -# Tools -# ----- - -PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi- -CC := $(PREFIX)gcc -CXX := $(PREFIX)g++ -LD := $(PREFIX)gcc -OBJDUMP := $(PREFIX)objdump -MKDIR := mkdir -RM := rm -rf - -# Verbose flag -# ------------ - -ifeq ($(VERBOSE),1) -V := -else -V := @ -endif - -# Source files -# ------------ - -ifneq ($(BINDIRS),) - SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin") - INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS)) -endif -ifneq ($(GFXDIRS),) - SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png") - INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS)) -endif -ifneq ($(AUDIODIRS),) - SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)') - ifneq ($(SOURCES_AUDIO),) - INCLUDEDIRS += $(SOUNDBANKINFODIR) - endif -endif - -SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s") -SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c") -SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp") - -# Compiler and linker flags -# ------------------------- - -DEFINES += -D__NDS__ -DARM9 - -ARCH := -march=armv5te -mtune=arm946e-s - -WARNFLAGS := -Wall - -ifeq ($(SOURCES_CPP),) - LIBS += -lc -else - LIBS += -lstdc++ -lc -endif - -INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \ - $(foreach path,$(LIBDIRS),-I$(path)/include) - -LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib) - -ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) \ - -ffunction-sections -fdata-sections - -CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ - -ffunction-sections -fdata-sections \ - -fomit-frame-pointer - -CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ - -ffunction-sections -fdata-sections \ - -fno-exceptions -fno-rtti \ - -fomit-frame-pointer - -LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \ - -Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \ - -T$(BLOCKSDS)/sys/crts/ds_arm9.mem \ - -T$(BLOCKSDS)/sys/crts/ds_arm9.ld \ - -Wl,--no-warn-rwx-segments \ - -Wl,--start-group $(LIBS) -lgcc -Wl,--end-group - -# Intermediate build files -# ------------------------ - -OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) - -HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ - $(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) - -ifneq ($(SOURCES_AUDIO),) - ifeq ($(strip $(NITROFSDIR)),) - OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o - endif - HEADERS_ASSETS += $(SOUNDBANKINFODIR)/soundbank.h -endif - -OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP))) - -OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES) - -DEPS := $(OBJS:.o=.d) - -# Targets -# ------- - -.PHONY: all clean dump dldipatch sdimage - -all: $(ROM) - -ifneq ($(strip $(NITROFSDIR)),) -# Additional arguments for ndstool -NDSTOOL_ARGS := -d $(NITROFSDIR) - -# Make the NDS ROM depend on the filesystem only if it is needed -$(ROM): $(NITROFSDIR) -endif - -# Combine the title strings -ifeq ($(strip $(GAME_SUBTITLE)),) - GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR) -else - GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR) -endif - -$(ROM): $(ELF) - @echo " NDSTOOL $@" - $(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \ - -7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \ - -b $(GAME_ICON) "$(GAME_FULL_TITLE)" \ - $(NDSTOOL_ARGS) - -$(ELF): $(OBJS) - @echo " LD $@" - $(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS) - -$(DUMP): $(ELF) - @echo " OBJDUMP $@" - $(V)$(OBJDUMP) -h -C -S $< > $@ - -dump: $(DUMP) - -clean: - @echo " CLEAN" - $(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE) \ - $(SOUNDBANKDIR)/soundbank.bin - -sdimage: - @echo " MKFATIMG $(SDIMAGE) $(SDROOT)" - $(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) - -dldipatch: $(ROM) - @echo " DLDIPATCH $(ROM)" - $(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch \ - $(BLOCKSDS)/sys/dldi_r4/r4tf.dldi $(ROM) - -# Rules -# ----- - -$(BUILDDIR)/%.s.o : %.s - @echo " AS $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.c.o : %.c - @echo " CC $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.arm.c.o : %.arm.c - @echo " CC $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< - -$(BUILDDIR)/%.cpp.o : %.cpp - @echo " CXX $<" - @$(MKDIR) -p $(@D) - $(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp - @echo " CXX $<" - @$(MKDIR) -p $(@D) - $(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< - -$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin - @echo " BIN2C $<" - @$(MKDIR) -p $(@D) - $(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c - -$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit - @echo " GRIT $<" - @$(MKDIR) -p $(@D) - $(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$* - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c - -ifneq ($(SOURCES_AUDIO),) - -$(SOUNDBANKINFODIR)/soundbank.h: $(SOURCES_AUDIO) - @echo " MMUTIL $^" - @$(MKDIR) -p $(@D) - @$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \ - -o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKINFODIR)/soundbank.h - -ifeq ($(strip $(NITROFSDIR)),) -$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKINFODIR)/soundbank.h - @echo " BIN2C soundbank.bin" - $(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \ - $(SOUNDBANKDIR) - @echo " CC.9 soundbank_bin.c" - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \ - $(SOUNDBANKDIR)/soundbank_bin.c -endif - -endif - -# All assets must be built before the source code -# ----------------------------------------------- - -$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS) - -# Include dependency files if they exist -# -------------------------------------- - --include $(DEPS) diff --git a/examples/templates/3d_single_screen/Makefile.dkp b/examples/templates/3d_single_screen/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/templates/3d_single_screen/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/templates/Makefile b/examples/templates/Makefile index 6c369fd..4cafacf 100644 --- a/examples/templates/Makefile +++ b/examples/templates/Makefile @@ -1,5 +1,25 @@ -SUBDIRS:= `ls` +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 + +.PHONY: all clean + +MAKE := make + all: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; + clean: - @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) clean --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; diff --git a/examples/templates/Makefile.blocksds b/examples/templates/Makefile.blocksds deleted file mode 100644 index 766b751..0000000 --- a/examples/templates/Makefile.blocksds +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023 - -.PHONY: all clean - -MAKE := make - -all: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; - -clean: - @for i in `ls`; do \ - if test -e $$i/Makefile.blocksds ; then \ - cd $$i; \ - $(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \ - cd ..; \ - fi; \ - done; diff --git a/examples/templates/using_nflib/Makefile b/examples/templates/using_nflib/Makefile index 13f5b24..b95b701 100644 --- a/examples/templates/using_nflib/Makefile +++ b/examples/templates/using_nflib/Makefile @@ -1,222 +1,297 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +BLOCKSDS ?= /opt/blocksds/core +BLOCKSDSEXT ?= /opt/blocksds/external -include $(DEVKITARM)/ds_rules +WONDERFUL_TOOLCHAIN ?= /opt/wonderful +ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/ -#--------------------------------------------------------------------------------- -# 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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := -AUDIO := -ICON := +# User config +# =========== -# specify a directory which contains the nitro filesystem -# this is relative to the Makefile -NITRO := nitrofiles +NAME := $(shell basename $(CURDIR)) +GAME_TITLE := NFlib + Nitro Engine template +GAME_SUBTITLE := Nitro Engine example +GAME_AUTHOR := github.com/AntonioND/nitro-engine +GAME_ICON := $(BLOCKSDS)/sys/icon.bmp -# These set the information text in the nds file -GAME_TITLE := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine +# DLDI and internal SD slot of DSi +# -------------------------------- -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s +# Root folder of the SD image +SDROOT := sdroot +# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode +SDIMAGE := image.bin -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) +# Source code paths +# ----------------- -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lnflib +SOURCEDIRS := source +INCLUDEDIRS := +GFXDIRS := +BINDIRS := +AUDIODIRS := +NITROFSDIR := nitrofiles -# automatigically add libraries for NitroFS -ifneq ($(strip $(NITRO)),) -LIBS := $(LIBS) -lfilesystem -lfat -endif -# automagically add maxmod library -ifneq ($(strip $(AUDIO)),) -LIBS := $(LIBS) -lmm9 -endif +# Defines passed to all files +# --------------------------- -LIBS := $(LIBS) -lnds9 +DEFINES := -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine $(DEVKITPRO)/nflib +# Libraries +# --------- -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- +LIBS := -lNE -lnflib -lnds9 -lc +LIBDIRS := $(BLOCKSDSEXT)/nitro-engine \ + $(BLOCKSDSEXT)/nflib \ + $(BLOCKSDS)/libs/libnds -export OUTPUT := $(CURDIR)/$(TARGET) +# Build artifacts +# --------------- -export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\ - $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\ - $(foreach dir,$(DATA),$(CURDIR)/$(dir))\ - $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) +BUILDDIR := build +ELF := build/$(NAME).elf +DUMP := build/$(NAME).dump +MAP := build/$(NAME).map +ROM := $(NAME).nds -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) -#--------------------------------------------------------------------------------- +# If NITROFSDIR is set, the output of mmutil will be placed in that directory +SOUNDBANKINFODIR := $(BUILDDIR)/maxmod +ifeq ($(strip $(NITROFSDIR)),) + SOUNDBANKDIR := $(BUILDDIR)/maxmod else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- + SOUNDBANKDIR := $(NITROFSDIR) endif -#--------------------------------------------------------------------------------- -export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +# Tools +# ----- -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi- +CC := $(PREFIX)gcc +CXX := $(PREFIX)g++ +LD := $(PREFIX)gcc +OBJDUMP := $(PREFIX)objdump +MKDIR := mkdir +RM := rm -rf -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) +# Verbose flag +# ------------ -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) +ifeq ($(VERBOSE),1) +V := +else +V := @ +endif -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) +# Source files +# ------------ -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp +ifneq ($(BINDIRS),) + SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS)) +endif +ifneq ($(GFXDIRS),) + SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS)) +endif +ifneq ($(AUDIODIRS),) + SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)') + ifneq ($(SOURCES_AUDIO),) + INCLUDEDIRS += $(SOUNDBANKINFODIR) endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif endif -.PHONY: $(BUILD) clean +SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s") +SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c") +SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp") -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile +# Compiler and linker flags +# ------------------------- + +DEFINES += -D__NDS__ -DARM9 + +ARCH := -march=armv5te -mtune=arm946e-s + +WARNFLAGS := -Wall + +ifeq ($(SOURCES_CPP),) + LIBS += -lc +else + LIBS += -lstdc++ -lc +endif + +INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \ + $(foreach path,$(LIBDIRS),-I$(path)/include) + +LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib) + +ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) \ + -ffunction-sections -fdata-sections + +CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ + -ffunction-sections -fdata-sections \ + -fomit-frame-pointer + +CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \ + -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ + -ffunction-sections -fdata-sections \ + -fno-exceptions -fno-rtti \ + -fomit-frame-pointer + +LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \ + -Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \ + -T$(BLOCKSDS)/sys/crts/ds_arm9.mem \ + -T$(BLOCKSDS)/sys/crts/ds_arm9.ld \ + -Wl,--no-warn-rwx-segments \ + -Wl,--start-group $(LIBS) -lgcc -Wl,--end-group + +# Intermediate build files +# ------------------------ + +OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) + +HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ + $(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) + +ifneq ($(SOURCES_AUDIO),) + ifeq ($(strip $(NITROFSDIR)),) + OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o + endif + HEADERS_ASSETS += $(SOUNDBANKINFODIR)/soundbank.h +endif + +OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP))) + +OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES) + +DEPS := $(OBJS:.o=.d) + +# Targets +# ------- + +.PHONY: all clean dump dldipatch sdimage + +all: $(ROM) + +ifneq ($(strip $(NITROFSDIR)),) +# Additional arguments for ndstool +NDSTOOL_ARGS := -d $(NITROFSDIR) + +# Make the NDS ROM depend on the filesystem only if it is needed +$(ROM): $(NITROFSDIR) +endif + +# Combine the title strings +ifeq ($(strip $(GAME_SUBTITLE)),) + GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR) +else + GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR) +endif + +$(ROM): $(ELF) + @echo " NDSTOOL $@" + $(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \ + -7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \ + -b $(GAME_ICON) "$(GAME_FULL_TITLE)" \ + $(NDSTOOL_ARGS) + +$(ELF): $(OBJS) + @echo " LD $@" + $(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS) + +$(DUMP): $(ELF) + @echo " OBJDUMP $@" + $(V)$(OBJDUMP) -h -C -S $< > $@ + +dump: $(DUMP) -#--------------------------------------------------------------------------------- clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + @echo " CLEAN" + $(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE) \ + $(SOUNDBANKDIR)/soundbank.bin -#--------------------------------------------------------------------------------- -else +sdimage: + @echo " MKFATIMG $(SDIMAGE) $(SDROOT)" + $(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) +dldipatch: $(ROM) + @echo " DLDIPATCH $(ROM)" + $(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch \ + $(BLOCKSDS)/sys/dldi_r4/r4tf.dldi $(ROM) -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) +# Rules +# ----- -# need to build soundbank first -$(OFILES): $(SOUNDBANK) +$(BUILDDIR)/%.s.o : %.s + @echo " AS $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h +$(BUILDDIR)/%.c.o : %.c + @echo " CC $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) +$(BUILDDIR)/%.arm.c.o : %.arm.c + @echo " CC $<" + @$(MKDIR) -p $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< -#--------------------------------------------------------------------------------- -# 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$* +$(BUILDDIR)/%.cpp.o : %.cpp + @echo " CXX $<" + @$(MKDIR) -p $(@D) + $(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $< -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr +$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp + @echo " CXX $<" + @$(MKDIR) -p $(@D) + $(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< --include $(DEPSDIR)/*.d +$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin + @echo " BIN2C $<" + @$(MKDIR) -p $(@D) + $(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D) + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c -#--------------------------------------------------------------------------------------- +$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit + @echo " GRIT $<" + @$(MKDIR) -p $(@D) + $(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$* + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c + +ifneq ($(SOURCES_AUDIO),) + +$(SOUNDBANKINFODIR)/soundbank.h: $(SOURCES_AUDIO) + @echo " MMUTIL $^" + @$(MKDIR) -p $(@D) + @$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \ + -o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKINFODIR)/soundbank.h + +ifeq ($(strip $(NITROFSDIR)),) +$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKINFODIR)/soundbank.h + @echo " BIN2C soundbank.bin" + $(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \ + $(SOUNDBANKDIR) + @echo " CC.9 soundbank_bin.c" + $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \ + $(SOUNDBANKDIR)/soundbank_bin.c endif -#--------------------------------------------------------------------------------------- + +endif + +# All assets must be built before the source code +# ----------------------------------------------- + +$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS) + +# Include dependency files if they exist +# -------------------------------------- + +-include $(DEPS) diff --git a/examples/templates/using_nflib/Makefile.blocksds b/examples/templates/using_nflib/Makefile.blocksds deleted file mode 100644 index b95b701..0000000 --- a/examples/templates/using_nflib/Makefile.blocksds +++ /dev/null @@ -1,297 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 -# -# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 - -BLOCKSDS ?= /opt/blocksds/core -BLOCKSDSEXT ?= /opt/blocksds/external - -WONDERFUL_TOOLCHAIN ?= /opt/wonderful -ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/ - -# User config -# =========== - -NAME := $(shell basename $(CURDIR)) -GAME_TITLE := NFlib + Nitro Engine template -GAME_SUBTITLE := Nitro Engine example -GAME_AUTHOR := github.com/AntonioND/nitro-engine -GAME_ICON := $(BLOCKSDS)/sys/icon.bmp - -# DLDI and internal SD slot of DSi -# -------------------------------- - -# Root folder of the SD image -SDROOT := sdroot -# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode -SDIMAGE := image.bin - -# Source code paths -# ----------------- - -SOURCEDIRS := source -INCLUDEDIRS := -GFXDIRS := -BINDIRS := -AUDIODIRS := -NITROFSDIR := nitrofiles - -# Defines passed to all files -# --------------------------- - -DEFINES := - -# Libraries -# --------- - -LIBS := -lNE -lnflib -lnds9 -lc -LIBDIRS := $(BLOCKSDSEXT)/nitro-engine \ - $(BLOCKSDSEXT)/nflib \ - $(BLOCKSDS)/libs/libnds - -# Build artifacts -# --------------- - -BUILDDIR := build -ELF := build/$(NAME).elf -DUMP := build/$(NAME).dump -MAP := build/$(NAME).map -ROM := $(NAME).nds - -# If NITROFSDIR is set, the output of mmutil will be placed in that directory -SOUNDBANKINFODIR := $(BUILDDIR)/maxmod -ifeq ($(strip $(NITROFSDIR)),) - SOUNDBANKDIR := $(BUILDDIR)/maxmod -else - SOUNDBANKDIR := $(NITROFSDIR) -endif - -# Tools -# ----- - -PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi- -CC := $(PREFIX)gcc -CXX := $(PREFIX)g++ -LD := $(PREFIX)gcc -OBJDUMP := $(PREFIX)objdump -MKDIR := mkdir -RM := rm -rf - -# Verbose flag -# ------------ - -ifeq ($(VERBOSE),1) -V := -else -V := @ -endif - -# Source files -# ------------ - -ifneq ($(BINDIRS),) - SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin") - INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS)) -endif -ifneq ($(GFXDIRS),) - SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png") - INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS)) -endif -ifneq ($(AUDIODIRS),) - SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)') - ifneq ($(SOURCES_AUDIO),) - INCLUDEDIRS += $(SOUNDBANKINFODIR) - endif -endif - -SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s") -SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c") -SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp") - -# Compiler and linker flags -# ------------------------- - -DEFINES += -D__NDS__ -DARM9 - -ARCH := -march=armv5te -mtune=arm946e-s - -WARNFLAGS := -Wall - -ifeq ($(SOURCES_CPP),) - LIBS += -lc -else - LIBS += -lstdc++ -lc -endif - -INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \ - $(foreach path,$(LIBDIRS),-I$(path)/include) - -LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib) - -ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) \ - -ffunction-sections -fdata-sections - -CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ - -ffunction-sections -fdata-sections \ - -fomit-frame-pointer - -CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \ - -mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \ - -ffunction-sections -fdata-sections \ - -fno-exceptions -fno-rtti \ - -fomit-frame-pointer - -LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \ - -Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \ - -T$(BLOCKSDS)/sys/crts/ds_arm9.mem \ - -T$(BLOCKSDS)/sys/crts/ds_arm9.ld \ - -Wl,--no-warn-rwx-segments \ - -Wl,--start-group $(LIBS) -lgcc -Wl,--end-group - -# Intermediate build files -# ------------------------ - -OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) - -HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \ - $(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG))) - -ifneq ($(SOURCES_AUDIO),) - ifeq ($(strip $(NITROFSDIR)),) - OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o - endif - HEADERS_ASSETS += $(SOUNDBANKINFODIR)/soundbank.h -endif - -OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \ - $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP))) - -OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES) - -DEPS := $(OBJS:.o=.d) - -# Targets -# ------- - -.PHONY: all clean dump dldipatch sdimage - -all: $(ROM) - -ifneq ($(strip $(NITROFSDIR)),) -# Additional arguments for ndstool -NDSTOOL_ARGS := -d $(NITROFSDIR) - -# Make the NDS ROM depend on the filesystem only if it is needed -$(ROM): $(NITROFSDIR) -endif - -# Combine the title strings -ifeq ($(strip $(GAME_SUBTITLE)),) - GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR) -else - GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR) -endif - -$(ROM): $(ELF) - @echo " NDSTOOL $@" - $(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \ - -7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \ - -b $(GAME_ICON) "$(GAME_FULL_TITLE)" \ - $(NDSTOOL_ARGS) - -$(ELF): $(OBJS) - @echo " LD $@" - $(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS) - -$(DUMP): $(ELF) - @echo " OBJDUMP $@" - $(V)$(OBJDUMP) -h -C -S $< > $@ - -dump: $(DUMP) - -clean: - @echo " CLEAN" - $(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE) \ - $(SOUNDBANKDIR)/soundbank.bin - -sdimage: - @echo " MKFATIMG $(SDIMAGE) $(SDROOT)" - $(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) - -dldipatch: $(ROM) - @echo " DLDIPATCH $(ROM)" - $(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch \ - $(BLOCKSDS)/sys/dldi_r4/r4tf.dldi $(ROM) - -# Rules -# ----- - -$(BUILDDIR)/%.s.o : %.s - @echo " AS $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.c.o : %.c - @echo " CC $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.arm.c.o : %.arm.c - @echo " CC $<" - @$(MKDIR) -p $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< - -$(BUILDDIR)/%.cpp.o : %.cpp - @echo " CXX $<" - @$(MKDIR) -p $(@D) - $(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $< - -$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp - @echo " CXX $<" - @$(MKDIR) -p $(@D) - $(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< - -$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin - @echo " BIN2C $<" - @$(MKDIR) -p $(@D) - $(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D) - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c - -$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit - @echo " GRIT $<" - @$(MKDIR) -p $(@D) - $(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$* - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c - -ifneq ($(SOURCES_AUDIO),) - -$(SOUNDBANKINFODIR)/soundbank.h: $(SOURCES_AUDIO) - @echo " MMUTIL $^" - @$(MKDIR) -p $(@D) - @$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \ - -o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKINFODIR)/soundbank.h - -ifeq ($(strip $(NITROFSDIR)),) -$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKINFODIR)/soundbank.h - @echo " BIN2C soundbank.bin" - $(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \ - $(SOUNDBANKDIR) - @echo " CC.9 soundbank_bin.c" - $(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \ - $(SOUNDBANKDIR)/soundbank_bin.c -endif - -endif - -# All assets must be built before the source code -# ----------------------------------------------- - -$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS) - -# Include dependency files if they exist -# -------------------------------------- - --include $(DEPS) diff --git a/examples/templates/using_nflib/Makefile.dkp b/examples/templates/using_nflib/Makefile.dkp new file mode 100644 index 0000000..3bee1e3 --- /dev/null +++ b/examples/templates/using_nflib/Makefile.dkp @@ -0,0 +1,222 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := data +GRAPHICS := +AUDIO := +ICON := + +# specify a directory which contains the nitro filesystem +# this is relative to the Makefile +NITRO := nitrofiles + +# These set the information text in the nds file +GAME_TITLE := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lnflib + +# automatigically add libraries for NitroFS +ifneq ($(strip $(NITRO)),) +LIBS := $(LIBS) -lfilesystem -lfat +endif +# automagically add maxmod library +ifneq ($(strip $(AUDIO)),) +LIBS := $(LIBS) -lmm9 +endif + +LIBS := $(LIBS) -lnds9 + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine $(DEVKITPRO)/nflib + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/text/Makefile b/examples/text/Makefile new file mode 100644 index 0000000..4cafacf --- /dev/null +++ b/examples/text/Makefile @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024 + +.PHONY: all clean + +MAKE := make + +all: + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; + +clean: + @for i in `ls`; do \ + if test -e $$i/Makefile ; then \ + cd $$i; \ + $(MAKE) clean --no-print-directory || exit 1 ; \ + cd ..; \ + fi; \ + done; diff --git a/examples/text/font_from_ram/Makefile b/examples/text/font_from_ram/Makefile index 6006f41..4d11b07 100644 --- a/examples/text/font_from_ram/Makefile +++ b/examples/text/font_from_ram/Makefile @@ -1,220 +1,7 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics +BINDIRS := data -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/text/font_from_ram/Makefile.blocksds b/examples/text/font_from_ram/Makefile.blocksds deleted file mode 100644 index c33d4aa..0000000 --- a/examples/text/font_from_ram/Makefile.blocksds +++ /dev/null @@ -1,7 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics -BINDIRS := data - -include ../../Makefile.example.blocksds diff --git a/examples/text/font_from_ram/Makefile.dkp b/examples/text/font_from_ram/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/text/font_from_ram/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/examples/text/monospaced_text/Makefile b/examples/text/monospaced_text/Makefile index 6a54f39..461477c 100644 --- a/examples/text/monospaced_text/Makefile +++ b/examples/text/monospaced_text/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../Makefile.example diff --git a/examples/text/monospaced_text/Makefile.blocksds b/examples/text/monospaced_text/Makefile.blocksds deleted file mode 100644 index 1c2569f..0000000 --- a/examples/text/monospaced_text/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../Makefile.example.blocksds diff --git a/examples/text/monospaced_text/Makefile.dkp b/examples/text/monospaced_text/Makefile.dkp new file mode 100644 index 0000000..6242cae --- /dev/null +++ b/examples/text/monospaced_text/Makefile.dkp @@ -0,0 +1,220 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := source +INCLUDES := include +DATA := +GRAPHICS := 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 := $(shell basename $(CURDIR)) +GAME_SUBTITLE1 := Nitro Engine example +GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project (order is important) +#--------------------------------------------------------------------------------- +LIBS := -lNE -lfat -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 +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +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_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) + +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) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.bmp) + + ifneq (,$(findstring $(TARGET).bmp,$(icons))) + export GAME_ICON := $(CURDIR)/$(TARGET).bmp + else + ifneq (,$(findstring icon.bmp,$(icons))) + export GAME_ICON := $(CURDIR)/icon.bmp + endif + endif +else + ifeq ($(suffix $(ICON)), .grf) + export GAME_ICON := $(CURDIR)/$(ICON) + else + export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf + endif +endif + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.dkp + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) +$(OUTPUT).elf: $(OFILES) + +# source files depend on generated headers +$(OFILES_SOURCES) : $(HFILES) + +# need to build soundbank first +$(OFILES): $(SOUNDBANK) + +#--------------------------------------------------------------------------------- +# rule to build solution from music files +#--------------------------------------------------------------------------------- +$(SOUNDBANK) : $(MODFILES) +#--------------------------------------------------------------------------------- + mmutil $^ -d -o$@ -hsoundbank.h + +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.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$* + +#--------------------------------------------------------------------------------- +# Convert non-GRF game icon to GRF if needed +#--------------------------------------------------------------------------------- +$(GAME_ICON): $(notdir $(ICON)) +#--------------------------------------------------------------------------------- + @echo convert $(notdir $<) + @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/readme.rst b/readme.rst index c386164..1badb55 100644 --- a/readme.rst +++ b/readme.rst @@ -8,8 +8,9 @@ Introduction This is a 3D game engine, a lot of functions designed to simplify the process of making a 3D game. It isn't standalone, it needs libnds to work. -You may use Nitro Engine with both devkitPro installations, and with `BlocksDS -`_. +You can use Nitro Engine with `BlocksDS `_ and +devkitPro, but BlocksDS is preferred as some features of Nitro Engine are only +available with BlocksDS. Features: @@ -36,6 +37,40 @@ to integrate Nitro Engine and NFlib in the same project `here Setup ===== +BlocksDS +-------- + +1. Clone this repository and run: + + .. code:: bash + + make + make NE_DEBUG=1 + make install + + This should build the library in both debug and release modes and install it. + +2. If you want to check that everything is working as expected, open one of the + folders of the examples and run: + + .. code:: bash + + make + + That should build an ``.nds`` file that you can run on an emulator or real + hardware. + +Note: The build system of the examples in this repository is make. The makefiles +aren't very flexible, and they don't support converting 3D models, or saving +graphics or models to the filesystem (you can only inject them as data to the +ARM9, which isn't acceptable for big games). + +For BlocksDS, try `ArchitectDS `. This +build system written in Python supports converting every format that Nitro +Engine supports, and it lets you save everything in NitroFS so that your game +can grow as much as you want. ArchitectDS comes with plenty of examples of how +to use it with Nitro Engine. + devkitpro --------- @@ -51,47 +86,18 @@ devkitpro .. code:: bash - make - make NE_DEBUG=1 + make -f Makefile.dkp + make -f Makefile.dkp NE_DEBUG=1 This should build the library in both debug and release modes. 3. If you want to check that everything is working as expected, open one of the - folders of the examples and type ``make``. That should build an ``.nds`` file - that you can run on an emulator or real hardware. + folders of the examples and type ``make -f Makefile.dkp``. That should build + an ``.nds`` file that you can run on an emulator or real hardware. -BlocksDS --------- - -1. Clone this repository and run: - - .. code:: bash - - make -f Makefile.blocksds - make -f Makefile.blocksds NE_DEBUG=1 - make -f Makefile.blocksds install - - This should build the library in both debug and release modes and install it. - -2. If you want to check that everything is working as expected, open one of the - folders of the examples and run: - - .. code:: bash - - make -f Makefile.blocksds - - That should build an ``.nds`` file that you can run on an emulator or real - hardware. - -Note: The build system of the examples in this repository is make. The makefiles -aren't very flexible, and they don't support converting 3D models, or saving -graphics or models to the filesystem (you can only inject them as data to the -ARM9, which isn't acceptable for big games). - -For BlocksDS, try `ArchitectDS `. This -build system written in Python supports converting every format that Nitro -Engine supports, and it lets you save everything in NitroFS so that your game -can grow as much as you want. +Note: If you're using **melonDS**, remember that any example that uses NitroFS +with will fail if it's built with the libraries that come with devkitPro because +of a bug in the libraries. Other emulators like **DeSmuME** still work. Common ------ @@ -174,7 +180,6 @@ Thanks to ========= - **devkitPro**: https://devkitpro.org/ -- **libnds**: https://github.com/devkitPro/libnds - **DLDI**: https://www.chishm.com/DLDI/ - **DeSmuME**: http://desmume.org/ - **melonDS**: https://melonds.kuribo64.net/ diff --git a/tests/3d_modes_lcd_depth/Makefile b/tests/3d_modes_lcd_depth/Makefile index 133ddc5..6d4902b 100644 --- a/tests/3d_modes_lcd_depth/Makefile +++ b/tests/3d_modes_lcd_depth/Makefile @@ -1,220 +1,3 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +BINDIRS := data -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../examples/Makefile.example diff --git a/tests/3d_modes_lcd_depth/Makefile.blocksds b/tests/3d_modes_lcd_depth/Makefile.blocksds deleted file mode 100644 index 2adc008..0000000 --- a/tests/3d_modes_lcd_depth/Makefile.blocksds +++ /dev/null @@ -1,3 +0,0 @@ -BINDIRS := data - -include ../../examples/Makefile.example.blocksds diff --git a/tests/allocator/Makefile b/tests/allocator/Makefile index 2a0ac57..e92c556 100644 --- a/tests/allocator/Makefile +++ b/tests/allocator/Makefile @@ -1,224 +1 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 - -# Enable debug mode of Nitro Engine -CFLAGS += -DNE_DEBUG - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE_debug -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../examples/Makefile.example diff --git a/tests/allocator/Makefile.blocksds b/tests/allocator/Makefile.blocksds deleted file mode 100644 index 8cf48a1..0000000 --- a/tests/allocator/Makefile.blocksds +++ /dev/null @@ -1 +0,0 @@ -include ../../examples/Makefile.example.blocksds diff --git a/tests/clone_materials/Makefile b/tests/clone_materials/Makefile index 6a54f39..35b9aa8 100644 --- a/tests/clone_materials/Makefile +++ b/tests/clone_materials/Makefile @@ -1,220 +1,6 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- +# This is a minimal makefile only used for the examples. If you want a makefile +# for your project, take one from the templates inside examples/templates. -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif +GFXDIRS := graphics -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 := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := -GRAPHICS := 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 := $(shell basename $(CURDIR)) -GAME_SUBTITLE1 := Nitro Engine example -GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lNE -lfat -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 -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -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_BIN := $(addsuffix .o,$(BINFILES)) - -export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES) - -export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES))) - -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) - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.bmp) - - ifneq (,$(findstring $(TARGET).bmp,$(icons))) - export GAME_ICON := $(CURDIR)/$(TARGET).bmp - else - ifneq (,$(findstring icon.bmp,$(icons))) - export GAME_ICON := $(CURDIR)/icon.bmp - endif - endif -else - ifeq ($(suffix $(ICON)), .grf) - export GAME_ICON := $(CURDIR)/$(ICON) - else - export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf - endif -endif - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -else - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON) -$(OUTPUT).elf: $(OFILES) - -# source files depend on generated headers -$(OFILES_SOURCES) : $(HFILES) - -# need to build soundbank first -$(OFILES): $(SOUNDBANK) - -#--------------------------------------------------------------------------------- -# rule to build solution from music files -#--------------------------------------------------------------------------------- -$(SOUNDBANK) : $(MODFILES) -#--------------------------------------------------------------------------------- - mmutil $^ -d -o$@ -hsoundbank.h - -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.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$* - -#--------------------------------------------------------------------------------- -# Convert non-GRF game icon to GRF if needed -#--------------------------------------------------------------------------------- -$(GAME_ICON): $(notdir $(ICON)) -#--------------------------------------------------------------------------------- - @echo convert $(notdir $<) - @grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr - --include $(DEPSDIR)/*.d - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- +include ../../examples/Makefile.example diff --git a/tests/clone_materials/Makefile.blocksds b/tests/clone_materials/Makefile.blocksds deleted file mode 100644 index 2597aa9..0000000 --- a/tests/clone_materials/Makefile.blocksds +++ /dev/null @@ -1,6 +0,0 @@ -# This is a minimal makefile only used for the examples. If you want a makefile -# for your project, take one from the templates inside examples/templates. - -GFXDIRS := graphics - -include ../../examples/Makefile.example.blocksds