2016-04-12 04:48:35 +02:00
|
|
|
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
|
2016-04-01 14:27:31 +02:00
|
|
|
|
|
|
|
ifeq ($(strip $(DEVKITARM)),)
|
|
|
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
|
|
endif
|
|
|
|
|
|
|
|
include $(DEVKITARM)/3ds_rules
|
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
CC := arm-none-eabi-gcc
|
|
|
|
AS := arm-none-eabi-as
|
|
|
|
LD := arm-none-eabi-ld
|
|
|
|
OC := arm-none-eabi-objcopy
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
name := $(shell basename $(CURDIR))
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
dir_source := source
|
|
|
|
dir_build := build
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
ASFLAGS := -mlittle-endian -mcpu=mpcore
|
|
|
|
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -fshort-wchar -std=c11 -Wno-main -O2 -flto -ffast-math -mthumb -mthumb-interwork
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
|
|
|
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
|
|
|
$(call rwildcard, $(dir_source), *.s *.c)))
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
.PHONY: all
|
|
|
|
all: $(name).bin
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
.PHONY: clean
|
2016-04-01 14:27:31 +02:00
|
|
|
clean:
|
2016-04-12 04:48:35 +02:00
|
|
|
@rm -rf $(dir_build)
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
$(name).bin: $(dir_build)/$(name).elf
|
|
|
|
$(OC) -S -O binary $< $@
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
$(dir_build)/$(name).elf: $(objects)
|
|
|
|
$(CC) -nostartfiles -T linker.ld $(OUTPUT_OPTION) $^
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
$(dir_build)/%.o: $(dir_source)/%.c
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
2016-04-01 14:27:31 +02:00
|
|
|
|
2016-04-12 04:48:35 +02:00
|
|
|
$(dir_build)/%.o: $(dir_source)/%.s
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
$(COMPILE.s) $(OUTPUT_OPTION) $<
|
|
|
|
include $(call rwildcard, $(dir_build), *.d)
|