Skip to content

Commit

Permalink
Cleaned up Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
raz0red committed Jan 5, 2020
1 parent 23fe2b0 commit 18f9c88
Showing 1 changed file with 51 additions and 47 deletions.
98 changes: 51 additions & 47 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ include $(DEVKITPPC)/wii_rules
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := boot
BUILD := build
SOURCES := \
TARGET := boot
BUILD := build
SOURCES := \
src \
src/zip \
src/wii
DATA := \
DATA := \
res/fonts \
res/gfx
INCLUDES := \
INCLUDES := \
wii-emucommon/include \
wii-emucommon/netprint/include \
wii-emucommon/pngu/include \
Expand All @@ -41,26 +41,27 @@ INCLUDES := \
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O1 -Wall $(MACHDEP) $(INCLUDE) \
-DNOCRYPT -DWII -DBIG_ENDIAN -DWII_BIN2O \
-Wno-format-truncation \
-Wno-narrowing
CFLAGS = \
-g -O1 -Wall $(MACHDEP) $(INCLUDE) \
-DNOCRYPT -DWII -DBIG_ENDIAN -DWII_BIN2O \
-Wno-format-truncation \
-Wno-narrowing

#-DLOWTRACE -DDEBUG
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lSDL -lemucommon -ltinysmb -lSDL_ttf -lSDL_image -lpng -lfreetype \
-lwiiuse -lfat -lbte -logc -lz -lbz2 -lm -lwiikeyboard
LIBS := -lSDL -lemucommon -ltinysmb -lSDL_ttf -lSDL_image -lpng -lfreetype \
-lwiiuse -lfat -lbte -logc -lz -lbz2 -lm -lwiikeyboard

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := \
LIBDIRS := \
wii-emucommon/ \
wii-emucommon/sdl/SDL/lib \
wii-emucommon/sdl/SDL_ttf/lib \
Expand All @@ -72,19 +73,19 @@ LIBDIRS := \
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
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 := \
CFILES := \
zip.c \
unzip.c

CPPFILES := \
CPPFILES := \
Archive.cpp \
Bios.cpp \
Cartridge.cpp \
Expand All @@ -111,41 +112,44 @@ CPPFILES := \
wii_atari_snapshot.cpp \
wii_direct_sound.cpp

sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
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)
export LD := $(CC)
else
export LD := $(CXX)
export LD := $(CXX)
endif

export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
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),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC) \
-I$(DEVKITPRO)/portlibs/ppc/include \
-I$(DEVKITPRO)/portlibs/ppc/include/freetype2

export INCLUDE := \
$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC) \
-I$(DEVKITPRO)/portlibs/ppc/include \
-I$(DEVKITPRO)/portlibs/ppc/include/freetype2

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(CURDIR)/$(dir)) \
-L$(LIBOGC_LIB) \
-L$(DEVKITPRO)/portlibs/ppc/lib

export OUTPUT := $(CURDIR)/$(TARGET)
export LIBPATHS := \
$(foreach dir,$(LIBDIRS),-L$(CURDIR)/$(dir)) \
-L$(LIBOGC_LIB) \
-L$(DEVKITPRO)/portlibs/ppc/lib

export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
Expand All @@ -170,7 +174,7 @@ reload:
#---------------------------------------------------------------------------------
else

DEPENDS := $(OFILES:.o=.d)
DEPENDS := $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
Expand All @@ -181,7 +185,7 @@ $(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
Expand All @@ -191,14 +195,14 @@ $(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .png extension
#---------------------------------------------------------------------------------
%.png.o : %.png
%.png.o : %.png
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)

-include $(DEPENDS)

%.ttf.o : %.ttf
%.ttf.o : %.ttf
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
Expand All @@ -208,12 +212,12 @@ $(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)

%.mod.o : %.mod
%.mod.o : %.mod
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
Expand Down

0 comments on commit 18f9c88

Please sign in to comment.