First, before I start my ranting, I would like to ask all the Linux
developers to NOT hardcode the Paths of the datadirs or the installation
dirs. It makes portability really weak, especially for an OS like BeOS where
a /usr/local/… does not exist. Allow the game to run from ANY directory.
Just for reference, this is really hard to do. You can’t use the current
directory because the user may be running the program from another directory.
I’m attaching public code that we use at Loki to determine the installation
path in our products.
Here is the code in SDL for BeOS:
#include <AppKit.h>
#include <storage/Path.h>
#include <storage/Entry.h>
/* Check if we started from Terminal or Tracker... */
/* Based on code posted to BeDevTalk by Marco Nelissen */
char *cmd = getenv("_");
if(!(cmd == NULL || strlen(cmd) < 7) &&
(!strcmp(cmd + strlen(cmd) - 7 , "Tracker"))) {
/* Change working to directory to that of executable */
app_info info;
if (B_OK == be_app->GetAppInfo(&info)) {
entry_ref ref = info.ref;
BEntry entry;
if (B_OK == entry.SetTo(&ref)) {
BPath path;
if (B_OK == path.SetTo(&entry)) {
if (B_OK == path.GetParent(&path)) {
chdir(path.Path());
}
}
}
}
} /* else started from Terminal */
can’t even ‘configure --prefix’ any app for BeOS, as BeOS is not Unix/Linux.
Well, you can, but the desktop user isn’t set up to run things that way.
For the SDL maintainers:
I am trying to port a number of SDL games to the BeOS, but the SDL_ttf and
SDL_net do not compile.
As was mentioned, SDL_ttf hasn’t been updated for FreeType 2.0 yet.
By the way, running a program to test for a library in configure does work
if the dependent shared libraries are installed in a system directory.
e.g. libSDL.so -> ~/config/lib/
SDL_net also failed to create a makefile, but I managed to fix that. The
problem occured later though when the libtool failed to create a shared lib,
it only created a .a static lib. The reason for that was because
SDL_net_error() (or something like that, can’t remember now, I am at work
now) had an unresolved symbol. BeOS will NOT allow to create shared libs if
there are unresolved symbols lying around.
Have you tried the latest CVS?
http://www.libsdl.org/cvs/
SDL_image-1.1.1.tar.gz
SDL_image-1.1.1.zip
SDL_net-1.1.2.tar.gz
SDL_ttf-1.2.2.tar.gz
I’m hoping to release updated versions of these as soon as I can get
Windows and BeOS booting again. :-/
Sam, please, if you test with BeOS and you find your lib working and you
already have the compiled versions somewhere, please post on your website
these BeOS compiled libs, not just the source.
Will do.
Also, did you have a look at the SDL 1.2 I compiled for you?
I’m going to do that right now.
On a more happy note, here it is, Java bindings for SDL, by a fellow BeOS
community member: http://jsdl.sourceforge.net
Cool! Can I announce that on the SDL website?
See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software
-------------- next part --------------
Function to find the real directory a program resides in.
Feb. 17, 2000 - Sam Lantinga, Loki Entertainment Software
FindPath()
{
fullpath="echo $1 | grep /
“
if [ “$fullpath” = “” ]; then
oIFS=”$IFS"
IFS=:
for path in $PATH
do if [ -x “$path/$1” ]; then
if [ “$path” = “” ]; then
path=".“
fi
fullpath=”$path/$1"
break
fi
done
IFS="$oIFS"
fi
if [ “$fullpath” = “” ]; then
fullpath="$1"
fi
# Is the awk/ls magic portable?
if [ -L “$fullpath” ]; then
fullpath=ls -l "$fullpath" | awk '{print $11}'
fi
dirname $fullpath
}
FindPath $0
-------------- next part --------------
/*
Loki_Update - A tool for updating Loki products over the Internet
Copyright © 2000 Loki Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
info at lokigames.com
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define PATH_MAX 8192
void goto_installpath(char *argv0)
{
char temppath[PATH_MAX];
char datapath[PATH_MAX];
char *home;
home = getenv("HOME");
if ( ! home ) {
home = ".";
}
strcpy(temppath, argv0); /* If this overflows, it's your own fault :) */
if ( ! strrchr(temppath, '/') ) {
char *path;
char *last;
int found;
found = 0;
path = getenv("PATH");
do {
/* Initialize our filename variable */
temppath[0] = '\0';
/* Get next entry from path variable */
last = strchr(path, ':');
if ( ! last )
last = path+strlen(path);
/* Perform tilde expansion */
if ( *path == '~' ) {
strcpy(temppath, home);
++path;
}
/* Fill in the rest of the filename */
if ( last > (path+1) ) {
strncat(temppath, path, (last-path));
strcat(temppath, "/");
}
strcat(temppath, "./");
strcat(temppath, argv0);
/* See if it exists, and update path */
if ( access(temppath, X_OK) == 0 ) {
++found;
}
path = last+1;
} while ( *last && !found );
} else {
/* Increment argv0 to the basename */
argv0 = strrchr(argv0, '/')+1;
}
/* Now canonicalize it to a full pathname for the data path */
datapath[0] = '\0';
if ( realpath(temppath, datapath) ) {
/* There should always be '/' in the path */
*(strrchr(datapath, '/')) = '\0';
}
if ( ! *datapath || (chdir(datapath) < 0) ) {
fprintf(stderr, "Couldn't change to install directory\n");
exit(1);
}
}