Author Topic: How to Port Wine for iPhone or arm  (Read 4009 times)

BooCocky

  • Leader
  • Hero Member
  • *****
  • Posts: 875
  • Reputation: 81
  • All your base are belong to ininjas
  • Badges:
  • Computers: Dell Inspirion
  • iDevices: ipod shuffle
How to Port Wine for iPhone or arm
« on: August 19, 2011, 02:03:48 pm »
Im posting this with the idea that it will be useful for future reference on the compilation of wine for other arm architechure devices.   If you are compiling on iDevice you will need atleast 2G of hardrive in /var partition.  Wine itself wont take up 2G, but when compiling Make creates files it needs on the fly which will take up a lot of space.  Also time, Probably about 4 hours of compiling.  Im still compiling :( so Im not %100 sure this will be useful.  Although its pretty much in the bag at this point as far as i'm concerned.

First thing you will need to do is download Wine.  This has only been tested with Wine-1.3.9. 

http://distfiles.macports.org/wine/wine-1.3.9.tar.bz2


Once you download the latest Wine.  You will need to edit some files.  First being the Make.vars.in file in the /Wine-1.3.9 directory.  Change the lines CC, LIBEXT, and DLLEXT from

Code: [Select]
CC = @CC@
LIBEXT = @LIBEXT@
DLLEXE = @DLLEXE@

to this:

Code: [Select]
CC = gcc
LIBEXT = so
DLLEXE = .so

Then, navigate to /Wine-1.3.9/libs/wine  And find the port.c file.  It that file is a register that xcode doesnt understand.  So we need to edit a couple lines near the end of the file after #elif defined(__arm__) && defined(__GNUC__)

You two lines your going to edit are

Code: [Select]
"push {r4,LR}\n\t"
"pop {r4,PC}"

to

Code: [Select]
"STMFD sp!, {r4,LR}\n\t"
"LDMFD r0!,{r4,PC}"


The next file, (in the same directory) is called loader.c

You need to find the wine_init function.  Were going to use the #ifdef #undef trick to undefine this function.  A litte harde to explain so here are screen shots of the file before and after.








Once we have done all this,  We can compile the first part of Wine.  The most important part being the tools. First set the CPP to 'gcc -E' 

Code: [Select]
export CPP='gcc -E'
 Use these configure flags:


Code: [Select]
./configure --build=arm --without-freetype --without-pthread --disable-win16
the --without-freetype and --without-pthread are optional if you have those installed or fell like compiling them yourself first.  Also, im not sure if you want to use the --enable-shared flag or not. 

Now run

Code: [Select]
make depend && make tools

After that, we need to go back into the file system and change the way winegcc behaves.  Navigate to the /Wine-1.3.9/dlls and open the Makedll.rules file and edit the WINEGCC line.  After the  -shared flag add -Wl,-read_only_relocs,suppress.  So it looks like this




If you dont see the Makedll.rules file.  Run make untill you get errors.  Then edit the Makedll.rules file
Then we can run make again.  Giving it the -k flag will tell it to keep going incase we get an error. 

Code: [Select]
make -k
This last make process is too create the .dll's and programs like calc, notepad, wow, things like that.  Not important.  Infact, the libwine file is already created.  You can download another wine source code, and when running configure, give it the --with-wine-tools=/wine-1.3.9   (where ever your precompiled wine-1.3.9 tools are stored)

Then go watch a movie or maybe even do this before you go to bed.  Ive been compiling for 4 hours now and still havent even gotten through all the DLLS yet.   Im pretty sure I got it though.  Im sure I will be adding to this.....

 
Ill be back laterz.
« Last Edit: August 22, 2011, 11:08:24 am by BooCocky »

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: How to Port Wine for iPhone or arm
« Reply #1 on: August 19, 2011, 02:36:02 pm »
Wow! Good going! Wine on iOS, who would have though? Awesome job man! Maximum respect!

BooCocky

  • Leader
  • Hero Member
  • *****
  • Posts: 875
  • Reputation: 81
  • All your base are belong to ininjas
  • Badges:
  • Computers: Dell Inspirion
  • iDevices: ipod shuffle
Re: How to Port Wine for iPhone or arm
« Reply #2 on: August 19, 2011, 02:50:38 pm »
thanks dude.  this is why I havent been on much the past week.

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: How to Port Wine for iPhone or arm
« Reply #3 on: August 19, 2011, 02:53:34 pm »
@Boo
On ios, shared libraries end with .dylib, not .so. Any reason you made it be .so? Also, that file gets edited by configure. It automatically detects those values and inserts them in the file. That trick you used with the push/pop to mov could be useful in another of my projects, mono.

BooCocky

  • Leader
  • Hero Member
  • *****
  • Posts: 875
  • Reputation: 81
  • All your base are belong to ininjas
  • Badges:
  • Computers: Dell Inspirion
  • iDevices: ipod shuffle
Re: How to Port Wine for iPhone or arm
« Reply #4 on: August 19, 2011, 02:57:12 pm »
right, you would think configure would set the variables.  But it trys to set them as sl and .sl.  Also the CC gets set to gcc -m24 or somthing like that.  And GCC cant use it.  Glad you pointes out the dylib part though.  Might have to change LIBEXT to dylib.  I also forgot you might run into errors with CPP so

Code: [Select]
export CPP='gcc -E'

Don't like seeing ads? Click here to register!

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: How to Port Wine for iPhone or arm
« Reply #5 on: August 19, 2011, 03:01:03 pm »
Why not g++?

BooCocky

  • Leader
  • Hero Member
  • *****
  • Posts: 875
  • Reputation: 81
  • All your base are belong to ininjas
  • Badges:
  • Computers: Dell Inspirion
  • iDevices: ipod shuffle
Re: How to Port Wine for iPhone or arm
« Reply #6 on: August 19, 2011, 03:06:01 pm »
I dont think that would work.  idk tbh, i know Ive used g++ before in porting and it gives alot of errors.  Maybe though,  now I wanna try using --enable-shared and setting LIBEXT to dylib.   Probably another week and it will be ported, its in the bag. 

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: How to Port Wine for iPhone or arm
« Reply #7 on: August 19, 2011, 03:08:49 pm »
Hopefully. You make it sound like a piece of cake (the cake is a lie!!!).

Sleepdawgg

  • Hero Member
  • *****
  • Posts: 544
  • Reputation: 37
  • Damn it feels good to be a gangsta
    • my twitter
  • Computers: hp dv6000 triple booting win 7, ubuntu and osx snow lepard in a vbox
  • iDevices: iPod touch 4g 5.0.1 jailbroken with redsnow untherethed iphone 3gs 4.3.2 jailbroken with jailbreak me [Android wildfire s rooted and s-off droid gingerbread 2.3.4 cdma][carrier unflashed]
Re: How to Port Wine for iPhone or arm
« Reply #8 on: August 20, 2011, 12:04:56 am »
Makes what we were doing with the emulators look cheesy +1 boo you rock can't wait to see how this works out and possibly try it. I don't know coding but am willing to learn for a chance at wine on iOS
NO PHONE BUT SHE STILL GIVING ME FACE TIME LOL

LankAsif

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2390
  • Reputation: 90
  • Forum pride 8)
  • Badges:
  • Computers: i7 with bits and pieces
  • iDevices: iPod Touch 1G (Basically storage for iNinja tools), iPhone 5
Re: How to Port Wine for iPhone or arm
« Reply #9 on: August 20, 2011, 02:48:28 pm »
Boo, how's it working out for you? Success?? Hope so. Props man.

Education is never achieved by wise men. it is only believed to have been achieved by fools

Don't like seeing ads? Click here to register!

BooCocky

  • Leader
  • Hero Member
  • *****
  • Posts: 875
  • Reputation: 81
  • All your base are belong to ininjas
  • Badges:
  • Computers: Dell Inspirion
  • iDevices: ipod shuffle
Re: How to Port Wine for iPhone or arm
« Reply #10 on: August 20, 2011, 07:36:15 pm »
OMG, I ran 'make -k' before I went to bed last night and when I woke up it stopped with an error because I ran out of disk space.  So I deleted a bunch of apps and stupid pictures and videos to try and keep up.  i might have to start from scratch.  I wish I had a cross compiler set up.  Fenyx tried setting that up but she said it didmt work out so well. 

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: How to Port Wine for iPhone or arm
« Reply #11 on: August 20, 2011, 07:37:28 pm »
Haha, ran out of disk space, classic.  I can only imagine how big the deb is going to be, lol.

A12danrulz

  • Leader
  • Hero Member
  • *****
  • Posts: 4016
  • Reputation: 216
  • Badges:
Re: How to Port Wine for iPhone or arm
« Reply #12 on: August 20, 2011, 07:47:16 pm »
Lol that's just classic.

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: How to Port Wine for iPhone or arm
« Reply #13 on: August 20, 2011, 07:49:11 pm »
Ya,

@boo I can only promise 10 gb of disk space on the server for wine, better figure out a way to make those debs with a really high compression ratio, lol

LankAsif

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2390
  • Reputation: 90
  • Forum pride 8)
  • Badges:
  • Computers: i7 with bits and pieces
  • iDevices: iPod Touch 1G (Basically storage for iNinja tools), iPhone 5
Re: How to Port Wine for iPhone or arm
« Reply #14 on: August 20, 2011, 08:21:51 pm »
Was it larger than expected or just didn't think to check space? That sucks man, bummer.

Education is never achieved by wise men. it is only believed to have been achieved by fools