Jump to content

PSP Programming/Creating Makefiles

From Wikibooks, open books for an open world

Makefile

[edit | edit source]

A makefile is used to quickly and easily compile our program when we are not using an IDE automating it. To create a makefile we just create a new file with no extension and give it the name "Makefile". We can then edit it in any simple text editor. To compile a program using a makefile we simply go to the folder using the command line (using "cd"), and type "make". The command line will tell you whether everything worked fine, or if there are errors to fix. Let's look at an example:

TARGET = my_program
OBJS   = main.o myLibrary.o

INCDIR   =
CFLAGS   = -G0 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS  = $(CFLAGS)

LIBDIR  =
LDFLAGS =
LIBS    = -lm

BUILD_PRX = 1 

EXTRA_TARGETS   = EBOOT.PBP
PSP_EBOOT_TITLE = My Program
PSP_EBOOT_ICON= ICON0.png
PSP_EBOOT_PIC1= PIC1.png
PSP_EBOOT_SND0= SND0.at3

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

As you can see, it's not that scary looking. Most of these parameters you won't even have to touch. The "target" tells the compiler the name of our source file, and "objs" to create a "main.o" and "myLibrary.o" as we are using "main.c" as the file where we program the code and “myLibrary.c” as a helper class. For now will not talk about the next four lines, just understand that we need them unchanged. Next we tell it the lib direction (same folder, so it is unchanged), a couple parameters, and the libraries which we will use.

Next we tell it to build a PRX binary rather than a static ELF binary. Static ELFs are generally depreciated, and only PRX-based homebrew can be signed to run on any PSP firmware. (PRX binaries in EBOOTs are different from PRX kernel mods!)

Afterwards we also create an "EBOOT.PBP" which is the file that will actually start up. Then you give it the title and have an option of an icon (144x80), a background picture (480x272), and a PSP sound file (at3). If you don't want one of these, then just delete the lines.