Initial Commit
[Projects.git] / libmii / Makefile
blob23df30ea6f66e4876d27a7e483a3b9b169a6ad85
1 #---------------------------------------------------------------------------------
2 # Clear the implicit built in rules
3 #---------------------------------------------------------------------------------
4 .SUFFIXES:
5 #---------------------------------------------------------------------------------
7 ifeq ($(strip $(DEVKITPPC)),)
8 $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
9 endif
11 include $(DEVKITPPC)/wii_rules
13 #---------------------------------------------------------------------------------
14 # TARGET is the name of the output
15 # BUILD is the directory where object files & intermediate files will be placed
16 # SOURCES is a list of directories containing source code
17 # INCLUDES is a list of directories containing extra header files
18 #---------------------------------------------------------------------------------
19 TARGET := build/$(notdir $(CURDIR))
20 BUILD := build
21 SOURCES := source
22 DATA := data
23 INCLUDES := $(DEVKITPRO)/libogc
24 RELEASE := release
25 VERSION := 0.3d
27 #---------------------------------------------------------------------------------
28 # options for code generation
29 #---------------------------------------------------------------------------------
31 CFLAGS = -g -O2 -mrvl -Wall $(MACHDEP) $(INCLUDE) -I$(DEVKITPPC)/local/include
32 CXXFLAGS = $(CFLAGS)
34 LDFLAGS = -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
36 #---------------------------------------------------------------------------------
37 # any extra libraries we wish to link with the project
38 #---------------------------------------------------------------------------------
39 LIBS := -lisfs
41 #---------------------------------------------------------------------------------
42 # list of directories containing libraries, this must be the top level containing
43 # include and lib
44 #---------------------------------------------------------------------------------
45 LIBDIRS :=
47 #---------------------------------------------------------------------------------
48 # no real need to edit anything past this point unless you need to add additional
49 # rules for different file extensions
50 #---------------------------------------------------------------------------------
51 ifneq ($(BUILD),$(notdir $(CURDIR)))
52 #---------------------------------------------------------------------------------
54 export OUTPUT := $(CURDIR)/$(TARGET)
56 export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
57 $(foreach dir,$(DATA),$(CURDIR)/$(dir))
59 export DEPSDIR := $(CURDIR)/$(BUILD)
61 #---------------------------------------------------------------------------------
62 # automatically build a list of object files for our project
63 #---------------------------------------------------------------------------------
64 CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
65 CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
66 sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
67 SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
68 BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
70 #---------------------------------------------------------------------------------
71 # use CXX for linking C++ projects, CC for standard C
72 #---------------------------------------------------------------------------------
73 ifeq ($(strip $(CPPFILES)),)
74 export LD := $(CC)
75 else
76 export LD := $(CXX)
77 endif
79 export OFILES := $(addsuffix .o,$(BINFILES)) \
80 $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
81 $(sFILES:.s=.o) $(SFILES:.S=.o)
83 #---------------------------------------------------------------------------------
84 # build a list of include paths
85 #---------------------------------------------------------------------------------
86 export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
87 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
88 -I$(CURDIR)/$(BUILD) \
89 -I$(LIBOGC_INC)
91 #---------------------------------------------------------------------------------
92 # build a list of library paths
93 #---------------------------------------------------------------------------------
94 export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
95 -L$(LIBOGC_LIB) -L$(DEVKITPPC)/local/lib
97 export OUTPUT := $(CURDIR)/$(TARGET)
98 .PHONY: $(BUILD) install clean
100 #---------------------------------------------------------------------------------
101 $(BUILD):
102 @[ -d $@ ] || mkdir -p $@
103 @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
105 #---------------------------------------------------------------------------------
106 clean:
107 @echo clean ...
108 @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
110 example:
111 @make --no-print-directory -f example/Makefile
113 dev: clean $(BUILD) install
115 $(RELEASE)/$(VERSION).tar.gz: $(OFILES) $(OUTPUT).a $(SOURCES)/*.h
116 @cp build/*.a lib/wii
117 @cp $(SOURCES)/*.h include
118 @cp isfs/source/*.h include/isfs
119 @tar -cvvzf $@ include/ lib/
121 $(RELEASE)/source-$(VERSION).tar.gz: $(OFILES)
122 @tar -cvvzf $@ data include source Makefile
124 source-tar: $(RELEASE)/source-$(VERSION).tar.gz
126 tar: $(RELEASE)/$(VERSION).tar.gz
128 install: $(OFILES)
129 @echo Copying libs and includes
130 @cp $(OUTPUT).a $(DEVKITPRO)/libogc/lib/wii
131 @cp $(SOURCES)/*.h $(DEVKITPRO)/libogc/include
133 #---------------------------------------------------------------------------------
134 else
136 DEPENDS := $(OFILES:.o=.d)
138 #---------------------------------------------------------------------------------
139 # main targets
140 #---------------------------------------------------------------------------------
141 $(OUTPUT).a: $(OFILES)
143 #---------------------------------------------------------------------------------
144 # This rule links in binary data with the .jpg extension
145 #---------------------------------------------------------------------------------
146 %.jpg.o : %.jpg
147 #---------------------------------------------------------------------------------
148 @echo $(notdir $<)
149 $(bin2o)
151 -include $(DEPENDS)
153 #---------------------------------------------------------------------------------
154 endif
155 #---------------------------------------------------------------------------------