2018-04-25 21:35:02 +01:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
.SUFFIXES:
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ifeq ($(strip $(DEVKITPRO)),)
|
|
|
|
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
|
|
|
endif
|
|
|
|
|
|
|
|
TOPDIR ?= $(CURDIR)
|
|
|
|
include $(DEVKITPRO)/libnx/switch_rules
|
|
|
|
|
2018-11-13 20:42:35 +00:00
|
|
|
AMSBRANCH := $(shell git symbolic-ref --short HEAD)
|
|
|
|
AMSREV := $(AMSBRANCH)-$(shell git rev-parse --short HEAD)
|
|
|
|
|
|
|
|
ifneq (, $(strip $(shell git status --porcelain 2>/dev/null)))
|
|
|
|
AMSREV := $(AMSREV)-dirty
|
|
|
|
endif
|
|
|
|
|
2019-05-03 01:55:50 +01:00
|
|
|
define _bin2o
|
|
|
|
bin2s $< | $(AS) -o $(@)
|
|
|
|
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _ | tr - _)`"_end[];" > `(echo $(<F) | tr . _ | tr - _)`.h
|
|
|
|
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _ | tr - _)`"[];" >> `(echo $(<F) | tr . _ | tr - _)`.h
|
|
|
|
echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _ | tr - _)`_size";" >> `(echo $(<F) | tr . _ | tr - _)`.h
|
|
|
|
endef
|
2018-11-13 20:42:35 +00:00
|
|
|
|
2018-04-25 21:35:02 +01: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
|
|
|
|
# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm".
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
TARGET := $(notdir $(CURDIR))
|
|
|
|
BUILD := build
|
2019-05-09 09:17:56 +01:00
|
|
|
SOURCES := source source/i2c_driver source/updater
|
2018-04-25 21:35:02 +01:00
|
|
|
DATA := data
|
2018-10-17 01:54:50 +01:00
|
|
|
INCLUDES := include ../../common/include
|
2018-04-25 21:35:02 +01:00
|
|
|
EXEFS_SRC := exefs_src
|
|
|
|
|
2018-11-13 20:42:35 +00:00
|
|
|
DEFINES := -DDISABLE_IPC -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
|
2018-04-25 21:35:02 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# options for code generation
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
|
|
|
|
|
|
|
|
CFLAGS := -g -Wall -O2 -ffunction-sections \
|
|
|
|
$(ARCH) $(DEFINES)
|
|
|
|
|
|
|
|
CFLAGS += $(INCLUDE) -D__SWITCH__
|
|
|
|
|
|
|
|
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
|
|
|
|
|
|
|
|
ASFLAGS := -g $(ARCH)
|
|
|
|
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
|
|
|
|
|
|
LIBS := -lstratosphere -lnx
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# list of directories containing libraries, this must be the top level containing
|
|
|
|
# include and lib
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/../libstratosphere
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# 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)) \
|
2019-05-03 01:55:50 +01:00
|
|
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) $(TOPDIR)/../../fusee/fusee-primary
|
2018-04-25 21:35:02 +01:00
|
|
|
|
|
|
|
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)))
|
2019-05-03 01:55:50 +01:00
|
|
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) fusee-primary.bin
|
2018-04-25 21:35:02 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# use CXX for linking C++ projects, CC for standard C
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
ifeq ($(strip $(CPPFILES)),)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
export LD := $(CC)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
else
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
export LD := $(CXX)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
endif
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
|
|
|
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
|
|
|
|
|
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
|
|
-I$(CURDIR)/$(BUILD)
|
|
|
|
|
|
|
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
|
|
|
|
|
|
export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
|
|
|
|
|
2018-05-15 18:38:04 +01:00
|
|
|
ifeq ($(strip $(CONFIG_JSON)),)
|
|
|
|
jsons := $(wildcard *.json)
|
|
|
|
ifneq (,$(findstring $(TARGET).json,$(jsons)))
|
|
|
|
export APP_JSON := $(TOPDIR)/$(TARGET).json
|
2018-04-25 21:35:02 +01:00
|
|
|
else
|
2018-05-15 18:38:04 +01:00
|
|
|
ifneq (,$(findstring config.json,$(jsons)))
|
|
|
|
export APP_JSON := $(TOPDIR)/config.json
|
2018-04-25 21:35:02 +01:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else
|
2018-05-15 18:38:04 +01:00
|
|
|
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
|
2018-04-25 21:35:02 +01:00
|
|
|
endif
|
|
|
|
|
2019-05-03 01:55:50 +01:00
|
|
|
.PHONY: $(BUILD) check_fusee clean all
|
2018-04-25 21:35:02 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
all: $(BUILD)
|
|
|
|
|
2019-05-03 01:55:50 +01:00
|
|
|
check_fusee:
|
|
|
|
@$(MAKE) -C $(TOPDIR)/../../fusee/fusee-primary all
|
|
|
|
|
|
|
|
$(BUILD): check_fusee
|
2018-04-25 21:35:02 +01:00
|
|
|
@[ -d $@ ] || mkdir -p $@
|
|
|
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
clean:
|
|
|
|
@echo clean ...
|
2019-05-03 01:55:50 +01:00
|
|
|
@$(MAKE) -C $(TOPDIR)/../../fusee/fusee-primary clean
|
2019-04-29 11:25:24 +01:00
|
|
|
@rm -fr $(BUILD) $(TARGET).kip $(TARGET).elf
|
2018-04-25 21:35:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
else
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
DEPENDS := $(OFILES:.o=.d)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# main targets
|
|
|
|
#---------------------------------------------------------------------------------
|
2019-04-29 11:25:24 +01:00
|
|
|
all : $(OUTPUT).kip
|
2018-04-25 21:35:02 +01:00
|
|
|
|
2019-04-29 11:25:24 +01:00
|
|
|
$(OUTPUT).kip : $(OUTPUT).elf
|
2018-04-25 21:35:02 +01:00
|
|
|
|
2019-04-29 11:25:24 +01:00
|
|
|
$(OUTPUT).elf : $(OFILES)
|
2018-04-25 21:35:02 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# you need a rule like this for each extension you use as binary data
|
|
|
|
#---------------------------------------------------------------------------------
|
2019-05-03 01:55:50 +01:00
|
|
|
fusee_primary.bin.o fusee_primary_bin.h: fusee-primary.bin
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
@echo $(notdir $<)
|
|
|
|
@$(_bin2o)
|
|
|
|
|
2018-04-25 21:35:02 +01:00
|
|
|
%.bin.o : %.bin
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
@echo $(notdir $<)
|
|
|
|
@$(bin2o)
|
|
|
|
|
|
|
|
-include $(DEPENDS)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
|
|
endif
|
|
|
|
#---------------------------------------------------------------------------------------
|