|
| 1 | +#--------------------------------------------------------------------------------- |
| 2 | +.SUFFIXES: |
| 3 | +#--------------------------------------------------------------------------------- |
| 4 | + |
| 5 | +ifeq ($(strip $(DEVKITPRO)),) |
| 6 | +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro") |
| 7 | +endif |
| 8 | + |
| 9 | +TOPDIR ?= $(CURDIR) |
| 10 | +include $(DEVKITPRO)/libnx/switch_rules |
| 11 | + |
| 12 | +#--------------------------------------------------------------------------------- |
| 13 | +# TARGET is the name of the output |
| 14 | +# BUILD is the directory where object files & intermediate files will be placed |
| 15 | +# SOURCES is a list of directories containing source code |
| 16 | +# DATA is a list of directories containing data files |
| 17 | +# INCLUDES is a list of directories containing header files |
| 18 | +# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". |
| 19 | +# |
| 20 | +# NO_ICON: if set to anything, do not use icon. |
| 21 | +# NO_NACP: if set to anything, no .nacp file is generated. |
| 22 | +# APP_TITLE is the name of the app stored in the .nacp file (Optional) |
| 23 | +# APP_AUTHOR is the author of the app stored in the .nacp file (Optional) |
| 24 | +# APP_VERSION is the version of the app stored in the .nacp file (Optional) |
| 25 | +# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional) |
| 26 | +# ICON is the filename of the icon (.jpg), relative to the project folder. |
| 27 | +# If not set, it attempts to use one of the following (in this order): |
| 28 | +# - <Project name>.jpg |
| 29 | +# - icon.jpg |
| 30 | +# - <libnx folder>/default_icon.jpg |
| 31 | +#--------------------------------------------------------------------------------- |
| 32 | + |
| 33 | +APP_VERSION := 1.0 |
| 34 | +ICON := icon.jpg |
| 35 | +APP_TITLE := Weather Text |
| 36 | +APP_AUTHOR := ELY M. |
| 37 | + |
| 38 | +TARGET := $(notdir $(CURDIR)) |
| 39 | +BUILD := build |
| 40 | +SOURCES := source |
| 41 | +DATA := data |
| 42 | +INCLUDES := include |
| 43 | +EXEFS_SRC := exefs_src |
| 44 | + |
| 45 | +#--------------------------------------------------------------------------------- |
| 46 | +# options for code generation |
| 47 | +#--------------------------------------------------------------------------------- |
| 48 | +ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE |
| 49 | + |
| 50 | +CFLAGS := -g -Wall -O2 -ffunction-sections \ |
| 51 | + $(ARCH) $(DEFINES) |
| 52 | + |
| 53 | +CFLAGS += $(INCLUDE) -DSWITCH |
| 54 | + |
| 55 | +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 |
| 56 | + |
| 57 | +ASFLAGS := -g $(ARCH) |
| 58 | +LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) |
| 59 | + |
| 60 | +LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lz -lnx |
| 61 | + |
| 62 | +#--------------------------------------------------------------------------------- |
| 63 | +# list of directories containing libraries, this must be the top level containing |
| 64 | +# include and lib |
| 65 | +#--------------------------------------------------------------------------------- |
| 66 | +LIBDIRS := $(PORTLIBS) $(LIBNX) |
| 67 | + |
| 68 | + |
| 69 | +#--------------------------------------------------------------------------------- |
| 70 | +# no real need to edit anything past this point unless you need to add additional |
| 71 | +# rules for different file extensions |
| 72 | +#--------------------------------------------------------------------------------- |
| 73 | +ifneq ($(BUILD),$(notdir $(CURDIR))) |
| 74 | +#--------------------------------------------------------------------------------- |
| 75 | + |
| 76 | +export OUTPUT := $(CURDIR)/$(TARGET) |
| 77 | +export TOPDIR := $(CURDIR) |
| 78 | + |
| 79 | +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ |
| 80 | + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) |
| 81 | + |
| 82 | +export DEPSDIR := $(CURDIR)/$(BUILD) |
| 83 | + |
| 84 | +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) |
| 85 | +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) |
| 86 | +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) |
| 87 | +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) |
| 88 | + |
| 89 | +#--------------------------------------------------------------------------------- |
| 90 | +# use CXX for linking C++ projects, CC for standard C |
| 91 | +#--------------------------------------------------------------------------------- |
| 92 | +ifeq ($(strip $(CPPFILES)),) |
| 93 | +#--------------------------------------------------------------------------------- |
| 94 | + export LD := $(CC) |
| 95 | +#--------------------------------------------------------------------------------- |
| 96 | +else |
| 97 | +#--------------------------------------------------------------------------------- |
| 98 | + export LD := $(CXX) |
| 99 | +#--------------------------------------------------------------------------------- |
| 100 | +endif |
| 101 | +#--------------------------------------------------------------------------------- |
| 102 | + |
| 103 | +export OFILES := $(addsuffix .o,$(BINFILES)) \ |
| 104 | + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) |
| 105 | + |
| 106 | +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ |
| 107 | + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ |
| 108 | + -I$(CURDIR)/$(BUILD) |
| 109 | + |
| 110 | +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) |
| 111 | + |
| 112 | +export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC) |
| 113 | + |
| 114 | +ifeq ($(strip $(ICON)),) |
| 115 | + icons := $(wildcard *.jpg) |
| 116 | + ifneq (,$(findstring $(TARGET).jpg,$(icons))) |
| 117 | + export APP_ICON := $(TOPDIR)/$(TARGET).jpg |
| 118 | + else |
| 119 | + ifneq (,$(findstring icon.jpg,$(icons))) |
| 120 | + export APP_ICON := $(TOPDIR)/icon.jpg |
| 121 | + endif |
| 122 | + endif |
| 123 | +else |
| 124 | + export APP_ICON := $(TOPDIR)/$(ICON) |
| 125 | +endif |
| 126 | + |
| 127 | +ifeq ($(strip $(NO_ICON)),) |
| 128 | + export NROFLAGS += --icon=$(APP_ICON) |
| 129 | +endif |
| 130 | + |
| 131 | +ifeq ($(strip $(NO_NACP)),) |
| 132 | + export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp |
| 133 | +endif |
| 134 | + |
| 135 | +ifneq ($(APP_TITLEID),) |
| 136 | + export NACPFLAGS += --titleid=$(APP_TITLEID) |
| 137 | +endif |
| 138 | + |
| 139 | +.PHONY: $(BUILD) clean all |
| 140 | + |
| 141 | +#--------------------------------------------------------------------------------- |
| 142 | +all: $(BUILD) |
| 143 | + |
| 144 | +$(BUILD): |
| 145 | + @[ -d $@ ] || mkdir -p $@ |
| 146 | + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile |
| 147 | + |
| 148 | +#--------------------------------------------------------------------------------- |
| 149 | +clean: |
| 150 | + @echo clean ... |
| 151 | + @rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf |
| 152 | + |
| 153 | + |
| 154 | +#--------------------------------------------------------------------------------- |
| 155 | +else |
| 156 | +.PHONY: all |
| 157 | + |
| 158 | +DEPENDS := $(OFILES:.o=.d) |
| 159 | + |
| 160 | +#--------------------------------------------------------------------------------- |
| 161 | +# main targets |
| 162 | +#--------------------------------------------------------------------------------- |
| 163 | +all : $(OUTPUT).pfs0 $(OUTPUT).nro |
| 164 | + |
| 165 | +$(OUTPUT).pfs0 : $(OUTPUT).nso |
| 166 | + |
| 167 | +$(OUTPUT).nso : $(OUTPUT).elf |
| 168 | + |
| 169 | +ifeq ($(strip $(NO_NACP)),) |
| 170 | +$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp |
| 171 | +else |
| 172 | +$(OUTPUT).nro : $(OUTPUT).elf |
| 173 | +endif |
| 174 | + |
| 175 | +$(OUTPUT).elf : $(OFILES) |
| 176 | + |
| 177 | +#--------------------------------------------------------------------------------- |
| 178 | +# you need a rule like this for each extension you use as binary data |
| 179 | +#--------------------------------------------------------------------------------- |
| 180 | +%.bin.o : %.bin |
| 181 | +#--------------------------------------------------------------------------------- |
| 182 | + @echo $(notdir $<) |
| 183 | + @$(bin2o) |
| 184 | + |
| 185 | +-include $(DEPENDS) |
| 186 | + |
| 187 | +#--------------------------------------------------------------------------------------- |
| 188 | +endif |
| 189 | +#--------------------------------------------------------------------------------------- |
0 commit comments