diff options
Diffstat (limited to 'Makefile.wii')
-rw-r--r-- | Makefile.wii | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/Makefile.wii b/Makefile.wii new file mode 100644 index 0000000..341c37b --- /dev/null +++ b/Makefile.wii | |||
@@ -0,0 +1,131 @@ | |||
1 | #--------------------------------------------------------------------------------- | ||
2 | # Clear the implicit built in rules | ||
3 | #--------------------------------------------------------------------------------- | ||
4 | .SUFFIXES: | ||
5 | #--------------------------------------------------------------------------------- | ||
6 | ifeq ($(strip $(DEVKITPPC)),) | ||
7 | $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC") | ||
8 | endif | ||
9 | |||
10 | include $(DEVKITPPC)/wii_rules | ||
11 | |||
12 | #--------------------------------------------------------------------------------- | ||
13 | # TARGET is the name of the output | ||
14 | # BUILD is the directory where object files & intermediate files will be placed | ||
15 | # SOURCES is a list of directories containing source code | ||
16 | # INCLUDES is a list of directories containing extra header files | ||
17 | #--------------------------------------------------------------------------------- | ||
18 | TARGET := linkcabledump_wii | ||
19 | BUILD := build | ||
20 | SOURCES := source | ||
21 | DATA := data | ||
22 | INCLUDES := source | ||
23 | |||
24 | #--------------------------------------------------------------------------------- | ||
25 | # options for code generation | ||
26 | #--------------------------------------------------------------------------------- | ||
27 | |||
28 | CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) | ||
29 | CXXFLAGS = $(CFLAGS) | ||
30 | |||
31 | LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map | ||
32 | |||
33 | #--------------------------------------------------------------------------------- | ||
34 | # any extra libraries we wish to link with the project | ||
35 | #--------------------------------------------------------------------------------- | ||
36 | LIBS := -lfat -logc | ||
37 | |||
38 | |||
39 | #--------------------------------------------------------------------------------- | ||
40 | # list of directories containing libraries, this must be the top level containing | ||
41 | # include and lib | ||
42 | #--------------------------------------------------------------------------------- | ||
43 | LIBDIRS := $(DEVKITPPC)/lib $(CURDIR) | ||
44 | |||
45 | #--------------------------------------------------------------------------------- | ||
46 | # no real need to edit anything past this point unless you need to add additional | ||
47 | # rules for different file extensions | ||
48 | #--------------------------------------------------------------------------------- | ||
49 | ifneq ($(BUILD),$(notdir $(CURDIR))) | ||
50 | #--------------------------------------------------------------------------------- | ||
51 | |||
52 | export OUTPUT := $(CURDIR)/$(TARGET) | ||
53 | |||
54 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ | ||
55 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) | ||
56 | |||
57 | export DEPSDIR := $(CURDIR)/$(BUILD) | ||
58 | |||
59 | #--------------------------------------------------------------------------------- | ||
60 | # automatically build a list of object files for our project | ||
61 | #--------------------------------------------------------------------------------- | ||
62 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) | ||
63 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) | ||
64 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) | ||
65 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) | ||
66 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) | ||
67 | |||
68 | #--------------------------------------------------------------------------------- | ||
69 | # use CXX for linking C++ projects, CC for standard C | ||
70 | #--------------------------------------------------------------------------------- | ||
71 | ifeq ($(strip $(CPPFILES)),) | ||
72 | export LD := $(CC) | ||
73 | else | ||
74 | export LD := $(CXX) | ||
75 | endif | ||
76 | |||
77 | export OFILES := $(addsuffix .o,$(BINFILES)) \ | ||
78 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ | ||
79 | $(sFILES:.s=.o) $(SFILES:.S=.o) | ||
80 | |||
81 | #--------------------------------------------------------------------------------- | ||
82 | # build a list of include paths | ||
83 | #--------------------------------------------------------------------------------- | ||
84 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ | ||
85 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ | ||
86 | -I$(CURDIR)/$(BUILD) \ | ||
87 | -I$(LIBOGC_INC) | ||
88 | |||
89 | #--------------------------------------------------------------------------------- | ||
90 | # build a list of library paths | ||
91 | #--------------------------------------------------------------------------------- | ||
92 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ | ||
93 | -L$(LIBOGC_LIB) | ||
94 | |||
95 | export OUTPUT := $(CURDIR)/$(TARGET) | ||
96 | .PHONY: $(BUILD) clean | ||
97 | |||
98 | #--------------------------------------------------------------------------------- | ||
99 | $(BUILD): | ||
100 | @[ -d $@ ] || mkdir -p $@ | ||
101 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.wii | ||
102 | |||
103 | #--------------------------------------------------------------------------------- | ||
104 | clean: | ||
105 | @echo clean ... | ||
106 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol | ||
107 | |||
108 | #--------------------------------------------------------------------------------- | ||
109 | else | ||
110 | |||
111 | DEPENDS := $(OFILES:.o=.d) | ||
112 | |||
113 | #--------------------------------------------------------------------------------- | ||
114 | # main targets | ||
115 | #--------------------------------------------------------------------------------- | ||
116 | $(OUTPUT).dol: $(OUTPUT).elf | ||
117 | $(OUTPUT).elf: $(OFILES) | ||
118 | |||
119 | #--------------------------------------------------------------------------------- | ||
120 | # This rule links in binary data with the .jpg extension | ||
121 | #--------------------------------------------------------------------------------- | ||
122 | %.gba.o : %.gba | ||
123 | #--------------------------------------------------------------------------------- | ||
124 | @echo $(notdir $<) | ||
125 | $(bin2o) | ||
126 | |||
127 | -include $(DEPENDS) | ||
128 | |||
129 | #--------------------------------------------------------------------------------- | ||
130 | endif | ||
131 | #--------------------------------------------------------------------------------- | ||