Guide to building under OS X?

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Guide to building under OS X?

Post by emendelson »

Is there a guide anywhere to building SheepShaver or BasiliskII under OS X? The github source says that a file 0_How_To_Build.html should be BasiliskII's src/MacOSX folder, but it isn't there, and I can't find anything else. Any information would be welcome. Thanks!
User avatar
Cat_7
Expert User
Posts: 6176
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Guide to building under OS X?

Post by Cat_7 »

emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

Right here on the site! Thank you!
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

EDIT: I removed the content of this message because it only wasted space. It reported my problems building BII and SS under Mountain Lion - but, as later messages show, it's simply impossible to do this under Mountain Lion!
Last edited by emendelson on Sun Aug 11, 2013 12:04 pm, edited 1 time in total.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7835
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Guide to building under OS X?

Post by Ronald P. Regensburg »

As far as I know, it is is not possible to build SheepShaver (and BasiliskII ?) from the current source in OSX 10.8.x. The manual describes building SheepShaver in OSX 10.6.x and that is what I have been doing, also for my recent builds. I have not tried to build BasiliskII in OSX 10.8.x. I suppose it is possible to build a X Window version in OSX 10.8.x that will run in OSX with XQuartz.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

That explains it! I already use 10.6 for building one or two other things, so I'll transfer this experiment to that. Thank you.

One reason I want to make my own build is that I want to change the Ctrl-F5 grab-mouse key assignment. I know how to do this when building DOSBox, but I can't figure out where it is in SheepShaver or Basilisk. If anyone knows where the keystroke is assigned, I'll be grateful to learn about it.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

The guide is perfect: I was able to build BasiliskII and SheepShaver under 10.6. Thank you!

EDIT: Irrelevant information removed.
Last edited by emendelson on Sun Aug 11, 2013 5:23 pm, edited 1 time in total.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

EDIT: Irrelevant information removed.
Last edited by emendelson on Sun Aug 11, 2013 12:05 pm, edited 1 time in total.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7835
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Guide to building under OS X?

Post by Ronald P. Regensburg »

If you start again with a new Terminal window in the same folders that you used to compile SDL and BasiliskII, you need to first cd again into the SDL folder and do:

Code: Select all

PATH=`pwd`/bin:$PATH
export PATH
Then cd into the BasiliskII/src/Unix folder and before you start compiling do:

Code: Select all

make clean
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

Thank you. I did the first (export PATH) because you specified it in the guide, and I thought I had done the second, but apparently not. This worked correctly. Thank you again.

Meanwhile, does anyone know the answer to the question: Where in the code is "Ctrl-F5 grabs the cursor" so that I can change it to another key? Thanks in advance for any help.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7835
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Guide to building under OS X?

Post by Ronald P. Regensburg »

The mouse grabbing is in BasiliskII/src/SDL/video_sdl.cpp

I think you will need more advanced programming knowledge to make the desired change. You could ask our member vasi in a pm. He made the latest changes in the mouse grabbing feature to correct a bug in the Mac version.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

I know almost nothing about C++ programming, but I was able to patch the BasiliskII source so that Ctrl-Option-F5 grabs and releases the mouse, and it's now possible to make the change so that any combination of Ctrl, Option, and Cmd plus another key can grab the mouse. If anyone is interested, I'll post the changes here.

EDIT: The changes I made in Basilisk were also applied automatically to SheepShaver, because they use the same SDL code. In the SheepShaver source, I only had to modify one string so that the title bar tells the correct keystroke to use to release the mouse.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7835
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Guide to building under OS X?

Post by Ronald P. Regensburg »

I suppose some will be interested. (I will follow with my published builds the source as it is at cebix/macemu.)

If you have an account at GitHub, also send it in to cebix/macemu. Maybe it is a useful change that can be applied generally. Include an explanation about why you propose this change, the conflict with keystrokes in MacOS software.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

As requested; these are the changes to source that make the mouse-grab function work with Ctrl-Option-F5, not Ctrl-F5, and the toggle-fullscreen function work with Ctrl-Option-Return, not Ctrl-Return. They give an example of how to modify the keystroke for this function.

1. In BasiliskII/src/SDL/video_sdl.cpp:

Find the line that begins "static bool ctrl_down = false;" and add these two lines above or below it:

Code: Select all

static bool meta_down = false;	// Flag: Win/Cmd key pressed
static bool alt_down = false;		// Flag: Alt/Option key pressed
2. In the same file, find the block that reads:

Code: Select all

static bool is_ctrl_down(SDL_keysym const & ks)
{
	return ctrl_down || (ks.mod & KMOD_CTRL);
}
Add these blocks below it to enable the Option key and Cmd (Meta) key for this purpose:

Code: Select all

static bool is_alt_down(SDL_keysym const & ks)
{
	return alt_down || (ks.mod & KMOD_ALT);
}	

static bool is_meta_down(SDL_keysym const & ks)
{
		return meta_down || (ks.mod & KMOD_META);
}
3. In the same file, find the line that begins "case SDLK_F5". Change it to read:

Code: Select all

case SDLK_F5: if ((is_alt_down(ks)) & (is_ctrl_down(ks))) {if (!key_down) drv->toggle_mouse_grab(); return -2;} else return 0x60;
And, to change ctrl-return to ctrl-option-return for full-screen toggle, find the line that begins "CASE SDLK_RETURN" and change it to read:

Code: Select all

case SDLK_RETURN: if ((is_alt_down(ks)) & (is_ctrl_down(ks))) {if (!key_down) toggle_fullscreen = true; return -2;} else return 0x24;
4. In the file BasiliskII/src/Unix/video_x.cpp, find the line that begins: "case XK_F5". Change it to read:

Code: Select all

case XK_F5: if ((alt_down) & (ctrl_down)) {if (key_down) drv->toggle_mouse_grab(); return -2;} else return 0x60;
5. In the file BasiliskII/src/Unix/user_strings_unix.cpp, find the line that begins "{STR_WINDOW_TITLE_GRABBED, "Basilisk II" and change "Ctrl-F5" to "Ctrl-Option-F5".

6. Make the same change in SheepShaver/src/Unix/user_strings_unix.cpp.

7. In the file SheepShaver/src/Unix/video_x.cpp, find the line that begins "static bool ctrl_down = false;" and add these two lines above or below it:

Code: Select all

static bool alt_down = false;				// Flag: Alt key pressed
static bool meta_down = false;				// Flag: Cmd/Win key pressed
I hope this is some use to someone!

EDIT: Added the code for ctrl-option-return.
Last edited by emendelson on Sun Aug 11, 2013 12:02 pm, edited 1 time in total.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

I've also been experimenting (with no success) in the hope of setting up a keystroke that could restore the correct color palette after restoring SheepShaver from hidden to normal. It's possible to do this in DOSBox, which also uses SDL, as described here:

http://www.vogons.org/viewtopic.php?f=32&t=36383

But I'm not able to translate this into SheepShaver. If anyone can figure it out, a lot of us would be grateful!
User avatar
Ronald P. Regensburg
Expert User
Posts: 7835
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Guide to building under OS X?

Post by Ronald P. Regensburg »

emendelson wrote:As requested; these are the changes to source that make the mouse-grab function work with Ctrl-Option-F5, not Ctrl-F5.
Eh, doesn't this replace Ctrl-F5 by Cmd-Option-F5 rather than Ctrl-Option-F5 ?
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

The meta_down code is not actually used; I added it merely so that someone could use if they wanted to. The actual keystroke-detecting code uses ctrl_down and alt_down, not meta_down.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

Also, I remembered that I had asked a few months ago about changing Ctrl-Return to another key (for full-screen toggle) to avoid conflict with applications. I've now edited my long message above to include the change.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

I've now also tried building SheepShaver with Xcode. I get two baffling errors:

Command /Developer/usr/bin/g++-4.2 failed with exit code 1
Command /bin/sh failed with exit code 1

The details of the first are:

Code: Select all

ld: framework not found SDL
collect2: ld returned 1 exit status
Command /Developer/usr/bin/g++-4.2 failed with exit code 1
The second seems to refer to a command to "change SDL load path".

Is this possibly the result of having installed the SDL for command-line operation?

Any insight would be very welcome. Thanks!

EDIT: Added details.
User avatar
Cat_7
Expert User
Posts: 6176
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Guide to building under OS X?

Post by Cat_7 »

Yes,

See the compiling instructions about placing the SDL.framework in /Library/Frameworks.

-download the SDL-framework from http://www.libsdl.org/release/SDL-1.2.15-OSX10.4.dmg
-find the SDL.framework folder and copy it to your /Library/Frameworks/ folder.

The whole idea is to be able to build SheepShaver/Basilisk for PowerPC and Intel in one environment. This brings with it some difficulties in setting up the build environment and is also (part of) the reason to build with Xcode 3.x.

Best,
Cat_7
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

Cat_7 wrote:Yes,

See the compiling instructions about placing the SDL.framework in /Library/Frameworks.

-download the SDL-framework from http://www.libsdl.org/release/SDL-1.2.15-OSX10.4.dmg
-find the SDL.framework folder and copy it to your /Library/Frameworks/ folder.

The whole idea is to be able to build SheepShaver/Basilisk for PowerPC and Intel in one environment. This brings with it some difficulties in setting up the build environment and is also (part of) the reason to build with Xcode 3.x.

Best,
Cat_7
I did exactly that, following your instructions to the letter - and I set up a separate 10.6 system with a fresh install of Xcode and the SDL framework and fresh source code, just to make certain. Here is a screen shot of the folder structure:

Image

I wonder if the problem isn't connected to this:

http://www.emaculation.com/forum/viewto ... 9&start=50

As you can see from the screen shot below, there's a build phase that seems to change the SDL path away from the framework in /Library/Frameworks (unless, which is likely, I completely misunderstand all this):

Image

Is that causing this problem? I tried deleting that phase, but it didn't help.

Apologies if I am being stupid about all this!
User avatar
Cat_7
Expert User
Posts: 6176
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Guide to building under OS X?

Post by Cat_7 »

I don't know the answer to that one. Did you try to build the SDL.framework for all three architectures, as shown in the last two post in the thread you are linking to above?

You need to check whether your framework supports all three architectures. And you can try to place it in the Xcode Libraries location as well, besides Libraries/Frameworks (don't know the exact place right now).

Best,
Cat_7
User avatar
Ronald P. Regensburg
Expert User
Posts: 7835
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Guide to building under OS X?

Post by Ronald P. Regensburg »

I haven't built SheepShaver from the XCode project for some time. When I did, I used to build a three-architecture SDL.framework with XCode while making sure it was built with the same settings that were used for SheepShaver. The SheepShaver project does that automatically, for SDL settings must be set manually.

Here are the notes I made for myself as a reminder:

Get latest hg SDL:

hg clone -u SDL-1.2 http://hg.libsdl.org/SDL SDL-1.2


To build SDL with the same settings as SheepShaver, do the following:

Choose Release

Architecture: ppc i386 x86_64

Set Base SDK to 10.4. and add a "Build Setting Condition" on Base SDK to set it to 10.5 on Intel 64-bit.
Change C/C++ Compiler to GCC 4.0.
Set Mac OS X Deployment Target to 10.4 and add a "Build Setting Condition" on Mac OS X Deployment Target to 10.5 on Intel 64-bit.

To add a "Build Setting Condition", have the property selected and use the gear menu on the bottom left corner of the window in Xcode.

(Do not forget to also choose Release for the SheepShaver build.)
Last edited by Ronald P. Regensburg on Sun Aug 11, 2013 7:42 pm, edited 1 time in total.
Reason:  
User avatar
Ronald P. Regensburg
Expert User
Posts: 7835
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Guide to building under OS X?

Post by Ronald P. Regensburg »

BTW: The XCode project must be updated from time to time for changes in the source code. The last time the XCode project was updated is 5 months ago.
emendelson
Forum All-Star
Posts: 1726
Joined: Tue Oct 14, 2008 12:12 am

Re: Guide to building under OS X?

Post by emendelson »

EDIT: I wrote this before following Ronald's instructions. Will try them and report back
Cat_7 wrote:I don't know the answer to that one. Did you try to build the SDL.framework for all three architectures, as shown in the last two post in the thread you are linking to above?

You need to check whether your framework supports all three architectures. And you can try to place it in the Xcode Libraries location as well, besides Libraries/Frameworks (don't know the exact place right now).
Thank you again:

What I did was follow the instructions, and put the SDL framework in the /Library/Frameworks folder, as shown in my screen shot in a previous message. When I checked whether it supports all three architectures, the result seems to be that it does:

Image

I did try to add the SDL frameworks path the properties of the project:

Image

I still get the same result:

Image

You ask whether I built the SDL framework. I didn't, because the instructions didn't say to do so, and I don't have the faintest idea of how I would do so. I've looked all over the forum, and many messages refer to building the framework, but I haven't yet found any instructions. If you happen to remember where I might find them, I'll be grateful.

I really am following the instructions to the letter!

BTW: I downloaded the source code yesterday. The .xcodeproj file is dated 2 June 2013.
Post Reply