|
| 1 | +#--------------------------------------------------------------------------------- |
| 2 | +.SUFFIXES: |
| 3 | +#--------------------------------------------------------------------------------- |
| 4 | + |
| 5 | +ifeq ($(strip $(DEVKITARM)),) |
| 6 | +$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") |
| 7 | +endif |
| 8 | + |
| 9 | +TOPDIR ?= $(CURDIR) |
| 10 | +include $(DEVKITARM)/3ds_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 | +# |
| 19 | +# NO_SMDH: if set to anything, no SMDH file is generated. |
| 20 | +# APP_TITLE is the name of the app stored in the SMDH file (Optional) |
| 21 | +# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional) |
| 22 | +# APP_AUTHOR is the author of the app stored in the SMDH file (Optional) |
| 23 | +# ICON is the filename of the icon (.png), relative to the project folder. |
| 24 | +# If not set, it attempts to use one of the following (in this order): |
| 25 | +# - <Project name>.png |
| 26 | +# - icon.png |
| 27 | +# - <libctru folder>/default_icon.png |
| 28 | +#--------------------------------------------------------------------------------- |
| 29 | +TARGET := $(notdir $(CURDIR)) |
| 30 | +BUILD := build |
| 31 | +SOURCES := source |
| 32 | +DATA := data |
| 33 | +INCLUDES := include |
| 34 | + |
| 35 | +APP_TITLE := sysUpdater |
| 36 | +APP_DESCRIPTION := sysUpdater |
| 37 | +APP_AUTHOR := profi200 |
| 38 | +ICON := /app/icon48x48.png |
| 39 | + |
| 40 | +#--------------------------------------------------------------------------------- |
| 41 | +# options for code generation |
| 42 | +#--------------------------------------------------------------------------------- |
| 43 | +ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard |
| 44 | + |
| 45 | +CFLAGS := -g -Wall -O2 -mword-relocations \ |
| 46 | + -fomit-frame-pointer -ffast-math \ |
| 47 | + $(ARCH) |
| 48 | + |
| 49 | +CFLAGS += $(INCLUDE) -DARM11 -D_3DS |
| 50 | + |
| 51 | +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 |
| 52 | + |
| 53 | +ASFLAGS := -g $(ARCH) |
| 54 | +LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) |
| 55 | + |
| 56 | +LIBS := -lctru -lm |
| 57 | + |
| 58 | +#--------------------------------------------------------------------------------- |
| 59 | +# list of directories containing libraries, this must be the top level containing |
| 60 | +# include and lib |
| 61 | +#--------------------------------------------------------------------------------- |
| 62 | +LIBDIRS := $(CTRULIB) |
| 63 | + |
| 64 | + |
| 65 | +#--------------------------------------------------------------------------------- |
| 66 | +# no real need to edit anything past this point unless you need to add additional |
| 67 | +# rules for different file extensions |
| 68 | +#--------------------------------------------------------------------------------- |
| 69 | +ifneq ($(BUILD),$(notdir $(CURDIR))) |
| 70 | +#--------------------------------------------------------------------------------- |
| 71 | + |
| 72 | +export OUTPUT := $(CURDIR)/$(TARGET) |
| 73 | +export TOPDIR := $(CURDIR) |
| 74 | + |
| 75 | +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ |
| 76 | + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) |
| 77 | + |
| 78 | +export DEPSDIR := $(CURDIR)/$(BUILD) |
| 79 | + |
| 80 | +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) |
| 81 | +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) |
| 82 | +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) |
| 83 | +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) |
| 84 | + |
| 85 | +#--------------------------------------------------------------------------------- |
| 86 | +# use CXX for linking C++ projects, CC for standard C |
| 87 | +#--------------------------------------------------------------------------------- |
| 88 | +ifeq ($(strip $(CPPFILES)),) |
| 89 | +#--------------------------------------------------------------------------------- |
| 90 | + export LD := $(CC) |
| 91 | +#--------------------------------------------------------------------------------- |
| 92 | +else |
| 93 | +#--------------------------------------------------------------------------------- |
| 94 | + export LD := $(CXX) |
| 95 | +#--------------------------------------------------------------------------------- |
| 96 | +endif |
| 97 | +#--------------------------------------------------------------------------------- |
| 98 | + |
| 99 | +export OFILES := $(addsuffix .o,$(BINFILES)) \ |
| 100 | + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) |
| 101 | + |
| 102 | +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ |
| 103 | + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ |
| 104 | + -I$(CURDIR)/$(BUILD) |
| 105 | + |
| 106 | +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) |
| 107 | + |
| 108 | +ifeq ($(strip $(ICON)),) |
| 109 | + icons := $(wildcard *.png) |
| 110 | + ifneq (,$(findstring $(TARGET).png,$(icons))) |
| 111 | + export APP_ICON := $(TOPDIR)/$(TARGET).png |
| 112 | + else |
| 113 | + ifneq (,$(findstring icon.png,$(icons))) |
| 114 | + export APP_ICON := $(TOPDIR)/icon.png |
| 115 | + endif |
| 116 | + endif |
| 117 | +else |
| 118 | + export APP_ICON := $(TOPDIR)/$(ICON) |
| 119 | +endif |
| 120 | + |
| 121 | +ifeq ($(strip $(NO_SMDH)),) |
| 122 | + export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh |
| 123 | +endif |
| 124 | + |
| 125 | +.PHONY: $(BUILD) clean all |
| 126 | + |
| 127 | +#--------------------------------------------------------------------------------- |
| 128 | +all: $(BUILD) |
| 129 | + |
| 130 | +$(BUILD): |
| 131 | + @[ -d $@ ] || mkdir -p $@ |
| 132 | + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile |
| 133 | + |
| 134 | +#--------------------------------------------------------------------------------- |
| 135 | +clean: |
| 136 | + @echo clean ... |
| 137 | + @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf |
| 138 | + |
| 139 | + |
| 140 | +#--------------------------------------------------------------------------------- |
| 141 | +else |
| 142 | + |
| 143 | +DEPENDS := $(OFILES:.o=.d) |
| 144 | + |
| 145 | +#--------------------------------------------------------------------------------- |
| 146 | +# main targets |
| 147 | +#--------------------------------------------------------------------------------- |
| 148 | +ifeq ($(strip $(NO_SMDH)),) |
| 149 | +$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh |
| 150 | +else |
| 151 | +$(OUTPUT).3dsx : $(OUTPUT).elf |
| 152 | +endif |
| 153 | + |
| 154 | +$(OUTPUT).elf : $(OFILES) |
| 155 | + |
| 156 | +#--------------------------------------------------------------------------------- |
| 157 | +# you need a rule like this for each extension you use as binary data |
| 158 | +#--------------------------------------------------------------------------------- |
| 159 | +%.bin.o : %.bin |
| 160 | +#--------------------------------------------------------------------------------- |
| 161 | + @echo $(notdir $<) |
| 162 | + @$(bin2o) |
| 163 | + |
| 164 | +# WARNING: This is not the right way to do this! TODO: Do it right! |
| 165 | +#--------------------------------------------------------------------------------- |
| 166 | +%.vsh.o : %.vsh |
| 167 | +#--------------------------------------------------------------------------------- |
| 168 | + @echo $(notdir $<) |
| 169 | + @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin |
| 170 | + @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@ |
| 171 | + @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h |
| 172 | + @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h |
| 173 | + @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h |
| 174 | + @rm ../$(notdir $<).shbin |
| 175 | + |
| 176 | +-include $(DEPENDS) |
| 177 | + |
| 178 | +#--------------------------------------------------------------------------------------- |
| 179 | +endif |
| 180 | +#--------------------------------------------------------------------------------------- |
0 commit comments