forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Building PRX using Code::Blocks without makefile

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
DirkJanssen



Joined: 11 Jan 2010
Posts: 9

PostPosted: Mon Jan 11, 2010 2:33 am    Post subject: Building PRX using Code::Blocks without makefile Reply with quote

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:
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?
Back to top
View user's profile Send private message
Criptych



Joined: 12 Sep 2009
Posts: 79

PostPosted: Mon Jan 11, 2010 8:32 am    Post subject: Re: Building PRX using Code::Blocks without makefile Reply with quote

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.
_________________
PSP-2000 // CFW: 5.50 GEN-D2 ...and not upgrading until OFW supports homebrew!
(But I did downgrade to 1.50 with TimeMachine...)
"I want you to tell me how the machine makes you feel."
Back to top
View user's profile Send private message
Ameen



Joined: 14 Jun 2009
Posts: 12
Location: Bahrain

PostPosted: Wed Jan 13, 2010 7:45 pm    Post subject: Re: Building PRX using Code::Blocks without makefile Reply with quote

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!
Back to top
View user's profile Send private message Visit poster's website
DirkJanssen



Joined: 11 Jan 2010
Posts: 9

PostPosted: Wed Jan 13, 2010 8:07 pm    Post subject: Reply with quote

@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!
Back to top
View user's profile Send private message
Criptych



Joined: 12 Sep 2009
Posts: 79

PostPosted: Thu Jan 14, 2010 5:50 am    Post subject: Reply with quote

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).
_________________
PSP-2000 // CFW: 5.50 GEN-D2 ...and not upgrading until OFW supports homebrew!
(But I did downgrade to 1.50 with TimeMachine...)
"I want you to tell me how the machine makes you feel."
Back to top
View user's profile Send private message
DirkJanssen



Joined: 11 Jan 2010
Posts: 9

PostPosted: Sat Jan 16, 2010 7:30 am    Post subject: Reply with quote

Hi people,

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

Code:
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:
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:
%.prx: %.elf
   psp-prxgen $< $@

%.c: %.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:
@echo off
@echo Create the Title.sfo
"C:\cygwin\usr\local\pspdev\bin\mksfo.exe" GameTitle title.sfo

@echo Create the EBOOT.PBP
"C:\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:\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
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Jan 16, 2010 7:47 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
coyotebean



Joined: 05 Dec 2009
Posts: 26

PostPosted: Sat Jan 16, 2010 10:29 pm    Post subject: Reply with quote

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:
target: 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.
Back to top
View user's profile Send private message
Criptych



Joined: 12 Sep 2009
Posts: 79

PostPosted: Sun Jan 17, 2010 2:36 am    Post subject: Reply with quote

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.
_________________
PSP-2000 // CFW: 5.50 GEN-D2 ...and not upgrading until OFW supports homebrew!
(But I did downgrade to 1.50 with TimeMachine...)
"I want you to tell me how the machine makes you feel."
Back to top
View user's profile Send private message
DirkJanssen



Joined: 11 Jan 2010
Posts: 9

PostPosted: Sun Jan 17, 2010 7:15 am    Post subject: Reply with quote

Thanks that made a lot clear :D Have converted it to codeblocks now, will let you guys know if it worked! :D thanks again
Back to top
View user's profile Send private message
Alberto



Joined: 12 Feb 2007
Posts: 57
Location: Sofia

PostPosted: Thu Jan 28, 2010 5:28 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
bkc



Joined: 20 May 2008
Posts: 20
Location: Sweden

PostPosted: Sat Jan 30, 2010 8:14 am    Post subject: Reply with quote

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 + +
  • ASM
  • Python
  • (x)HTML
  • PHP
  • CSS
  • SQL
  • JavaScript
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
DirkJanssen



Joined: 11 Jan 2010
Posts: 9

PostPosted: Mon Feb 15, 2010 2:10 am    Post subject: Reply with quote

Yes I have it working now,

i used this tutorial:

http://forums.qj.net/psp-development-forum/81882-tutorial-setting-up-code-blocks-devkitpsp.html

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

Code:
@echo off

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

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

@echo Create the Title.sfo
"C:\cygwin\usr\local\pspdev\bin\mksfo.exe" Game title.sfo

@echo Create the EBOOT.PBP
"C:\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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group