How to build standalone DOSBox SVN for OS X Lion with new SDL code

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby emendelson » 2011-8-30 @ 22:55

Everything in this post was worked out by Dominus, not by me, but I thought it might be useful to put all the details together in one place. Here how to build a standalone version of DOSBox SVN using the revised SDL 1.2 code that works correctly under Lion. This assumes that you already have DOSBox SVN code on your system.

EDIT: These instructions create a standalone build that can be used on any other Lion system, not just your own. (Dominus spells this out in one of his replies.) I needed to do this because I've build a downloadable application around DOSBox that I distribute freely.

1. Install MacPorts from http://www.macports.org

2. To make this version of DOSBox portable, and if (like me) you don't need sdl_net or sdl_sound, then install these items only:

Code: Select all
sudo port install libsdl +universal +no_x11
sudo port install libpng +universal
sudo port install pkgconfig +universal


3. Install Mercurial for OS X (find via Google), and then download the latest SDL 1.2 source code by using the hg clone command described on this page: http://www.libsdl.org/hg.php

4. Examine the downloaded code, and (if this has not been fixed by the time you do this), revert the change described on this page: http://hg.libsdl.org/SDL/rev/8e0dd46ad0e0

5. Create the following script in your SDL-1.2 folder and make it executable (chmod +x filename.sh):

Code: Select all
#!/bin/sh
export CC='/usr/bin/gcc-4.2 -arch i386'
export CXX='/usr/bin/g++-4.2 -arch i386'
export GCOV='/usr/bin/gcov-4.2 -arch i386'
./autogen.sh

## I didn't need joystick or cdrom, but they're easy to restore using the strings below
# ./configure --enable-static --enable-joystick --enable-cdrom --disable-video-x11 --enable-video-cocoa --enable-video-opengl --without-x --prefix=/path/for/SDL/binaries

## REPLACE path shown below with correct path for current system
./configure --enable-static --disable-video-x11 --enable-video-cocoa --without-x --prefix=/path/for/SDL/binaries

make clean
make
make install


Of course, replace "/path/for/SDL/binaries" with a path that can actually exist on your system. The path should either not exist, or be empty. It should not be the same path that contains the SDL 1.2 source code.

6. Run the script that you created, and see whether the SDL binaries were created in the path that you specified in the --prefix string. If successful, proceed to building DOSBox.

7. In your DOSBox SVN directory, create the following script and make it executable. Replace "/path/for/SDL/binaries" with the actual path that you specfied in step 5.

Code: Select all
#!/bin/sh

export CC='/usr/bin/gcc-4.2 -arch i386'
export CXX='/usr/bin/g++-4.2 -arch i386'
export GCOV='/usr/bin/gcov-4.2 -arch i386'

./autogen.sh

./configure --prefix=/opt/local --with-sdl-prefix=/path/for/SDL/binaries
make clean

sed -i.old -e "s@-L/path/for/SDL/binaries/lib -lSDLmain -lSDL -Wl,-framework,Cocoa@-L/path/for/SDL/binaries/lib/ /path/for/SDL/binaries/lib/libSDLmain.a /path/for/SDL/binaries/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit@g" Makefile

cd src

sed -i.old -e "s@-L/path/for/SDL/binaries/lib -lSDLmain -lSDL -Wl,-framework,Cocoa@-L/path/for/SDL/binaries/lib/ /path/for/SDL/binaries/lib/libSDLmain.a /path/for/SDL/binaries/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit@g" Makefile

cd ..

make


8. Run the script. Test the resulting dosbox executable on a system that does not have MacPorts installed.

If anything is wildly wrong here, I hope someone will correct it. As I said, Dominus worked out every detail of this, and I just put it all together in one post.

PS One further note: I've tested this only with my patched version of SVN, but if it works with my patched version, it should probably work with plain SVN.
Last edited by emendelson on 2012-9-06 @ 12:18, edited 2 times in total.
emendelson
Member
 
Posts: 434
Joined: 2010-2-14 @ 02:00

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby Dominus » 2011-8-30 @ 23:41

Actually this can all be shortcut if you don't care about Dosbox' screenshot functionality.
Without that you don't need MacPorts at all (I think, I'm not sure whether Dosbox will correctly run .configure if there is no libpng) (or compile it similar to SDL on your own thus eliminating the need for MacPorts)

Some corrections and hints:
in the SDL script the only important things are
./configure --enable-static --disable-video-x11 --without-x --prefix=/path/for/SDL/binaries all other things will get enabled by default anyway (so your builds *DO* have joystick and CD-Rom support), I just let it enable explicitly to make sure it gets done, but it should be done anyway :)

In step 7 you need to check what your sed command does. At the moment it doesn't do anything useful :)
You want to edit Makefile and replace the "Libs = ..." line and replace it with your own to make it build a static version of Dosbox.
So you need to replace "-L/path/for/SDL/binaries/lib -lSDLmain -lSDL" with "-L/path/for/SDL/binaries/lib /path/for/SDL/binaries/lib/libSDLmain.a /path/for/SDL/binaries/lib/libSDL.a -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,IOKit"
How I got to that replacement?
After you've done the Dosbox ./configure --prefix=/opt/local --with-sdl-prefix=/path/for/SDL/binaries look at the Makefiles "Libs = " line. This lists all the libs needed for a dynamic built. You want a static one.
So execute /path/for/SDL/binaries/bin/sdl-config --libs
and /path/for/SDL/binaries/bin/sdl-config --static-libs
The first one gives you the things you need to replace with the second one in the "Libs = " line.

ALSO!!! you will need to replace -lpng with /opt/local/lib/libpng14.a AND -lz with /opt/local/lib/libz.a

(so in the end the whole Libs line in the makefiles should read:
LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit /opt/local/lib/libpng14.a /opt/local/lib/libz.a -framework CoreMIDI
)
Since you haven't done the static png/lz thing, I assume your static built might be unstable when you try the screenshot function of Dosbox
User avatar
Dominus
DOSBox Moderator
 
Posts: 5389
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby Dominus » 2011-8-30 @ 23:43

sorry, your sed command is correct, you still need to do the whole thing sdl-config --static-libs gives you and the static path for png and libzip.

And to be nitpicky in your guide, make sure to note that the whole sed thing is only needed when the goal is to have a static Dosbox for use on other Macs. On your own mac with all the libs there a dynamic Dosbox works just fine and is one less hassle :)
Last edited by Dominus on 2011-8-31 @ 00:02, edited 1 time in total.
User avatar
Dominus
DOSBox Moderator
 
Posts: 5389
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby emendelson » 2011-8-31 @ 00:01

1.

Dominus wrote:Some corrections and hints:
in the SDL script the only important things are
./configure --enable-static --disable-video-x11 --without-x --prefix=/path/for/SDL/binaries all other things will get enabled by default anyway (so your builds *DO* have joystick and CD-Rom support), I just let it enable explicitly to make sure it gets done, but it should be done anyway :)


OK - I'll rework that. Thanks!

2.

Just to clarify: you're saying that I can ignore the whole paragraph in your first reply about my sed command?

3.

ALSO!!! you will need to replace -lpng with /opt/local/lib/libpng14.a AND -lz with /opt/local/lib/libz.a

(so in the end the whole Libs line in the makefiles should read:
LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit /opt/local/lib/libpng14.a /opt/local/lib/libz.a -framework CoreMIDI
)
Since you haven't done the static png/lz thing, I assume your static built might be unstable when you try the screenshot function of Dosbox


Hmm... when I run my build on a clean system (no MacPorts or Xcode or SDL installed, my builds don't capture the screen at all. When I press Ctrl-F5, the console doesn't report that a capture occurred, and nothing gets saved in the ~/Library/Preferences/capture directory. But I'll experiment with the changes you suggested anyway. I'll have to check whether anything happens on my own machine. I think I deliberately removed the screen capture ability (following your instructions) many months ago when I first started to attempt this.

4.

I've edited my first post to explain that the point of all this is to create a portable executable that can be run on anyone's Lion machine.

Thanks for getting back so quickly with this!
Last edited by emendelson on 2011-8-31 @ 00:08, edited 1 time in total.
emendelson
Member
 
Posts: 434
Joined: 2010-2-14 @ 02:00

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby Dominus » 2011-8-31 @ 00:07

Just to clarify: you're saying that I can ignore the whole paragraph about my sed command?

no, my writings got a little confusing, I think...
Your sed block is fine, it's just that it needs fine tuning, so everything "sdl-config --static-libs" gives back is really in the Libs= line (along with the other things). Your sed block is needed to make a static compile of Dosbox, for use on other machines that don't have macports, SDL etc...
The capture command is not working for you because you probably screwed things up by not adding it statically. Lucky that Dosbox doesn't crash :)
When you change it so it compiles the libpng/libz things static, it will capture on the other systems as well :)
User avatar
Dominus
DOSBox Moderator
 
Posts: 5389
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby Dominus » 2011-8-31 @ 00:11

you can add another sed line to replace -lpng -lz with opt/local/lib/libpng14.a /opt/local/lib/libz.a (you need to replace it both times of course)
User avatar
Dominus
DOSBox Moderator
 
Posts: 5389
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby emendelson » 2011-8-31 @ 00:29

Dominus wrote:
Just to clarify: you're saying that I can ignore the whole paragraph about my sed command?

no, my writings got a little confusing, I think...
Your sed block is fine, it's just that it needs fine tuning, so everything "sdl-config --static-libs" gives back is really in the Libs= line (along with the other things). Your sed block is needed to make a static compile of Dosbox, for use on other machines that don't have macports, SDL etc...
The capture command is not working for you because you probably screwed things up by not adding it statically. Lucky that Dosbox doesn't crash :)
When you change it so it compiles the libpng/libz things static, it will capture on the other systems as well :)


OK, will work on this tonight and will edit my post once I get everything working. Thanks again for taking such care over this. As I said in another method, I finally got SDL working by pure dumb luck and by reading error messages from the compiler, not by any knowledge.
emendelson
Member
 
Posts: 434
Joined: 2010-2-14 @ 02:00

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby emendelson » 2011-8-31 @ 01:38

Dominus wrote:you can add another sed line to replace -lpng -lz with opt/local/lib/libpng14.a /opt/local/lib/libz.a (you need to replace it both times of course)


Actually, my makefile doesn't have -lpng or -lz in it at all. In fact, when I go to stock DOSBox SVN, and run ./autogen.sh and ./configure, the makefile doesn't have png or libz at all. So I'm a bit puzzled by all this. My build does seem to work, and doesn't crash when I press Ctrl-F5...
emendelson
Member
 
Posts: 434
Joined: 2010-2-14 @ 02:00

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby Dominus » 2011-8-31 @ 06:35

Strange that it doesn't have -png. Are you sure you installed libpng via macports? Because configure should pick that up when it is availlable.
User avatar
Dominus
DOSBox Moderator
 
Posts: 5389
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby emendelson » 2011-8-31 @ 14:06

Dominus wrote:Strange that it doesn't have -png. Are you sure you installed libpng via macports? Because configure should pick that up when it is availlable.


Very strange. When I run "sudo port installed" the output includes this line (among many others):
libpng @1.4.8_0+universal (active)

Again, I don't understand this at all.
emendelson
Member
 
Posts: 434
Joined: 2010-2-14 @ 02:00

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby Dominus » 2011-8-31 @ 14:50

Oh, well, let's shrug it off and not think about it anymore ;)
User avatar
Dominus
DOSBox Moderator
 
Posts: 5389
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby emendelson » 2011-8-31 @ 15:39

Dominus wrote:Oh, well, let's shrug it off and not think about it anymore ;)


Agreed! My application works perfectly for what it's designed to do. But I'll probably now start experimenting with this, and if I find anything useful, I'll report back.

And, once again, a thousand thanks for making this possible. I hope it's OK with you that I tried to put together your advice this way, even if I got a few things wrong or backwards or otherwise confused!
emendelson
Member
 
Posts: 434
Joined: 2010-2-14 @ 02:00

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby Dominus » 2011-8-31 @ 15:48

No problem at all ;)
And yes please report anything back, I like to learn new things too.

I have something I'd really like you to test. I'll pm you.
User avatar
Dominus
DOSBox Moderator
 
Posts: 5389
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby emendelson » 2011-8-31 @ 15:53

Dominus wrote:I have something I'd really like you to test. I'll pm you.


I'll be very happy to do so!
emendelson
Member
 
Posts: 434
Joined: 2010-2-14 @ 02:00

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby emendelson » 2012-7-26 @ 12:46

I'm happy to report that DOSBox builds perfectly under OS X Mountain Lion, after updating MacPorts, and using the techniques spelled out by Dominus in other postings in this thread. Thank you again to Dominus!
Last edited by emendelson on 2012-7-26 @ 12:56, edited 1 time in total.
emendelson
Member
 
Posts: 434
Joined: 2010-2-14 @ 02:00

Re: How to build standalone DOSBox SVN for OS X Lion with new SDL code

Postby Dominus » 2012-7-26 @ 12:55

;) indeed it does
User avatar
Dominus
DOSBox Moderator
 
Posts: 5389
Joined: 2002-10-03 @ 09:54
Location: Vienna


Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 0 guests