]> Chaos Git - corbenik/ctrulib.git/commitdiff
Update template Makefile with the following changes:
authorfincs <fincs.alt1@gmail.com>
Sat, 21 Nov 2015 00:12:33 +0000 (01:12 +0100)
committerfincs <fincs.alt1@gmail.com>
Sat, 21 Nov 2015 00:12:33 +0000 (01:12 +0100)
- Add RomFS embedding support
- Add proper rules for assembling GPU shaders
- Use -ffunction-sections and --gc-sections by default
- Remove -ffast-math

21 files changed:
examples/app_launch/Makefile
examples/audio/mic/Makefile
examples/camera/image/Makefile
examples/camera/video/Makefile
examples/get_system_language/Makefile
examples/graphics/printing/both-screen-text/Makefile
examples/graphics/printing/colored-text/Makefile
examples/graphics/printing/hello-world/Makefile
examples/graphics/printing/multiple-windows-text/Makefile
examples/http/Makefile
examples/input/read-controls/Makefile
examples/input/touch-screen/Makefile
examples/libapplet_launch/Makefile
examples/mvd/Makefile
examples/qtm/Makefile
examples/romfs/Makefile
examples/sdmc/Makefile
examples/templates/application/Makefile
examples/templates/library/Makefile
examples/threads/event/Makefile
examples/time/rtc/Makefile

index 8dce08d22b4a5acf90c270bf2534e37e5f6bcc42..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -113,6 +118,14 @@ else
        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
 
 #---------------------------------------------------------------------------------
@@ -137,10 +150,11 @@ DEPENDS   :=      $(OFILES:.o=.d)
 # 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)
 
 #---------------------------------------------------------------------------------
@@ -151,17 +165,29 @@ $(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)
 
index 8dce08d22b4a5acf90c270bf2534e37e5f6bcc42..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -113,6 +118,14 @@ else
        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
 
 #---------------------------------------------------------------------------------
@@ -137,10 +150,11 @@ DEPENDS   :=      $(OFILES:.o=.d)
 # 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)
 
 #---------------------------------------------------------------------------------
@@ -151,17 +165,29 @@ $(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)
 
index b50b77f3f36364721281094a6ce1dbe2f2544c21..6db27db027031ccb91a984a2f2f64ad4f4703e46 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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
@@ -26,14 +27,12 @@ include $(DEVKITARM)/3ds_rules
 #     - 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
@@ -41,7 +40,7 @@ APP_AUTHOR      :=  wchill
 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
@@ -49,7 +48,7 @@ CFLAGS        +=      $(INCLUDE) -DARM11 -D_3DS
 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
@@ -78,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 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
@@ -95,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------\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
@@ -116,6 +118,14 @@ else
        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
@@ -123,13 +133,14 @@ all: $(BUILD)
 \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
@@ -139,10 +150,11 @@ DEPENDS   :=      $(OFILES:.o=.d)
 # 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
@@ -153,17 +165,29 @@ $(OUTPUT).elf     :       $(OFILES)
        @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
index b50b77f3f36364721281094a6ce1dbe2f2544c21..6db27db027031ccb91a984a2f2f64ad4f4703e46 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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
@@ -26,14 +27,12 @@ include $(DEVKITARM)/3ds_rules
 #     - 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
@@ -41,7 +40,7 @@ APP_AUTHOR      :=  wchill
 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
@@ -49,7 +48,7 @@ CFLAGS        +=      $(INCLUDE) -DARM11 -D_3DS
 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
@@ -78,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 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
@@ -95,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------\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
@@ -116,6 +118,14 @@ else
        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
@@ -123,13 +133,14 @@ all: $(BUILD)
 \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
@@ -139,10 +150,11 @@ DEPENDS   :=      $(OFILES:.o=.d)
 # 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
@@ -153,17 +165,29 @@ $(OUTPUT).elf     :       $(OFILES)
        @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
index e6815d1786dcb56797be402260be6ea06d36072c..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -156,17 +165,29 @@ $(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)
 
index d75f5482ead557cbc72a0e2aea60e01bbebfb590..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -124,7 +133,7 @@ all: $(BUILD)
 
 $(BUILD):
        @[ -d $@ ] || mkdir -p $@
-       @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+       @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
 
 #---------------------------------------------------------------------------------
 clean:
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index d75f5482ead557cbc72a0e2aea60e01bbebfb590..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -124,7 +133,7 @@ all: $(BUILD)
 
 $(BUILD):
        @[ -d $@ ] || mkdir -p $@
-       @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+       @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
 
 #---------------------------------------------------------------------------------
 clean:
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index e881aac4c3be2a7f4091572a37a3d7d83ebaaeb9..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index d75f5482ead557cbc72a0e2aea60e01bbebfb590..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -124,7 +133,7 @@ all: $(BUILD)
 
 $(BUILD):
        @[ -d $@ ] || mkdir -p $@
-       @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+       @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
 
 #---------------------------------------------------------------------------------
 clean:
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index e881aac4c3be2a7f4091572a37a3d7d83ebaaeb9..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index d75f5482ead557cbc72a0e2aea60e01bbebfb590..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -124,7 +133,7 @@ all: $(BUILD)
 
 $(BUILD):
        @[ -d $@ ] || mkdir -p $@
-       @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+       @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
 
 #---------------------------------------------------------------------------------
 clean:
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index e881aac4c3be2a7f4091572a37a3d7d83ebaaeb9..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index e881aac4c3be2a7f4091572a37a3d7d83ebaaeb9..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index e881aac4c3be2a7f4091572a37a3d7d83ebaaeb9..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index 7606ca6ce45d82a7cca439f81584a0d6475c8325..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,10 +32,7 @@ BUILD                :=      build
 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
@@ -42,7 +40,7 @@ APP_AUTHOR := yellows8
 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
@@ -50,7 +48,7 @@ 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
 
@@ -79,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -96,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -121,8 +122,8 @@ ifeq ($(strip $(NO_SMDH)),)
        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
@@ -164,17 +165,29 @@ $(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)
 
index 014079ea82e7669855175f577fadb4b2fbe15e45..949e44f36a21a21e257b581acc07a37aa85787c0 100644 (file)
@@ -40,7 +40,7 @@ ROMFS         :=      romfs
 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
@@ -48,7 +48,7 @@ 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
 
@@ -77,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -94,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -162,17 +165,29 @@ $(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)
 
index e881aac4c3be2a7f4091572a37a3d7d83ebaaeb9..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)
 
index e6815d1786dcb56797be402260be6ea06d36072c..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -156,17 +165,29 @@ $(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)
 
index 887909ff6168c563b168a2bf1e244eda6319f9c8..3ea616cc82399daa37a02bb3c281c976af1f62b0 100644 (file)
@@ -26,8 +26,9 @@ INCLUDES      :=      include
 #---------------------------------------------------------------------------------
 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
index 2ed6a29aaa1371d84a1d618ea61e5b2ce8147665..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -156,6 +165,30 @@ $(OUTPUT).elf      :       $(OFILES)
        @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)
 
 #---------------------------------------------------------------------------------------
index d75f5482ead557cbc72a0e2aea60e01bbebfb590..504d5c7e75381b1fbd9c673a7e412d1a13265b60 100644 (file)
@@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules
 # 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)
@@ -31,6 +32,7 @@ BUILD         :=      build
 SOURCES                :=      source
 DATA           :=      data
 INCLUDES       :=      include
+#ROMFS         :=      romfs
 
 #---------------------------------------------------------------------------------
 # options for code generation
@@ -38,7 +40,7 @@ INCLUDES      :=      include
 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
@@ -46,7 +48,7 @@ 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
 
@@ -75,6 +77,8 @@ export DEPSDIR        :=      $(CURDIR)/$(BUILD)
 CFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 CPPFILES       :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 SFILES         :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES      :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+SHLISTFILES    :=      $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
 BINFILES       :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
 #---------------------------------------------------------------------------------
@@ -92,6 +96,7 @@ endif
 #---------------------------------------------------------------------------------
 
 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)) \
@@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),)
        export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
 endif
 
+ifneq ($(ROMFS),)
+       export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -124,7 +133,7 @@ all: $(BUILD)
 
 $(BUILD):
        @[ -d $@ ] || mkdir -p $@
-       @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+       @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
 
 #---------------------------------------------------------------------------------
 clean:
@@ -145,6 +154,7 @@ $(OUTPUT).3dsx      :       $(OUTPUT).elf $(OUTPUT).smdh
 else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
 endif
+
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
@@ -155,17 +165,29 @@ $(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)