Give 3ds_injector a sane makefile
This commit is contained in:
parent
70e82e627b
commit
b926ab7dd2
4
Makefile
4
Makefile
@ -24,7 +24,7 @@ dir_ninjhax := CakeBrah
|
|||||||
dir_build := build
|
dir_build := build
|
||||||
dir_out := out
|
dir_out := out
|
||||||
|
|
||||||
ASFLAGS := -mlittle-endian -mcpu=arm946e-s -march=armv5te
|
ASFLAGS := -mcpu=arm946e-s
|
||||||
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -fshort-wchar -std=c11 -Wno-main -O2 -flto -ffast-math
|
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -fshort-wchar -std=c11 -Wno-main -O2 -flto -ffast-math
|
||||||
LDFLAGS := -nostartfiles
|
LDFLAGS := -nostartfiles
|
||||||
FLAGS := name=$(name).dat dir_out=$(abspath $(dir_out)) ICON=$(abspath icon.png) APP_DESCRIPTION="Noob-friendly 3DS CFW." APP_AUTHOR="Reisyukaku/Aurora Wright" --no-print-directory
|
FLAGS := name=$(name).dat dir_out=$(abspath $(dir_out)) ICON=$(abspath icon.png) APP_DESCRIPTION="Noob-friendly 3DS CFW." APP_AUTHOR="Reisyukaku/Aurora Wright" --no-print-directory
|
||||||
@ -87,7 +87,7 @@ $(dir_build)/main.bin: $(dir_build)/main.elf
|
|||||||
$(OC) -S -O binary $< $@
|
$(OC) -S -O binary $< $@
|
||||||
|
|
||||||
$(dir_build)/main.elf: $(objects)
|
$(dir_build)/main.elf: $(objects)
|
||||||
$(CC) $(LDFLAGS) -T linker.ld $(OUTPUT_OPTION) $^
|
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
||||||
|
|
||||||
$(dir_build)/patches.h: $(dir_patches)/emunand.s $(dir_patches)/reboot.s $(dir_injector)/Makefile
|
$(dir_build)/patches.h: $(dir_patches)/emunand.s $(dir_patches)/reboot.s $(dir_injector)/Makefile
|
||||||
@mkdir -p "$(@D)"
|
@mkdir -p "$(@D)"
|
||||||
|
109
injector/Makefile
Normal file → Executable file
109
injector/Makefile
Normal file → Executable file
@ -1,102 +1,51 @@
|
|||||||
#---------------------------------------------------------------------------------
|
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
|
||||||
.SUFFIXES:
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
ifeq ($(strip $(DEVKITARM)),)
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TOPDIR ?= $(CURDIR)
|
|
||||||
include $(DEVKITARM)/3ds_rules
|
include $(DEVKITARM)/3ds_rules
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
CC := arm-none-eabi-gcc
|
||||||
# TARGET is the name of the output
|
AS := arm-none-eabi-as
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
LD := arm-none-eabi-ld
|
||||||
# SOURCES is a list of directories containing source code
|
OC := arm-none-eabi-objcopy
|
||||||
# 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
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
name := $(shell basename $(CURDIR))
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
|
||||||
|
|
||||||
CFLAGS := -flto -Wall -O2 -mword-relocations \
|
dir_source := source
|
||||||
-ffast-math -fno-builtin -ffunction-sections -fdata-sections \
|
dir_build := build
|
||||||
$(ARCH) $(INCLUDE) -DARM11 -D_3DS
|
|
||||||
|
|
||||||
LDFLAGS = -flto -Xlinker --defsym="__start__=0x14000000" -specs=3dsx.specs $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
LIBS := -lctru
|
LIBS := -lctru
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(CTRULIB)
|
LIBDIRS := $(CTRULIB)
|
||||||
|
LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||||
|
|
||||||
|
INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
ARCH := -mcpu=mpcore -mfloat-abi=hard -mtp=soft
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ARCH) -fno-builtin -std=c11 -O2 -flto -ffast-math -mword-relocations \
|
||||||
# rules for different file extensions
|
-ffunction-sections -fdata-sections $(INCLUDE) -DARM11 -D_3DS
|
||||||
#---------------------------------------------------------------------------------
|
LDFLAGS := -Xlinker --defsym="__start__=0x14000000" -specs=3dsx.specs $(ARCH)
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
objects = $(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||||
export TOPDIR := $(CURDIR)
|
$(call rwildcard, $(dir_source), *.c))
|
||||||
|
|
||||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
|
.PHONY: all
|
||||||
|
all: $(name).cxi
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
.PHONY: clean
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
|
|
||||||
export LD := $(CC)
|
|
||||||
|
|
||||||
export OFILES := $(CFILES:.c=.o)
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean all
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
all: $(BUILD)
|
|
||||||
|
|
||||||
$(BUILD):
|
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
clean:
|
||||||
@echo clean ...
|
@rm -rf $(dir_build)
|
||||||
@rm -fr $(BUILD) $(TARGET).elf
|
|
||||||
|
|
||||||
|
$(name).cxi: $(dir_build)/$(name).elf
|
||||||
|
@makerom -f ncch -rsf loader.rsf -nocodepadding -o $@ -elf $<
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
$(dir_build)/$(name).elf: $(objects)
|
||||||
else
|
$(LINK.o) $(OUTPUT_OPTION) $^ $(LIBPATHS) $(LIBS)
|
||||||
|
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
$(dir_build)/memory.o : CFLAGS += -O3
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
$(dir_build)/%.o: $(dir_source)/%.c
|
||||||
# main targets
|
@mkdir -p "$(@D)"
|
||||||
#---------------------------------------------------------------------------------
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||||
$(OUTPUT).cxi : $(OUTPUT).elf
|
include $(call rwildcard, $(dir_build), *.d)
|
||||||
@makerom -f ncch -rsf ../loader.rsf -nocodepadding -o $@ -elf $<
|
|
||||||
|
|
||||||
memory.o : CFLAGS += -O3
|
|
||||||
|
|
||||||
$(OUTPUT).elf : $(OFILES)
|
|
||||||
|
|
||||||
-include $(DEPENDS)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -461,14 +461,14 @@ void __sync_init();
|
|||||||
void __sync_fini();
|
void __sync_fini();
|
||||||
void __system_initSyscalls();
|
void __system_initSyscalls();
|
||||||
|
|
||||||
void __ctru_exit(int rc)
|
void __ctru_exit()
|
||||||
{
|
{
|
||||||
__appExit();
|
__appExit();
|
||||||
__sync_fini();
|
__sync_fini();
|
||||||
svcExitProcess();
|
svcExitProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSystem(void (*retAddr)(void))
|
void initSystem()
|
||||||
{
|
{
|
||||||
__sync_init();
|
__sync_init();
|
||||||
__system_initSyscalls();
|
__system_initSyscalls();
|
||||||
@ -520,7 +520,7 @@ int main()
|
|||||||
if (R_FAILED(ret))
|
if (R_FAILED(ret))
|
||||||
{
|
{
|
||||||
// check if any handle has been closed
|
// check if any handle has been closed
|
||||||
if (ret == 0xC920181A)
|
if (ret == (int)0xC920181A)
|
||||||
{
|
{
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,8 @@ name := $(shell basename $(CURDIR))
|
|||||||
dir_source := source
|
dir_source := source
|
||||||
dir_build := build
|
dir_build := build
|
||||||
|
|
||||||
ASFLAGS := -mlittle-endian -mcpu=arm946e-s -march=armv5te
|
ASFLAGS := -mcpu=arm946e-s
|
||||||
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math -mthumb -mthumb-interwork
|
CFLAGS := -Wall -Wextra -MMD -MP -mthumb -mthumb-interwork $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
|
||||||
LDFLAGS := -nostartfiles
|
LDFLAGS := -nostartfiles
|
||||||
|
|
||||||
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
||||||
@ -35,7 +35,7 @@ $(name).bin: $(dir_build)/$(name).elf
|
|||||||
$(OC) -S -O binary $< $@
|
$(OC) -S -O binary $< $@
|
||||||
|
|
||||||
$(dir_build)/$(name).elf: $(objects)
|
$(dir_build)/$(name).elf: $(objects)
|
||||||
$(CC) $(LDFLAGS) -T linker.ld $(OUTPUT_OPTION) $^
|
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
||||||
|
|
||||||
$(dir_build)/%.o: $(dir_source)/%.c
|
$(dir_build)/%.o: $(dir_source)/%.c
|
||||||
@mkdir -p "$(@D)"
|
@mkdir -p "$(@D)"
|
||||||
|
@ -16,8 +16,8 @@ name := $(shell basename $(CURDIR))
|
|||||||
dir_source := source
|
dir_source := source
|
||||||
dir_build := build
|
dir_build := build
|
||||||
|
|
||||||
ASFLAGS := -mlittle-endian -mcpu=mpcore
|
ASFLAGS := -mcpu=mpcore -mfloat-abi=hard
|
||||||
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math -mthumb -mthumb-interwork
|
CFLAGS := -Wall -Wextra -MMD -MP -mthumb -mthumb-interwork $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
|
||||||
LDFLAGS := -nostdlib
|
LDFLAGS := -nostdlib
|
||||||
|
|
||||||
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
||||||
@ -35,7 +35,7 @@ $(name).bin: $(dir_build)/$(name).elf
|
|||||||
$(OC) -S -O binary $< $@
|
$(OC) -S -O binary $< $@
|
||||||
|
|
||||||
$(dir_build)/$(name).elf: $(objects)
|
$(dir_build)/$(name).elf: $(objects)
|
||||||
$(CC) $(LDFLAGS) -T linker.ld $(OUTPUT_OPTION) $^
|
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
||||||
|
|
||||||
$(dir_build)/%.o: $(dir_source)/%.c
|
$(dir_build)/%.o: $(dir_source)/%.c
|
||||||
@mkdir -p "$(@D)"
|
@mkdir -p "$(@D)"
|
||||||
|
Reference in New Issue
Block a user