-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
62 lines (49 loc) · 1.95 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
.SUFFIXES:
name = dasShiny
ARCH = -march=native
CFLAGS = -I. -O3
CXXFLAGS =
LDFLAGS = -Wl,-Map,build/$(name).map
include Platform.make
include nall/Makefile
include phoenix/Makefile
include ruby/Makefile
add = $(foreach m,$2,$(eval $(call addmodule,$1,$(m))))
rule = $(if $(wildcard $2),$2; @echo Building $1;$3)
define addmodule
objects += build/$(subst /,-,$1)$2.o
# double $$ defers evaluation so target-specific variables will work
build/$(subst /,-,$1)$2.o: \
$(call rule, $1$2, $1$2/$2.c, $$(CC) $$(ARCH) $$(CFLAGS) -MMD -MP -MF build/$(subst /,-,$1)$2.d -c $$< -o $$@) \
$(call rule, $1$2, $1$2/$2.cpp, $$(CXX) $$(ARCH) $$(CFLAGS) $$(CXXFLAGS) -MMD -MP -MF build/$(subst /,-,$1)$2.d -c $$< -o $$@)
endef
all: build $(name)$(exe)
build:; @mkdir $@
ifneq ($(filter osx,$(platform)),)
# Objective-C++ for ruby/phoenix Cocoa ports
build/phoenix.o: CXX := $(OBJCXX)
build/ruby.o: CXX := $(OBJCXX)
endif
build/phoenix.o: CXXFLAGS += $(phoenixflags)
build/ruby.o: CXXFLAGS += $(rubyflags)
# Embedded resources (note: both zip and ld are path-sensitive here).
build/data-resources.o: $(shell find data/resources/ -iname '*' | sed 's/ /\\ /g')
@echo Packing $(notdir $(basename $@))
@cd data/resources; zip -9qr ../../build/resources.zip .
@cd build; ld -r -b binary -o $(notdir $@) resources.zip
# Windows icon + manifest
build/win-resources.o: ui/resource.rc data/dasShiny.manifest data/dasShiny.ico
@echo Building $(notdir $(basename $@))
@$(WINRC) $< $@
clean:
-@$(call RM,build/*)
-@rmdir build
$(call add,nds/, apu cpu gpu interface memory ppu slot1 slot2 system utility video wifi)
$(call add,ui/, configuration general input interface settings utility window)
$(call add,, ui phoenix ruby libco)
objects += $(if $(filter win,$(platform)),build/win-resources.o)
$(name)$(exe): $(objects) build/data-resources.o
@echo Linking $(name)
@$(LD) $(ARCH) -o $@ $^ $(LDFLAGS) $(phoenixlink) $(rubylink)
%.d:;
-include build/*.d