Front SD ELF loader added
[svpe-wii.git] / sdelfloader / miniloader / Makefile
blob79d6a415635eba09b500ae0da6bacf27e0c6393e
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
10 include $(DEVKITPPC)/wii_rules
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 := $(notdir $(CURDIR))
19 BUILD := build
20 SOURCES := source
21 DATA := data
22 INCLUDES :=
24 #---------------------------------------------------------------------------------
25 # options for code generation
26 #---------------------------------------------------------------------------------
28 CFLAGS = -g -Os -mrvl -Wall $(MACHDEP) $(INCLUDE)
29 CXXFLAGS = $(CFLAGS)
31 LDFLAGS = -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
33 #---------------------------------------------------------------------------------
34 # any extra libraries we wish to link with the project
35 #---------------------------------------------------------------------------------
36 LIBS := -logc
38 #---------------------------------------------------------------------------------
39 # list of directories containing libraries, this must be the top level containing
40 # include and lib
41 #---------------------------------------------------------------------------------
42 LIBDIRS :=
44 #---------------------------------------------------------------------------------
45 # no real need to edit anything past this point unless you need to add additional
46 # rules for different file extensions
47 #---------------------------------------------------------------------------------
48 ifneq ($(BUILD),$(notdir $(CURDIR)))
49 #---------------------------------------------------------------------------------
51 export OUTPUT := $(CURDIR)/$(TARGET)
53 export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
54 $(foreach dir,$(DATA),$(CURDIR)/$(dir))
56 export DEPSDIR := $(CURDIR)/$(BUILD)
58 #---------------------------------------------------------------------------------
59 # automatically build a list of object files for our project
60 #---------------------------------------------------------------------------------
61 CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
62 CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
63 sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
64 SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
65 BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
67 #---------------------------------------------------------------------------------
68 # use CXX for linking C++ projects, CC for standard C
69 #---------------------------------------------------------------------------------
70 ifeq ($(strip $(CPPFILES)),)
71 export LD := $(CC)
72 else
73 export LD := $(CXX)
74 endif
76 export OFILES := $(addsuffix .o,$(BINFILES)) \
77 $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
78 $(sFILES:.s=.o) $(SFILES:.S=.o)
80 #---------------------------------------------------------------------------------
81 # build a list of include paths
82 #---------------------------------------------------------------------------------
83 export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
84 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
85 -I$(CURDIR)/$(BUILD) \
86 -I$(LIBOGC_INC)
88 #---------------------------------------------------------------------------------
89 # build a list of library paths
90 #---------------------------------------------------------------------------------
91 export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
92 -L$(LIBOGC_LIB)
94 export OUTPUT := $(CURDIR)/$(TARGET)
95 .PHONY: $(BUILD) clean
97 #---------------------------------------------------------------------------------
98 $(BUILD):
99 @[ -d $@ ] || mkdir -p $@
100 @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
102 #---------------------------------------------------------------------------------
103 clean:
104 @echo clean ...
105 @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
107 #---------------------------------------------------------------------------------
108 run:
109 psoload $(TARGET).dol
111 #---------------------------------------------------------------------------------
112 reload:
113 psoload -r $(TARGET).dol
116 #---------------------------------------------------------------------------------
117 else
119 DEPENDS := $(OFILES:.o=.d)
121 #---------------------------------------------------------------------------------
122 # main targets
123 #---------------------------------------------------------------------------------
124 $(OUTPUT).dol: $(OUTPUT).elf
125 $(OUTPUT).elf: $(OFILES)
127 #---------------------------------------------------------------------------------
128 # This rule links in binary data with the .jpg extension
129 #---------------------------------------------------------------------------------
130 %.jpg.o : %.jpg
131 #---------------------------------------------------------------------------------
132 @echo $(notdir $<)
133 $(bin2o)
135 -include $(DEPENDS)
137 $(OUTPUT).dol: $(OUTPUT).elf
138 @echo "Output ... "$(notdir $@)
139 @$(OBJCOPY) -O binary $< $@
141 #---------------------------------------------------------------------------------
142 endif
143 #---------------------------------------------------------------------------------