Changeset 182
- Timestamp:
- 06/10/07 11:56:57 (2 years ago)
- Files:
-
- trunk/acinclude.m4 (modified) (4 diffs)
- trunk/config.guess (deleted)
- trunk/config.sub (deleted)
- trunk/configure.ac (modified) (10 diffs)
- trunk/mk/objective.mk (modified) (1 diff)
- trunk/mk/rules.mk.in (modified) (5 diffs)
- trunk/src/Makefile (modified) (1 diff)
- trunk/src/Makefile.src (modified) (1 diff)
- trunk/src/autoconf.h.in (deleted)
- trunk/src/config.h (modified) (3 diffs)
- trunk/src/externs.h (modified) (2 diffs)
- trunk/src/files.c (modified) (2 diffs)
- trunk/src/h-basic.h (modified) (5 diffs)
- trunk/src/signals.c (added)
- trunk/src/z-file.c (modified) (7 diffs)
- trunk/src/z-file.h (modified) (1 diff)
- trunk/src/z-virt.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/acinclude.m4
r159 r182 101 101 102 102 if test x$sdl_exec_prefix != x ; then 103 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"104 if test x${SDL_CONFIG+set} != xset ; then105 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config106 fi107 fi108 if test x$sdl_prefix != x ; then109 sdl_args="$sdl_args --prefix=$sdl_prefix"110 if test x${SDL_CONFIG+set} != xset ; then111 SDL_CONFIG=$sdl_prefix/bin/sdl-config112 fi113 fi114 115 if test "x$prefix" != xNONE; then116 PATH="$prefix/bin:$prefix/usr/bin:$PATH"117 fi118 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])119 min_sdl_version=ifelse([$1], ,0.11.0,$1)120 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)121 no_sdl=""122 if test "$SDL_CONFIG" = "no" ; then123 no_sdl=yes124 else125 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`126 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`127 128 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \129 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`130 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \131 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`132 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \133 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`134 if test "x$enable_sdltest" = "xyes" ; then135 ac_save_CFLAGS="$CFLAGS"136 ac_save_CXXFLAGS="$CXXFLAGS"137 ac_save_LIBS="$LIBS"138 CFLAGS="$CFLAGS $SDL_CFLAGS"139 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"140 LIBS="$LIBS $SDL_LIBS"141 dnl142 dnl Now check if the installed SDL is sufficiently new. (Also sanity143 dnl checks the results of sdl-config to some extent144 dnl145 rm -f conf.sdltest146 AC_TRY_RUN([147 #include <stdio.h>148 #include <stdlib.h>149 #include <string.h>150 #include "SDL.h"151 152 char*153 my_strdup (char *str)154 {155 char *new_str;156 157 if (str)158 {159 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));160 strcpy (new_str, str);161 }162 else163 new_str = NULL;164 165 return new_str;166 }167 168 int main (int argc, char *argv[])169 {170 int major, minor, micro;171 char *tmp_version;172 173 /* This hangs on some systems (?)174 system ("touch conf.sdltest");175 */176 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }177 178 /* HP/UX 9 (%@#!) writes to sscanf strings */179 tmp_version = my_strdup("$min_sdl_version");180 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {181 printf("%s, bad version string\n", "$min_sdl_version");182 exit(1);183 }184 185 if (($sdl_major_version > major) ||186 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||187 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))188 {189 return 0;190 }191 else192 {193 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);194 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);195 printf("*** best to upgrade to the required version.\n");196 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");197 printf("*** to point to the correct copy of sdl-config, and remove the file\n");198 printf("*** config.cache before re-running configure\n");199 return 1;200 }201 }202 203 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])204 CFLAGS="$ac_save_CFLAGS"205 CXXFLAGS="$ac_save_CXXFLAGS"206 LIBS="$ac_save_LIBS"207 fi208 fi209 if test "x$no_sdl" = x ; then210 AC_MSG_RESULT(yes)211 ifelse([$2], , :, [$2])212 else213 AC_MSG_RESULT(no)214 if test "$SDL_CONFIG" = "no" ; then215 echo "*** The sdl-config script installed by SDL could not be found"216 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"217 echo "*** your path, or set the SDL_CONFIG environment variable to the"218 echo "*** full path to sdl-config."219 else220 if test -f conf.sdltest ; then221 :222 else223 echo "*** Could not run SDL test program, checking why..."224 CFLAGS="$CFLAGS $SDL_CFLAGS"225 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"226 LIBS="$LIBS $SDL_LIBS"227 AC_TRY_LINK([228 #include <stdio.h>229 #include "SDL.h"230 231 int main(int argc, char *argv[])232 { return 0; }233 #undef main234 #define main K_and_R_C_main235 ], [ return 0; ],236 [ echo "*** The test program compiled, but did not run. This usually means"237 echo "*** that the run-time linker is not finding SDL or finding the wrong"238 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"239 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"240 echo "*** to the installed location Also, make sure you have run ldconfig if that"241 echo "*** is required on your system"242 echo "***"243 echo "*** If you have an old version installed, it is best to remove it, although"244 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],245 [ echo "*** The test program failed to compile or link. See the file config.log for the"246 echo "*** exact error that occured. This usually means SDL was incorrectly installed"247 echo "*** or that you have moved SDL since it was installed. In the latter case, you"248 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])249 CFLAGS="$ac_save_CFLAGS"250 CXXFLAGS="$ac_save_CXXFLAGS"251 LIBS="$ac_save_LIBS"252 fi253 fi254 SDL_CFLAGS=""255 SDL_LIBS=""256 ifelse([$3], , :, [$3])257 fi258 AC_SUBST(SDL_CFLAGS)259 AC_SUBST(SDL_LIBS)260 rm -f conf.sdltest261 ])262 # Configure paths for SDL263 # Sam Lantinga 9/21/99264 # stolen from Manish Singh265 # stolen back from Frank Belew266 # stolen from Manish Singh267 # Shamelessly stolen from Owen Taylor268 269 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])270 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS271 dnl272 AC_DEFUN([AM_PATH_SDL],273 [dnl274 dnl Get the cflags and libraries from the sdl-config script275 dnl276 AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],277 sdl_prefix="$withval", sdl_prefix="")278 AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],279 sdl_exec_prefix="$withval", sdl_exec_prefix="")280 AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],281 , enable_sdltest=yes)282 283 if test x$sdl_exec_prefix != x ; then284 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"285 if test x${SDL_CONFIG+set} != xset ; then286 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config287 fi288 fi289 if test x$sdl_prefix != x ; then290 sdl_args="$sdl_args --prefix=$sdl_prefix"291 if test x${SDL_CONFIG+set} != xset ; then292 SDL_CONFIG=$sdl_prefix/bin/sdl-config293 fi294 fi295 296 if test "x$prefix" != xNONE; then297 PATH="$prefix/bin:$prefix/usr/bin:$PATH"298 fi299 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])300 min_sdl_version=ifelse([$1], ,0.11.0,$1)301 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)302 no_sdl=""303 if test "$SDL_CONFIG" = "no" ; then304 no_sdl=yes305 else306 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`307 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`308 309 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \310 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`311 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \312 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`313 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \314 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`315 if test "x$enable_sdltest" = "xyes" ; then316 ac_save_CFLAGS="$CFLAGS"317 ac_save_CXXFLAGS="$CXXFLAGS"318 ac_save_LIBS="$LIBS"319 CFLAGS="$CFLAGS $SDL_CFLAGS"320 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"321 LIBS="$LIBS $SDL_LIBS"322 dnl323 dnl Now check if the installed SDL is sufficiently new. (Also sanity324 dnl checks the results of sdl-config to some extent325 dnl326 rm -f conf.sdltest327 AC_TRY_RUN([328 #include <stdio.h>329 #include <stdlib.h>330 #include <string.h>331 #include "SDL.h"332 333 char*334 my_strdup (char *str)335 {336 char *new_str;337 338 if (str)339 {340 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));341 strcpy (new_str, str);342 }343 else344 new_str = NULL;345 346 return new_str;347 }348 349 int main (int argc, char *argv[])350 {351 int major, minor, micro;352 char *tmp_version;353 354 /* This hangs on some systems (?)355 system ("touch conf.sdltest");356 */357 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }358 359 /* HP/UX 9 (%@#!) writes to sscanf strings */360 tmp_version = my_strdup("$min_sdl_version");361 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {362 printf("%s, bad version string\n", "$min_sdl_version");363 exit(1);364 }365 366 if (($sdl_major_version > major) ||367 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||368 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))369 {370 return 0;371 }372 else373 {374 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);375 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);376 printf("*** best to upgrade to the required version.\n");377 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");378 printf("*** to point to the correct copy of sdl-config, and remove the file\n");379 printf("*** config.cache before re-running configure\n");380 return 1;381 }382 }383 384 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])385 CFLAGS="$ac_save_CFLAGS"386 CXXFLAGS="$ac_save_CXXFLAGS"387 LIBS="$ac_save_LIBS"388 fi389 fi390 if test "x$no_sdl" = x ; then391 AC_MSG_RESULT(yes)392 ifelse([$2], , :, [$2])393 else394 AC_MSG_RESULT(no)395 if test "$SDL_CONFIG" = "no" ; then396 echo "*** The sdl-config script installed by SDL could not be found"397 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"398 echo "*** your path, or set the SDL_CONFIG environment variable to the"399 echo "*** full path to sdl-config."400 else401 if test -f conf.sdltest ; then402 :403 else404 echo "*** Could not run SDL test program, checking why..."405 CFLAGS="$CFLAGS $SDL_CFLAGS"406 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"407 LIBS="$LIBS $SDL_LIBS"408 AC_TRY_LINK([409 #include <stdio.h>410 #include "SDL.h"411 412 int main(int argc, char *argv[])413 { return 0; }414 #undef main415 #define main K_and_R_C_main416 ], [ return 0; ],417 [ echo "*** The test program compiled, but did not run. This usually means"418 echo "*** that the run-time linker is not finding SDL or finding the wrong"419 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"420 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"421 echo "*** to the installed location Also, make sure you have run ldconfig if that"422 echo "*** is required on your system"423 echo "***"424 echo "*** If you have an old version installed, it is best to remove it, although"425 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],426 [ echo "*** The test program failed to compile or link. See the file config.log for the"427 echo "*** exact error that occured. This usually means SDL was incorrectly installed"428 echo "*** or that you have moved SDL since it was installed. In the latter case, you"429 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])430 CFLAGS="$ac_save_CFLAGS"431 CXXFLAGS="$ac_save_CXXFLAGS"432 LIBS="$ac_save_LIBS"433 fi434 fi435 SDL_CFLAGS=""436 SDL_LIBS=""437 ifelse([$3], , :, [$3])438 fi439 AC_SUBST(SDL_CFLAGS)440 AC_SUBST(SDL_LIBS)441 rm -f conf.sdltest442 ])443 # Configure paths for SDL444 # Sam Lantinga 9/21/99445 # stolen from Manish Singh446 # stolen back from Frank Belew447 # stolen from Manish Singh448 # Shamelessly stolen from Owen Taylor449 450 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])451 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS452 dnl453 AC_DEFUN([AM_PATH_SDL],454 [dnl455 dnl Get the cflags and libraries from the sdl-config script456 dnl457 AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],458 sdl_prefix="$withval", sdl_prefix="")459 AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],460 sdl_exec_prefix="$withval", sdl_exec_prefix="")461 AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],462 , enable_sdltest=yes)463 464 if test x$sdl_exec_prefix != x ; then465 103 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" 466 104 if test x${SDL_CONFIG+set} != xset ; then … … 475 113 fi 476 114 477 AC_REQUIRE([AC_CANONICAL_TARGET]) 478 PATH="$prefix/bin:$prefix/usr/bin:$PATH" 479 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) 115 AC_PATH_PROG(SDL_CONFIG, sdl-config, no) 480 116 min_sdl_version=ifelse([$1], ,0.11.0,$1) 481 117 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) … … 585 221 #include <stdio.h> 586 222 #include "SDL.h" 587 588 int main(int argc, char *argv[])589 { return 0; }590 #undef main591 #define main K_and_R_C_main592 223 ], [ return 0; ], 593 224 [ echo "*** The test program compiled, but did not run. This usually means" … … 616 247 rm -f conf.sdltest 617 248 ]) 249 trunk/configure.ac
r181 r182 1 1 dnl Process this file with autoconf to produce a configure script. 2 AC_INIT([ angband], [3.0.8], [bugs@rephial.org])2 AC_INIT([Angband], [3.0.8], [bugs@rephial.org], [angband]) 3 3 AC_PREREQ([2.50]) 4 5 AC_CANONICAL_HOST6 AC_CANONICAL_TARGET7 4 8 5 AC_CONFIG_HEADER(src/autoconf.h) … … 17 14 dnl Check for C compiler 18 15 AC_PROG_CC 19 AC_ISC_POSIX20 AC_C_BIGENDIAN21 16 22 17 test "$GCC" = "yes" && CFLAGS="$CFLAGS -Wall -pipe -g -fno-strength-reduce" … … 32 27 AC_PATH_PROG(MV, mv) 33 28 AC_PATH_PROG(CP, cp) 34 AC_PATH_PROG(AR, ar)35 AC_PATH_PROG(RANLIB, ranlib)36 29 37 30 AC_ARG_WITH(setgid, … … 91 84 [enable_sdl_mixer=$enable_sdl_mixer], 92 85 [enable_sdl_mixer=yes]) 86 87 93 88 94 89 … … 127 122 fi 128 123 124 129 125 dnl X11 checking 130 126 if test "$enable_x11" = "yes"; then … … 140 136 fi 141 137 fi 138 142 139 143 140 dnl SDL checking … … 158 155 fi 159 156 fi 157 160 158 161 159 dnl GTK checking … … 177 175 fi 178 176 177 179 178 dnl SDL mixer checking 180 181 179 if test "$enable_sdl_mixer" = "yes"; then 182 180 AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio, found_sdl_mixer=yes, found_sdl_mixer=no) … … 189 187 190 188 191 dnl Check for headers. 192 dnl AC_HEADER_STDBOOL -- not yet 193 AC_HEADER_TIME 194 AC_CHECK_HEADERS([unistd.h fcntl.h dirent.h limits.h stdint.h sys/time.h termios.h]) 195 196 dnl Check for types. 189 190 dnl Check for headers, types, functions 191 AC_CHECK_HEADERS([fcntl.h stdint.h]) 192 AC_HEADER_STDBOOL 193 AC_C_CONST 197 194 AC_TYPE_SIGNAL 198 199 dnl Check for structs. 200 AC_STRUCT_TM 201 202 dnl Check for functions. 203 AC_CHECK_FUNCS([memmove memset mkdir strtol mkstemp setegid can_change_color]) 195 AC_CHECK_FUNCS([mkstemp setegid can_change_color]) 196 197 204 198 205 199 dnl XXX: Work around some autoconf bugs. … … 212 206 213 207 214 AC_CONFIG_FILES([ 215 mk/rules.mk 216 ]) 208 AC_CONFIG_FILES([mk/rules.mk]) 217 209 218 210 AC_OUTPUT trunk/mk/objective.mk
r74 r182 262 262 echo "[building depend file for subobjective: $$i]"; \ 263 263 fi; \ 264 cd $$i; touch .depend; $(MAKE) depend || exit; cd ..; \264 cd $$i; touch .depend; $(MAKE) -f Makefile depend || exit; cd ..; \ 265 265 if [ $(VERBOSITY) -gt 0 ]; then \ 266 266 echo "[finished subobjective: $$i]"; \ trunk/mk/rules.mk.in
r165 r182 21 21 PRE_UNINSTALL = : 22 22 POST_UNINSTALL = : 23 build_triplet = @build@24 host_triplet = @host@25 target_triplet = @target@26 23 subdir = . 27 24 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 … … 55 52 distuninstallcheck_listfiles = find . -type f -print 56 53 distcleancheck_listfiles = find . -type f -print 57 ACLOCAL = @ACLOCAL@58 54 ALLOCA = @ALLOCA@ 59 55 AMDEP_FALSE = @AMDEP_FALSE@ 60 56 AMDEP_TRUE = @AMDEP_TRUE@ 61 57 AMTAR = @AMTAR@ 62 AR = @AR@63 AUTOCONF = @AUTOCONF@64 AUTOHEADER = @AUTOHEADER@65 AUTOMAKE = @AUTOMAKE@66 58 AWK = @AWK@ 67 59 BUILDERS_INCLUDES = @BUILDERS_INCLUDES@ … … 76 68 CPP = @CPP@ 77 69 CPPFLAGS += @CPPFLAGS@ 78 CXX = @CXX@79 CXXCPP = @CXXCPP@80 CXXDEPMODE = @CXXDEPMODE@81 CXXFLAGS += @CXXFLAGS@82 70 CYGPATH_W = @CYGPATH_W@ 83 71 DATA_PATH = @DATA_PATH@ … … 145 133 am__untar = @am__untar@ 146 134 bindir = @bindir@ 147 build = @build@148 build_alias = @build_alias@149 build_cpu = @build_cpu@150 build_os = @build_os@151 build_vendor = @build_vendor@152 135 datadir = @datadir@ 153 136 datarootdir = @datarootdir@ 154 137 exec_prefix = @exec_prefix@ 155 host = @host@156 host_alias = @host_alias@157 host_cpu = @host_cpu@158 host_os = @host_os@159 host_vendor = @host_vendor@160 138 includedir = @includedir@ 161 139 infodir = @infodir@ … … 184 162 PICLDFLAGS = @PICLDFLAGS@ 185 163 LIBLDFLAGS = @LIBLDFLAGS@ 186 trunk/src/Makefile
r164 r182 7 7 HEADERS = $(HDRS) $(INCS) 8 8 OBJECTS = $(ANGFILES) $(MAINFILES) $(ZFILES) 9 SOURCES = ${ FILES:.o=.c}9 SOURCES = ${OBJECTS:.o=.c} 10 10 11 11 # These are for OS-specific ports; ignore 'em until we use autoconf everywhere. trunk/src/Makefile.src
r171 r182 44 44 randname.o \ 45 45 pathfind.o \ 46 signals.o \ 46 47 save.o \ 47 48 spells1.o \ trunk/src/config.h
r171 r182 16 16 * have to modify any lines not indicated by "OPTION". 17 17 * 18 * Note: Also examine the "system" configuration file "h- config.h".18 * Note: Also examine the "system" configuration file "h-basic.h". 19 19 * 20 20 * And finally, remember that the "Makefile" will specify some rather … … 236 236 237 237 /* 238 * Hack -- Macintosh stuff 239 */ 240 #ifdef MACINTOSH 241 242 /* Do not handle signals */ 238 * Do not handle signals 239 */ 240 #if defined(MACINTOSH) || defined(WINDOWS) 243 241 # undef HANDLE_SIGNALS 244 245 242 #endif 246 243 247 248 /*249 * Hack -- Windows stuff250 */251 #ifdef WINDOWS252 253 /* Do not handle signals */254 # undef HANDLE_SIGNALS255 256 #endif257 258 259 /*260 * Hack -- EMX stuff261 */262 #ifdef USE_EMX263 264 /* Do not handle signals */265 # undef HANDLE_SIGNALS266 267 #endif268 244 269 245 … … 375 351 * OPTION: Attempt to minimize the size of the game 376 352 */ 377 #ifndef ANGBAND_LITE378 353 /* #define ANGBAND_LITE */ 379 #endif 354 380 355 381 356 /* trunk/src/externs.h
r156 r182 334 334 extern void close_game(void); 335 335 extern void exit_game_panic(void); 336 #ifdef HANDLE_SIGNALS337 extern void (*(*signal_aux)(int, void (*)(int)))(int);338 #endif339 extern void signals_ignore_tstp(void);340 extern void signals_handle_tstp(void);341 extern void signals_init(void);342 336 343 337 /* generate.c */ … … 481 475 /* pathfind.c */ 482 476 extern bool findpath(int y, int x); 477 478 /* signals.c */ 479 extern void signals_ignore_tstp(void); 480 extern void signals_handle_tstp(void); 481 extern void signals_init(void); 483 482 484 483 /* save.c */ trunk/src/files.c
r156 r182 12 12 13 13 #define MAX_PANEL 12 14 15 16 /*17 * Hack -- drop permissions18 */19 void safe_setuid_drop(void)20 {21 22 #ifdef SET_UID23 24 # ifdef SAFE_SETUID25 26 # ifdef HAVE_SETEGID27 28 if (setegid(getgid()) != 0)29 {30 quit("setegid(): cannot set permissions correctly!");31 }32 33 # else /* HAVE_SETEGID */34 35 # ifdef SAFE_SETUID_POSIX36 37 if (setgid(getgid()) != 0)38 {39 quit("setgid(): cannot set permissions correctly!");40 }41 42 # else /* SAFE_SETUID_POSIX */43 44 if (setregid(getegid(), getgid()) != 0)45 {46 quit("setregid(): cannot set permissions correctly!");47 }48 49 # endif /* SAFE_SETUID_POSIX */50 51 # endif /* HAVE_SETEGID */52 53 # endif /* SAFE_SETUID */54 55 #endif /* SET_UID */56 57 }58 59 60 /*61 * Hack -- grab permissions62 */63 void safe_setuid_grab(void)64 {65 66 #ifdef SET_UID67 68 # ifdef SAFE_SETUID69 70 # ifdef HAVE_SETEGID71 72 if (setegid(player_egid) != 0)73 {74 quit("setegid(): cannot set permissions correctly!");75 }76 77 # else /* HAVE_SETEGID */78 79 # ifdef SAFE_SETUID_POSIX80 81 if (setgid(player_egid) != 0)82 {83 quit("setgid(): cannot set permissions correctly!");84 }85 86 # else /* SAFE_SETUID_POSIX */87 88 if (setregid(getegid(), getgid()) != 0)89 {90 quit("setregid(): cannot set permissions correctly!");91 }92 93 # endif /* SAFE_SETUID_POSIX */94 95 # endif /* HAVE_SETEGID */96 97 # endif /* SAFE_SETUID */98 99 #endif /* SET_UID */100 101 }102 14 103 15 … … 4069 3981 4070 3982 4071 #ifdef HANDLE_SIGNALS4072 4073 4074 #include <signal.h>4075 4076 4077 typedef void (*Signal_Handler_t)(int);4078 4079 /*4080 * Wrapper around signal() which it is safe to take the address4081 * of, in case signal itself is hidden by some some macro magic.4082 */4083 static Signal_Handler_t wrap_signal(int sig, Signal_Handler_t handler)4084 {4085 return signal(sig, handler);4086 }4087 4088 /* Call this instead of calling signal() directly. */4089 Signal_Handler_t (*signal_aux)(int, Signal_Handler_t) = wrap_signal;4090 4091 4092 /*4093 * Handle signals -- suspend4094 *4095 * Actually suspend the game, and then resume cleanly4096 */4097 static void handle_signal_suspend(int sig)4098 {4099 /* Protect errno from library calls in signal handler */4100 int save_errno = errno;4101 4102 /* Disable handler */4103 (void)(*signal_aux)(sig, SIG_IGN);4104 4105 #ifdef SIGSTOP4106 4107 /* Flush output */4108 Term_fresh();4109 4110 /* Suspend the "Term" */4111 Term_xtra(TERM_XTRA_ALIVE, 0);4112 4113 /* Suspend ourself */4114 (void)kill(0, SIGSTOP);4115 4116 /* Resume the "Term" */4117 Term_xtra(TERM_XTRA_ALIVE, 1);4118 4119 /* Redraw the term */4120 Term_redraw();4121 4122 /* Flush the term */4123 Term_fresh();4124 4125 #endif4126 4127 /* Restore handler */4128 (void)(*signal_aux)(sig, handle_signal_suspend);4129 4130 /* Restore errno */4131 errno = save_errno;4132 }4133 4134 4135 /*4136 * Handle signals -- simple (interrupt and quit)4137 *4138 * This function was causing a *huge* number of problems, so it has4139 * been simplified greatly. We keep a global variable which counts4140 * the number of times the user attempts to kill the process, and4141 * we commit suicide if the user does this a certain number of times.4142 *4143 * We attempt to give "feedback" to the user as he approaches the4144 * suicide thresh-hold, but without penalizing accidental keypresses.4145 *4146 * To prevent messy accidents, we should reset this global variable4147 * whenever the user enters a keypress, or something like that.4148 */4149 static void handle_signal_simple(int sig)4150 {4151 /* Protect errno from library calls in signal handler */4152 int save_errno = errno;4153 4154 /* Disable handler */4155 (void)(*signal_aux)(sig, SIG_IGN);4156 4157 4158 /* Nothing to save, just quit */4159 if (!character_generated || character_saved) quit(NULL);4160 4161 4162 /* Count the signals */4163 signal_count++;4164 4165 4166 /* Terminate dead characters */4167 if (p_ptr->is_dead)4168 {4169 /* Mark the savefile */4170 my_strcpy(p_ptr->died_from, "Abortion", sizeof(p_ptr->died_from));4171 4172 /* HACK - Skip the tombscreen if it is already displayed */4173 if (score_idx == -1)4174 {4175 /* Close stuff */4176 close_game();4177 }4178 4179 /* Quit */4180 quit("interrupt");4181 }4182 4183 /* Allow suicide (after 5) */4184 else if (signal_count >= 5)4185 {4186 /* Cause of "death" */4187 my_strcpy(p_ptr->died_from, "Interrupting", sizeof(p_ptr->died_from));4188 4189 /* Commit suicide */4190 p_ptr->is_dead = TRUE;4191 4192 /* Stop playing */4193 p_ptr->playing = FALSE;4194 4195 /* Leaving */4196 p_ptr->leaving = TRUE;4197 4198 /* Close stuff */4199 close_game();4200 4201 /* Quit */4202 quit("interrupt");4203 }4204 4205 /* Give warning (after 4) */4206 else if (signal_count >= 4)4207 {4208 /* Make a noise */4209 Term_xtra(TERM_XTRA_NOISE, 0);4210 4211 /* Clear the top line */4212 Term_erase(0, 0, 255);4213 4214 /* Display the cause */4215 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");4216 4217 /* Flush */4218 Term_fresh();4219 }4220 4221 /* Give warning (after 2) */4222 else if (signal_count >= 2)4223 {4224 /* Make a noise */4225 Term_xtra(TERM_XTRA_NOISE, 0);4226 }4227 4228 /* Restore handler */4229 (void)(*signal_aux)(sig, handle_signal_simple);4230 4231 /* Restore errno */4232 errno = save_errno;4233 }4234 4235 4236 /*4237 * Handle signal -- abort, kill, etc4238 */4239 static void handle_signal_abort(int sig)4240 {4241 /* Disable handler */4242 (void)(*signal_aux)(sig, SIG_IGN);4243 4244 4245 /* Nothing to save, just quit */4246 if (!character_generated || character_saved) quit(NULL);4247 4248 4249 /* Clear the bottom line */4250 Term_erase(0, 23, 255);4251 4252 /* Give a warning */4253 Term_putstr(0, 23, -1, TERM_RED,4254 "A gruesome software bug LEAPS out at you!");4255 4256 /* Message */4257 Term_putstr(45, 23, -1, TERM_RED, "Panic save...");4258 4259 /* Flush output */4260 Term_fresh();4261 4262 /* Panic Save */4263 p_ptr->panic_save = 1;4264 4265 /* Panic save */4266 my_strcpy(p_ptr->died_from, "(panic save)", sizeof(p_ptr->died_from));4267 4268 /* Forbid suspend */4269 signals_ignore_tstp();4270 4271 /* Attempt to save */4272 if (save_player())4273 {4274 Term_putstr(45, 23, -1, TERM_RED, "Panic save succeeded!");4275 }4276 4277 /* Save failed */4278 else4279 {4280 Term_putstr(45, 23, -1, TERM_RED, "Panic save failed!");4281 }4282 4283 /* Flush output */4284 Term_fresh();4285 4286 /* Quit */4287 quit("software bug");4288 }4289 4290 4291 4292 4293 /*4294 * Ignore SIGTSTP signals (keyboard suspend)4295 */4296 void signals_ignore_tstp(void)4297 {4298 4299 #ifdef SIGTSTP4300 (void)(*signal_aux)(SIGTSTP, SIG_IGN);4301 #endif4302 4303 }4304 4305 /*4306 * Handle SIGTSTP signals (keyboard suspend)4307 */4308 void signals_handle_tstp(void)4309 {4310 4311 #ifdef SIGTSTP4312 (void)(*signal_aux)(SIGTSTP, handle_signal_suspend);4313 #endif4314 4315 }4316 4317 4318 /*4319 * Prepare to handle the relevant signals4320 */4321 void signals_init(void)4322 {4323 4324 #ifdef SIGHUP4325 (void)(*signal_aux)(SIGHUP, SIG_IGN);4326 #endif4327 4328 4329 #ifdef SIGTSTP4330 (void)(*signal_aux)(SIGTSTP, handle_signal_suspend);4331 #endif4332 4333 4334 #ifdef SIGINT4335 (void)(*signal_aux)(SIGINT, handle_signal_simple);4336 #endif4337 4338 #ifdef SIGQUIT4339 (void)(*signal_aux)(SIGQUIT, handle_signal_simple);4340 #endif4341 4342 4343 #ifdef SIGFPE4344 (void)(*signal_aux)(SIGFPE, handle_signal_abort);4345 #endif4346 4347 #ifdef SIGILL4348 (void)(*signal_aux)(SIGILL, handle_signal_abort);4349 #endif4350 4351 #ifdef SIGTRAP4352 (void)(*signal_aux)(SIGTRAP, handle_signal_abort);4353 #endif4354 4355 #ifdef SIGIOT4356 (void)(*signal_aux)(SIGIOT, handle_signal_abort);4357 #endif4358 4359 #ifdef SIGKILL4360 (void)(*signal_aux)(SIGKILL, handle_signal_abort);4361 #endif4362 4363 #ifdef SIGBUS4364 (void)(*signal_aux)(SIGBUS, handle_signal_abort);4365 #endif4366 4367 #ifdef SIGSEGV4368 (void)(*signal_aux)(SIGSEGV, handle_signal_abort);4369 #endif4370 4371 #ifdef SIGTERM4372 (void)(*signal_aux)(SIGTERM, handle_signal_abort);4373 #endif4374 4375 #ifdef SIGPIPE4376 (void)(*signal_aux)(SIGPIPE, handle_signal_abort);4377 #endif4378 4379 #ifdef SIGEMT4380 (void)(*signal_aux)(SIGEMT, handle_signal_abort);4381 #endif4382 4383 /*4384 * SIGDANGER:4385 * This is not a common (POSIX, SYSV, BSD) signal, it is used by AIX(?) to4386 * signal that the system will soon be out of memory.4387 */4388 #ifdef SIGDANGER4389 (void)(*signal_aux)(SIGDANGER, handle_signal_abort);4390 #endif4391 4392 #ifdef SIGSYS4393 (void)(*signal_aux)(SIGSYS, handle_signal_abort);4394 #endif4395 4396 #ifdef SIGXCPU4397 (void)(*signal_aux)(SIGXCPU, handle_signal_abort);4398 #endif4399 4400 #ifdef SIGPWR4401 (void)(*signal_aux)(SIGPWR, handle_signal_abort);4402 #endif4403 4404 }4405 4406 4407 #else /* HANDLE_SIGNALS */4408 4409 4410 /*4411 * Do
