# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export APP_ICON := $(TOPDIR)/$(ICON)
endif
+ifeq ($(strip $(NO_SMDH)),)
+ export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
+endif
+
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
-.PHONY: all
-all : $(OUTPUT).3dsx $(OUTPUT).smdh
-endif
+$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
+else
$(OUTPUT).3dsx : $(OUTPUT).elf
+endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export APP_ICON := $(TOPDIR)/$(ICON)
endif
+ifeq ($(strip $(NO_SMDH)),)
+ export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
+endif
+
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
-.PHONY: all
-all : $(OUTPUT).3dsx $(OUTPUT).smdh
-endif
+$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
+else
$(OUTPUT).3dsx : $(OUTPUT).elf
+endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files\r
#\r
# NO_SMDH: if set to anything, no SMDH file is generated.\r
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)\r
# APP_TITLE is the name of the app stored in the SMDH file (Optional)\r
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)\r
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)\r
# - icon.png\r
# - <libctru folder>/default_icon.png\r
#---------------------------------------------------------------------------------\r
-TARGET := $(notdir $(CURDIR))\r
-BUILD := build\r
-SOURCES := src\r
-DATA := data\r
-INCLUDES := include\r
-APP_TITLE := 3D Camera Example\r
-APP_DESCRIPTION := Example application that takes 3D pictures\r
-APP_AUTHOR := wchill\r
+TARGET := $(notdir $(CURDIR))\r
+BUILD := build\r
+SOURCES := source\r
+DATA := data\r
+INCLUDES := include\r
+#ROMFS := romfs\r
\r
#---------------------------------------------------------------------------------\r
# options for code generation\r
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard\r
\r
CFLAGS := -g -Wall -O2 -mword-relocations \\r
- -fomit-frame-pointer -ffast-math \\r
+ -fomit-frame-pointer -ffunction-sections \\r
$(ARCH)\r
\r
CFLAGS += $(INCLUDE) -DARM11 -D_3DS\r
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11\r
\r
ASFLAGS := -g $(ARCH)\r
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)\r
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections\r
\r
LIBS := -lctru -lm\r
\r
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))\r
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))\r
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))\r
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))\r
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))\r
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))\r
\r
#---------------------------------------------------------------------------------\r
#---------------------------------------------------------------------------------\r
\r
export OFILES := $(addsuffix .o,$(BINFILES)) \\r
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \\r
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)\r
\r
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \\r
export APP_ICON := $(TOPDIR)/$(ICON)\r
endif\r
\r
+ifeq ($(strip $(NO_SMDH)),)\r
+ export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh\r
+endif\r
+\r
+ifneq ($(ROMFS),)\r
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)\r
+endif\r
+\r
.PHONY: $(BUILD) clean all\r
\r
#---------------------------------------------------------------------------------\r
\r
$(BUILD):\r
@[ -d $@ ] || mkdir -p $@\r
- @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile\r
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile\r
\r
#---------------------------------------------------------------------------------\r
clean:\r
@echo clean ...\r
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf\r
\r
+\r
#---------------------------------------------------------------------------------\r
else\r
\r
# main targets\r
#---------------------------------------------------------------------------------\r
ifeq ($(strip $(NO_SMDH)),)\r
-.PHONY: all\r
-all : $(OUTPUT).3dsx $(OUTPUT).smdh\r
-endif\r
+$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh\r
+else\r
$(OUTPUT).3dsx : $(OUTPUT).elf\r
+endif\r
+\r
$(OUTPUT).elf : $(OFILES)\r
\r
#---------------------------------------------------------------------------------\r
@echo $(notdir $<)\r
@$(bin2o)\r
\r
-# WARNING: This is not the right way to do this! TODO: Do it right!\r
#---------------------------------------------------------------------------------\r
-%.vsh.o : %.vsh\r
+# rules for assembling GPU shaders\r
#---------------------------------------------------------------------------------\r
+define shader-as\r
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))\r
+ picasso -o $(CURBIN) $1\r
+ bin2s $(CURBIN) | $(AS) -o $@\r
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h\r
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h\r
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h\r
+endef\r
+\r
+%.shbin.o : %.v.pica %.g.pica\r
+ @echo $(notdir $^)\r
+ @$(call shader-as,$^)\r
+\r
+%.shbin.o : %.v.pica\r
+ @echo $(notdir $<)\r
+ @$(call shader-as,$<)\r
+\r
+%.shbin.o : %.shlist\r
@echo $(notdir $<)\r
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin\r
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@\r
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h\r
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h\r
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h\r
- @rm ../$(notdir $<).shbin\r
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))\r
\r
-include $(DEPENDS)\r
\r
# INCLUDES is a list of directories containing header files\r
#\r
# NO_SMDH: if set to anything, no SMDH file is generated.\r
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)\r
# APP_TITLE is the name of the app stored in the SMDH file (Optional)\r
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)\r
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)\r
# - icon.png\r
# - <libctru folder>/default_icon.png\r
#---------------------------------------------------------------------------------\r
-TARGET := $(notdir $(CURDIR))\r
-BUILD := build\r
-SOURCES := src\r
-DATA := data\r
-INCLUDES := include\r
-APP_TITLE := 3D Camera Example\r
-APP_DESCRIPTION := Example application that takes 3D pictures\r
-APP_AUTHOR := wchill\r
+TARGET := $(notdir $(CURDIR))\r
+BUILD := build\r
+SOURCES := source\r
+DATA := data\r
+INCLUDES := include\r
+#ROMFS := romfs\r
\r
#---------------------------------------------------------------------------------\r
# options for code generation\r
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard\r
\r
CFLAGS := -g -Wall -O2 -mword-relocations \\r
- -fomit-frame-pointer -ffast-math \\r
+ -fomit-frame-pointer -ffunction-sections \\r
$(ARCH)\r
\r
CFLAGS += $(INCLUDE) -DARM11 -D_3DS\r
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11\r
\r
ASFLAGS := -g $(ARCH)\r
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)\r
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections\r
\r
LIBS := -lctru -lm\r
\r
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))\r
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))\r
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))\r
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))\r
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))\r
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))\r
\r
#---------------------------------------------------------------------------------\r
#---------------------------------------------------------------------------------\r
\r
export OFILES := $(addsuffix .o,$(BINFILES)) \\r
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \\r
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)\r
\r
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \\r
export APP_ICON := $(TOPDIR)/$(ICON)\r
endif\r
\r
+ifeq ($(strip $(NO_SMDH)),)\r
+ export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh\r
+endif\r
+\r
+ifneq ($(ROMFS),)\r
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)\r
+endif\r
+\r
.PHONY: $(BUILD) clean all\r
\r
#---------------------------------------------------------------------------------\r
\r
$(BUILD):\r
@[ -d $@ ] || mkdir -p $@\r
- @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile\r
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile\r
\r
#---------------------------------------------------------------------------------\r
clean:\r
@echo clean ...\r
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf\r
\r
+\r
#---------------------------------------------------------------------------------\r
else\r
\r
# main targets\r
#---------------------------------------------------------------------------------\r
ifeq ($(strip $(NO_SMDH)),)\r
-.PHONY: all\r
-all : $(OUTPUT).3dsx $(OUTPUT).smdh\r
-endif\r
+$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh\r
+else\r
$(OUTPUT).3dsx : $(OUTPUT).elf\r
+endif\r
+\r
$(OUTPUT).elf : $(OFILES)\r
\r
#---------------------------------------------------------------------------------\r
@echo $(notdir $<)\r
@$(bin2o)\r
\r
-# WARNING: This is not the right way to do this! TODO: Do it right!\r
#---------------------------------------------------------------------------------\r
-%.vsh.o : %.vsh\r
+# rules for assembling GPU shaders\r
#---------------------------------------------------------------------------------\r
+define shader-as\r
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))\r
+ picasso -o $(CURBIN) $1\r
+ bin2s $(CURBIN) | $(AS) -o $@\r
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h\r
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h\r
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h\r
+endef\r
+\r
+%.shbin.o : %.v.pica %.g.pica\r
+ @echo $(notdir $^)\r
+ @$(call shader-as,$^)\r
+\r
+%.shbin.o : %.v.pica\r
+ @echo $(notdir $<)\r
+ @$(call shader-as,$<)\r
+\r
+%.shbin.o : %.shlist\r
@echo $(notdir $<)\r
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin\r
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@\r
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h\r
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h\r
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h\r
- @rm ../$(notdir $<).shbin\r
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))\r
\r
-include $(DEPENDS)\r
\r
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
- @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
- @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
- @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
- @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
-
-APP_TITLE := Head tracking demo
-APP_DESCRIPTION := This is a small demo app for the New 3DS head tracking.
-APP_AUTHOR := yellows8
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
-ifeq ($(strip $(NO_SMDH)),)
- export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif
.PHONY: $(BUILD) clean all
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
-CFLAGS := -g -Wall -O2\
- $(ARCH)
+CFLAGS := -g -Wall -O2 -mword-relocations \
+ -fomit-frame-pointer -ffunction-sections \
+ $(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
+#---------------------------------------------------------------------------------
+# rules for assembling GPU shaders
+#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
+ @echo $(notdir $<)
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
+
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
+# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
SOURCES := source
DATA := data
INCLUDES := include
+#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
- -fomit-frame-pointer -ffast-math \
+ -fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
-LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
LIBS := -lctru -lm
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
+ifneq ($(ROMFS),)
+ export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
- @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
+
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
-%.vsh.o : %.vsh
+# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
+define shader-as
+ $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(CURBIN) $1
+ bin2s $(CURBIN) | $(AS) -o $@
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
+ echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
@echo $(notdir $<)
- @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
- @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
- @rm ../$(notdir $<).shbin
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)