forked from tallbl0nde/NX-Activity-Log
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
168 lines (139 loc) · 7.34 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
# Check for DevkitPro before attempting to compile
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
# TOPDIR stores the top level of the directory (ie. the current folder)
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
# Options for compilation
# TARGET: Name of the output file(s)
# BUILD: Directory where object files & intermediate files will be placed
# SOURCES: List of directories containing source code
# INCLUDES: List of directories containing header files
# ROMFS: Directory containing data to be added to RomFS
# OUTDIR: Directory to structure sdcard contents
# FDIR: Directory where forwarder makefile/files/output is
# FFILE: Name of forwarder nsp
#---------------------------------------------------------------------------------
TARGET := NX-Activity-Log
BUILD := build
SOURCES := source source/nx source/ui source/ui/screen source/ui/element source/ui/overlay source/utils
INCLUDES := include include/nx include/ui include/ui/screen include/ui/element include/ui/overlay include/utils
ROMFS := romfs
OUTDIR := sdcard
FDIR := forwarder
FFILE := exefs.nsp
#---------------------------------------------------------------------------------
# Application version
#---------------------------------------------------------------------------------
VER_MAJOR := 1
VER_MINOR := 3
VER_MICRO := 0
#---------------------------------------------------------------------------------
# Options for .nacp information
#---------------------------------------------------------------------------------
APP_TITLE := NX Activity Log
APP_AUTHOR := tallbl0nde
APP_VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_MICRO)
ICON := img/icon.jpg
#---------------------------------------------------------------------------------
# Options for code generation
# LIBS: Libraries to link against
# (I dunno what the rest is)
#---------------------------------------------------------------------------------
LIBS := -lAether -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lminizip -lnx `sdl2-config --libs` -lSDL2_ttf `freetype-config --libs` -lSDL2_gfx -lSDL2_image -lpng -ljpeg -lwebp -lSimpleIniParser
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O2 -ffunction-sections $(ARCH) $(DEFINES) $(INCLUDE) -D__SWITCH__ \
-DVER_MAJOR=$(VER_MAJOR) -DVER_MINOR=$(VER_MINOR) -DVER_MICRO=$(VER_MICRO) -DVER_STRING=\"$(VER_MAJOR).$(VER_MINOR).$(VER_MICRO)\" \
`freetype-config --cflags` `sdl2-config --cflags`
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/libs/SimpleIniParser $(CURDIR)/libs/Aether
#---------------------------------------------------------------------------------
# This is all wizardry to me also
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) $(foreach dir,$(DATA),$(CURDIR)/$(dir))
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)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
export LD := $(CXX)
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
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)
#---------------------------------------------------------------------------------
# End of wizardry
# Set .nro flags
#---------------------------------------------------------------------------------
# Add icon and nacp flags (as these will always be present)
export APP_ICON := $(TOPDIR)/$(ICON)
export NROFLAGS += --icon=$(APP_ICON) --nacp=$(CURDIR)/$(TARGET).nacp --romfsdir=$(CURDIR)/$(ROMFS)
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
# Default build target: everything
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
ifeq ($(wildcard $(CURDIR)/libs/Aether/LICENSE),)
@$(error "Please run 'git submodule update --init' before running 'make'")
endif
@[ -d $@ ] || mkdir -p $@
@$(MAKE) -C $(CURDIR)/libs/SimpleIniParser -f $(CURDIR)/libs/SimpleIniParser/Makefile
@$(MAKE) -C $(CURDIR)/libs/Aether -f $(CURDIR)/libs/Aether/Makefile
@$(MAKE) -C $(CURDIR)/$(FDIR) -f $(CURDIR)/$(FDIR)/Makefile
@cp $(FDIR)/$(FFILE) $(ROMFS)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
# Clean removes all build files + sdcard directory
#---------------------------------------------------------------------------------
clean:
@echo Cleaning ALL build files...
@rm -rf $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf $(OUTDIR) $(ROMFS)/$(FFILE)
@$(MAKE) -C $(CURDIR)/libs/SimpleIniParser -f $(CURDIR)/libs/SimpleIniParser/Makefile clean
@$(MAKE) -C $(CURDIR)/libs/Aether -f $(CURDIR)/libs/Aether/Makefile clean
@$(MAKE) -C $(CURDIR)/$(FDIR) -f $(CURDIR)/$(FDIR)/Makefile clean
@echo Done!
#---------------------------------------------------------------------------------
else
.PHONY: all
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# Main target
#---------------------------------------------------------------------------------
# Important binaries are copied into approporiate places
# (I gave up figuring out how to do it properly)
all: $(OUTPUT).nro
@mkdir -p $(TOPDIR)/$(OUTDIR)/switch/$(TARGET)
@cp $(OUTPUT).nro $(TOPDIR)/$(OUTDIR)/switch/$(TARGET)/
@echo
@echo "All done! Simply copy the folders within ./$(OUTDIR) to your SD card :)"
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
$(OUTPUT).elf : $(OFILES)
$(OFILES_SRC) : $(HFILES_BIN)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------