Skip to content

Instantly share code, notes, and snippets.

@Razzlegames
Created October 17, 2020 20:51
Show Gist options
  • Save Razzlegames/68be18f2f895392c0b4e6c770c885307 to your computer and use it in GitHub Desktop.
Save Razzlegames/68be18f2f895392c0b4e6c770c885307 to your computer and use it in GitHub Desktop.
Makefile for PSP project
TARGET = RazzlePuzzle
#---------------------------------------------------------------------------------
# Icon and picture for your game in menu
#---------------------------------------------------------------------------------
# Uncomment and change to your picture name
#PSP_EBOOT_PIC1 = PIC1.PNG
#PSP_EBOOT_ICON = ICON0.PNG
# Build a PRX file
BUILD_PRX = 1
#---------------------------------------------------------------------------------
# Account for normal c/cpp files
#---------------------------------------------------------------------------------
CFILES := $(wildcard *.c)
CPPFILES := $(wildcard *.cpp)
export OBJS += \
$(CFILES:.c=.o) \
$(CPPFILES:.cpp=.o) \
PSP_FW_VERSION = 500
#---------------------------------------------------------------------------------
## Any other build targets you want to add
#---------------------------------------------------------------------------------
#OBJS += logo.o
CDEPS = $(CFILES:.c=.d)
CPPDEPS = $(CPPFILES:.cpp=.d)
DEPS = $(CDEPS) $(CPPDEPS)
SOURCES = $(CFILES) $(CPPFILES)
#---------------------------------------------------------------------------------
# Account for image c files
#---------------------------------------------------------------------------------
IMAGE_C := $(wildcard Images/*.c)
export OBJS += \
$(IMAGE_C:.c=.o)
DEPS += $(IMAGE_C:.c=.d)
INCDIR = ../ ./ $(PSPDIR)/include $(PSPDIR)/psp/include $(PSPSDK)/include
CFLAGS = -g3 -O0 -G0 -Wall -DPSP_BUILD
CXXFLAGS = $(CFLAGS) -fno-exceptions
# Had to allow rtti for boost library...
#-fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS= -lc -lstdc++ -lmikmod -lpspaudio -lpspgum -lpspgu -lpsprtc \
-lpng -lz -lm -lpsppower \
-lpspmp3 \
-lpspwlan \
-lpspusb \
-lpspusbstor \
-lpspgum \
-lpspgu \
-lm \
-lpspumd \
-lpspnet_adhocctl \
-lpspnet_adhocmatching \
-lpspnet_adhoc \
# original Libs
#LIBS = -lc -g -lpspgum -lpspgu -lpng -lz -lstdc++ -lm -lpsppower
EXTRA_TARGETS = EBOOT.PBP
EXTRA_CLEAN = $(DEPS)
PSP_EBOOT_TITLE = $(TARGET)
PSP_EBOOT_ICON = ./Images/icon.png
PSP_EBOOT_PIC1 = ./Images/boot_image.png
#PSP_EBOOT_SND0 = ./MusicSource/eboot_sound.wav
export PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
INCDIR += $(PSPSDK)/include
#---------------------------------------------------------------------------------
# Release details
#---------------------------------------------------------------------------------
REL_OPTIMIZE = -O2
export RELEASE_FOLDER = release_dir/TimeCube/
export RELEASE_FLAGS = -DBUILD_TYPE=RELEASE -DRELEASE $(REL_OPTIMIZE)
# Will create the release in RELEASE_FOLDER and ready for transfer to
# PSP
release: ctags
$(MAKE) "CFLAGS= $(addprefix -I,$(INCDIR)) $(RELEASE_FLAGS) \
-G0 -Wall -DPSP_BUILD "
-mkdir -p $(RELEASE_FOLDER)
cp -v EBOOT.PBP $(RELEASE_FOLDER)/
$(MAKE) release -C Music
$(MAKE) release -C Sounds
$(MAKE) release -C Images
rar: ctags
rar a $(TARGET).rar $(RELEASE_FOLDER)
#---------------------------------------------------------------------------------
# Remake editor tags
#---------------------------------------------------------------------------------
tags: $(SOURCES)
-ctags -R --sort=yes --c++-kinds=+cdefgmnpstux \
--fields=+iaKsS --extra=+q ./ ../
ctags: tags
sdk_ctags:
-ctags -R -o $(HOME)/.vim/ctags/psp_cpp --sort=yes --c++-kinds=+cdefgmnpstux \
--fields=+iaKS --extra=+q $(INCDIR) $(PSPSDK) $(PSPDIR)
#---------------------------------------------------------------------------------
# include all resource building targets
#---------------------------------------------------------------------------------
#include Images/images.mk
#include Sounds/sounds.mk
#include MusicSource/music.mk
#---------------------------------------------------------------------------------
# Rules for building Image c files if you have them
#---------------------------------------------------------------------------------
Images/%.o: Images/%.c
@echo "------------------------------------------------\n"
@echo "Building image $<"
@echo "------------------------------------------------\n"
@echo $(notdir $<)
$(CC) -MMD -MP -MF $*.d $(CFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# Rules for building cpp files (if you have them)
#---------------------------------------------------------------------------------
%.o: %.cpp
@echo $(notdir $<)
$(MAKE) tags
$(CXX) -MMD -MP -MF $*.d $(CXXFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# Rules for building c files if you have them
#---------------------------------------------------------------------------------
%.o: %.c
@echo $(notdir $<)
$(MAKE) tags
$(CC) -MMD -MP -MF $*.d $(CFLAGS) -c $< -o $@
-include $(DEPS)
##---------------------------------------------------------------------------------
## Maybe for a log target, you could use something like this
##---------------------------------------------------------------------------------
#logo.o: logo.raw
# bin2o -i logo.raw logo.o logo
.IGNORE: clean
#---------------------------------------------------------------------------------
# Get rid of all the intermediary makefiles (.d files)
#---------------------------------------------------------------------------------
clean-deps:
-rm $(DEPS)
#---------------------------------------------------------------------------------
# Clean Deps and all object files
#---------------------------------------------------------------------------------
clean-all: clean-deps clean
diff:
svn diff --diff-cmd=diffwrap
#-----------------------------------------------------------
# Ctags flag info:
#-----------------------------------------------------------
#C++
# c classes
# d macro definitions
# e enumerators (values inside an enumeration)
# f function definitions
# g enumeration names
# l local variables [off]
# m class, struct, and union members
# n namespaces
# p function prototypes [off]
# s structure names
# t typedefs
# u union names
# v variable definitions
# x external and forward variable declarations [off]
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment