Building PRX using Code::Blocks without makefile

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
DirkJanssen
Posts: 9
Joined: Mon Jan 11, 2010 1:31 am

Building PRX using Code::Blocks without makefile

Post by DirkJanssen »

Hi people,

I am trying to get my code compiling and outputting a prx file in Code::Blocks but I can't seem to get it working :s

I can compile a elf file without a problem, do some postbuild options to make an eboot file.

Code: Select all

PSP_MODULE_INFO("game", 0x0000, 1, 1);
PSP_HEAP_SIZE_MAX();
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER | THREAD_ATTR_VFPU);

// We replace the standaard printf function with the psp variant.
#define printf pspDebugScreenPrintf



/*!
*	@brief      The exit callback
*/
int exit_callback(int arg1, int arg2, void *common)
{
    sceKernelExitGame();

    return 0;
}


/*!
*	@brief      The callback thread
*/
int CallbackThread(SceSize args, void *argp)
{
    int cbid;

    cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
    sceKernelRegisterExitCallback(cbid);

    sceKernelSleepThreadCB();

    return 0;
}


/*!
*	@brief      Sets up a callback thread.
*
*	@returns    The id of the callback thread
*/
int SetupCallbacks(void)
{
    int thid = 0;

    thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
    if (thid >= 0)
    {
        sceKernelStartThread(thid, 0, 0);
    }

    return thid;
}

int main(void){

    printf("Test...\n");
/
    sceKernelSleepThread();
    return 0;
}
In code block I added the following values to the custom variables:

BUILD_PRX = 1
PSP_FW_VERSION = 371

now I change the output extention to prx but as far as the file, it still is an elf as it seems. Has anybody any pointers to get this to work in Code::Blocks without a makefile?

P.S. I know this is probably not enough information to give, but as there are a lot of settings, it is maybe wiser to list the info you require when asked for it?
Criptych
Posts: 64
Joined: Sat Sep 12, 2009 5:18 am

Re: Building PRX using Code::Blocks without makefile

Post by Criptych »

DirkJanssen wrote:In code block I added the following values to the custom variables:

BUILD_PRX = 1
PSP_FW_VERSION = 371
If you're not using a Makefile, these variables won't do anything, you'll have to add the appropriate post-build steps manually; check build.make (comes with the SDK) to see what they are.
"You hungry? I haven't eaten since later this afternoon."
User avatar
Ameen
Posts: 10
Joined: Sun Jun 14, 2009 6:28 am
Location: Bahrain
Contact:

Re: Building PRX using Code::Blocks without makefile

Post by Ameen »

Criptych wrote:
DirkJanssen wrote:In code block I added the following values to the custom variables:

BUILD_PRX = 1
PSP_FW_VERSION = 371
If you're not using a Makefile, these variables won't do anything, you'll have to add the appropriate post-build steps manually; check build.make (comes with the SDK) to see what they are.
Exactly, those must be in the Makefile!
DirkJanssen
Posts: 9
Joined: Mon Jan 11, 2010 1:31 am

Post by DirkJanssen »

@Criptych, thanks I was afraid of that, first look of it seems rather complex, but it will probably be not as difficult as it seems.

@Ameen, yeah I look into the build.mak file and it acts on those variables. The thing is, I don't want to use the makefiles, just the IDE.

Thanks for the replies guys!
Criptych
Posts: 64
Joined: Sat Sep 12, 2009 5:18 am

Post by Criptych »

DirkJanssen wrote:@Criptych, thanks I was afraid of that, first look of it seems rather complex, but it will probably be not as difficult as it seems.
Shouldn't be too difficult, IIRC the important ones are fixupexports and prxgen (plus mksfo and pack-pbp, for EBOOTs).
"You hungry? I haven't eaten since later this afternoon."
DirkJanssen
Posts: 9
Joined: Mon Jan 11, 2010 1:31 am

Post by DirkJanssen »

Hi people,

@Criptych, thanks for the pointers, have been trying to do this but I am stuck at the following places:

Code: Select all

ifeq ($(BUILD_PRX),1)
LDFLAGS  := $(addprefix -L,$(LIBDIR)) -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx $(LDFLAGS)
EXTRA_CLEAN += $(TARGET).elf
# Setup default exports if needed
ifdef PRX_EXPORTS
EXPORT_OBJ=$(patsubst %.exp,%.o,$(PRX_EXPORTS))
EXTRA_CLEAN += $(EXPORT_OBJ)
else 
EXPORT_OBJ=$(PSPSDK)/lib/prxexports.o
endif
else
LDFLAGS  := $(addprefix -L,$(LIBDIR)) $(LDFLAGS)
endif
Now as far as I understand this, it LDFLAGS are linker flags, the same as all the -lpspkernel -lc etc. Can I just copy this lines, fill in the variables and expect it to work correctly or do I have to change it somewhat?

Code: Select all

all: $(EXTRA_TARGETS) $(FINAL_TARGET)

kxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
	mkdir -p "$(TARGET)"
	$(STRIP) $(TARGET).elf -o $(TARGET)/$(PSP_EBOOT)
	mkdir -p "$(TARGET)%"
	$(PACK_PBP) "$(TARGET)%/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
		$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
		$(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)

SCEkxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
	mkdir -p "__SCE__$(TARGET)"
	$(STRIP) $(TARGET).elf -o __SCE__$(TARGET)/$(PSP_EBOOT)
	mkdir -p "%__SCE__$(TARGET)"
	$(PACK_PBP) "%__SCE__$(TARGET)/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
		$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
		$(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)

$(TARGET).elf: $(OBJS) $(EXPORT_OBJ)
	$(LINK.c) $^ $(LIBS) -o $@
	$(FIXUP) $@

$(TARGET_LIB): $(OBJS)
	$(AR) cru $@ $(OBJS)
	$(RANLIB) $@

$(PSP_EBOOT_SFO): 
	$(MKSFO) '$(PSP_EBOOT_TITLE)' $@

ifeq ($(BUILD_PRX),1)
$(PSP_EBOOT): $(TARGET).prx $(PSP_EBOOT_SFO)
	$(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
		$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
		$(PSP_EBOOT_SND0)  $(TARGET).prx $(PSP_EBOOT_PSAR)
else
$(PSP_EBOOT): $(TARGET).elf $(PSP_EBOOT_SFO)
	$(STRIP) $(TARGET).elf -o $(TARGET)_strip.elf
	$(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
		$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
		$(PSP_EBOOT_SND0)  $(TARGET)_strip.elf $(PSP_EBOOT_PSAR)
	-rm -f $(TARGET)_strip.elf
endif
The last part I get, see the batch file below.
What does the all: line mean? it does not seem to do anything?
the kxploit part is that neccesary? as it also does the pbp stuff. And what does the first line of the kxploit part mean? the rest is basicly batchfile stuff for creating the 2 directory with the correct files, but the first line is somewhat more difficult to translate.
The target elf: part seems to be the normal build process of all the sourcefiles, done by codeblocks now. the fixup is also in that line, do I have to start my batch file with the fixup? as yo usaid it is important.
And what does the targetlib part do?

Code: Select all

%.prx: %.elf
	psp-prxgen $< $@

%.c&#58; %.exp
	psp-build-exports -b $< > $@
How do I read this? psp-prxgen source target, where source = %.elf and target is %.prx, for which both the % stands for ?

And finally: I'm a little bit confused, it seems to me that an elf file is build, but all the option BUILD_PRX is overwriting, not creating an elf, but still it needs elfs? what am I not seeing regarding this?


CURRENT BATCH FILE (without the above issues):

Code: Select all

@echo off
@echo Create the Title.sfo
"C&#58;\cygwin\usr\local\pspdev\bin\mksfo.exe" GameTitle title.sfo

@echo Create the EBOOT.PBP
"C&#58;\cygwin\usr\local\pspdev\bin\pack-pbp.exe" EBOOT.PBP title.sfo NULL NULL NULL NULL NULL bin\Debug\GameTitle.prx NULL

@echo PRX-gen
"C&#58;\cygwin\usr\local\pspdev\bin\psp-prxgen.exe" bin\Debug\GameTitle.elf bin\Debug\GameTitle.prx

@echo Clean up all the files
copy bin\Debug\GameTitle.prx GameTitle\GT.prx
del title.sfo
del bin\Debug\GameTitle.prx

@echo Copy the executables and setup correct file structure!
md GameTitle
copy EBOOT.PBP GameTitle\EBOOT.PBP
del EBOOT.PBP
I hope you can help me a little bit further, every piece of info is more than welcome!

With kind regards
Last edited by DirkJanssen on Sun Jan 17, 2010 3:25 am, edited 1 time in total.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

I suggest you run a normal "make" i.e. go to a PSPSDK sample (say gu/sprite) and run 'make BUILD_PRX=1' in what ever you have available and see what psp-gcc lines are run. Then replicate those.
coyotebean
Posts: 18
Joined: Sat Dec 05, 2009 1:02 am

Post by coyotebean »

If you want to understand the Makefile, read the doc/spec on the Makefile :)

The basics I know is that the format is like this:

Code: Select all

target&#58; source files required to build this target
     command to execute
That "%" will looks like a template, i.e. to build "a.prx" requires "a.elf". And I would guess $@ in the command is the thing to the left of ":" and $< is all the stuff to the right of ":" in the "target" line.
Criptych
Posts: 64
Joined: Sat Sep 12, 2009 5:18 am

Post by Criptych »

As TyRaNiD said, running make normally will show you the commands as they are executed. You can also (with most versions) use make -n to show the commands but not execute them, and make -Bn to basically print out exactly what a shell script needs to do to perform the build.
"You hungry? I haven't eaten since later this afternoon."
DirkJanssen
Posts: 9
Joined: Mon Jan 11, 2010 1:31 am

Post by DirkJanssen »

Thanks that made a lot clear :D Have converted it to codeblocks now, will let you guys know if it worked! :D thanks again
Alberto
Posts: 51
Joined: Mon Feb 12, 2007 8:16 pm
Location: Sofia

Post by Alberto »

DirkJanssen wrote:Thanks that made a lot clear :D Have converted it to codeblocks now, will let you guys know if it worked! :D thanks again
Have you been successfull in having C::B do all the things for you without any external makefile? I am using C::B as well, and would be interested in this...

Cheers, A.
User avatar
bkc
Posts: 19
Joined: Tue May 20, 2008 8:45 pm
Location: Sweden
Contact:

Post by bkc »

I'm also very interested in having C::B doing all the work without me editing the makefile every time I add a sourcefile or use the C::B GUI to add libraries that it should link...
I only speak these languages:
  • C / C + +
  • (x)HTML
  • PHP
  • CSS
  • SQL
  • JavaScript
DirkJanssen
Posts: 9
Joined: Mon Jan 11, 2010 1:31 am

Post by DirkJanssen »

Yes I have it working now,

i used this tutorial:

http://forums.qj.net/psp-development-fo ... itpsp.html

After it I walked through the makefile and created this batchfile, as a post build script:

Code: Select all

@echo off

@echo Fix imports
"C&#58;\cygwin\usr\local\pspdev\bin\psp-fixup-imports.exe" bin\Debug\Game.elf

@echo PRX-gen
"C&#58;\cygwin\usr\local\pspdev\bin\psp-prxgen.exe" bin\Debug\Game.elf bin\Debug\Game.prx

@echo Create the Title.sfo
"C&#58;\cygwin\usr\local\pspdev\bin\mksfo.exe" Game title.sfo

@echo Create the EBOOT.PBP
"C&#58;\cygwin\usr\local\pspdev\bin\pack-pbp.exe" EBOOT.PBP title.sfo ../ImagesRelease/ICON0.PNG NULL NULL ../ImagesRelease/PIC1.PNG NULL bin\Debug\Game.prx NULL

@echo Copy the executables and setup correct file structure!
md Game
copy EBOOT.PBP Game\EBOOT.PBP
copy bin\Debug\Game.prx Game\Game.prx
copy bin\Debug\Game.elf Game\Game.elf

@echo Clean up all the files
del title.sfo
del bin\Debug\Game.prx
del bin\Debug\Game.elf
del EBOOT.PBP
And that all did the trick, let me know if it helped you guys out, theres some stuff in their probably only for me but you get the idea of it.
Post Reply