2018-05-23 03:16:32 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
.SUFFIXES:
|
|
|
|
#---------------------------------------------------------------------------------
|
2017-06-05 02:02:04 +02:00
|
|
|
|
|
|
|
ifeq ($(strip $(DEVKITARM)),)
|
|
|
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
|
|
endif
|
|
|
|
|
2018-05-23 03:16:32 +02:00
|
|
|
TOPDIR ?= $(CURDIR)
|
2017-06-05 02:02:04 +02:00
|
|
|
include $(DEVKITARM)/3ds_rules
|
|
|
|
|
2018-05-23 03:16:32 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# 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
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
TARGET := $(notdir $(CURDIR))
|
|
|
|
BUILD := build
|
2019-03-15 18:51:18 +01:00
|
|
|
SOURCES := source source/gdb source/menus source/redshift
|
2018-05-23 03:16:32 +02:00
|
|
|
DATA := source/gdb/xml
|
2019-03-15 18:51:18 +01:00
|
|
|
INCLUDES := include include/gdb include/menus include/redshift
|
2018-05-23 03:16:32 +02:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# options for code generation
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
|
|
|
DEFINES := -DARM11 -D_3DS
|
|
|
|
|
2019-06-29 17:05:43 +02:00
|
|
|
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -Wno-unused-value -O2 -mword-relocations \
|
2020-04-16 20:50:18 +02:00
|
|
|
-fomit-frame-pointer -ffunction-sections -fdata-sections -ffast-math \
|
2018-05-23 03:16:32 +02:00
|
|
|
$(ARCH) $(DEFINES)
|
|
|
|
|
|
|
|
CFLAGS += $(INCLUDE)
|
|
|
|
|
|
|
|
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
|
|
|
|
|
|
|
ASFLAGS := -g $(ARCH)
|
|
|
|
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map),--section-start,.text=0x14000000
|
|
|
|
|
2020-04-16 20:50:18 +02:00
|
|
|
LIBS := -lctru
|
2018-05-23 03:16:32 +02:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# list of directories containing libraries, this must be the top level containing
|
|
|
|
# include and lib
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
LIBDIRS := $(CTRULIB)
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# 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 TOPDIR := $(CURDIR)
|
|
|
|
|
|
|
|
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
|
|
|
|
#---------------------------------------------------------------------------------
|
2017-06-05 02:02:04 +02:00
|
|
|
|
2018-05-23 03:16:32 +02:00
|
|
|
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
|
|
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
|
|
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
|
|
|
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
2017-06-05 02:02:04 +02:00
|
|
|
|
2018-05-23 03:16:32 +02:00
|
|
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
|
|
-I$(CURDIR)/$(BUILD)
|
2017-06-05 02:02:04 +02:00
|
|
|
|
2018-05-23 03:16:32 +02:00
|
|
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
2017-06-05 02:02:04 +02:00
|
|
|
|
2018-05-23 03:16:32 +02:00
|
|
|
.PHONY: $(BUILD) clean all
|
2017-06-05 02:02:04 +02:00
|
|
|
|
2018-05-23 03:16:32 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
all: $(BUILD)
|
2017-06-05 02:02:04 +02:00
|
|
|
|
2018-05-23 03:16:32 +02:00
|
|
|
$(BUILD):
|
|
|
|
@[ -d $@ ] || mkdir -p $@
|
|
|
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
2017-06-05 02:02:04 +02:00
|
|
|
|
2018-05-23 03:16:32 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
2017-06-05 02:02:04 +02:00
|
|
|
clean:
|
2018-05-23 03:16:32 +02:00
|
|
|
@echo clean ...
|
2018-05-23 09:50:19 +02:00
|
|
|
@rm -fr $(BUILD) $(TARGET).cxi $(TARGET).elf
|
2018-05-23 03:16:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
else
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
DEPENDS := $(OFILES:.o=.d)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# main targets
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
all : $(OUTPUT).cxi
|
|
|
|
|
|
|
|
$(OUTPUT).cxi : $(OUTPUT).elf $(OUTPUT).rsf
|
2019-03-15 19:14:47 +01:00
|
|
|
@makerom -f ncch -rsf $(word 2,$^) -nocodepadding -o $@ -elf $<
|
2018-05-23 03:16:32 +02:00
|
|
|
@echo built ... $(notdir $@)
|
|
|
|
|
|
|
|
$(OUTPUT).elf : $(OFILES)
|
|
|
|
|
|
|
|
%.elf: $(OFILES)
|
|
|
|
@echo linking $(notdir $@)
|
|
|
|
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
|
|
|
|
@$(NM) -CSn $@ > $(notdir $*.lst)
|
|
|
|
|
|
|
|
$(OFILES_SRC) : $(HFILES_BIN)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# you need a rule like this for each extension you use as binary data
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
%.bin.o %_bin.h: %.bin
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
@echo $(notdir $<)
|
|
|
|
@$(bin2o)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
%.xml.o %_xml.h: %.xml
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
@echo $(notdir $<)
|
|
|
|
@$(bin2o)
|
|
|
|
|
|
|
|
-include $(DEPENDS)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
|
|
endif
|
|
|
|
#---------------------------------------------------------------------------------------
|