1TARGET := scummvm
2
3APP_TITLE       := ScummVM
4APP_DESCRIPTION := Point-and-click adventure game engines
5APP_AUTHOR      := ScummVM Team
6APP_ICON        := $(srcdir)/backends/platform/3ds/app/icon.png
7
8APP_RSF         := $(srcdir)/backends/platform/3ds/app/scummvm.rsf
9APP_BANNER_IMAGE:= $(srcdir)/backends/platform/3ds/app/banner.png
10APP_BANNER_AUDIO:= $(srcdir)/backends/platform/3ds/app/banner.wav
11
12.PHONY: clean_3ds dist_3ds
13
14clean: clean_3ds
15
16clean_3ds:
17	$(RM) backends/platform/3ds/shader.shbin
18	$(RM) backends/platform/3ds/shader_shbin.h
19	$(RM) $(TARGET).smdh
20	$(RM) $(TARGET).3dsx
21	$(RM) $(TARGET).bnr
22	$(RM) $(TARGET).cia
23	$(RM) -rf romfs
24	$(RM) -rf dist_3ds
25
26romfs: $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD) $(DIST_3DS_EXTRA_FILES) $(PLUGINS)
27	@rm -rf romfs
28	@mkdir -p romfs
29	@cp $(DIST_FILES_THEMES) romfs/
30ifdef DIST_FILES_ENGINEDATA
31	@cp $(DIST_FILES_ENGINEDATA) romfs/
32endif
33ifdef DIST_FILES_NETWORKING
34	@cp $(DIST_FILES_NETWORKING) romfs/
35endif
36ifdef DIST_FILES_VKEYBD
37	@cp $(DIST_FILES_VKEYBD) romfs/
38endif
39ifdef DIST_3DS_EXTRA_FILES
40	@cp -a $(DIST_3DS_EXTRA_FILES) romfs/
41endif
42ifeq ($(DYNAMIC_MODULES),1)
43	@mkdir -p romfs/plugins
44	@for i in $(PLUGINS); do $(STRIP) --strip-debug $$i -o romfs/plugins/`basename $$i`; done
45endif
46
47$(TARGET).smdh: $(APP_ICON)
48	@smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@
49	@echo built ... $(notdir $@)
50
51$(TARGET).3dsx: $(EXECUTABLE) $(TARGET).smdh romfs
52	@3dsxtool $< $@ --smdh=$(TARGET).smdh --romfs=romfs
53	@echo built ... $(notdir $@)
54
55$(TARGET).bnr: $(APP_BANNER_IMAGE) $(APP_BANNER_AUDIO)
56	@bannertool makebanner -o $@ -i $(APP_BANNER_IMAGE) -a $(APP_BANNER_AUDIO)
57	@echo built ... $(notdir $@)
58
59$(TARGET).cia: $(EXECUTABLE) $(APP_RSF) $(TARGET).smdh $(TARGET).bnr romfs
60	@makerom -f cia -target t -exefslogo -o $@ -elf $(EXECUTABLE) -rsf $(APP_RSF) -banner $(TARGET).bnr -icon $(TARGET).smdh -DAPP_ROMFS=romfs/
61	@echo built ... $(notdir $@)
62
63dist_3ds: $(TARGET).cia $(TARGET).3dsx $(DIST_FILES_DOCS)
64	@rm -rf dist_3ds
65	@mkdir -p dist_3ds
66	@cp $(TARGET).3dsx $(TARGET).cia dist_3ds/
67	@cp $(DIST_FILES_DOCS) dist_3ds/
68	@cp $(srcdir)/backends/platform/3ds/README.md dist_3ds/README-3DS.md
69	@echo built ... $(notdir $@)
70
71#---------------------------------------------------------------------------------
72# rules for assembling GPU shaders
73#---------------------------------------------------------------------------------
74define shader-as
75	$(eval FILEPATH := $(patsubst %.shbin.o,%.shbin,$@))
76	$(eval FILE := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
77	picasso -o $(FILEPATH) $1
78	bin2s $(FILEPATH) | $(AS) -o $@
79	echo "extern const u8" `(echo $(FILE) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(FILEPATH) | tr . _)`.h
80	echo "extern const u8" `(echo $(FILE) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(FILEPATH) | tr . _)`.h
81	echo "extern const u32" `(echo $(FILE) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(FILEPATH) | tr . _)`.h
82endef
83
84vpath %.v.pica $(srcdir)
85vpath %.g.pica $(srcdir)
86vpath %.shlist $(srcdir)
87
88%.shbin.o : %.v.pica %.g.pica
89	@echo $(notdir $^)
90	@$(call shader-as,$^)
91
92%.shbin.o : %.v.pica
93	@echo $(notdir $<)
94	@$(call shader-as,$<)
95
96%.shbin.o : %.shlist
97	@echo $(notdir $<)
98	@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
99
100# osystem-graphics.cpp includes shader_shbin.h that is generated by the shader assembler
101backends/platform/3ds/osystem-graphics.o: backends/platform/3ds/shader.shbin.o
102