Skip to content

Commit 4575818

Browse files
committed
Fix parallel building. Closes #27
1 parent e49924e commit 4575818

File tree

1 file changed

+33
-104
lines changed

1 file changed

+33
-104
lines changed

graphics/bitmap/24bit-color/Makefile

Lines changed: 33 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@ include $(DEVKITARM)/3ds_rules
1515
# SOURCES is a list of directories containing source code
1616
# DATA is a list of directories containing data files
1717
# INCLUDES is a list of directories containing header files
18-
# GRAPHICS is a list of directories containing graphics files
19-
# GFXBUILD is the directory where converted graphics files will be placed
20-
# If set to $(BUILD), it will statically link in the converted
21-
# files as if they were data files.
2218
#
2319
# NO_SMDH: if set to anything, no SMDH file is generated.
24-
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
2520
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
2621
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
2722
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
@@ -34,20 +29,17 @@ include $(DEVKITARM)/3ds_rules
3429
TARGET := $(notdir $(CURDIR))
3530
BUILD := build
3631
SOURCES := source
37-
DATA := data
32+
DATA :=
3833
INCLUDES := include
3934
GRAPHICS := gfx
40-
GFXBUILD := $(BUILD)
41-
#ROMFS := romfs
42-
#GFXBUILD := $(ROMFS)/gfx
4335

4436
#---------------------------------------------------------------------------------
4537
# options for code generation
4638
#---------------------------------------------------------------------------------
47-
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
39+
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
4840

4941
CFLAGS := -g -Wall -O2 -mword-relocations \
50-
-fomit-frame-pointer -ffunction-sections \
42+
-fomit-frame-pointer -ffast-math \
5143
$(ARCH)
5244

5345
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
@@ -65,7 +57,6 @@ LIBS := -lctru -lm
6557
#---------------------------------------------------------------------------------
6658
LIBDIRS := $(CTRULIB)
6759

68-
6960
#---------------------------------------------------------------------------------
7061
# no real need to edit anything past this point unless you need to add additional
7162
# rules for different file extensions
@@ -77,18 +68,16 @@ export OUTPUT := $(CURDIR)/$(TARGET)
7768
export TOPDIR := $(CURDIR)
7869

7970
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
80-
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
81-
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
71+
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
72+
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
8273

8374
export DEPSDIR := $(CURDIR)/$(BUILD)
8475

8576
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
8677
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
8778
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
88-
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
89-
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
90-
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
9179
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
80+
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
9281

9382
#---------------------------------------------------------------------------------
9483
# use CXX for linking C++ projects, CC for standard C
@@ -104,39 +93,21 @@ else
10493
endif
10594
#---------------------------------------------------------------------------------
10695

107-
#---------------------------------------------------------------------------------
108-
ifeq ($(GFXBUILD),$(BUILD))
109-
#---------------------------------------------------------------------------------
110-
export T3XFILES := $(GFXFILES:.t3s=.t3x)
111-
#---------------------------------------------------------------------------------
112-
else
113-
#---------------------------------------------------------------------------------
114-
export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES))
115-
export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES))
116-
#---------------------------------------------------------------------------------
117-
endif
118-
#---------------------------------------------------------------------------------
119-
12096
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
12197

12298
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
123-
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
124-
$(addsuffix .o,$(T3XFILES))
99+
$(PNGFILES:.png=.bgr.o) \
125100

126101
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
127102

128-
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \
129-
$(addsuffix .h,$(subst .,_,$(BINFILES))) \
130-
$(GFXFILES:.t3s=.h)
103+
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) $(PNGFILES:.png=_bgr.h)
131104

132105
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
133106
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
134107
-I$(CURDIR)/$(BUILD)
135108

136109
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
137110

138-
export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh)
139-
140111
ifeq ($(strip $(ICON)),)
141112
icons := $(wildcard *.png)
142113
ifneq (,$(findstring $(TARGET).png,$(icons)))
@@ -150,17 +121,13 @@ else
150121
export APP_ICON := $(TOPDIR)/$(ICON)
151122
endif
152123

124+
IMAGEMAGICK := $(shell which convert)
125+
153126
ifeq ($(strip $(NO_SMDH)),)
154127
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
155128
endif
156129

157-
ifneq ($(ROMFS),)
158-
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
159-
endif
160-
161-
IMAGEMAGICK := $(shell which convert)
162-
163-
.PHONY: all clean
130+
.PHONY: $(BUILD) clean all
164131

165132
#---------------------------------------------------------------------------------
166133
ifneq ($(strip $(IMAGEMAGICK)),)
@@ -171,55 +138,43 @@ HAVE_CONVERT := yes
171138
endif
172139
endif
173140

174-
#---------------------------------------------------------------------------------
175141
ifeq ($(strip $(HAVE_CONVERT)),yes)
176-
#---------------------------------------------------------------------------------
177-
178-
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
179-
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
180-
181-
$(BUILD):
182-
@mkdir -p $@
183-
184-
ifneq ($(GFXBUILD),$(BUILD))
185-
$(GFXBUILD):
186-
@mkdir -p $@
187-
endif
188142

189-
ifneq ($(DEPSDIR),$(BUILD))
190-
$(DEPSDIR):
191-
@mkdir -p $@
192-
endif
143+
all: $(BUILD)
193144

194-
#---------------------------------------------------------------------------------
195145
else
196-
#---------------------------------------------------------------------------------
197146

198147
all:
199148
@echo "Image Magick not found!"
200149
@echo
201150
@echo "Please install Image Magick from http://www.imagemagick.org/ to build this example"
202151

203-
#---------------------------------------------------------------------------------
204152
endif
153+
154+
#---------------------------------------------------------------------------------
155+
$(BUILD):
156+
@[ -d $@ ] || mkdir -p $@
157+
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
158+
205159
#---------------------------------------------------------------------------------
206160
clean:
207161
@echo clean ...
208-
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(GFXBUILD)
162+
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
209163

210-
#---------------------------------------------------------------------------------
211-
$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
212-
#---------------------------------------------------------------------------------
213-
@echo $(notdir $<)
214-
@tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
215164

216165
#---------------------------------------------------------------------------------
217166
else
218167

168+
DEPENDS := $(OFILES:.o=.d)
169+
219170
#---------------------------------------------------------------------------------
220171
# main targets
221172
#---------------------------------------------------------------------------------
222-
$(OUTPUT).3dsx : $(OUTPUT).elf $(_3DSXDEPS)
173+
ifeq ($(strip $(NO_SMDH)),)
174+
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
175+
else
176+
$(OUTPUT).3dsx : $(OUTPUT).elf
177+
endif
223178

224179
$(OFILES_SOURCES) : $(HFILES)
225180

@@ -228,52 +183,26 @@ $(OUTPUT).elf : $(OFILES)
228183
#---------------------------------------------------------------------------------
229184
# you need a rule like this for each extension you use as binary data
230185
#---------------------------------------------------------------------------------
231-
%.bin.o %_bin.h : %.bin
186+
%.bin.o : %.bin
232187
#---------------------------------------------------------------------------------
233188
@echo $(notdir $<)
234189
@$(bin2o)
235190

236-
#---------------------------------------------------------------------------------
237-
.PRECIOUS : %.t3x
238-
#---------------------------------------------------------------------------------
239-
%.t3x.o %_t3x.h : %.t3x
240-
#---------------------------------------------------------------------------------
241-
@echo $(notdir $<)
242-
@$(bin2o)
191+
243192

244193
#---------------------------------------------------------------------------------
245-
# rules for assembling GPU shaders
194+
%_bgr.h %.bgr.o: %.bgr
246195
#---------------------------------------------------------------------------------
247-
define shader-as
248-
$(eval CURBIN := $*.shbin)
249-
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
250-
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
251-
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
252-
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
253-
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
254-
picasso -o $(CURBIN) $1
255-
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
256-
endef
257-
258-
%.shbin.o %_shbin.h : %.v.pica %.g.pica
259-
@echo $(notdir $^)
260-
@$(call shader-as,$^)
261-
262-
%.shbin.o %_shbin.h : %.v.pica
263196
@echo $(notdir $<)
264-
@$(call shader-as,$<)
265-
266-
%.shbin.o %_shbin.h : %.shlist
267-
@echo $(notdir $<)
268-
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
197+
@$(bin2o)
269198

270199
#---------------------------------------------------------------------------------
271-
%.t3x %.h : %.t3s
200+
%.bgr: %.png
272201
#---------------------------------------------------------------------------------
273202
@echo $(notdir $<)
274-
@tex3ds -i $< -H $*.h -d $*.d -o $*.t3x
203+
@convert $< -rotate 90 $@
275204

276-
-include $(DEPSDIR)/*.d
205+
-include $(DEPENDS)
277206

278207
#---------------------------------------------------------------------------------------
279208
endif

0 commit comments

Comments
 (0)