mirror of
https://github.com/knightfox75/nds_nflib.git
synced 2025-06-18 16:55:32 -04:00

The main reason is that BlocksDS doesn't have any bug with NitroFS, and NitroFS is strictly required to use NFlib. With devkitPro, melonDS won't be able to run any program made with NFlib due to a bug with NitroFS.
193 lines
4.6 KiB
Makefile
193 lines
4.6 KiB
Makefile
# 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
|
|
GFXDIRS :=
|
|
BINDIRS :=
|
|
|
|
# Defines passed to all files
|
|
# ---------------------------
|
|
|
|
DEFINES := -DBLOCKSDS
|
|
|
|
# Libraries
|
|
# ---------
|
|
|
|
LIBDIRS := $(BLOCKSDS)/libs/libnds $(BLOCKSDS)/libs/dswifi
|
|
|
|
# Build artifacts
|
|
# ---------------
|
|
|
|
NAME := nflib
|
|
INSTALLNAME := nflib
|
|
BUILDDIR := build
|
|
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 -Wextra
|
|
|
|
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 docs install
|
|
|
|
all: $(ARCHIVE)
|
|
|
|
$(ARCHIVE): $(OBJS)
|
|
@echo " AR $@"
|
|
@$(MKDIR) -p $(@D)
|
|
$(V)$(AR) rcs $@ $(OBJS)
|
|
|
|
clean:
|
|
@echo " CLEAN"
|
|
$(V)$(RM) $(ARCHIVE) $(BUILDDIR)
|
|
|
|
install: all
|
|
@echo " INSTALL $(BLOCKSDSEXT)/$(INSTALLNAME)/"
|
|
$(V)$(RM) $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
|
$(V)$(INSTALL) -d $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
|
$(V)$(CP) -r include lib $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
|
|
|
docs:
|
|
$(V)doxygen Doxyfile
|
|
|
|
# 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)
|