diff --git a/Makefile b/Makefile index d4c4d9b..0709937 100644 --- a/Makefile +++ b/Makefile @@ -2,107 +2,207 @@ # Clear the implicit built in rules #--------------------------------------------------------------------------------- .SUFFIXES: - +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") +endif +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPRO") +endif ifeq ($(strip $(WUT_ROOT)),) $(error "Please ensure WUT_ROOT is in your environment.") endif - -ifeq ($(findstring CYGWIN,$(shell uname -s)),CYGWIN) -ROOT := $(shell cygpath -w ${CURDIR}) -WUT_ROOT := $(shell cygpath -w ${WUT_ROOT}) -else -ROOT := $(CURDIR) -endif - - +export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH) +export LIBOGC_INC := $(DEVKITPRO)/libogc/include +export LIBOGC_LIB := $(DEVKITPRO)/libogc/lib/wii export PORTLIBS := $(DEVKITPRO)/portlibs/ppc -include $(WUT_ROOT)/rules/rpl.mk +PREFIX := powerpc-eabi- -AS := $(PREFIX)as +export AS := $(PREFIX)as +export CC := $(PREFIX)gcc +export CXX := $(PREFIX)g++ +export AR := $(PREFIX)ar +export OBJCOPY := $(PREFIX)objcopy -TARGET := $(notdir $(CURDIR)) -BUILD := build -SOURCE := src \ - src/dynamic_libs \ - src/fs \ - src/game \ - src/gui \ - src/kernel \ - src/loader \ - src/menu \ - src/network \ - src/patcher \ - src/resources \ - src/settings \ - src/sounds \ - src/system \ - src/utils \ - src/video \ - src/video/shaders -INCLUDE := src -DATA := data \ - data/images \ - data/fonts \ - data/sounds -LIBS := -lgcc -lcrt -lcoreinit -lproc_ui -lnsysnet -lsndcore2 -lvpad -lgx2 -lgd -lpng -lz -lfreetype -lmad -lvorbisidec +export ELF2RPL := $(WUT_ROOT)/bin/elf2rpl -CFLAGS += -O3 -std=gnu11 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -CXXFLAGS += -O3 -std=gnu++11 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing +#--------------------------------------------------------------------------------- +# 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 := homebrew_launcher +BUILD := build +BUILD_DBG := $(TARGET)_dbg +SOURCES := src \ + src/dynamic_libs \ + src/fs \ + src/game \ + src/gui \ + src/kernel \ + src/loader \ + src/menu \ + src/network \ + src/patcher \ + src/resources \ + src/settings \ + src/sounds \ + src/system \ + src/utils \ + src/video \ + src/video/shaders +DATA := data \ + data/images \ + data/fonts \ + data/sounds +INCLUDES := src + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ + -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE) +CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ + -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE) +ASFLAGS := -mregnames +LDFLAGS := -nostartfiles -T $(WUT_ROOT)/rules/rpl.ld -pie -fPIE -z common-page-size=64 -z max-page-size=64 -lcrt \ + -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size \ + -Wl,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r \ + -Wl,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,-wrap,__eabi -Wl,--gc-sections + +#--------------------------------------------------------------------------------- +Q := @ +MAKEFLAGS += --no-print-directory +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := -lcrt -lcoreinit -lproc_ui -lnsysnet -lsndcore2 -lvpad -lgx2 -lgd -lpng -lz -lfreetype -lmad -lvorbisidec + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(CURDIR) \ + $(DEVKITPPC)/ \ + $(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2 \ + $(WUT_ROOT)/lib + +#--------------------------------------------------------------------------------- +# 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 PROJECTDIR := $(CURDIR) +export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET) +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) +export DEPSDIR := $(CURDIR)/$(BUILD) -export OUTPUT := $(ROOT)/$(TARGET) -export VPATH := $(foreach dir,$(SOURCE),$(ROOT)/$(dir)) \ - $(foreach dir,$(DATA),$(ROOT)/$(dir)) -export BUILDDIR := $(ROOT) -export DEPSDIR := $(BUILDDIR) - -CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c))) -CXXFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.S))) +#--------------------------------------------------------------------------------- +# automatically build a list of object files for our project +#--------------------------------------------------------------------------------- +FILELIST := $(shell bash ./filelist.sh) +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)/*.*))) +TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf))) +PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) -ifeq ($(strip $(CXXFILES)),) -export LD := $(CC) +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) + export LD := $(CC) else -export LD := $(CXX) + export LD := $(CXX) endif -export OFILES := $(CFILES:.c=.o) \ - $(CXXFILES:.cpp=.o) \ - $(SFILES:.S=.o) \ - $(addsuffix .o,$(BINFILES)) +export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ + $(sFILES:.s=.o) $(SFILES:.S=.o) \ + $(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES)) + +#--------------------------------------------------------------------------------- +# build a list of include paths +#--------------------------------------------------------------------------------- +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + -I$(CURDIR)/$(BUILD) -I$(WUT_ROOT)/include \ + -I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2 -export INCLUDES := $(foreach dir,$(INCLUDE),-I$(ROOT)/$(dir)) \ - -I$(ROOT)/$(BUILD) \ - -I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2 #--------------------------------------------------------------------------------- # build a list of library paths #--------------------------------------------------------------------------------- -export LIB_DIRS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ - -L$(PORTLIBS)/lib +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)) \ + -L$(LIBOGC_LIB) -L$(PORTLIBS)/lib -.PHONY: $(BUILD) clean +export OUTPUT := $(CURDIR)/$(TARGET) +.PHONY: $(BUILD) clean install +#--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(ROOT)/Makefile + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile +#--------------------------------------------------------------------------------- clean: - @echo "[RM] $(notdir $(OUTPUT))" - @rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).rpx $(OUTPUT).a + @echo clean ... + @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf +#--------------------------------------------------------------------------------- else -# workaround as wut overwrites the LIBPATHS with its rules -> not cool -export LIBPATHS := $(LIBPATHS) $(LIB_DIRS) +DEPENDS := $(OFILES:.o=.d) -DEPENDS := $(OFILES:.o=.d) +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).rpx: $(OUTPUT).elf +$(OUTPUT).elf: $(OFILES) -$(OUTPUT).rpx: $(OUTPUT).elf -$(OUTPUT).elf: $(OFILES) +#--------------------------------------------------------------------------------- +# This rule links in binary data with the .jpg extension +#--------------------------------------------------------------------------------- +%.elf: $(OFILES) + @echo "linking ... $(TARGET).elf" + $(Q)$(LD) $^ $(LDFLAGS) -o $@ $(LIBPATHS) $(LIBS) +# $(Q)$(OBJCOPY) -S -R .comment -R .gnu.attributes ../$(BUILD_DBG).elf $@ +../data/loader.bin: + $(MAKE) -C ../loader clean + $(MAKE) -C ../loader + +#--------------------------------------------------------------------------------- +%.rpx: %.elf +#--------------------------------------------------------------------------------- + @echo "[RPX] $(notdir $@)" + $(ELF2RPL) $^ $@ + +#--------------------------------------------------------------------------------- +%.a: +#--------------------------------------------------------------------------------- + @echo $(notdir $@) + @rm -f $@ + @$(AR) -rc $@ $^ + +#--------------------------------------------------------------------------------- +%.o: %.cpp + @echo $(notdir $<) + @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER) + +#--------------------------------------------------------------------------------- +%.o: %.c + @echo $(notdir $<) + @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ $(ERROR_FILTER) + +#--------------------------------------------------------------------------------- +%.o: %.S + @echo $(notdir $<) + @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER) #--------------------------------------------------------------------------------- %.png.o : %.png diff --git a/src/gui/FreeTypeGX.cpp b/src/gui/FreeTypeGX.cpp index 9a9cc59..c35432d 100755 --- a/src/gui/FreeTypeGX.cpp +++ b/src/gui/FreeTypeGX.cpp @@ -20,10 +20,9 @@ * along with FreeTypeGX. If not, see . */ -#include "FreeTypeGX.h" #include "video/CVideo.h" #include "video/shaders/Texture2DShader.h" -#include "utils/logger.h" +#include "FreeTypeGX.h" using namespace std; diff --git a/src/utils/utils.S b/src/utils/utils_asm.S similarity index 100% rename from src/utils/utils.S rename to src/utils/utils_asm.S