rendered paste body#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source source/libtommath source/pcre \
source/arch source/arch/ArchHooks source/arch/Dialog source/arch/InputHandler source/arch/Lights source/arch/LoadingWindow \
source/arch/LowLevelWindow source/arch/MemoryCard source/arch/MovieTexture source/arch/Sound source/arch/Threads \
source/libtomcrypt/src/ciphers/aes source/libtomcrypt/src/hases source/libtomcrypt/src/hashes/helper \
source/libtomcrypt/src/math source/libtomcrypt/src/math/fp source/libtomcrypt/src/misc source/libtomcrypt/src/misc/base64 \
source/libtomcrypt/src/misc/crypt source/libtomcrypt/src/misc/pkcs5 source/libtomcrypt/src/modes/cbc \
source/libtomcrypt/src/modes/cfb source/libtomcrypt/src/modes/ctr source/libtomcrypt/src/modes/ecb source/libtomcrypt/src/mode/ofb/ \
source/libtomcrypt/src/pk/asn1/der/bit source/libtomcrypt/src/pk/asn1/der/boolean source/libtomcrypt/src/pk/asn1/der/choice \
source/libtomcrypt/src/pk/asn1/der/ia5 source/libtomcrypt/src/pk/asn1/der/integer source/libtomcrypt/src/pk/asn1/der/ \
source/libtomcrypt/src/pk/asn1/der/octet source/libtomcrypt/src/pk/asn1/der/squence source/libtomcrypt/src/pk/asn1/der/set \
source/libtomcrypt/src/pk/asn1/der/set source/libtomcrypt/src/pk/asn1/der/short_integer source/libtomcrypt/src/pk/asn1/der/utctime \
source/libtomcrypt/src/pk/asn1/der/utf8 \
source/libtomcrypt/src/pk/dsa source/libtomcrypt/src/pk/pkcs1 source/libtomcrypt/src/pk/rsa source/libtomcrypt/src/prngs \
source/lua-5.1/src source/pcre
#source/archutils source/archutils/Common There is no code here, except for some Unix stuff.
# SOURCES := source source/crypto source/crypto51 source/disasm source/docs source/libjpeg source/pcre source/zlib \
# source/arch source/arch/ArchHooks source/arch/Dialog source/arch/InputHandler source/arch/Lights source/arch/LoadingWindow \
# source/arch/LowLevelWindow source/arch/MemoryCard source/arch/MovieTexture source/arch/Sound source/arch/Threads \
# source/archutils \
# source/ffmpeg source/ffmpeg/include source/ffmpeg/include/ffmpeg source/ffmpeg/lib \
# source/libpng source/libpng/include source/libpng/lib \
# source/libresample source/libresample/include source/libresample/src
DATA := data
INCLUDES := source source/rage
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
#,-Dwchar=short,-Dwstring=wchar
#-D_GLIBCXX_USE_WCHAR_T
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) -Wp,-DWII,-DENDIAN_LITTLE
#Use -v for debugging preprocessor.
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -stdlib -cstdlib -cwchar -lwiiuse -lbte -logc -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o) \
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
wiiload $(TARGET).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------