1AC_INIT(xsokoban.man) 2 3############################################################################ 4# Create config files 5AC_CONFIG_HEADER(config_local.h) 6 7############################################################################ 8# Check for programs 9 10AC_ARG_WITH(CC,CC="$withval") 11 12AC_PROG_INSTALL 13AC_PROG_CC 14AC_PROG_CPP 15 16##################### 17# Find Xpm if needed 18 19define(AC_VAR_CHECK, 20avc_ic='#include "config.h"' 21(echo ${avc_ic}; echo $2) > configure.tmp.$$.h 22$1=`$CPP configure.tmp.$$.h | egrep -v "^#"` 23rm configure.tmp.$$.h 24$1=`echo $$1` 25# last line strips out extra whitespace 26) 27 28define(AC_FEATURE_CHECK, 29AC_MSG_CHECKING(whether $3 is turned on); 30AC_VAR_CHECK($1,$2) 31if test $$1 = 1; then 32 AC_MSG_RESULT(yes) 33else 34 AC_MSG_RESULT(no) 35fi 36) 37 38 39AC_FEATURE_CHECK(use_xpm, USE_XPM, use of color bitmaps through XPM) 40AC_FEATURE_CHECK(www, WWW, WWW scoring) 41 42if test $use_xpm = 1; then 43 libxpm=1 44 incxpm=1 45 AC_CHECK_LIB(Xpm, main, [LIBS="$LIBS -lXpm"], 46 [ 47 libok=no; 48 AC_MSG_CHECKING(other locations for libXpm) 49 for lib in /usr/local/lib xpm*/lib ../xpm*/lib; 50 do 51 if test -r $lib/libXpm.a; then 52 AC_MSG_RESULT(Found it in $lib!) 53 LIBS="$LIBS -L$lib -lXpm"; 54 libok=yes; 55 break; 56 fi 57 done 58 if test $libok = no; then 59 AC_MSG_WARN(Can't find libXpm.a! You must add it to LIBS in Makefile.) 60 fi 61 ]) 62 AC_HEADER_CHECK(xpm.h,, 63 [ 64 incok=no; 65 for inc in /usr/local/include /usr/local/include/X11* \ 66 /usr/local/X11*/include xpm*/lib ../xpm*/lib; 67 do 68 if test -r $inc/xpm.h; then 69 AC_MSG_RESULT(Found it in $inc!) 70 INCS="$INCS -I$inc"; 71 incok=yes; 72 break; 73 fi 74 done 75 if test $incok = no; then 76 AC_MSG_WARN(Can't find xpm.h! You must add its location to INCS in Makefile.) 77 fi 78 ]) 79fi 80rm -f tmp.$$.c tmp2.$$ 81 82################### 83# Find X 84 85AC_FIND_X 86if test -n "$no_x"; then 87 AC_MSG_WARN(Cannot find X libraries! Package may not compile) 88 x_includes= 89 x_libraries=-lX11 90else 91 if test "x$x_includes" != x && 92 test "x$x_includes" != x/usr/include; then 93 INCS="$INCS -I$x_includes" 94 fi 95 if test "x$x_libraries" != x && 96 test "x$x_libraries" != x/usr/lib; then 97 LIBS="$LIBS -L$x_libraries" 98 fi 99 LIBS="$LIBS -lX11" 100fi 101 102AC_SUBST(LIBS) 103AC_SUBST(INCS) 104 105############## 106# Check HERE 107if test $www = 1; then 108 AC_MSG_CHECKING(location of client) 109 AC_VAR_CHECK(HERE,HERE) 110 AC_MSG_RESULT($HERE) 111 if test "$HERE" = '"@somewhere.somedomain"'; then 112 AC_MSG_ERROR(You have not defined the variable HERE in config.h! Do it.) 113 fi 114fi 115 116############## 117# Figure out OWNER 118AC_MSG_CHECKING(owner of game) 119AC_VAR_CHECK(OWNER, OWNER) 120OWNER=`echo $OWNER | sed -e 's/"//g'` 121AC_TRY_RUN([ 122#include <stdio.h> 123#include <pwd.h> 124#include <stdlib.h> 125 126main(int argc, char **argv) { 127 struct passwd *p; 128 p = getpwnam("$OWNER"); 129 exit((p == 0) ? 1 : 0); 130}], ownerok=1, ownerok="", ownerok=1) 131if test -n "$ownerok"; then 132 AC_MSG_RESULT("owner is $OWNER") 133 AC_SUBST(OWNER) 134else 135 AC_MSG_WARN(\"$OWNER\" seems not to be a username. \nEdit \"config.h\" and change OWNER.), 136fi 137 138############## 139# DEC bogosity 140 141AC_CHECK_LIB(dnet_stub,main) 142 143#################################### 144# Turn on all compiler warning flags 145 146if test -n "$GCC" 147then 148 WARN=-Wall 149else 150 if test -f /bin/uname && 151 test `uname` = OSF1 152 then 153 WARN=-std1 154 else 155 WARN= 156 fi 157fi 158AC_SUBST(WARN) 159 160############################################################################ 161# Check for library functions and C++ prototypes 162 163AC_MSG_CHECKING(function prototypes) 164AC_TRY_LINK([#include <stdlib.h>], 165[char *s = getpass("prompt");], 166AC_DEFINE(GETPASS_PROTO)) 167 168AC_TRY_LINK([#include <stdio.h>], 169[fprintf(stderr, "foo");], 170AC_DEFINE(FPRINTF_PROTO)) 171 172AC_TRY_LINK([#include <stdio.h>], 173[FILE *f; fclose(f);], 174AC_DEFINE(FCLOSE_PROTO)) 175 176AC_TRY_LINK([#include <time.h>], 177[time_t t; t = time(&t);], 178AC_DEFINE(TIME_PROTO)) 179 180AC_TRY_LINK([#include <time.h>], 181[time_t t; struct tm stm = *localtime(&t);], 182AC_DEFINE(LOCALTIME_PROTO)) 183 184AC_TRY_LINK([#include <stdlib.h>], 185[char *s = mktemp("fooXXXXXX"); ], 186AC_DEFINE(MKTEMP_PROTO)) 187 188AC_TRY_LINK( 189[#include <errno.h> 190#include <stdio.h>], 191[perror("bleah"); ], 192AC_DEFINE(PERROR_PROTO)) 193 194AC_TRY_LINK( 195[#include <unistd.h> 196#include <stdio.h>], 197[int x = rename("foo", "bar");], 198AC_DEFINE(RENAME_PROTO)) 199 200AC_TRY_LINK( 201[#include <string.h>], 202[char *s = strdup("foo");], 203AC_DEFINE(STRDUP_PROTO)) 204 205AC_TRY_LINK( 206[#include <stdlib.h> 207#include <unistd.h>], 208[usleep(1);], 209AC_DEFINE(HAS_USLEEP) 210AC_DEFINE(USLEEP_PROTO)) 211 212AC_TRY_LINK( 213[#include <stdlib.h>], 214[char *x; int l; bzero(x, l);], 215AC_DEFINE(BZERO_PROTO)) 216 217AC_TRY_LINK( 218[#include <langinfo.h>], 219[char *jan = nl_langinfo(ABMON_1);], 220AC_DEFINE(HAVE_NL_LANGINFO)) 221 222AC_TRY_LINK( 223[#include <sys/param.h>], 224[int x;], 225AC_DEFINE(HAVE_SYS_PARAM_H)) 226 227AC_MSG_RESULT(yes) 228 229AC_HAVE_HEADERS(limits.h sys/limits.h sys/select.h) 230 231 232found_htons="" 233 234define(ACHTONS_CHECK, 235 AC_MSG_CHECKING(whether htons & ntohs in $1) 236 AC_TRY_LINK([ 237#include <sys/types.h> 238#include <$1> 239 ], 240 [unsigned short x,y; x = htons(y);], 241 [AC_DEFINE($2) 242 found_htons=yes 243 AC_MSG_RESULT(yes)], 244 AC_MSG_RESULT(no))) 245 246ACHTONS_CHECK(machine/endian.h, NEED_ENDIAN) 247ACHTONS_CHECK(netinet/in.h, NEED_NETINET_IN) 248ACHTONS_CHECK(net/nh.h, NEED_NH) 249ACHTONS_CHECK(sys/byteorder.h, NEED_BYTEORDER) 250 251if test -z "$found_htons" 252then 253 AC_MSG_ERROR(no) 254fi 255 256############################################################################ 257# Build configured files 258 259AC_OUTPUT(Makefile) 260