-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70e82e6
commit b926ab7
Showing
5 changed files
with
41 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,51 @@ | ||
#--------------------------------------------------------------------------------- | ||
.SUFFIXES: | ||
#--------------------------------------------------------------------------------- | ||
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2)) | ||
|
||
ifeq ($(strip $(DEVKITARM)),) | ||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") | ||
endif | ||
|
||
TOPDIR ?= $(CURDIR) | ||
include $(DEVKITARM)/3ds_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 | ||
#--------------------------------------------------------------------------------- | ||
TARGET := $(notdir $(CURDIR)) | ||
BUILD := build | ||
SOURCES := source | ||
CC := arm-none-eabi-gcc | ||
AS := arm-none-eabi-as | ||
LD := arm-none-eabi-ld | ||
OC := arm-none-eabi-objcopy | ||
|
||
#--------------------------------------------------------------------------------- | ||
# options for code generation | ||
#--------------------------------------------------------------------------------- | ||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft | ||
name := $(shell basename $(CURDIR)) | ||
|
||
CFLAGS := -flto -Wall -O2 -mword-relocations \ | ||
-ffast-math -fno-builtin -ffunction-sections -fdata-sections \ | ||
$(ARCH) $(INCLUDE) -DARM11 -D_3DS | ||
dir_source := source | ||
dir_build := build | ||
|
||
LDFLAGS = -flto -Xlinker --defsym="__start__=0x14000000" -specs=3dsx.specs $(ARCH) -Wl,-Map,$(notdir $*.map) | ||
|
||
LIBS := -lctru | ||
|
||
#--------------------------------------------------------------------------------- | ||
# list of directories containing libraries, this must be the top level containing | ||
# include and lib | ||
#--------------------------------------------------------------------------------- | ||
LIBS := -lctru | ||
LIBDIRS := $(CTRULIB) | ||
LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) | ||
|
||
INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# 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)) | ||
|
||
export DEPSDIR := $(CURDIR)/$(BUILD) | ||
|
||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) | ||
|
||
export LD := $(CC) | ||
|
||
export OFILES := $(CFILES:.c=.o) | ||
ARCH := -mcpu=mpcore -mfloat-abi=hard -mtp=soft | ||
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ARCH) -fno-builtin -std=c11 -O2 -flto -ffast-math -mword-relocations \ | ||
-ffunction-sections -fdata-sections $(INCLUDE) -DARM11 -D_3DS | ||
LDFLAGS := -Xlinker --defsym="__start__=0x14000000" -specs=3dsx.specs $(ARCH) | ||
|
||
export INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ | ||
-I$(CURDIR)/$(BUILD) | ||
objects = $(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \ | ||
$(call rwildcard, $(dir_source), *.c)) | ||
|
||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) | ||
.PHONY: all | ||
all: $(name).cxi | ||
|
||
.PHONY: $(BUILD) clean all | ||
|
||
#--------------------------------------------------------------------------------- | ||
all: $(BUILD) | ||
|
||
$(BUILD): | ||
@[ -d $@ ] || mkdir -p $@ | ||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile | ||
|
||
#--------------------------------------------------------------------------------- | ||
.PHONY: clean | ||
clean: | ||
@echo clean ... | ||
@rm -fr $(BUILD) $(TARGET).elf | ||
|
||
@rm -rf $(dir_build) | ||
|
||
#--------------------------------------------------------------------------------- | ||
else | ||
$(name).cxi: $(dir_build)/$(name).elf | ||
@makerom -f ncch -rsf loader.rsf -nocodepadding -o $@ -elf $< | ||
|
||
DEPENDS := $(OFILES:.o=.d) | ||
$(dir_build)/$(name).elf: $(objects) | ||
$(LINK.o) $(OUTPUT_OPTION) $^ $(LIBPATHS) $(LIBS) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# main targets | ||
#--------------------------------------------------------------------------------- | ||
$(OUTPUT).cxi : $(OUTPUT).elf | ||
@makerom -f ncch -rsf ../loader.rsf -nocodepadding -o $@ -elf $< | ||
$(dir_build)/memory.o : CFLAGS += -O3 | ||
|
||
memory.o : CFLAGS += -O3 | ||
|
||
$(OUTPUT).elf : $(OFILES) | ||
|
||
-include $(DEPENDS) | ||
|
||
#--------------------------------------------------------------------------------------- | ||
endif | ||
#--------------------------------------------------------------------------------------- | ||
$(dir_build)/%.o: $(dir_source)/%.c | ||
@mkdir -p "$(@D)" | ||
$(COMPILE.c) $(OUTPUT_OPTION) $< | ||
include $(call rwildcard, $(dir_build), *.d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters