| 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 |
| 9 |
|
| 10 |
include $(DEVKITPRO)/libogc2/gamecube_rules |
| 11 |
|
| 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 := genplus_cube_low-mem |
| 19 |
BUILD := build_cube_low-mem |
| 20 |
SOURCES := core core/m68k core/z80 core/sound core/sound/tremor core/ntsc core/input_hw core/cd_hw core/cart_hw core/cart_hw/svp \ |
| 21 |
gx gx/utils gx/gui gx/fileio gx/images gx/sounds |
| 22 |
INCLUDES := core core/m68k core/z80 core/sound core/sound/minimp3 core/sound/tremor core/ntsc core/input_hw core/cd_hw core/cart_hw core/cart_hw/svp \ |
| 23 |
gx gx/utils gx/gui gx/fileio gx/images gx/sounds |
| 24 |
|
| 25 |
#--------------------------------------------------------------------------------- |
| 26 |
# options for code generation |
| 27 |
#--------------------------------------------------------------------------------- |
| 28 |
|
| 29 |
CFLAGS = -O3 -fomit-frame-pointer -Wall -Wno-strict-aliasing $(MACHDEP) $(INCLUDE) -DUSE_LIBTREMOR -DDISABLE_MANY_OGG_OPEN_FILES -DUSE_16BPP_RENDERING -DALT_RENDERER -DBLIP_INVERT -DM68K_OVERCLOCK_SHIFT=20 -DZ80_OVERCLOCK_SHIFT=20 -DUSE_DYNAMIC_ALLOC |
| 30 |
CXXFLAGS = $(CFLAGS) |
| 31 |
|
| 32 |
LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map |
| 33 |
|
| 34 |
#--------------------------------------------------------------------------------- |
| 35 |
# any extra libraries we wish to link with the project |
| 36 |
#--------------------------------------------------------------------------------- |
| 37 |
LIBS := -lpng -lfat -liso9660 -lasnd -logc -lm -lz |
| 38 |
|
| 39 |
#--------------------------------------------------------------------------------- |
| 40 |
# list of directories containing libraries, this must be the top level containing |
| 41 |
# include and lib |
| 42 |
#--------------------------------------------------------------------------------- |
| 43 |
LIBDIRS := $(PORTLIBS) |
| 44 |
|
| 45 |
#--------------------------------------------------------------------------------- |
| 46 |
# no real need to edit anything past this point unless you need to add additional |
| 47 |
# rules for different file extensions |
| 48 |
#--------------------------------------------------------------------------------- |
| 49 |
ifneq ($(BUILD),$(notdir $(CURDIR))) |
| 50 |
#--------------------------------------------------------------------------------- |
| 51 |
|
| 52 |
export OUTPUT := $(CURDIR)/$(TARGET) |
| 53 |
|
| 54 |
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ |
| 55 |
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) |
| 56 |
|
| 57 |
export DEPSDIR := $(CURDIR)/$(BUILD) |
| 58 |
|
| 59 |
#--------------------------------------------------------------------------------- |
| 60 |
# automatically build a list of object files for our project |
| 61 |
#--------------------------------------------------------------------------------- |
| 62 |
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) |
| 63 |
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) |
| 64 |
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) |
| 65 |
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) |
| 66 |
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) |
| 67 |
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) |
| 68 |
PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm))) |
| 69 |
OGGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ogg))) |
| 70 |
|
| 71 |
#--------------------------------------------------------------------------------- |
| 72 |
# use CXX for linking C++ projects, CC for standard C |
| 73 |
#--------------------------------------------------------------------------------- |
| 74 |
ifeq ($(strip $(CPPFILES)),) |
| 75 |
export LD := $(CC) |
| 76 |
else |
| 77 |
export LD := $(CXX) |
| 78 |
endif |
| 79 |
|
| 80 |
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \ |
| 81 |
$(PNGFILES:.png=.png.o) $(PCMFILES:.pcm=.pcm.o) $(OGGFILES:.ogg=.ogg.o) |
| 82 |
|
| 83 |
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o) |
| 84 |
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) |
| 85 |
|
| 86 |
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) |
| 87 |
|
| 88 |
#--------------------------------------------------------------------------------- |
| 89 |
# build a list of include paths |
| 90 |
#--------------------------------------------------------------------------------- |
| 91 |
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ |
| 92 |
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ |
| 93 |
-I$(CURDIR)/$(BUILD) \ |
| 94 |
-I$(LIBOGC_INC) |
| 95 |
|
| 96 |
#--------------------------------------------------------------------------------- |
| 97 |
# build a list of library paths |
| 98 |
#--------------------------------------------------------------------------------- |
| 99 |
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ |
| 100 |
-L$(LIBOGC_LIB) |
| 101 |
|
| 102 |
export OUTPUT := $(CURDIR)/$(TARGET) |
| 103 |
.PHONY: $(BUILD) clean |
| 104 |
|
| 105 |
#--------------------------------------------------------------------------------- |
| 106 |
$(BUILD): |
| 107 |
@[ -d $@ ] || mkdir -p $@ |
| 108 |
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.gc.low-mem |
| 109 |
|
| 110 |
#--------------------------------------------------------------------------------- |
| 111 |
clean: |
| 112 |
@echo clean ... |
| 113 |
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol |
| 114 |
|
| 115 |
|
| 116 |
#--------------------------------------------------------------------------------- |
| 117 |
else |
| 118 |
|
| 119 |
DEPENDS := $(OFILES:.o=.d) |
| 120 |
|
| 121 |
#--------------------------------------------------------------------------------- |
| 122 |
# main targets |
| 123 |
#--------------------------------------------------------------------------------- |
| 124 |
$(OUTPUT).dol: $(OUTPUT).elf |
| 125 |
$(OUTPUT).elf: $(OFILES) |
| 126 |
|
| 127 |
$(OFILES_SOURCES) : $(HFILES) |
| 128 |
|
| 129 |
#--------------------------------------------------------------------------------- |
| 130 |
# This rule links in binary data with the various extension |
| 131 |
#--------------------------------------------------------------------------------- |
| 132 |
%.jpg.o %_jpg.h : %.jpg |
| 133 |
$(SILENTMSG) $(notdir $<) |
| 134 |
$(SILENTCMD)$(bin2o) |
| 135 |
|
| 136 |
|
| 137 |
%.png.o %_png.h : %.png |
| 138 |
$(SILENTMSG) $(notdir $<) |
| 139 |
$(SILENTCMD)$(bin2o) |
| 140 |
|
| 141 |
%.pcm.o %_pcm.h : %.pcm |
| 142 |
$(SILENTMSG) $(notdir $<) |
| 143 |
$(SILENTCMD)$(bin2o) |
| 144 |
|
| 145 |
%.ogg.o %_ogg.h : %.ogg |
| 146 |
$(SILENTMSG) $(notdir $<) |
| 147 |
$(SILENTCMD)$(bin2o) |
| 148 |
|
| 149 |
-include $(DEPENDS) |
| 150 |
|
| 151 |
#--------------------------------------------------------------------------------- |
| 152 |
endif |
| 153 |
#--------------------------------------------------------------------------------- |