- Fixed up make install target, so that the dynamic modules

are installed into the correct places.
- Added libltdl, the libtool dynamic loader to the code, as
  the libraries are now under libtool control.  Libtool and
  libltdl are evil.
- Fixed various paths inside the code to point to PKGLIBDIR
  for the game and refresher modules, and PKGDATADIR for the
  game data.
- updated .gitignore
This commit is contained in:
Jamie Wilkinson 2002-07-04 00:50:09 +00:00
parent 0974879e67
commit 3973c870cc
13 changed files with 365 additions and 398 deletions

2
.gitignore vendored
View file

@ -15,3 +15,5 @@ missing
mkinstalldirs
stamp-*
compile
libltdl
ltmain.sh

View file

@ -1,3 +1,3 @@
# $Id$
SUBDIRS = src
SUBDIRS = libltdl src

View file

@ -17,16 +17,25 @@ if [ "$1" = "clean" ]; then
fi
find . -name Makefile.in -print0 | xargs -r0 rm -f
rm -f aclocal.m4 install-sh missing mkinstalldirs \
stamp-h.in tags configure config.* \
compile depcomp stamp-h
rm -rf autom4te.cache
stamp-* tags configure config.* \
compile depcomp ltmain.sh
rm -rf autom4te.cache libltdl
find . -name '*~' -print0 | xargs -r0 rm -f
find . -name '*.rej' -print0 | xargs -r0 rm -f
find . -name '*.orig' -print0 | xargs -r0 rm -f
else
VERSION=`automake --version |head| sed 's/automake (GNU automake) //'`
MAJOR=`echo $VERSION | cut -f1 -d.`
MINOR=`echo $VERSION | cut -f2 -d.`
if test "$MAJOR" -ge "1" -a "$MINOR" -ge "6"; then
aclocal
autoheader
libtoolize --copy --ltdl --automake
automake --foreign --add-missing --copy
autoconf
else
echo "Need automake version 1.6 or higher"
fi
fi

View file

@ -1,10 +1,11 @@
dnl $Id$
dnl Process this file with autoconf to produce a configure script.
dnl usual stuff
AC_PREREQ(2.50)
AC_INIT(src/main.c)
dnl stick the revision info into the resulting configure script
AC_REVISION($Revision$) dnl
AC_PREREQ(2.50)
AC_INIT(src/main.c)
AM_CONFIG_HEADER(config.h)
dnl get the build and target hosts
@ -23,8 +24,14 @@ dnl Checks for programs
dnl -------------------
AC_PROG_CC
#AC_PROG_RANLIB
#AC_PROG_LIBTOOL
dnl libtool is evil
AC_LIBTOOL_DLOPEN
AC_LIBLTDL_CONVENIENCE
AC_PROG_LIBTOOL
AC_CONFIG_SUBDIRS(libltdl)
AC_SUBST(INCLTDL)
AC_SUBST(LIBLTDL)
HAVE_MASM=""
AC_SUBST(HAVE_MASM)
@ -271,8 +278,9 @@ dnl -----------------------------
#AC_CHECK_FUNCS([bzero floor getcwd gethostbyname getmntent getpagesize gettimeofday memmove memset mkdir munmap pow putenv select socket sqrt strcasecmp strchr strdup strerror strrchr strstr])
AC_FUNC_VA_COPY
AC_FUNC__VA_COPY
AC_CHECK_FUNCS(dlopen)
dnl Check for dynamic loader -- needed for the GL refreshers
AC_CHECK_FUNCS(dlopen)
DL_LIBS=""
if test "x$ac_cv_func_dlopen" != "xyes"; then
AC_CHECK_LIB(dl,
@ -331,6 +339,25 @@ fi
AM_CONDITIONAL(DO_XATRIX, test "$DO_XATRIX" = "yes")
AM_CONDITIONAL(DO_ROGUE, test "$DO_ROGUE" = "yes")
dnl ----------------------
dnl Fill in path variables
dnl ----------------------
dnl $libdir usually gets set to ${exec_prefix}/lib,
dnl $exec_prefix is likely to be "NONE"
dnl Autoconf usually sets pkglibdir correctly in the Makefile, but not in
dnl the configure script :(
eval tmp_libdir="$libdir"
if test "x$tmp_libdir" != "xNONE/lib"; then
eval PKGLIBDIR="$libdir/$PACKAGE"
else
eval PKGLIBDIR="$prefix/lib/$PACKAGE"
fi
AC_DEFINE_UNQUOTED(PKGLIBDIR, "$PKGLIBDIR", [Define this to the path containing the dynamic modules (\${exec-prefix}/lib/quake2/)])
eval PKGDATADIR="$datadir/$PACKAGE"
AC_DEFINE_UNQUOTED(PKGDATADIR, "$PKGDATADIR", [Define this to the path containing the game data (\${prefix}/share/quake2/)])
dnl ---------------------------------
dnl Work out what refreshers to build
dnl ---------------------------------
@ -338,32 +365,32 @@ dnl ---------------------------------
VID_REFS=""
if test "x$HAVE_SVGALIB" = xyes; then
VID_REFS="$VID_REFS ref_soft.so"
VID_REFS="$VID_REFS ref_soft.la"
BUILD_SOFT="yes"
fi
if test "x$HAVE_X" = xyes; then
VID_REFS="$VID_REFS ref_softx.so"
VID_REFS="$VID_REFS ref_softx.la"
BUILD_SOFTX="yes"
fi
if test "x$HAVE_SDL" = xyes; then
VID_REFS="$VID_REFS ref_softsdl.so"
VID_REFS="$VID_REFS ref_softsdl.la"
BUILD_SOFTSDL="yes"
fi
if test "x$HAVE_X" = xyes -a "x$HAVE_OPENGL" = xyes; then
VID_REFS="$VID_REFS ref_glx.so"
VID_REFS="$VID_REFS ref_glx.la"
BUILD_GLX="yes"
fi
if test "x$HAVE_X" = xyes -a "x$HAVE_GLIDE" = xyes -a "x$HAVE_SVGALIB" = xyes; then
VIDREFS="$VID_REFS ref_fxgl.so"
BUILD_FXGL="yes"
VID_REFS="$VID_REFS ref_tdfx.la"
BUILD_TDFX="yes"
fi
if test "x$HAVE_X" = xyes -a "x$HAVE_OPENGL" = xyes -a "x$HAVE_SDL" = xyes; then
VID_REFS="$VID_REFS ref_sdlgl.so"
VID_REFS="$VID_REFS ref_sdlgl.la"
BUILD_SDLGL="yes"
fi
@ -371,7 +398,7 @@ AM_CONDITIONAL(BUILD_SOFT, test "x$BUILD_SOFT" = xyes)
AM_CONDITIONAL(BUILD_SOFTX, test "x$BUILD_SOFTX" = xyes)
AM_CONDITIONAL(BUILD_SOFTSDL, test "x$BUILD_SOFTSDL" = xyes)
AM_CONDITIONAL(BUILD_GLX, test "x$BUILD_GLX" = xyes)
AM_CONDITIONAL(BUILD_FXGL, test "x$BUILD_FXGL" = xyes)
AM_CONDITIONAL(BUILD_TDFX, test "x$BUILD_TDFX" = xyes)
AM_CONDITIONAL(BUILD_SDLGL, test "x$BUILD_SDLGL" = xyes)
AC_SUBST(VID_REFS)
@ -390,6 +417,7 @@ AC_CONFIG_FILES([
])
AC_OUTPUT
VID_REFS=`echo $VID_REFS | sed -e 's/ref_//g' -e 's/\.la//g'`
AC_MSG_RESULT([
Video refreshers: ${VID_REFS- no}
Video refreshers: ${VID_REFS- none}
])

View file

@ -2,10 +2,14 @@
SUBDIRS = . baseq2 ctf xatrix rogue
bin_PROGRAMS = quake2 @VID_REFS@
ALL_CFLAGS = -Wall -Werror -pipe
AM_LDFLAGS = -module -avoid-version -rpath $(pkglibdir)
#AM_LDFLAGS = -shared
EXTRA_PROGRAMS = ref_soft.so ref_softx.so ref_softsdl.so \
ref_glx.so ref_sdlgl.so ref_fxgl.so
bin_PROGRAMS = quake2
pkglib_PROGRAMS = @VID_REFS@
EXTRA_PROGRAMS = ref_soft.la ref_softx.la ref_softsdl.la \
ref_glx.la ref_sdlgl.la ref_tdfx.la
# Common source files
REF_GL_COMMON = q_sh.c q_shared.c glob.c qgl.c \
@ -48,66 +52,54 @@ quake2_SOURCES = main.c q_sh.c vid_menu.c vid_so.c glob.c net_udp.c \
m_flash.c
# \
# #snd_mixa.S
quake2_LDFLAGS = -lm -pthread @DL_LIBS@
#AM_CFLAGS = -Wall -Werror -pipe -I/usr/X11R6/include $(shell sdl-config --cflags) -DOPENGL -fPIC
AM_CFLAGS = -Wall -Werror -pipe
quake2_CFLAGS = $(ALL_CFLAGS) @INCLTDL@
quake2_LDFLAGS = -lm -pthread
quake2_LDADD = @LIBLTDL@
# ref_glx
if BUILD_GLX
ref_glx_so_SOURCES = $(REF_GL_COMMON) gl_glx.c
ref_glx_so_CFLAGS = -fPIC @X_CFLAGS@ @OPENGL_CFLAGS@
ref_glx_so_LDFLAGS = -shared
#ref_glx_so_LDADD = -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm -lGL
ref_glx_so_LDADD = @X_PRE_LIBS@ @X_LIBS@ @XTRA_LIBS@ @X_EXTRA_LIBS@ @OPENGL_LIBS@
ref_glx_la_SOURCES = $(REF_GL_COMMON) gl_glx.c
ref_glx_la_CFLAGS = $(ALL_CFLAGS) -fPIC @X_CFLAGS@ @OPENGL_CFLAGS@
ref_glx_la_LDADD = @X_PRE_LIBS@ @X_LIBS@ @XTRA_LIBS@ @X_EXTRA_LIBS@ @OPENGL_LIBS@ @DL_LIBS@
endif
# ref_fxgl
if BUILD_FXGL
ref_fxgl_so_SOURCES = $(REF_GL_COMMON) rw_in_svgalib.c gl_fxmesa.c
ref_fxgl_so_CFLAGS = -fPIC @GLIDE_CFLAGS@ @X_CFLAGS@ @SVGALIB_CFLAGS@
#ref_fxgl_so_LDFLAGS = -shared -L/usr/local/glide/lib -L/usr/X11R6/lib -L/usr/local/lib -lX11 -lXext -lGL -lvga
#ref_fxgl_so_LDFADD = -L/usr/local/glide/lib -L/usr/X11R6/lib -L/usr/local/lib -lX11 -lXext -lGL -lvga
ref_fxgl_so_LDFLAGS = -shared
ref_fxgl_so_LDADD = @GLIDE_LIBS@ @X_LIBS@ @SVGALIB_LIBS@
# ref_tdfx
if BUILD_TDFX
ref_tdfx_la_SOURCES = $(REF_GL_COMMON) rw_in_svgalib.c gl_fxmesa.c
ref_tdfx_la_CFLAGS = $(ALL_CFLAGS) -fPIC @GLIDE_CFLAGS@ @X_CFLAGS@ @SVGALIB_CFLAGS@
ref_tdfx_la_LDADD = @GLIDE_LIBS@ @X_LIBS@ @SVGALIB_LIBS@
endif
# ref_sdlgl
if BUILD_SDLGL
ref_sdlgl_so_SOURCES = $(REF_GL_COMMON) rw_sdl.c
ref_sdlgl_so_CFLAGS = -fPIC -DOPENGL @SDL_CFLAGS@ @OPENGL_CFLAGS@
ref_sdlgl_so_LDFLAGS = -shared
ref_sdlgl_so_LDADD = @SDL_LIBS@ @OPENGL_LIBS@
ref_sdlgl_la_SOURCES = $(REF_GL_COMMON) rw_sdl.c
ref_sdlgl_la_CFLAGS = $(ALL_CFLAGS) -fPIC -DOPENGL @SDL_CFLAGS@ @OPENGL_CFLAGS@
ref_sdlgl_la_LDADD = @SDL_LIBS@ @OPENGL_LIBS@
endif
# ref_soft
if BUILD_SOFT
if ASM_ARCH
SOFT_ASM=$(REF_SOFT_ASM) d_copy.S
DCOPY_S = d_copy.S
else
SOFT_ASM=$(REF_SOFT_ASM)
DCOPY_S =
endif
ref_soft_so_SOURCES = $(REF_SOFT_COMMON) $(SOFT_ASM) \
ref_soft_la_SOURCES = $(REF_SOFT_COMMON) $(REF_SOFT_ASM) $(DCOPY_S) \
rw_svgalib.c rw_in_svgalib.c
ref_soft_so_CFLAGS = -fPIC @SVGALIB_CFLAGS@
ref_soft_so_LDFLAGS = -shared
ref_soft_so_LDADD = @SVGALIB_LIBS@
ref_soft_la_CFLAGS = $(ALL_CFLAGS) -fPIC @SVGALIB_CFLAGS@
ref_soft_la_LDADD = @SVGALIB_LIBS@
endif
# ref_softx
if BUILD_SOFTX
ref_softx_so_SOURCES = $(REF_SOFT_COMMON) $(REF_SOFT_ASM) rw_x11.c
ref_softx_so_CFLAGS = -fPIC @X_CFLAGS@
ref_softx_so_LDFLAGS = -shared
#ref_softx_so_LDADD = -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm
ref_softx_so_LDADD = @X_PRE_LIBS@ @X_LIBS@ @XTRA_LIBS@ @X_EXTRA_LIBS@
ref_softx_la_SOURCES = $(REF_SOFT_COMMON) $(REF_SOFT_ASM) rw_x11.c
ref_softx_la_CFLAGS = $(ALL_CFLAGS) -fPIC @X_CFLAGS@
ref_softx_la_LDADD = @X_PRE_LIBS@ @X_LIBS@ @XTRA_LIBS@ @X_EXTRA_LIBS@
endif
# ref_softsdl
if BUILD_SOFTSDL
ref_softsdl_so_SOURCES = $(REF_SOFT_COMMON) $(REF_SOFT_ASM) rw_sdl.c
ref_softsdl_so_CFLAGS = -fPIC @SDL_CFLAGS@
ref_softsdl_so_LDFLAGS = -shared
ref_softsdl_so_LDADD = @SDL_LIBS@
ref_softsdl_la_SOURCES = $(REF_SOFT_COMMON) $(REF_SOFT_ASM) rw_sdl.c
ref_softsdl_la_CFLAGS = $(ALL_CFLAGS) -fPIC @SDL_CFLAGS@
ref_softsdl_la_LDADD = @SDL_LIBS@
endif

View file

@ -2,7 +2,8 @@
# Process this file with automake to create Makefile.in
bin_PROGRAMS = game.so
pkglibdir=$(libdir)/@PACKAGE@/baseq2
pkglib_PROGRAMS = game.so
game_so_SOURCES = g_ai.c \
p_client.c \
g_chase.c \

View file

@ -1,6 +1,7 @@
# $Id$
bin_PROGRAMS = game.so
pkglibdir=$(libdir)/@PACKAGE@/ctf
pkglib_PROGRAMS = game.so
game_so_SOURCES = \
g_ai.c \
g_chase.c \

View file

@ -1,22 +1,30 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* quake filesystem
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "qcommon.h"
@ -31,15 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// OEM
//#define PAK0_CHECKSUM 0x78e135c
/*
=============================================================================
QUAKE FILESYSTEM
=============================================================================
*/
//
// in memory
//
@ -907,7 +906,8 @@ void FS_InitFilesystem (void)
//
// add baseq2 to search path
//
FS_AddGameDirectory (va("%s/"BASEDIRNAME, fs_basedir->string) );
/*FS_AddGameDirectory (va("%s/"BASEDIRNAME, fs_basedir->string) );*/
FS_AddGameDirectory(PKGDATADIR"/"BASEDIRNAME);
//
// then add a '.quake2/baseq2' directory in home directory by default

View file

@ -53,9 +53,8 @@
#include <sys/file.h>
#endif
#ifdef HAVE_DLOPEN
# include <dlfcn.h>
#endif
/* libtool dynamic loader */
#include <ltdl.h>
/* merged from sys_bsd.c -- jaq */
#ifndef RTLD_NOW
@ -119,11 +118,11 @@ void Sys_Printf (char *fmt, ...) {
}
}
void Sys_Quit (void)
{
CL_Shutdown ();
Qcommon_Shutdown ();
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
void Sys_Quit (void) {
CL_Shutdown();
Qcommon_Shutdown();
lt_dlexit();
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
_exit(0);
}
@ -223,39 +222,21 @@ char *Sys_ConsoleInput(void)
/*****************************************************************************/
static void *game_library;
static lt_dlhandle game_library = NULL;
typedef game_export_t * gameapi_t(game_import_t *);
/*
=================
Sys_UnloadGame
=================
*/
void Sys_UnloadGame (void)
{
void Sys_UnloadGame(void) {
if (game_library)
dlclose (game_library);
lt_dlclose(game_library);
game_library = NULL;
}
/*
=================
Sys_GetGameAPI
Loads the game dll
=================
*/
void *Sys_GetGameAPI (void *parms)
{
game_export_t *(*GetGameAPI) (game_import_t *);
char name[MAX_OSPATH];
char *path;
char *str_p;
/* relnev 0.9 added -- jaq */
FILE * fp;
const char * gamename = "game.so";
/* Loads the game dll */
void *Sys_GetGameAPI (void *parms) {
gameapi_t * GetGameAPI;
cvar_t * gamename;
char path[MAX_OSPATH];
char * str_p;
setreuid(getuid(), getuid());
setegid(getgid());
@ -263,31 +244,23 @@ void *Sys_GetGameAPI (void *parms)
if (game_library)
Com_Error (ERR_FATAL, "Sys_GetGameAPI without Sys_UnloadingGame");
Com_Printf("------- Loading %s -------\n", gamename);
gamename = Cvar_Get("gamedir", BASEDIRNAME, CVAR_LATCH|CVAR_SERVERINFO);
// now run through the search paths
path = NULL;
while (1)
{
path = FS_NextPath (path);
if (!path)
return NULL; // couldn't find one anywhere
snprintf (name, MAX_OSPATH, "%s/%s", path, gamename);
Com_Printf("------- Loading %s -------\n", gamename->string);
/* relnev 0.9 added -- jaq */
/* skip it if it just doesn't exist */
fp = fopen(name, "rb");
if (fp == NULL)
continue;
fclose(fp);
/* set the module search path */
snprintf(path, MAX_OSPATH, ".:"PKGLIBDIR"/%s", gamename->string);
lt_dlsetsearchpath(path);
/* load the module */
game_library = lt_dlopenext("game.so");
game_library = dlopen(name, RTLD_NOW);
if (game_library) {
Com_MDPrintf ("LoadLibrary (%s)\n",name);
break;
Com_MDPrintf("LoadLibrary (%s)\n", gamename->string);
} else {
Com_MDPrintf ("LoadLibrary (%s)\n", name);
str_p = strchr(dlerror(), ':'); // skip the path (already shown)
Com_MDPrintf("LoadLibrary (%s)\n", gamename->string);
//str_p = strchr(lt_dlerror(), ':'); // skip the path (already shown)
str_p = (char *) lt_dlerror();
if (str_p != NULL) {
Com_MDPrintf (" **");
while (*str_p)
@ -295,17 +268,15 @@ void *Sys_GetGameAPI (void *parms)
Com_MDPrintf ("\n");
}
}
}
GetGameAPI = (game_export_t * (*)(game_import_t *)) dlsym(game_library, "GetGameAPI");
GetGameAPI = (gameapi_t *) lt_dlsym(game_library, "GetGameAPI");
if (!GetGameAPI)
{
if (!GetGameAPI) {
Sys_UnloadGame ();
return NULL;
}
return GetGameAPI (parms);
return GetGameAPI(parms);
}
/*****************************************************************************/
@ -327,37 +298,36 @@ void Sys_SendKeyEvents (void)
/*****************************************************************************/
int main (int argc, char **argv)
{
int main (int argc, char **argv) {
int time, oldtime, newtime;
// go back to real user for config loads
/* go back to real user for config loads */
saved_euid = geteuid();
seteuid(getuid());
/* relnev 0.9 added -- jaq */
printf("QuakeIIForge %s\n", VERSION);
/* initialiase libltdl */
lt_dlinit();
Qcommon_Init(argc, argv);
/* sys_irix.c had this and the fcntl line 3 lines down commented out */
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
nostdout = Cvar_Get("nostdout", "0", 0);
if (!nostdout->value) {
if (!nostdout->value)
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
// printf ("Linux Quake -- Version %0.3f\n", LINUX_VERSION);
}
/* main loop */
oldtime = Sys_Milliseconds ();
while (1)
{
// find time spent rendering last frame
while (1) {
/* find time spent rendering last frame */
do {
newtime = Sys_Milliseconds ();
newtime = Sys_Milliseconds();
time = newtime - oldtime;
} while (time < 1);
Qcommon_Frame (time);
Qcommon_Frame(time);
oldtime = newtime;
}
}

View file

@ -1,22 +1,24 @@
/*
Copyright (C) 1997-2001 Id 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id$
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include "r_local.h"

View file

@ -1,7 +1,8 @@
# $Id$
if DO_ROGUE
bin_PROGRAMS = game.so
pkglibdir=$(libdir)/@PACKAGE@/rogue
pkglib_PROGRAMS = game.so
game_so_SOURCES = dm_ball.c dm_tag.c \
g_ai.c g_chase.c g_cmds.c g_combat.c g_func.c \

View file

@ -42,7 +42,11 @@
#include <unistd.h>
#include <errno.h>
/* libtool dynamic loader */
#include <ltdl.h>
/* merged in from bsd -- jaq */
/*
#ifndef RTLD_NOW
#define RTLD_NOW RTLD_LAZY
#endif
@ -54,6 +58,7 @@
#ifdef __OpenBSD__
#define dlsym(X, Y) dlsym(X, "_"##Y)
#endif
*/
#include "client.h"
#include "rw.h"
@ -62,9 +67,11 @@
refexport_t re;
/* merged from irix/vid_so.c -- jaq */
/*
#ifdef REF_HARD_LINKED
refexport_t GetRefAPI(refimport_t rimp);
#endif
*/
// Console variables that we need to access from this module
cvar_t *vid_gamma;
@ -75,7 +82,7 @@ cvar_t *vid_fullscreen;
// Global variables used internally by this module
viddef_t viddef; // global video state; used by other modules
void *reflib_library; // Handle to refresh DLL
lt_dlhandle reflib_library = NULL; // Handle to refresh DLL
qboolean reflib_active = 0;
#define VID_NUM_MODES ( sizeof( vid_modes ) / sizeof( vid_modes[0] ) )
@ -213,9 +220,13 @@ void VID_FreeReflib (void)
if (RW_IN_Shutdown_fp)
RW_IN_Shutdown_fp();
/* merged from irix/vid_so.c -- jaq */
/*
#ifndef REF_HARD_LINKED
dlclose(reflib_library);
*/
lt_dlclose(reflib_library);
/*
#endif
*/
}
KBD_Init_fp = NULL;
@ -239,20 +250,13 @@ void VID_FreeReflib (void)
VID_LoadRefresh
==============
*/
qboolean VID_LoadRefresh( char *name )
{
qboolean VID_LoadRefresh(char * name) {
refimport_t ri;
/* from irix/vid_so.c -- jaq */
#ifndef REF_HARD_LINKED
GetRefAPI_t GetRefAPI;
#endif
char fn[MAX_OSPATH];
char *path;
struct stat st;
extern uid_t saved_euid;
if ( reflib_active )
{
/* clean up a previous reflib */
if (reflib_active) {
if (KBD_Close_fp)
KBD_Close_fp();
if (RW_IN_Shutdown_fp)
@ -263,30 +267,20 @@ qboolean VID_LoadRefresh( char *name )
VID_FreeReflib ();
}
/* from irix/vid_so.c -- jaq */
#ifndef REF_HARD_LINKED
Com_Printf( "------- Loading %s -------\n", name );
//regain root
seteuid(saved_euid);
path = Cvar_Get ("basedir", ".", CVAR_NOSET)->string;
snprintf (fn, MAX_OSPATH, "%s/%s", path, name );
if (stat(fn, &st) == -1) {
Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name, strerror(errno));
return false;
}
lt_dlsetsearchpath(".:"PKGLIBDIR);
// permission checking
if (strstr(fn, "softx") == NULL &&
strstr(fn, "glx") == NULL &&
strstr(fn, "softsdl") == NULL &&
strstr(fn, "sdlgl") == NULL &&
strstr(fn, "fxgl") == NULL) { // softx doesn't require root
#if 0
if (strstr(name, "softx") == NULL &&
strstr(name, "glx") == NULL &&
strstr(name, "softsdl") == NULL &&
strstr(name, "sdlgl") == NULL &&
strstr(name, "fxgl") == NULL) { /* ref_soft doesn't require root */
/*
if (st.st_uid != 0) {
Com_Printf( "LoadLibrary(\"%s\") failed: ref is not owned by root\n", name);
return false;
@ -295,21 +289,19 @@ qboolean VID_LoadRefresh( char *name )
Com_Printf( "LoadLibrary(\"%s\") failed: invalid permissions, must be 700 for security considerations\n", name);
return false;
}
#endif
*/
} else {
// softx requires we give up root now
/* ref_soft requires we give up root now */
setreuid(getuid(), getuid());
setegid(getgid());
}
if ( ( reflib_library = dlopen( fn, RTLD_LAZY | RTLD_GLOBAL ) ) == 0 )
{
Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name , dlerror());
if ((reflib_library = lt_dlopenext(name)) == 0) {
Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name , lt_dlerror());
return false;
}
Com_Printf( "LoadLibrary(\"%s\")\n", fn );
#endif /* REF_HARD_LINKED */
Com_Printf( "LoadLibrary(\"%s\")\n", name );
ri.Cmd_AddCommand = Cmd_AddCommand;
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
@ -328,15 +320,12 @@ qboolean VID_LoadRefresh( char *name )
ri.Vid_MenuInit = VID_MenuInit;
ri.Vid_NewWindow = VID_NewWindow;
#ifndef REF_HARD_LINKED
if ( ( GetRefAPI = (GetRefAPI_t) dlsym( reflib_library, "GetRefAPI" ) ) == 0 )
Com_Error( ERR_FATAL, "dlsym failed on %s", name );
#endif
if ((GetRefAPI = (GetRefAPI_t) lt_dlsym(reflib_library, "GetRefAPI")) == 0)
Com_Error(ERR_FATAL, "dlsym failed on %s", name);
re = GetRefAPI( ri );
if (re.api_version != API_VERSION)
{
if (re.api_version != API_VERSION) {
VID_FreeReflib ();
Com_Error (ERR_FATAL, "%s has incompatible api_version", name);
}
@ -347,81 +336,52 @@ qboolean VID_LoadRefresh( char *name )
in_state.viewangles = cl.viewangles;
in_state.in_strafe_state = &in_strafe.state;
#ifndef REF_HARD_LINKED
if ((RW_IN_Init_fp = (void (*)(in_state_t *)) dlsym(reflib_library, "RW_IN_Init")) == NULL ||
(RW_IN_Shutdown_fp = (void(*)(void)) dlsym(reflib_library, "RW_IN_Shutdown")) == NULL ||
(RW_IN_Activate_fp = (void(*)(qboolean)) dlsym(reflib_library, "RW_IN_Activate")) == NULL ||
(RW_IN_Commands_fp = (void(*)(void)) dlsym(reflib_library, "RW_IN_Commands")) == NULL ||
(RW_IN_Move_fp = (void(*)(usercmd_t *)) dlsym(reflib_library, "RW_IN_Move")) == NULL ||
(RW_IN_Frame_fp = (void(*)(void)) dlsym(reflib_library, "RW_IN_Frame")) == NULL)
if ((RW_IN_Init_fp = (void (*)(in_state_t *)) lt_dlsym(reflib_library, "RW_IN_Init")) == NULL ||
(RW_IN_Shutdown_fp = (void(*)(void)) lt_dlsym(reflib_library, "RW_IN_Shutdown")) == NULL ||
(RW_IN_Activate_fp = (void(*)(qboolean)) lt_dlsym(reflib_library, "RW_IN_Activate")) == NULL ||
(RW_IN_Commands_fp = (void(*)(void)) lt_dlsym(reflib_library, "RW_IN_Commands")) == NULL ||
(RW_IN_Move_fp = (void(*)(usercmd_t *)) lt_dlsym(reflib_library, "RW_IN_Move")) == NULL ||
(RW_IN_Frame_fp = (void(*)(void)) lt_dlsym(reflib_library, "RW_IN_Frame")) == NULL)
Sys_Error("No RW_IN functions in REF.\n");
/* this one is optional */
RW_Sys_GetClipboardData_fp = (char*(*)(void)) dlsym(reflib_library, "RW_Sys_GetClipboardData");
RW_Sys_GetClipboardData_fp = (char*(*)(void)) lt_dlsym(reflib_library, "RW_Sys_GetClipboardData");
Real_IN_Init();
#else /* ref-hard-linked */
{
void RW_IN_Init(in_state_t *in_state_p);
void RW_IN_Shutdown(void);
void RW_IN_Commands (void);
void RW_IN_Move (usercmd_t *cmd);
void RW_IN_Frame (void);
void RW_IN_Activate(void);
RW_IN_Init_fp = RW_IN_Init;
RW_IN_Shutdown_fp = RW_IN_Shutdown;
RW_IN_Activate_fp = (void(*)(qboolean))RW_IN_Activate;
RW_IN_Commands_fp = RW_IN_Commands;
RW_IN_Move_fp = RW_IN_Move;
RW_IN_Frame_fp = RW_IN_Frame;
}
#endif
if ( re.Init( 0, 0 ) == -1 )
{
if (re.Init(0, 0) == -1) {
re.Shutdown();
VID_FreeReflib ();
return false;
}
/* merged in from irix/vid_so.c */
/*
#ifdef __sgi
/* give up root now */
give up root now
setreuid(getuid(), getuid());
setegid(getgid());
#endif
*/
/* Init KBD */
#ifndef REF_HARD_LINKED
if ((KBD_Init_fp = (void(*)(Key_Event_fp_t)) dlsym(reflib_library, "KBD_Init")) == NULL ||
(KBD_Update_fp = (void(*)(void)) dlsym(reflib_library, "KBD_Update")) == NULL ||
(KBD_Close_fp = (void(*)(void)) dlsym(reflib_library, "KBD_Close")) == NULL)
if ((KBD_Init_fp = (void(*)(Key_Event_fp_t)) lt_dlsym(reflib_library, "KBD_Init")) == NULL ||
(KBD_Update_fp = (void(*)(void)) lt_dlsym(reflib_library, "KBD_Update")) == NULL ||
(KBD_Close_fp = (void(*)(void)) lt_dlsym(reflib_library, "KBD_Close")) == NULL)
Sys_Error("No KBD functions in REF.\n");
#else
{
void KBD_Init(void);
void KBD_Update(void);
void KBD_Close(void);
KBD_Init_fp = (void(*)(Key_Event_fp_t))KBD_Init;
KBD_Update_fp = KBD_Update;
KBD_Close_fp = KBD_Close;
}
#endif
KBD_Init_fp(Do_Key_Event);
/* for some reason irix has this swapped with elsewhere, kinda dodgy, needs
* cleaning */
#ifndef __sgi
Key_ClearStates();
// give up root now
setreuid(getuid(), getuid());
setegid(getgid());
#else
/* sgi
Real_IN_Init();
#endif
*/
Com_Printf( "------------------------------------\n");
reflib_active = true;

View file

@ -1,7 +1,8 @@
# $Id$
if DO_XATRIX
bin_PROGRAMS = game.so
pkglibdir=$(libdir)/@PACKAGE@/xatrix
pkglib_PROGRAMS = game.so
game_so_SOURCES = g_ai.c g_chase.c g_cmds.c g_combat.c g_func.c \
g_items.c g_main.c g_misc.c g_monster.c g_phys.c \