-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (57 loc) · 2.86 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Makefile - Build configuration file.
# Copyright (C) 2023 Makonede
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=path/to/devkitPro")
endif
include $(DEVKITPRO)/libnx/switch_rules
TARGET := LinkCannon
BUILD_DIR := .
ROOT_DIR := ..
LIB_DIR := $(ROOT_DIR)/lib
SOURCE_DIR := $(ROOT_DIR)/src
CONFIG_DIR := $(ROOT_DIR)/config
ALL_SOURCES_DIRS := $(shell find $(SOURCE_DIR) -type d)
LIBDIRS := $(PORTLIBS) $(LIBNX)
ALL_INCLUDE_DIRS := $(SOURCE_DIR) $(LIB_DIR)/nnheaders/include $(LIB_DIR)/sead/include $(LIB_DIR)/botw/src $(LIB_DIR)/botw/lib/agl/include
VPATH := $(foreach dir,$(ALL_SOURCES_DIRS),$(CURDIR)/$(dir))
LDSCRIPT := $(CONFIG_DIR)/symbols.ld
LINKER_VERSION_SCRIPT := $(CONFIG_DIR)/exported.ld
SWITCH_SPECS := $(CONFIG_DIR)/switch.specs
BOTW_DIR := $(LIB_DIR)/botw/src
SEAD_DIR := $(LIB_DIR)/sead/modules/src
CFILES := $(foreach dir,$(ALL_SOURCES_DIRS),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(ALL_SOURCES_DIRS),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(ALL_SOURCES_DIRS),$(notdir $(wildcard $(dir)/*.s)))
OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
DFILES := $(OFILES:.o=.d)
APP_JSON := $(CONFIG_DIR)/app.json
LD := $(CXX)
INCLUDE := $(foreach dir,$(ALL_INCLUDE_DIRS),-I$(CURDIR)/$(dir)) $(foreach dir,$(LIBDIRS),-I$(dir)/include)
DEFINES := -D__SWITCH__ -DSWITCH -DNNSDK -D_GNU_SOURCE -D_GLIBCXX_HAVE_ALIGNED_ALLOC $(EXTRA_DEFINES)
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
CFLAGS := -g -Wall -ffunction-sections -O3 $(ARCH) $(DEFINES) $(INCLUDE) $(BOTW_VERSION_DEFINES)
CXXFLAGS := $(CFLAGS) -fno-rtti -fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -enable-libstdcxx-allocator=new -fpermissive -std=gnu++23
ASFLAGS := -g $(ARCH)
LDFLAGS := -specs=$(SWITCH_SPECS) -g $(ARCH) -Wl,-Map,$(TARGET).map -Wl,--version-script=$(LINKER_VERSION_SCRIPT) -Wl,-init=LinkCannon_init -Wl,-fini=LinkCannon_fini -Wl,--export-dynamic -nodefaultlibs
LIBS := -lgcc -lstdc++ -u malloc
LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
DEPSDIR ?= .
.PHONY: all
all: $(TARGET).nso app.npdm
$(TARGET).elf: $(OFILES) $(SWITCH_SPECS)
app.npdm: $(APP_JSON)
npdmtool $(APP_JSON) $@ 2> /dev/null
-include $(DFILES)