Changeset 182

Show
Ignore:
Timestamp:
06/10/07 11:56:57 (2 years ago)
Author:
takkaria
Message:
  • Clean up autoconf support more:
    • we never make use of info on what system we're built on, so remove config.sub and config.guess
    • stop checking for things we never use, or we use irrespectively of whether they're detected or not
    • use better SDL checking code
    • fix SOURCE line in src/Makefile so dependencies are generated once again
  • Move signals code to signals.c, and permissions grabbing code to z-file.c
  • Clean up the macros in z-virt.h
  • Remove autoconf.h.in (autogenerated by autoheader, so unnecessary)
  • Remove various double-includes and simplify bits of the header files

diff: +586 lines, -3898 lines, -3312 net.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/acinclude.m4

    r159 r182  
    101101 
    102102  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 ; then 
    105       SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config 
    106     fi 
    107   fi 
    108   if test x$sdl_prefix != x ; then 
    109     sdl_args="$sdl_args --prefix=$sdl_prefix" 
    110     if test x${SDL_CONFIG+set} != xset ; then 
    111       SDL_CONFIG=$sdl_prefix/bin/sdl-config 
    112     fi 
    113   fi 
    114  
    115   if test "x$prefix" != xNONE; then 
    116     PATH="$prefix/bin:$prefix/usr/bin:$PATH" 
    117   fi 
    118   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" ; then 
    123     no_sdl=yes 
    124   else 
    125     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" ; then 
    135       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 dnl 
    142 dnl Now check if the installed SDL is sufficiently new. (Also sanity 
    143 dnl checks the results of sdl-config to some extent 
    144 dnl 
    145       rm -f conf.sdltest 
    146       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   else 
    163     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, &micro) != 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   else 
    192     { 
    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      fi 
    208   fi 
    209   if test "x$no_sdl" = x ; then 
    210      AC_MSG_RESULT(yes) 
    211      ifelse([$2], , :, [$2])      
    212   else 
    213      AC_MSG_RESULT(no) 
    214      if test "$SDL_CONFIG" = "no" ; then 
    215        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      else 
    220        if test -f conf.sdltest ; then 
    221         : 
    222        else 
    223           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  main 
    234 #define main K_and_R_C_main 
    235 ],      [ 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        fi 
    253      fi 
    254      SDL_CFLAGS="" 
    255      SDL_LIBS="" 
    256      ifelse([$3], , :, [$3]) 
    257   fi 
    258   AC_SUBST(SDL_CFLAGS) 
    259   AC_SUBST(SDL_LIBS) 
    260   rm -f conf.sdltest 
    261 ]) 
    262 # Configure paths for SDL 
    263 # Sam Lantinga 9/21/99 
    264 # stolen from Manish Singh 
    265 # stolen back from Frank Belew 
    266 # stolen from Manish Singh 
    267 # Shamelessly stolen from Owen Taylor 
    268  
    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_LIBS 
    271 dnl 
    272 AC_DEFUN([AM_PATH_SDL], 
    273 [dnl  
    274 dnl Get the cflags and libraries from the sdl-config script 
    275 dnl 
    276 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 ; then 
    284     sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" 
    285     if test x${SDL_CONFIG+set} != xset ; then 
    286       SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config 
    287     fi 
    288   fi 
    289   if test x$sdl_prefix != x ; then 
    290     sdl_args="$sdl_args --prefix=$sdl_prefix" 
    291     if test x${SDL_CONFIG+set} != xset ; then 
    292       SDL_CONFIG=$sdl_prefix/bin/sdl-config 
    293     fi 
    294   fi 
    295  
    296   if test "x$prefix" != xNONE; then 
    297     PATH="$prefix/bin:$prefix/usr/bin:$PATH" 
    298   fi 
    299   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" ; then 
    304     no_sdl=yes 
    305   else 
    306     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" ; then 
    316       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 dnl 
    323 dnl Now check if the installed SDL is sufficiently new. (Also sanity 
    324 dnl checks the results of sdl-config to some extent 
    325 dnl 
    326       rm -f conf.sdltest 
    327       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   else 
    344     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, &micro) != 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   else 
    373     { 
    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      fi 
    389   fi 
    390   if test "x$no_sdl" = x ; then 
    391      AC_MSG_RESULT(yes) 
    392      ifelse([$2], , :, [$2])      
    393   else 
    394      AC_MSG_RESULT(no) 
    395      if test "$SDL_CONFIG" = "no" ; then 
    396        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      else 
    401        if test -f conf.sdltest ; then 
    402         : 
    403        else 
    404           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  main 
    415 #define main K_and_R_C_main 
    416 ],      [ 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        fi 
    434      fi 
    435      SDL_CFLAGS="" 
    436      SDL_LIBS="" 
    437      ifelse([$3], , :, [$3]) 
    438   fi 
    439   AC_SUBST(SDL_CFLAGS) 
    440   AC_SUBST(SDL_LIBS) 
    441   rm -f conf.sdltest 
    442 ]) 
    443 # Configure paths for SDL 
    444 # Sam Lantinga 9/21/99 
    445 # stolen from Manish Singh 
    446 # stolen back from Frank Belew 
    447 # stolen from Manish Singh 
    448 # Shamelessly stolen from Owen Taylor 
    449  
    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_LIBS 
    452 dnl 
    453 AC_DEFUN([AM_PATH_SDL], 
    454 [dnl  
    455 dnl Get the cflags and libraries from the sdl-config script 
    456 dnl 
    457 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 ; then 
    465103     sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" 
    466104     if test x${SDL_CONFIG+set} != xset ; then 
     
    475113  fi 
    476114 
    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) 
    480116  min_sdl_version=ifelse([$1], ,0.11.0,$1) 
    481117  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) 
     
    585221#include <stdio.h> 
    586222#include "SDL.h" 
    587  
    588 int main(int argc, char *argv[]) 
    589 { return 0; } 
    590 #undef  main 
    591 #define main K_and_R_C_main 
    592223],      [ return 0; ], 
    593224        [ echo "*** The test program compiled, but did not run. This usually means" 
     
    616247  rm -f conf.sdltest 
    617248]) 
     249 
  • trunk/configure.ac

    r181 r182  
    11dnl Process this file with autoconf to produce a configure script. 
    2 AC_INIT([angband], [3.0.8], [bugs@rephial.org]) 
     2AC_INIT([Angband], [3.0.8], [bugs@rephial.org], [angband]) 
    33AC_PREREQ([2.50]) 
    4  
    5 AC_CANONICAL_HOST 
    6 AC_CANONICAL_TARGET 
    74 
    85AC_CONFIG_HEADER(src/autoconf.h) 
     
    1714dnl Check for C compiler 
    1815AC_PROG_CC 
    19 AC_ISC_POSIX 
    20 AC_C_BIGENDIAN 
    2116 
    2217test "$GCC" = "yes" && CFLAGS="$CFLAGS -Wall -pipe -g -fno-strength-reduce" 
     
    3227AC_PATH_PROG(MV, mv) 
    3328AC_PATH_PROG(CP, cp) 
    34 AC_PATH_PROG(AR, ar) 
    35 AC_PATH_PROG(RANLIB, ranlib) 
    3629 
    3730AC_ARG_WITH(setgid, 
     
    9184        [enable_sdl_mixer=$enable_sdl_mixer], 
    9285        [enable_sdl_mixer=yes]) 
     86 
     87 
    9388 
    9489 
     
    127122fi 
    128123 
     124 
    129125dnl X11 checking 
    130126if test "$enable_x11" = "yes"; then 
     
    140136        fi 
    141137fi 
     138 
    142139 
    143140dnl SDL checking 
     
    158155        fi 
    159156fi 
     157 
    160158 
    161159dnl GTK checking 
     
    177175fi 
    178176 
     177 
    179178dnl SDL mixer checking 
    180  
    181179if test "$enable_sdl_mixer" = "yes"; then 
    182180        AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio, found_sdl_mixer=yes, found_sdl_mixer=no) 
     
    189187 
    190188 
    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 
     190dnl Check for headers, types, functions 
     191AC_CHECK_HEADERS([fcntl.h stdint.h]) 
     192AC_HEADER_STDBOOL 
     193AC_C_CONST 
    197194AC_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]) 
     195AC_CHECK_FUNCS([mkstemp setegid can_change_color]) 
     196 
     197 
    204198 
    205199dnl XXX: Work around some autoconf bugs. 
     
    212206 
    213207 
    214 AC_CONFIG_FILES([ 
    215         mk/rules.mk 
    216 ]) 
     208AC_CONFIG_FILES([mk/rules.mk]) 
    217209 
    218210AC_OUTPUT 
  • trunk/mk/objective.mk

    r74 r182  
    262262                                echo "[building depend file for subobjective: $$i]"; \ 
    263263                        fi; \ 
    264                         cd $$i; touch .depend; $(MAKE) depend || exit; cd ..; \ 
     264                        cd $$i; touch .depend; $(MAKE) -f Makefile depend || exit; cd ..; \ 
    265265                        if [ $(VERBOSITY) -gt 0 ]; then \ 
    266266                                echo "[finished subobjective: $$i]"; \ 
  • trunk/mk/rules.mk.in

    r165 r182  
    2121PRE_UNINSTALL = : 
    2222POST_UNINSTALL = : 
    23 build_triplet = @build@ 
    24 host_triplet = @host@ 
    25 target_triplet = @target@ 
    2623subdir = . 
    2724ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 
     
    5552distuninstallcheck_listfiles = find . -type f -print 
    5653distcleancheck_listfiles = find . -type f -print 
    57 ACLOCAL = @ACLOCAL@ 
    5854ALLOCA = @ALLOCA@ 
    5955AMDEP_FALSE = @AMDEP_FALSE@ 
    6056AMDEP_TRUE = @AMDEP_TRUE@ 
    6157AMTAR = @AMTAR@ 
    62 AR = @AR@ 
    63 AUTOCONF = @AUTOCONF@ 
    64 AUTOHEADER = @AUTOHEADER@ 
    65 AUTOMAKE = @AUTOMAKE@ 
    6658AWK = @AWK@ 
    6759BUILDERS_INCLUDES = @BUILDERS_INCLUDES@ 
     
    7668CPP = @CPP@ 
    7769CPPFLAGS += @CPPFLAGS@ 
    78 CXX = @CXX@ 
    79 CXXCPP = @CXXCPP@ 
    80 CXXDEPMODE = @CXXDEPMODE@ 
    81 CXXFLAGS += @CXXFLAGS@ 
    8270CYGPATH_W = @CYGPATH_W@ 
    8371DATA_PATH = @DATA_PATH@ 
     
    145133am__untar = @am__untar@ 
    146134bindir = @bindir@ 
    147 build = @build@ 
    148 build_alias = @build_alias@ 
    149 build_cpu = @build_cpu@ 
    150 build_os = @build_os@ 
    151 build_vendor = @build_vendor@ 
    152135datadir = @datadir@ 
    153136datarootdir = @datarootdir@ 
    154137exec_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@ 
    160138includedir = @includedir@ 
    161139infodir = @infodir@ 
     
    184162PICLDFLAGS = @PICLDFLAGS@ 
    185163LIBLDFLAGS = @LIBLDFLAGS@ 
    186  
  • trunk/src/Makefile

    r164 r182  
    77HEADERS = $(HDRS) $(INCS) 
    88OBJECTS = $(ANGFILES) $(MAINFILES) $(ZFILES) 
    9 SOURCES = ${FILES:.o=.c} 
     9SOURCES = ${OBJECTS:.o=.c} 
    1010 
    1111# These are for OS-specific ports; ignore 'em until we use autoconf everywhere. 
  • trunk/src/Makefile.src

    r171 r182  
    4444        randname.o \ 
    4545        pathfind.o \ 
     46        signals.o \ 
    4647        save.o \ 
    4748        spells1.o \ 
  • trunk/src/config.h

    r171 r182  
    1616 * have to modify any lines not indicated by "OPTION". 
    1717 * 
    18  * Note: Also examine the "system" configuration file "h-config.h". 
     18 * Note: Also examine the "system" configuration file "h-basic.h". 
    1919 * 
    2020 * And finally, remember that the "Makefile" will specify some rather 
     
    236236 
    237237/* 
    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) 
    243241# undef HANDLE_SIGNALS 
    244  
    245242#endif 
    246243 
    247  
    248 /* 
    249  * Hack -- Windows stuff 
    250  */ 
    251 #ifdef WINDOWS 
    252  
    253 /* Do not handle signals */ 
    254 # undef HANDLE_SIGNALS 
    255  
    256 #endif 
    257  
    258  
    259 /* 
    260  * Hack -- EMX stuff 
    261  */ 
    262 #ifdef USE_EMX 
    263  
    264 /* Do not handle signals */ 
    265 # undef HANDLE_SIGNALS 
    266  
    267 #endif 
    268244 
    269245 
     
    375351 * OPTION: Attempt to minimize the size of the game 
    376352 */ 
    377 #ifndef ANGBAND_LITE 
    378353/* #define ANGBAND_LITE */ 
    379 #endif 
     354 
    380355 
    381356/* 
  • trunk/src/externs.h

    r156 r182  
    334334extern void close_game(void); 
    335335extern void exit_game_panic(void); 
    336 #ifdef HANDLE_SIGNALS 
    337 extern void (*(*signal_aux)(int, void (*)(int)))(int); 
    338 #endif 
    339 extern void signals_ignore_tstp(void); 
    340 extern void signals_handle_tstp(void); 
    341 extern void signals_init(void); 
    342336 
    343337/* generate.c */ 
     
    481475/* pathfind.c */ 
    482476extern bool findpath(int y, int x); 
     477 
     478/* signals.c */ 
     479extern void signals_ignore_tstp(void); 
     480extern void signals_handle_tstp(void); 
     481extern void signals_init(void); 
    483482 
    484483/* save.c */ 
  • trunk/src/files.c

    r156 r182  
    1212 
    1313#define MAX_PANEL 12 
    14  
    15  
    16 /* 
    17  * Hack -- drop permissions 
    18  */ 
    19 void safe_setuid_drop(void) 
    20 { 
    21  
    22 #ifdef SET_UID 
    23  
    24 # ifdef SAFE_SETUID 
    25  
    26 #  ifdef HAVE_SETEGID 
    27  
    28         if (setegid(getgid()) != 0) 
    29         { 
    30                 quit("setegid(): cannot set permissions correctly!"); 
    31         } 
    32   
    33 #  else /* HAVE_SETEGID */ 
    34  
    35 #   ifdef SAFE_SETUID_POSIX 
    36  
    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 permissions 
    62  */ 
    63 void safe_setuid_grab(void) 
    64 { 
    65  
    66 #ifdef SET_UID 
    67  
    68 # ifdef SAFE_SETUID 
    69  
    70 #  ifdef HAVE_SETEGID 
    71  
    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_POSIX 
    80  
    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 } 
    10214 
    10315 
     
    40693981 
    40703982 
    4071 #ifdef HANDLE_SIGNALS 
    4072  
    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 address 
    4081  * 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 -- suspend 
    4094  * 
    4095  * Actually suspend the game, and then resume cleanly 
    4096  */ 
    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 SIGSTOP 
    4106  
    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 #endif 
    4126  
    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 has 
    4139  * been simplified greatly.  We keep a global variable which counts 
    4140  * the number of times the user attempts to kill the process, and 
    4141  * 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 the 
    4144  * suicide thresh-hold, but without penalizing accidental keypresses. 
    4145  * 
    4146  * To prevent messy accidents, we should reset this global variable 
    4147  * 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, etc 
    4238  */ 
    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         else 
    4279         { 
    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 SIGTSTP 
    4300         (void)(*signal_aux)(SIGTSTP, SIG_IGN); 
    4301 #endif 
    4302  
    4303 } 
    4304  
    4305 /* 
    4306  * Handle SIGTSTP signals (keyboard suspend) 
    4307  */ 
    4308 void signals_handle_tstp(void) 
    4309 { 
    4310  
    4311 #ifdef SIGTSTP 
    4312         (void)(*signal_aux)(SIGTSTP, handle_signal_suspend); 
    4313 #endif 
    4314  
    4315 } 
    4316  
    4317  
    4318 /* 
    4319  * Prepare to handle the relevant signals 
    4320  */ 
    4321 void signals_init(void) 
    4322 { 
    4323  
    4324 #ifdef SIGHUP 
    4325         (void)(*signal_aux)(SIGHUP, SIG_IGN); 
    4326 #endif 
    4327  
    4328  
    4329 #ifdef SIGTSTP 
    4330         (void)(*signal_aux)(SIGTSTP, handle_signal_suspend); 
    4331 #endif 
    4332  
    4333  
    4334 #ifdef SIGINT 
    4335         (void)(*signal_aux)(SIGINT, handle_signal_simple); 
    4336 #endif 
    4337  
    4338 #ifdef SIGQUIT 
    4339         (void)(*signal_aux)(SIGQUIT, handle_signal_simple); 
    4340 #endif 
    4341  
    4342  
    4343 #ifdef SIGFPE 
    4344         (void)(*signal_aux)(SIGFPE, handle_signal_abort); 
    4345 #endif 
    4346  
    4347 #ifdef SIGILL 
    4348         (void)(*signal_aux)(SIGILL, handle_signal_abort); 
    4349 #endif 
    4350  
    4351 #ifdef SIGTRAP 
    4352         (void)(*signal_aux)(SIGTRAP, handle_signal_abort); 
    4353 #endif 
    4354  
    4355 #ifdef SIGIOT 
    4356         (void)(*signal_aux)(SIGIOT, handle_signal_abort); 
    4357 #endif 
    4358  
    4359 #ifdef SIGKILL 
    4360         (void)(*signal_aux)(SIGKILL, handle_signal_abort); 
    4361 #endif 
    4362  
    4363 #ifdef SIGBUS 
    4364         (void)(*signal_aux)(SIGBUS, handle_signal_abort); 
    4365 #endif 
    4366  
    4367 #ifdef SIGSEGV 
    4368         (void)(*signal_aux)(SIGSEGV, handle_signal_abort); 
    4369 #endif 
    4370  
    4371 #ifdef SIGTERM 
    4372         (void)(*signal_aux)(SIGTERM, handle_signal_abort); 
    4373 #endif 
    4374  
    4375 #ifdef SIGPIPE 
    4376         (void)(*signal_aux)(SIGPIPE, handle_signal_abort); 
    4377 #endif 
    4378  
    4379 #ifdef SIGEMT 
    4380         (void)(*signal_aux)(SIGEMT, handle_signal_abort); 
    4381 #endif 
    4382  
    4383 /* 
    4384  * SIGDANGER: 
    4385  * This is not a common (POSIX, SYSV, BSD) signal, it is used by AIX(?) to 
    4386  * signal that the system will soon be out of memory. 
    4387  */ 
    4388 #ifdef SIGDANGER 
    4389         (void)(*signal_aux)(SIGDANGER, handle_signal_abort); 
    4390 #endif 
    4391  
    4392 #ifdef SIGSYS 
    4393         (void)(*signal_aux)(SIGSYS, handle_signal_abort); 
    4394 #endif 
    4395  
    4396 #ifdef SIGXCPU 
    4397         (void)(*signal_aux)(SIGXCPU, handle_signal_abort); 
    4398 #endif 
    4399  
    4400 #ifdef SIGPWR 
    4401         (void)(*signal_aux)(SIGPWR, handle_signal_abort); 
    4402 #endif 
    4403  
    4404 } 
    4405  
    4406  
    4407 #else   /* HANDLE_SIGNALS */ 
    4408  
    4409  
    4410 /* 
    4411  * Do