mirror of
https://github.com/AntonioND/palib.git
synced 2025-06-18 14:45:43 -04:00
145 lines
3.2 KiB
Makefile
145 lines
3.2 KiB
Makefile
# SPDX-License-Identifier: CC0-1.0
|
|
#
|
|
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
|
|
|
export BLOCKSDS ?= /opt/blocksds/core
|
|
export BLOCKSDSEXT ?= /opt/blocksds/external
|
|
|
|
export WONDERFUL_TOOLCHAIN ?= /opt/wonderful
|
|
ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/
|
|
|
|
# Source code paths
|
|
# -----------------
|
|
|
|
SOURCEDIRS := source/arm7
|
|
INCLUDEDIRS := source/arm7 source/arm7/helix source/arm7/helix/real \
|
|
include include/arm7
|
|
|
|
# Defines passed to all files
|
|
# ---------------------------
|
|
|
|
DEFINES :=
|
|
|
|
# Libraries
|
|
# ---------
|
|
|
|
LIBDIRS := $(BLOCKSDS)/libs/libnds \
|
|
$(BLOCKSDS)/libs/dswifi \
|
|
$(BLOCKSDS)/libs/maxmod
|
|
|
|
# Build artifacts
|
|
# ---------------
|
|
|
|
NAME := pa7
|
|
BUILDDIR := build/$(NAME)
|
|
ARCHIVE := lib/lib$(NAME).a
|
|
|
|
# Tools
|
|
# -----
|
|
|
|
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
|
|
CC := $(PREFIX)gcc
|
|
CXX := $(PREFIX)g++
|
|
AR := $(PREFIX)gcc-ar
|
|
MKDIR := mkdir
|
|
RM := rm -rf
|
|
|
|
# Verbose flag
|
|
# ------------
|
|
|
|
ifeq ($(VERBOSE),1)
|
|
V :=
|
|
else
|
|
V := @
|
|
endif
|
|
|
|
# Source files
|
|
# ------------
|
|
|
|
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
|
|
# -------------------------
|
|
|
|
ARCH := -mthumb -mcpu=arm7tdmi
|
|
|
|
SPECS := $(BLOCKSDS)/sys/crts/ds_arm7.specs
|
|
|
|
WARNFLAGS := -Wall
|
|
|
|
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
|
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
|
|
|
ASFLAGS += -x assembler-with-cpp $(DEFINES) $(INCLUDEFLAGS) \
|
|
$(ARCH) -ffunction-sections -fdata-sections \
|
|
-specs=$(SPECS)
|
|
|
|
CFLAGS += -std=gnu17 $(WARNFLAGS) $(DEFINES) $(INCLUDEFLAGS) \
|
|
$(ARCH) -O2 -ffunction-sections -fdata-sections \
|
|
-specs=$(SPECS)
|
|
|
|
CXXFLAGS += -std=gnu++17 $(WARNFLAGS) $(DEFINES) $(INCLUDEFLAGS) \
|
|
$(ARCH) -O2 -ffunction-sections -fdata-sections \
|
|
-fno-exceptions -fno-rtti \
|
|
-specs=$(SPECS)
|
|
|
|
# Intermediate build files
|
|
# ------------------------
|
|
|
|
OBJS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
|
|
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \
|
|
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP)))
|
|
|
|
DEPS := $(OBJS:.o=.d)
|
|
|
|
# Targets
|
|
# -------
|
|
|
|
.PHONY: all clean
|
|
|
|
all: $(ARCHIVE)
|
|
|
|
$(ARCHIVE): $(OBJS)
|
|
@echo " AR.7 $@"
|
|
@$(MKDIR) -p $(@D)
|
|
$(V)$(AR) rcs $@ $(OBJS)
|
|
|
|
clean:
|
|
@echo " CLEAN.7"
|
|
$(V)$(RM) $(ARCHIVE) $(BUILDDIR)
|
|
|
|
# Rules
|
|
# -----
|
|
|
|
$(BUILDDIR)/%.s.o : %.s
|
|
@echo " AS.7 $<"
|
|
@$(MKDIR) -p $(@D)
|
|
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<
|
|
|
|
$(BUILDDIR)/%.c.o : %.c
|
|
@echo " CC.7 $<"
|
|
@$(MKDIR) -p $(@D)
|
|
$(V)case $< in *"helix"*) $(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $< ;; *) $(CC) $(CFLAGS) -MMD -MP -c -o $@ $< ;; esac
|
|
|
|
$(BUILDDIR)/%.arm.c.o : %.arm.c
|
|
@echo " CC.7 $<"
|
|
@$(MKDIR) -p $(@D)
|
|
$(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $<
|
|
|
|
$(BUILDDIR)/%.cpp.o : %.cpp
|
|
@echo " CXX.7 $<"
|
|
@$(MKDIR) -p $(@D)
|
|
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
|
|
|
|
$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp
|
|
@echo " CXX.7 $<"
|
|
@$(MKDIR) -p $(@D)
|
|
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $<
|
|
|
|
# Include dependency files if they exist
|
|
# --------------------------------------
|
|
|
|
-include $(DEPS)
|