Debian Codegraph @

tools/ds_tests/armwrestler/Makefile

raw symbols SCIP
1 #---------------------------------------------------------------------------------
2 .SUFFIXES:
3 #---------------------------------------------------------------------------------
4
5 ifeq ($(strip $(DEVKITARM)),)
6 $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
7 endif
8
9 include $(DEVKITARM)/ds_rules
10
11 #---------------------------------------------------------------------------------
12 # TARGET is the name of the output
13 # BUILD is the directory where object files & intermediate files will be placed
14 # SOURCES is a list of directories containing source code
15 # INCLUDES is a list of directories containing extra header files
16 # DATA is a list of directories containing binary files embedded using bin2o
17 # GRAPHICS is a list of directories containing image files to be converted with grit
18 #---------------------------------------------------------------------------------
19 TARGET := $(shell basename $(CURDIR))
20 BUILD := build
21 SOURCES := source
22 INCLUDES := include
23 DATA :=
24 GRAPHICS := gfx
25
26 #---------------------------------------------------------------------------------
27 # options for code generation
28 #---------------------------------------------------------------------------------
29 ARCH := -mthumb -mthumb-interwork
30
31 CFLAGS := -g -Wall -O2\
32 -march=armv5te -fomit-frame-pointer\
33 -ffast-math \
34 $(ARCH)
35
36 CFLAGS += $(INCLUDE) -DARM9
37 CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
38
39 ASFLAGS := -g -march=armv5te $(ARCH)
40 LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
41
42 #---------------------------------------------------------------------------------
43 # any extra libraries we wish to link with the project (order is important)
44 #---------------------------------------------------------------------------------
45 LIBS := -lnds9
46
47
48 #---------------------------------------------------------------------------------
49 # list of directories containing libraries, this must be the top level containing
50 # include and lib
51 #---------------------------------------------------------------------------------
52 LIBDIRS := $(LIBNDS)
53
54 #---------------------------------------------------------------------------------
55 # no real need to edit anything past this point unless you need to add additional
56 # rules for different file extensions
57 #---------------------------------------------------------------------------------
58 ifneq ($(BUILD),$(notdir $(CURDIR)))
59 #---------------------------------------------------------------------------------
60
61 export OUTPUT := $(CURDIR)/$(TARGET)
62
63 export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
64 $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
65 $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
66
67 export DEPSDIR := $(CURDIR)/$(BUILD)
68
69 CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
70 CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
71 SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
72 PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
73 BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
74
75 #---------------------------------------------------------------------------------
76 # use CXX for linking C++ projects, CC for standard C
77 #---------------------------------------------------------------------------------
78 ifeq ($(strip $(CPPFILES)),)
79 #---------------------------------------------------------------------------------
80 export LD := $(CC)
81 #---------------------------------------------------------------------------------
82 else
83 #---------------------------------------------------------------------------------
84 export LD := $(CXX)
85 #---------------------------------------------------------------------------------
86 endif
87 #---------------------------------------------------------------------------------
88
89 export OFILES := $(addsuffix .o,$(BINFILES)) \
90 $(PNGFILES:.png=.o) \
91 $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
92
93 export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
94 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
95 -I$(CURDIR)/$(BUILD)
96
97 export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
98
99 icons := $(wildcard *.bmp)
100
101 ifneq (,$(findstring $(TARGET).bmp,$(icons)))
102 export GAME_ICON := $(CURDIR)/$(TARGET).bmp
103 else
104 ifneq (,$(findstring icon.bmp,$(icons)))
105 export GAME_ICON := $(CURDIR)/icon.bmp
106 endif
107 endif
108
109 .PHONY: $(BUILD) clean
110
111 #---------------------------------------------------------------------------------
112 $(BUILD):
113 @[ -d $@ ] || mkdir -p $@
114 @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
115
116 #---------------------------------------------------------------------------------
117 clean:
118 @echo clean ...
119 @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds
120
121 #---------------------------------------------------------------------------------
122 else
123
124 #---------------------------------------------------------------------------------
125 # main targets
126 #---------------------------------------------------------------------------------
127 $(OUTPUT).nds : $(OUTPUT).elf
128 $(OUTPUT).elf : $(OFILES)
129
130 #---------------------------------------------------------------------------------
131 %.bin.o : %.bin
132 #---------------------------------------------------------------------------------
133 @echo $(notdir $<)
134 $(bin2o)
135
136 #---------------------------------------------------------------------------------
137 # This rule creates assembly source files using grit
138 # grit takes an image file and a .grit describing how the file is to be processed
139 # add additional rules like this for each image extension
140 # you use in the graphics folders
141 #---------------------------------------------------------------------------------
142 %.s %.h : %.png %.grit
143 #---------------------------------------------------------------------------------
144 grit $< -fts -o$*
145
146 -include $(DEPSDIR)/*.d
147
148 #---------------------------------------------------------------------------------------
149 endif
150 #---------------------------------------------------------------------------------------