- 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 mkinstalldirs
stamp-* stamp-*
compile compile
libltdl
ltmain.sh

View file

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

View file

@ -17,16 +17,25 @@ if [ "$1" = "clean" ]; then
fi fi
find . -name Makefile.in -print0 | xargs -r0 rm -f find . -name Makefile.in -print0 | xargs -r0 rm -f
rm -f aclocal.m4 install-sh missing mkinstalldirs \ rm -f aclocal.m4 install-sh missing mkinstalldirs \
stamp-h.in tags configure config.* \ stamp-* tags configure config.* \
compile depcomp stamp-h compile depcomp ltmain.sh
rm -rf autom4te.cache rm -rf autom4te.cache libltdl
find . -name '*~' -print0 | xargs -r0 rm -f find . -name '*~' -print0 | xargs -r0 rm -f
find . -name '*.rej' -print0 | xargs -r0 rm -f
find . -name '*.orig' -print0 | xargs -r0 rm -f
else 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 aclocal
autoheader autoheader
libtoolize --copy --ltdl --automake
automake --foreign --add-missing --copy automake --foreign --add-missing --copy
autoconf autoconf
else
echo "Need automake version 1.6 or higher"
fi
fi fi

View file

@ -1,10 +1,11 @@
dnl $Id$ dnl $Id$
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl usual stuff dnl stick the revision info into the resulting configure script
AC_PREREQ(2.50)
AC_INIT(src/main.c)
AC_REVISION($Revision$) dnl AC_REVISION($Revision$) dnl
AC_PREREQ(2.50)
AC_INIT(src/main.c)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
dnl get the build and target hosts dnl get the build and target hosts
@ -23,8 +24,14 @@ dnl Checks for programs
dnl ------------------- dnl -------------------
AC_PROG_CC 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="" HAVE_MASM=""
AC_SUBST(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_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_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="" DL_LIBS=""
if test "x$ac_cv_func_dlopen" != "xyes"; then if test "x$ac_cv_func_dlopen" != "xyes"; then
AC_CHECK_LIB(dl, AC_CHECK_LIB(dl,
@ -331,6 +339,25 @@ fi
AM_CONDITIONAL(DO_XATRIX, test "$DO_XATRIX" = "yes") AM_CONDITIONAL(DO_XATRIX, test "$DO_XATRIX" = "yes")
AM_CONDITIONAL(DO_ROGUE, test "$DO_ROGUE" = "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 ---------------------------------
dnl Work out what refreshers to build dnl Work out what refreshers to build
dnl --------------------------------- dnl ---------------------------------
@ -338,32 +365,32 @@ dnl ---------------------------------
VID_REFS="" VID_REFS=""
if test "x$HAVE_SVGALIB" = xyes; then if test "x$HAVE_SVGALIB" = xyes; then
VID_REFS="$VID_REFS ref_soft.so" VID_REFS="$VID_REFS ref_soft.la"
BUILD_SOFT="yes" BUILD_SOFT="yes"
fi fi
if test "x$HAVE_X" = xyes; then if test "x$HAVE_X" = xyes; then
VID_REFS="$VID_REFS ref_softx.so" VID_REFS="$VID_REFS ref_softx.la"
BUILD_SOFTX="yes" BUILD_SOFTX="yes"
fi fi
if test "x$HAVE_SDL" = xyes; then if test "x$HAVE_SDL" = xyes; then
VID_REFS="$VID_REFS ref_softsdl.so" VID_REFS="$VID_REFS ref_softsdl.la"
BUILD_SOFTSDL="yes" BUILD_SOFTSDL="yes"
fi fi
if test "x$HAVE_X" = xyes -a "x$HAVE_OPENGL" = xyes; then 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" BUILD_GLX="yes"
fi fi
if test "x$HAVE_X" = xyes -a "x$HAVE_GLIDE" = xyes -a "x$HAVE_SVGALIB" = xyes; then if test "x$HAVE_X" = xyes -a "x$HAVE_GLIDE" = xyes -a "x$HAVE_SVGALIB" = xyes; then
VIDREFS="$VID_REFS ref_fxgl.so" VID_REFS="$VID_REFS ref_tdfx.la"
BUILD_FXGL="yes" BUILD_TDFX="yes"
fi fi
if test "x$HAVE_X" = xyes -a "x$HAVE_OPENGL" = xyes -a "x$HAVE_SDL" = xyes; then 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" BUILD_SDLGL="yes"
fi 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_SOFTX, test "x$BUILD_SOFTX" = xyes)
AM_CONDITIONAL(BUILD_SOFTSDL, test "x$BUILD_SOFTSDL" = xyes) AM_CONDITIONAL(BUILD_SOFTSDL, test "x$BUILD_SOFTSDL" = xyes)
AM_CONDITIONAL(BUILD_GLX, test "x$BUILD_GLX" = 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) AM_CONDITIONAL(BUILD_SDLGL, test "x$BUILD_SDLGL" = xyes)
AC_SUBST(VID_REFS) AC_SUBST(VID_REFS)
@ -390,6 +417,7 @@ AC_CONFIG_FILES([
]) ])
AC_OUTPUT AC_OUTPUT
VID_REFS=`echo $VID_REFS | sed -e 's/ref_//g' -e 's/\.la//g'`
AC_MSG_RESULT([ AC_MSG_RESULT([
Video refreshers: ${VID_REFS- no} Video refreshers: ${VID_REFS- none}
]) ])

View file

@ -2,10 +2,14 @@
SUBDIRS = . baseq2 ctf xatrix rogue 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 \ bin_PROGRAMS = quake2
ref_glx.so ref_sdlgl.so ref_fxgl.so 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 # Common source files
REF_GL_COMMON = q_sh.c q_shared.c glob.c qgl.c \ 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 m_flash.c
# \ # \
# #snd_mixa.S # #snd_mixa.S
quake2_CFLAGS = $(ALL_CFLAGS) @INCLTDL@
quake2_LDFLAGS = -lm -pthread @DL_LIBS@ quake2_LDFLAGS = -lm -pthread
quake2_LDADD = @LIBLTDL@
#AM_CFLAGS = -Wall -Werror -pipe -I/usr/X11R6/include $(shell sdl-config --cflags) -DOPENGL -fPIC
AM_CFLAGS = -Wall -Werror -pipe
# ref_glx # ref_glx
if BUILD_GLX if BUILD_GLX
ref_glx_so_SOURCES = $(REF_GL_COMMON) gl_glx.c ref_glx_la_SOURCES = $(REF_GL_COMMON) gl_glx.c
ref_glx_so_CFLAGS = -fPIC @X_CFLAGS@ @OPENGL_CFLAGS@ ref_glx_la_CFLAGS = $(ALL_CFLAGS) -fPIC @X_CFLAGS@ @OPENGL_CFLAGS@
ref_glx_so_LDFLAGS = -shared ref_glx_la_LDADD = @X_PRE_LIBS@ @X_LIBS@ @XTRA_LIBS@ @X_EXTRA_LIBS@ @OPENGL_LIBS@ @DL_LIBS@
#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@
endif endif
# ref_fxgl # ref_tdfx
if BUILD_FXGL if BUILD_TDFX
ref_fxgl_so_SOURCES = $(REF_GL_COMMON) rw_in_svgalib.c gl_fxmesa.c ref_tdfx_la_SOURCES = $(REF_GL_COMMON) rw_in_svgalib.c gl_fxmesa.c
ref_fxgl_so_CFLAGS = -fPIC @GLIDE_CFLAGS@ @X_CFLAGS@ @SVGALIB_CFLAGS@ ref_tdfx_la_CFLAGS = $(ALL_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_tdfx_la_LDADD = @GLIDE_LIBS@ @X_LIBS@ @SVGALIB_LIBS@
#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@
endif endif
# ref_sdlgl # ref_sdlgl
if BUILD_SDLGL if BUILD_SDLGL
ref_sdlgl_so_SOURCES = $(REF_GL_COMMON) rw_sdl.c ref_sdlgl_la_SOURCES = $(REF_GL_COMMON) rw_sdl.c
ref_sdlgl_so_CFLAGS = -fPIC -DOPENGL @SDL_CFLAGS@ @OPENGL_CFLAGS@ ref_sdlgl_la_CFLAGS = $(ALL_CFLAGS) -fPIC -DOPENGL @SDL_CFLAGS@ @OPENGL_CFLAGS@
ref_sdlgl_so_LDFLAGS = -shared ref_sdlgl_la_LDADD = @SDL_LIBS@ @OPENGL_LIBS@
ref_sdlgl_so_LDADD = @SDL_LIBS@ @OPENGL_LIBS@
endif endif
# ref_soft # ref_soft
if BUILD_SOFT if BUILD_SOFT
if ASM_ARCH if ASM_ARCH
SOFT_ASM=$(REF_SOFT_ASM) d_copy.S DCOPY_S = d_copy.S
else else
SOFT_ASM=$(REF_SOFT_ASM) DCOPY_S =
endif 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 rw_svgalib.c rw_in_svgalib.c
ref_soft_so_CFLAGS = -fPIC @SVGALIB_CFLAGS@ ref_soft_la_CFLAGS = $(ALL_CFLAGS) -fPIC @SVGALIB_CFLAGS@
ref_soft_so_LDFLAGS = -shared ref_soft_la_LDADD = @SVGALIB_LIBS@
ref_soft_so_LDADD = @SVGALIB_LIBS@
endif endif
# ref_softx # ref_softx
if BUILD_SOFTX if BUILD_SOFTX
ref_softx_so_SOURCES = $(REF_SOFT_COMMON) $(REF_SOFT_ASM) rw_x11.c ref_softx_la_SOURCES = $(REF_SOFT_COMMON) $(REF_SOFT_ASM) rw_x11.c
ref_softx_so_CFLAGS = -fPIC @X_CFLAGS@ ref_softx_la_CFLAGS = $(ALL_CFLAGS) -fPIC @X_CFLAGS@
ref_softx_so_LDFLAGS = -shared ref_softx_la_LDADD = @X_PRE_LIBS@ @X_LIBS@ @XTRA_LIBS@ @X_EXTRA_LIBS@
#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@
endif endif
# ref_softsdl # ref_softsdl
if BUILD_SOFTSDL if BUILD_SOFTSDL
ref_softsdl_so_SOURCES = $(REF_SOFT_COMMON) $(REF_SOFT_ASM) rw_sdl.c ref_softsdl_la_SOURCES = $(REF_SOFT_COMMON) $(REF_SOFT_ASM) rw_sdl.c
ref_softsdl_so_CFLAGS = -fPIC @SDL_CFLAGS@ ref_softsdl_la_CFLAGS = $(ALL_CFLAGS) -fPIC @SDL_CFLAGS@
ref_softsdl_so_LDFLAGS = -shared ref_softsdl_la_LDADD = @SDL_LIBS@
ref_softsdl_so_LDADD = @SDL_LIBS@
endif endif

View file

@ -2,7 +2,8 @@
# Process this file with automake to create Makefile.in # 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 \ game_so_SOURCES = g_ai.c \
p_client.c \ p_client.c \
g_chase.c \ g_chase.c \

View file

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

View file

@ -1,22 +1,30 @@
/* /* $Id$
Copyright (C) 1997-2001 Id Software, Inc. *
* 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 #ifdef HAVE_CONFIG_H
modify it under the terms of the GNU General Public License # include "config.h"
as published by the Free Software Foundation; either version 2 #endif
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 "qcommon.h" #include "qcommon.h"
@ -31,15 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// OEM // OEM
//#define PAK0_CHECKSUM 0x78e135c //#define PAK0_CHECKSUM 0x78e135c
/*
=============================================================================
QUAKE FILESYSTEM
=============================================================================
*/
// //
// in memory // in memory
// //
@ -907,7 +906,8 @@ void FS_InitFilesystem (void)
// //
// add baseq2 to search path // 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 // then add a '.quake2/baseq2' directory in home directory by default

View file

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

View file

@ -1,22 +1,24 @@
/* /* $Id$
Copyright (C) 1997-2001 Id Software, Inc. *
* Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or * Copyright (c) 2002 The Quakeforge Project.
modify it under the terms of the GNU General Public License *
as published by the Free Software Foundation; either version 2 * This program is free software; you can redistribute it and/or
of the License, or (at your option) any later version. * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
This program is distributed in the hope that it will be useful, * of the License, or (at your option) any later version.
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
See the GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
You should have received a copy of the GNU General Public License * See the GNU General Public License for more details.
along with this program; if not, write to the Free Software *
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 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" #include "r_local.h"

View file

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

View file

@ -1,7 +1,8 @@
# $Id$ # $Id$
if DO_XATRIX 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 \ 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 \ g_items.c g_main.c g_misc.c g_monster.c g_phys.c \