HOWTO: Compile the SDK on OSX - Consolidated Info

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

Moderators: cheriff, TyRaNiD

UsefulIdiot
Posts: 13
Joined: Tue Jan 17, 2006 4:44 pm

HOWTO: Compile the SDK on OSX - Consolidated Info

Post by UsefulIdiot »

HOWTO: Compile the PSP-SDK on MacOSX 10.4 Tiger
After spending many hours, and many attempts of installing and using the psptoolchain on my old ibook g3, I am writing a complete guide to consolidate all the required information that is necessary to build the sdk from the subversion repository. There are a number of threads which contain the same information in here, but in less detailed, and no specific order, which makes them very hard to follow through on. The following steps were completed on a fresh install of Mac OS X Tiger, and are known to work.

1.Install XCode & GNU Compiler Collection
In order to download xcode, and the gnu compiler collection for macs, you must register at the Apple Developer Connection. Point your browser of choice to http://connect.apple.com and register. Once complete, login, go into the downloads section, followed by Developer Tools section, and download the Xcode Tools 2.2.1 (Disk Image) which weighs in at 820MB. Once Downloaded, Install everything in the XcodeTools.mpkg installer. If you desire, you can remove the java components, sdk’s, and documentation to save space.

2. Install Fink & Tools
Point your browser to http://fink.sourceforge.net/download/index.php and download the Fink binaries for OSX (Direct Link: http://prdownloads.sourceforge.net/fink ... g?download ). Install fink from the disk image downloaded. During the install process, it will try to set profile variables, and fail, this is ok, we will set them ourselves in the next step. Next, open up a terminal ( Applications/Utilities/Terminal ) and enter the following command:

Code: Select all

sudo fink -y install autogen autoconf2.5 automake1.8 libtool make svn-client wget sdl libtool14

3. Set Environment Variables
Open a Terminal, and type the following commands

Code: Select all

cd ~/
vim .bash_profile
Once inside vim, type the following lines, then press escape, colon (: ) and then type wq (write and quit) followed by enter. It is very important to not miss any quotation marks below.

NOTE: You can do this in another editor, but make sure to save the filename correctly. For example, using TextEdit will save the file as .bash_profile.rtf instead of .bash_profile

Code: Select all

export PSPDEV="/usr/local/pspdev"
export PSPSDK="$PSPDEV/psp/sdk"
export PSPPATH="$PSPDEV/bin:$PSPDEV/psp/bin:$PSPSDK/bin"
export PATH="/sw/bin:$PATH:$PSPPATH"

4. Create a PSPDEV directory and handle permissions
Open a Terminal and type the following commands.

Code: Select all

sudo mkdir -p /usr/local/pspdev
sudo chmod a+rwx /usr/local/pspdev
5. Checkout the psptoolchain script from subversion, and run it.
Open a terminal and type:

Code: Select all

svn co svn://svn.ps2dev.org/psp/trunk/psptoolchain
cd psptoolchain
sh ./toolchain.sh
After these steps, the psp-sdk will compile, which will take a long time, sit back and relax, all your work is done(hopefully!)

Once the toolchain script is complete, The PSP SDK will be installed into /usr/local/pspdev .
bronxbomber92
Posts: 36
Joined: Fri Jul 21, 2006 11:00 am

Post by bronxbomber92 »

This should be stickied instead of the other one, as this less confusing, and explains better.
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

I should point out that making a .rtf file in Textedit will add extra stuff to it.

Its not recommended to do it this way.

Seeing there are a small amount of apple platforms i dont see why we cant have a pre compiled toolchain binary for each of the later OS's

Im going to compile the one for my macbook and post it in a DMG file

Hopefully this saves people time and money
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

Well I have compiled the toolchain.

I will upload it in dmg format tomorrow
Elenaher
Posts: 4
Joined: Tue Oct 03, 2006 4:04 am

Post by Elenaher »

I'm just a newb in PSP development and i tried to follow exactly your instructions but i got an error :

I'm using Os 10.4.7. I'm using FinkCommander and installation seems to be a bit different with it.
When toolshain.sh made its "wget" test, I got a first error because wget wasn't recognized as a command... I just modified toolshain.sh to and change wget to "/sw/bin/wget" ( idem for svn ).
Finally, i managed to launch the script.
I didn't got any problem during the download but i got many warnings from gcc during the compilation ( especially "warning: function declaration isn't a prototype" ).
At the end i got an "fatal" error on the compilation of a file named "flat_bl.m" :

Code: Select all

gcc -g -O2    -c -o flat_bl.o ../../gprof/flat_bl.m
../../gprof/flat_bl.m:2: error: parse error before '%' token
make[3]: *** [flat_bl.o] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [all-gprof] Error 2
ERROR BUILDING BINUTILS
Do you have any idea to help me ? Thank you.

( I got this error twice in two tests )

( I'm french so excuse my mistakes in english )
cycologist
Posts: 1
Joined: Sun Nov 12, 2006 11:34 am

PSPSDK toolchain compilation on OSX, latest Fink & scrip

Post by cycologist »

When compiling binutils on OSX I got errors in the gprof make, for some reason the flat_bl.m is used instead of flat_bl.c in the gcc call to produce the object file. Same happens with the other *.m files. I renamed these, since they were already used by the awk script to produce the C sources.

See also Elenaher's post from October 2nd, 2006, mentioning the same issue.

Is there an official fix, and, what is causing this mixup, error in makefile or is OSX behaving in some non-standard ways?
LopsidedElf
Posts: 2
Joined: Sun Mar 04, 2007 3:42 am

trouble with svn

Post by LopsidedElf »

Im kinda new to this and I'm trying to checkout the psptoolchain but when i type
svn co svn://svn.ps2dev.org/psp/trunk/psptoolchain
it gives me a -bash: svn: Command not found
I feel like i'm doing something stupid but if anyone could help thatd be great.
Thanks :)
bronxbomber92
Posts: 36
Joined: Fri Jul 21, 2006 11:00 am

Post by bronxbomber92 »

You need to install the svn tool.
LopsidedElf
Posts: 2
Joined: Sun Mar 04, 2007 3:42 am

svn tool

Post by LopsidedElf »

How would i do that?
User avatar
pailes
Posts: 16
Joined: Fri Feb 16, 2007 4:31 am
Contact:

Post by pailes »

seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Elenaher wrote:I'm just a newb in PSP development and i tried to follow exactly your instructions but i got an error :

I'm using Os 10.4.7. I'm using FinkCommander and installation seems to be a bit different with it.
When toolshain.sh made its "wget" test, I got a first error because wget wasn't recognized as a command... I just modified toolshain.sh to and change wget to "/sw/bin/wget" ( idem for svn ).
Finally, i managed to launch the script.
I didn't got any problem during the download but i got many warnings from gcc during the compilation ( especially "warning: function declaration isn't a prototype" ).
At the end i got an "fatal" error on the compilation of a file named "flat_bl.m" :

Code: Select all

gcc -g -O2    -c -o flat_bl.o ../../gprof/flat_bl.m
../../gprof/flat_bl.m:2: error: parse error before '%' token
make[3]: *** [flat_bl.o] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [all-gprof] Error 2
ERROR BUILDING BINUTILS
Do you have any idea to help me ? Thank you.

( I got this error twice in two tests )

( I'm french so excuse my mistakes in english )
I get the same error, anyone have a fix?
urchin
Posts: 121
Joined: Thu Jun 02, 2005 5:41 pm

Post by urchin »

".m" is also the extension for Objective C files, so on OS X gcc tries to compile the file and fails. If you search the other OS X threads, there's a way to fix this (you need to build with "make -r" I think)
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

How would i make the toolchain use make -r? do i just search and replace? Can make -r hurt the rest of the builds?
surfchen
Posts: 5
Joined: Sun Dec 10, 2006 5:36 am

Post by surfchen »

seventoes wrote:How would i make the toolchain use make -r? do i just search and replace? Can make -r hurt the rest of the builds?
1)open the toolchain.sh
2)find "ERROR BUILDING BINUTILS
3)replace $MAKE|| with $MAKE -r||


btw:the variable CFLAGS and other similar variables may make the progress to be failure..
Gardo
Posts: 7
Joined: Fri May 04, 2007 4:33 am

Post by Gardo »

Hi,

I followed the instructons in this thread http://forums.ps2dev.org/viewtopic.php?t=2792 and in step 6.
Grab the psptoolchain-200xxxxxxx.tgz script from http://www.oopo.net/consoledev/ . Safari should extract it as psptoolchain/ on the desktop, so type

Code: Select all

 cd ~/Desktop/psptoolchain/ 
./toolchain.sh 

I get:
Error while checking the dependencies. Aborting

Any ideas?

Thanx

BTW any way to unisntall fink?

EDIT: I think the problem starts here:

Code: Select all

  sudo fink -y install autogen autoconf2.5 automake1.8 libtool make svn-client wget sdl 

as libtool14 is missing, right?

I don't have my MAC here, but I'll try as soon as I'm back home.

Anyway, still any ideas?
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

try using the latest toolchain from svn
urchin
Posts: 121
Joined: Thu Jun 02, 2005 5:41 pm

Post by urchin »

Gardo wrote: BTW any way to unisntall fink?
I got rid of fink by deleting the /sw directory.
Gardo
Posts: 7
Joined: Fri May 04, 2007 4:33 am

Post by Gardo »

Well,
Wally4000 wrote: try using the latest toolchain from svn
Yepp! I've allrady done that, and I tried running the script

Code: Select all

 sh ./toolchain.sh 
when I ran it, everything seemed smooth, until I've got this:

Code: Select all

can't find file to patch at input line 2825
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -burN binutils-2.16.1/ld/configure.tgt binutils-psp/ld/configure.tgt
|--- binutils-2.16.1/ld/configure.tgt   2005-02-08 19:54:27.000000000 +0000
|+++ binutils-psp/ld/configure.tgt      2006-05-09 02:55:36.000000000 +0100
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
1 out of 1 hunk ignored
patching file ld/emulparams/elf_mipsallegrexel_psp.sh
can't find file to patch at input line 2863
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -burN binutils-2.16.1/ld/Makefile.am binutils-psp/ld/Makefile.am
|--- binutils-2.16.1/ld/Makefile.am     2005-01-20 19:37:49.000000000 +0000
|+++ binutils-psp/ld/Makefile.am        2006-05-09 02:55:36.000000000 +0100
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
2 out of 2 hunks ignored
can't find file to patch at input line 2884
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -burN binutils-2.16.1/ld/Makefile.in binutils-psp/ld/Makefile.in
|--- binutils-2.16.1/ld/Makefile.in     2005-01-23 05:36:37.000000000 +0000
|+++ binutils-psp/ld/Makefile.in        2006-05-09 02:55:36.000000000 +0100
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
2 out of 2 hunks ignored
patching file ld/scripttempl/elf_psp.sc
can't find file to patch at input line 3405
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -burN binutils-2.16.1/opcodes/mips-dis.c binutils-psp/opcodes/mips-dis.c
|--- binutils-2.16.1/opcodes/mips-dis.c 2005-03-03 11:49:50.000000000 +0000
|+++ binutils-psp/opcodes/mips-dis.c    2006-05-09 02:55:36.000000000 +0100
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
4 out of 4 hunks ignored
can't find file to patch at input line 3962
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -burN binutils-2.16.1/opcodes/mips-opc.c binutils-psp/opcodes/mips-opc.c
|--- binutils-2.16.1/opcodes/mips-opc.c 2005-03-03 11:49:50.000000000 +0000
|+++ binutils-psp/opcodes/mips-opc.c    2006-05-09 02:55:36.000000000 +0100
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
22 out of 22 hunks ignored
ERROR PATCHING BINUTILS
urchin wrote: I got rid of fink by deleting the /sw directory.
OK thanx dudes :)

BTW I did de BINUTILS fix, but I still get this errors when patching'em
Gardo
Posts: 7
Joined: Fri May 04, 2007 4:33 am

Post by Gardo »

Well, I've found out the problem... I didn't have bison and flex installed.

Code: Select all

 sudo fink -y install bison flex 
Now I've PSP SDK installed... the fun begins
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

Ah cool,

what ya goin to be workin on?
Gardo
Posts: 7
Joined: Fri May 04, 2007 4:33 am

Post by Gardo »

Wally4000 wrote:Ah cool,

what ya goin to be workin on?
I first want to start "understanding" how the PSP works, so I think before working an app from scrach I'll look at some open source apps, and from there we'll see; I'm interested in making plugins more than apps.

By the way, I've compiled some of the examples in /usr/local/pspdev/psp/sdk/samples with no problems, but I've tried to compile the neogeoCD 0.91 in order to be able to compile the MP3 Player plugin from IRshell (irsmp3) but i get:

Code: Select all

/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [neocd.elf] Error 1
before I was getting an other error, something to do with the zlib, I think something about the zlib.h missing.( I copied the zlib folder to the zip folder in the source code)

Any ideas what Im doing wrong?

cheers
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Build and install zlib for the psp. svn://svn.ps2dev.org/psp/trunk/zlib
Gardo
Posts: 7
Joined: Fri May 04, 2007 4:33 am

Post by Gardo »

jimparis wrote:Build and install zlib for the psp. svn://svn.ps2dev.org/psp/trunk/zlib
great tip, I've forgotten to run

Code: Select all

make install
thanx
isis
Posts: 1
Joined: Tue Jun 05, 2007 7:53 am

Post by isis »

hi !

here are the error I got when I run toolchain.sh

/bin/sh ./libtool --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -o ld-new ldgram.o ldlex.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o eelf_mipsallegrexel_psp.o eelf32elmip.o ../bfd/libbfd.la ../libiberty/libiberty.a ./../intl/libintl.a
mkdir .libs
gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -o ld-new ldgram.o ldlex.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o eelf_mipsallegrexel_psp.o eelf32elmip.o ../bfd/.libs/libbfd.a ../libiberty/libiberty.a ./../intl/libintl.a
../scripts/001-binutils-2.16.1.sh: Failed.


can anybody help me ?
thx
azza
Posts: 3
Joined: Mon Sep 03, 2007 7:00 pm

Post by azza »

HELLO!
I'm a new developper in the psp world and, I did the installation but , in the last command it displayed

Code: Select all

ERROR: Set $PSPDEV before continuing.
../depends/check-pspdev.sh: Failed.
How can I do?
PSPJunkie
Posts: 14
Joined: Tue Jan 23, 2007 12:55 pm
Location: Jersey
Contact:

Post by PSPJunkie »

If you would read the readme, you would get the answer.

Type:

Code: Select all

$ nano .bash_profile
Paste the following lines into .bash_profile:
export PSPDEV=/usr/local/pspdev
export PATH=$PATH:$PSPDEV/bin
Press CTRL + 'X', then type 'y', then hit enter.

Finally, type:

Code: Select all

$ source .bash_profile
Then try to run the toolchain script again.
azza
Posts: 3
Joined: Mon Sep 03, 2007 7:00 pm

Post by azza »

When I type "$ nano .bash_profile ", it puts "-bash: $:command not found"
then , now , What can I do ?
(sorry , but it's the first time I use the terminal to install something ...)
PSPJunkie
Posts: 14
Joined: Tue Jan 23, 2007 12:55 pm
Location: Jersey
Contact:

Post by PSPJunkie »

:/ The '$' just meant for you to type it into the terminal. Don't actually type it. :P
azza
Posts: 3
Joined: Mon Sep 03, 2007 7:00 pm

Post by azza »

AAAHH,thank you but now, when I try to run the toolchain script , it puts "ERROR: Install subversion before continuing.
../depends/check-subversion.sh: Failed."
???
thx
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

Install subversion. Before continuing.

The readme.txt has a list of stuff you need to install before running the script.
Post Reply