|
| 1 | +.SUFFIXES: |
| 2 | + |
| 3 | +ifeq ($(strip $(DEVKITPRO)),) |
| 4 | +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro") |
| 5 | +endif |
| 6 | + |
| 7 | +TOPDIR ?= $(CURDIR) |
| 8 | +include $(DEVKITPRO)/libnx/switch_rules |
| 9 | + |
| 10 | +TARGET := xor.play |
| 11 | +BUILD := build |
| 12 | +SOURCES := Source |
| 13 | +DATA := data |
| 14 | +INCLUDES := Source |
| 15 | +EXEFS_SRC := exefs_src |
| 16 | + |
| 17 | +KIP_NAME := xor:play |
| 18 | +KIP_HEAP := 950000 |
| 19 | +KIP_TITLEID := 31200000000000AB |
| 20 | + |
| 21 | +ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE |
| 22 | + |
| 23 | +CFLAGS := -g -Wall -Wextra -O2 -fpermissive -ffunction-sections \ |
| 24 | + $(ARCH) $(DEFINES) |
| 25 | + |
| 26 | +CFLAGS += $(INCLUDE) -D__SWITCH__ |
| 27 | +CFLAGS += -DKIP_NAME=\"$(KIP_NAME)\" -DKIP_HEAP=0x$(KIP_HEAP) -DKIP_TITLEID=0x$(KIP_TITLEID) |
| 28 | + |
| 29 | +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 |
| 30 | + |
| 31 | +ASFLAGS := -g $(ARCH) |
| 32 | +LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) |
| 33 | + |
| 34 | +LIBS := -lfreetype -lSDL2_mixer -lmodplug -lmpg123 -lvorbisidec -logg -lSDL2_ttf -lSDL2_gfx -lSDL2_image -lpng -ljpeg `sdl2-config --libs` `freetype-config --libs` -lnx -lm |
| 35 | + |
| 36 | +LIBDIRS := $(PORTLIBS) $(LIBNX) |
| 37 | + |
| 38 | +ifneq ($(BUILD),$(notdir $(CURDIR))) |
| 39 | + |
| 40 | +export OUTPUT := $(CURDIR)/$(TARGET) |
| 41 | +export TOPDIR := $(CURDIR) |
| 42 | + |
| 43 | +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ |
| 44 | + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) |
| 45 | + |
| 46 | +export DEPSDIR := $(CURDIR)/$(BUILD) |
| 47 | + |
| 48 | +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) |
| 49 | +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) |
| 50 | +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) |
| 51 | +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) |
| 52 | + |
| 53 | +ifeq ($(strip $(CPPFILES)),) |
| 54 | + export LD := $(CC) |
| 55 | +else |
| 56 | + export LD := $(CXX) |
| 57 | +endif |
| 58 | + |
| 59 | +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) |
| 60 | +export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) |
| 61 | +export OFILES := $(OFILES_BIN) $(OFILES_SRC) |
| 62 | +export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) |
| 63 | + |
| 64 | +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ |
| 65 | + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ |
| 66 | + -I$(CURDIR)/$(BUILD) |
| 67 | + |
| 68 | +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) |
| 69 | + |
| 70 | +export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC) |
| 71 | + |
| 72 | +ifeq ($(strip $(CONFIG_JSON)),) |
| 73 | + jsons := $(wildcard *.json) |
| 74 | + ifneq (,$(findstring $(TARGET).json,$(jsons))) |
| 75 | + export APP_JSON := $(TOPDIR)/$(TARGET).json |
| 76 | + else |
| 77 | + ifneq (,$(findstring config.json,$(jsons))) |
| 78 | + export APP_JSON := $(TOPDIR)/config.json |
| 79 | + endif |
| 80 | + endif |
| 81 | +else |
| 82 | + export APP_JSON := $(TOPDIR)/$(CONFIG_JSON) |
| 83 | +endif |
| 84 | + |
| 85 | +.PHONY: $(BUILD) clean all |
| 86 | + |
| 87 | +all: $(BUILD) |
| 88 | + |
| 89 | +$(BUILD): |
| 90 | + @[ -d $@ ] || mkdir -p $@ |
| 91 | + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile |
| 92 | + |
| 93 | +clean: |
| 94 | + @echo clean ... |
| 95 | + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).kip |
| 96 | + |
| 97 | +else |
| 98 | +.PHONY: all |
| 99 | + |
| 100 | +DEPENDS := $(OFILES:.o=.d) |
| 101 | + |
| 102 | +all : $(OUTPUT).kip |
| 103 | + |
| 104 | +$(OUTPUT).kip : $(OUTPUT).elf |
| 105 | + |
| 106 | +$(OUTPUT).elf : $(OFILES) |
| 107 | + |
| 108 | +$(OFILES_SRC) : $(HFILES_BIN) |
| 109 | + |
| 110 | +%.bin.o %_bin.h : %.bin |
| 111 | + @echo $(notdir $<) |
| 112 | + @$(bin2o) |
| 113 | + |
| 114 | +-include $(DEPENDS) |
| 115 | + |
| 116 | +endif |
0 commit comments