1dnl	UNNETHACK autoconf template
2AC_INIT(UNNETHACK, 5.1.0, bhaak@gmx.net)
3dnl Avoid AC_REVISION() because we check configure into CVS
4dnl and it will cause confusing revision numbers to be included
5dnl in configure if developers forget to check in configure.ac
6dnl before running bootstrap.sh and checking in configure.
7
8AC_CONFIG_SRCDIR(Files)
9AC_SUBST(SRCDIR,[../$srcdir/src])
10AC_CONFIG_AUX_DIR(sys/autoconf)
11
12dnl  ----- Precious variables
13AC_ARG_VAR(CC, [C compiler])
14AC_ARG_VAR(CHGRP, [sets GAMEUID (set this to true as a no op)])
15AC_ARG_VAR(CHOWN, [sets GAMEGRP (set this to true as a no op)])
16AC_ARG_VAR(CHMOD, [sets file modes (set this to true as a no op)])
17AC_ARG_VAR(ZLIB_CFLAGS, [Compiler flags to find zlib header files])
18AC_ARG_VAR(ZLIB_LIBS, [Linker flags to find zlib library files])
19
20AC_PROG_LN_S
21AC_PROG_AWK
22
23dnl  ----- Check options
24dnl  ----- Window systems
25
26# NETHACK_WIN_ENABLE(proxy, auto)
27nethack_default_win=""
28# Note: Order is important: The last listed enabled port will be the default.
29NETHACK_WIN_ENABLE(dummy, no, [dummy graphics for unit tests])
30NETHACK_WIN_ENABLE(lisp, no, [enable playing UnNetHack in Emacs])
31NETHACK_WIN_ENABLE(curses, no, [use curses interface])
32NETHACK_WIN_ENABLE(tty, auto)
33NETHACK_WIN_ENABLE(x11, no)
34NETHACK_WIN_ENABLE(mswin, no, [use Microsoft Window's native graphics])
35dnl deactivate X11 and Win32 tiles version
36dnl enable_x11_graphics="no"
37
38dnl  ----- Figure out a C compiler to use; set @CC@
39AC_PROG_CC
40AC_SUBST(LFLAGS)
41
42dnl  ----- Check OS
43AC_CANONICAL_HOST
44
45dnl  ----- Early checks for libraries, as needed
46
47dnl PKG_PROG_PKG_CONFIG([])
48if test "$enable_x11_graphics" != "no"; then
49    # We have to check for libXaw before we define SYSV,
50    # since the X11 include files change their behaviour
51    # depending on whether the compiler defines it or not.
52    NETHACK_CHECK_LIBXAW([LIBXAW], have_libXaw=yes, have_libXaw=no)
53fi
54
55dnl  ------ Main OS types
56case $host_os in
57     mingw32 )		AC_DEFINE(WIN32,[],[An MS-Windows system])
58			AC_SUBST(HOST_MSWIN,[])
59			AC_SUBST(HOST_UNIX,[#])
60			SYSTEM="Syswinnt"
61			SYSSRC="\${SYSMSWINSRC}"
62			SYSOBJ="\${SYSMSWINOBJ}"
63			;;
64     *bsd* )		AC_DEFINE(BSD,[],[A BSD like system])
65			AC_SUBST(HOST_MSWIN,[#])
66			AC_SUBST(HOST_UNIX,[])
67			SYSTEM="Sysunix"
68			SYSSRC="\${SYSUNIXSRC}"
69			SYSOBJ="\${SYSUNIXOBJ}"
70			;;
71     * )		AC_DEFINE(SYSV,[],[A System V like system])
72			AC_SUBST(HOST_MSWIN,[#])
73			AC_SUBST(HOST_UNIX,[])
74			SYSTEM="Sysunix"
75			SYSSRC="\${SYSUNIXSRC}"
76			SYSOBJ="\${SYSUNIXOBJ}"
77			;;
78esac
79AC_SUBST(SYSTEM)
80AC_SUBST(SYSSRC)
81AC_SUBST(SYSOBJ)
82
83if test $host_os = mingw32; then
84    AC_MSG_CHECKING([for how to build UnNetHack key dynamic libraries])
85    if test "$GCC" = yes; then
86	AC_MSG_RESULT([gcc])
87	AC_SUBST(NHKEYDLL_GCC,[])
88    else
89	AC_MSG_RESULT([unknown])
90	if test "$enable_tty_graphics" = yes; then
91	    AC_MSG_ERROR([Don't know how to build UnNetHack key DLLs with $CC])
92	else
93	    AC_MSG_WARN([Can't enable tty graphics (key dynamic libraries)])
94	    NETHACK_AUTO_WIN_DISABLE(tty)
95	fi
96    fi
97fi
98
99
100dnl ------ Common subtypes
101case $host_os in
102     *cygwin* )		AC_DEFINE(CYGWIN32,[],[Unix on win32]);;
103     *linux* )		AC_DEFINE(LINUX,[],[GNU Linux]);;
104esac
105
106dnl  ----- Check for programs
107AC_PROG_LEX
108if test "$LEX" = ":"; then
109	AC_MSG_ERROR([cannot find flex or lex])
110fi
111AC_CHECK_PROGS(YACC, ['bison -y' byacc yacc])
112if test -z "$YACC"; then
113	AC_MSG_ERROR([cannot find bison, byacc or yacc])
114fi
115AC_CHECK_TOOLS(CHOWN,[chown true])
116AC_CHECK_TOOLS(CHGRP,[chgrp true])
117AC_CHECK_TOOLS(CHMOD,[chmod true])
118AC_CHECK_TOOL(WINDRES,windres,no)
119NETHACK_PROG_COMPRESS
120
121dnl  ----- Check for libraries
122
123dnl NETHACK_CHECK_LIBPNG(NETHACK_LIBPNG, have_libpng=yes, have_libpng=no)
124
125dnl  ----- Select window systems
126
127WINSRC=
128WINOBJ=
129WINLIB=
130CNF_SHARE_DATND=
131
132OPTIONS_FILE=
133OPTIONS_FILES=
134
135WINTTYLIB=
136if test "$enable_tty_graphics" != "no"; then
137    if test $host_os = mingw32; then
138	AC_SUBST(EXTRA_UNSHARE,["nhdefkey.dll nh340key.dll nhraykey.dll"])
139	CFLAGS="$CFLAGS -DWIN32CON"
140	WINTTYLIB=""
141	WINSRC="${WINSRC} \$(WINTTYSRC)"
142	WINOBJ="${WINOBJ} \$(WINTTYOBJ)"
143	WINLIB="${WINLIB} \$(WINTTYLIB)"
144	AC_DEFINE(TTY_GRAPHICS, [], [Console output])
145    else
146	# For TTY, determine the termlib
147	# Check for termlib before termcap because Solaris termcap needs libucb.
148	TERMLIB_VARIANTS="ncurses curses termlib termcap terminfo"
149	for termlib in ${TERMLIB_VARIANTS}; do
150	    AC_CHECK_LIB(${termlib}, tgetent,
151	      [WINTTYLIB="-l${termlib}"
152	      WINSRC="${WINSRC} \$(WINTTYSRC)"
153	      WINOBJ="${WINOBJ} \$(WINTTYOBJ)"
154	      WINLIB="${WINLIB} \$(WINTTYLIB)"
155	      AC_DEFINE(TTY_GRAPHICS, [], [Console output])
156	      break])
157	done
158	if test -z "$termlib"; then
159	    if test "$enable_tty_graphics" = yes; then
160		AC_MSG_ERROR([Can't find tgetent (needed for tty graphics)])
161	    else
162		AC_MSG_WARN([Can't enable tty graphics (no tgetent)])
163		NETHACK_AUTO_WIN_DISABLE(tty)
164	    fi
165	fi
166	dnl  ----- Check for tparm in curses
167	AC_CHECK_HEADERS(ncurses.h curses.h termcap.h)
168	AC_CHECK_LIB(curses, tparm, AC_DEFINE(HAVE_TPARM, 1, [Define this if you have the tparm function in an included lib.]),
169	  [AC_CHECK_LIB(ncurses, tparm, AC_DEFINE(HAVE_TPARM, 1, [Define this if you have the tparm function in an included lib.])]))
170
171    fi
172
173    OPTIONS_FILE="options"
174    OPTIONS_FILES="options"
175fi
176if test "$enable_tty_graphics" = "no" -a $host_os = mingw32; then
177    LFLAGS="$LFLAGS -mwindows"
178fi
179AC_SUBST(WINTTYLIB)
180
181
182WINCURSESLIB=
183if test "$enable_curses_graphics" != "no"; then
184	# For curses, determine the curses lib
185	CURSES_VARIANTS="ncurses curses"
186	for curseslib in ${CURSES_VARIANTS}; do
187	    AC_CHECK_LIB(${curseslib}, tgetent,
188	      [WINCURSESLIB="-l${curseslib}"
189	      WINSRC="${WINSRC} \$(WINCURSESSRC)"
190	      WINOBJ="${WINOBJ} \$(WINCURSESOBJ)"
191	      WINLIB="${WINLIB} \$(WINCURSESLIB)"
192	      AC_DEFINE(CURSES_GRAPHICS, [], [Curses interface])
193	      break])
194	done
195	if test -z "$curseslib"; then
196	    if test "$enable_curses_graphics" = yes; then
197		AC_MSG_ERROR([Can't find tgetent (needed for curses graphics)])
198	    else
199		AC_MSG_WARN([Can't enable curses graphics (no tgetent)])
200		NETHACK_AUTO_WIN_DISABLE(curses)
201	    fi
202	fi
203
204	OPTIONS_FILE="options"
205	OPTIONS_FILES="options"
206fi
207AC_SUBST(WINCURSESLIB)
208
209dnl if test "$enable_proxy_graphics" != "no"; then
210dnl     if test "$have_libpng" = "no"; then
211dnl 	if test "$enable_proxy_graphics" = "yes"; then
212dnl 	    AC_MSG_ERROR([Need libpng for proxy graphics])
213dnl 	else
214dnl 	    AC_MSG_WARN([Can't enable proxy graphics (no useable libpng)])
215dnl 	fi
216dnl     else
217dnl 	if test "$enable_proxy_graphics" = "yes"; then
218dnl 	    PKG_CHECK_MODULES(NETHACK_PROXY, nhproxy >= 0.9.0)
219dnl 	else
220dnl 	    PKG_CHECK_MODULES(NETHACK_PROXY, nhproxy >= 0.9.0, :, :)
221dnl 	fi
222dnl 	if test -n "$NETHACK_PROXY_LIBS"; then
223dnl 	    CFLAGS="${CFLAGS} ${NETHACK_LIBPNG_CFLAGS}"
224dnl 	    LFLAGS="${LFLAGS} ${NETHACK_LIBPNG_LFLAGS}"
225dnl 	    WINSRC="${WINSRC} \$(WINPROXYSRC)"
226dnl 	    WINOBJ="${WINOBJ} \$(WINPROXYOBJ)"
227dnl 	    WINLIB="${WINLIB} ${NETHACK_PROXY_LIBS}"
228dnl 	    CNF_SHARE_DATND="${CNF_SHARE_DATND} \$(CNF_SHARE_PROXYND)"
229dnl 	    AC_DEFINE(PROXY_GRAPHICS, [], [proxy graphics])
230dnl 	fi
231dnl     fi
232dnl fi
233dnl AC_SUBST(NETHACK_PROXY_CFLAGS)
234
235if test "$enable_x11_graphics" != "no"; then
236    if test $have_libXaw != yes; then
237      AC_MSG_ERROR([Need X Athena Widgets Library for X11 graphics])
238    fi
239    CFLAGS="${CFLAGS} ${LIBXAW_CFLAGS}"
240    WINSRC="${WINSRC} \$(WINX11SRC)"
241    WINOBJ="${WINOBJ} \$(WINX11OBJ)"
242    WINLIB="${WINLIB} ${LIBXAW_LIBS}"
243    CNF_SHARE_DATND="${CNF_SHARE_DATND} \$(CNF_SHARE_X11ND)"
244    AC_DEFINE(X11_GRAPHICS, [], [X11 graphics])
245
246    OPTIONS_FILE="options"
247    OPTIONS_FILES="options"
248fi
249
250if test "$enable_dummy_graphics" != "no"; then
251    WINSRC="${WINSRC} \$(WINDUMMYSRC)"
252    WINOBJ="${WINOBJ} \$(WINDUMMYOBJ)"
253    AC_DEFINE(DUMMY_GRAPHICS, [], [Dummy graphics])
254
255    OPTIONS_FILE="options"
256    OPTIONS_FILES="options"
257fi
258
259if test "$enable_mswin_graphics" != "no"; then
260    AC_MINGW32
261
262    if test "$WINDRES" = "no"; then
263	AC_MSG_ERROR([Need windres for Microsoft Window's native graphics])
264    fi
265    WINSRC="${WINSRC} \$(WINMSSRC)"
266    WINOBJ="${WINOBJ} \$(WINMSOBJ)"
267    WINLIB="${WINLIB} \$(WINMSLIB)"
268    CNF_SHARE_DATND="${CNF_SHARE_DATND} \$(CNF_SHARE_MSND)"
269    AC_DEFINE(MSWIN_GRAPHICS, [], [Microsoft Window's native graphics])
270
271    OPTIONS_FILE="guioptions"
272    OPTIONS_FILES="$OPTIONS_FILES guioptions"
273fi
274
275LISPLIB=
276if test "$enable_lisp_graphics" != "no"; then
277    WINSRC="${WINSRC} \$(WINLISPSRC)"
278    WINOBJ="${WINOBJ} \$(WINLISPOBJ)"
279    WINLIB="${WINLIB} \$(WINLISPLIB)"
280    AC_DEFINE(LISP_GRAPHICS, [], [Lisp interface])
281
282    OPTIONS_FILE="options"
283    OPTIONS_FILES="options"
284fi
285AC_SUBST(LISPLIB)
286
287AC_SUBST(WINSRC)
288AC_SUBST(WINOBJ)
289AC_SUBST(WINLIB)
290AC_SUBST(CNF_SHARE_DATND)
291AC_SUBST(OPTIONS_FILE)
292AC_SUBST(OPTIONS_FILES)
293
294AC_MSG_CHECKING(for valid window system configuration)
295if test -n "$nethack_wins"; then
296    AC_MSG_RESULT([yes])
297    for win in $nethack_wins; do
298	AC_DEFINE_UNQUOTED(DEFAULT_WINDOW_SYS,["$win"],
299	  [The default windowing system])
300	break
301    done
302else
303    AC_MSG_RESULT([no])
304    AC_MSG_ERROR([need to enable at least one window system])
305fi
306
307
308dnl  ----- Check for header files
309AC_HEADER_STDC
310# Due to what may be a bug in autoconf, we have to call AC_CHECK_HEADERS()
311# to get the various HAVE_xxx_H preprocessor variables detected by
312# AC_HEADER_STDC active. These are needed for AC_CHECK_DECLS(), below.
313AC_CHECK_HEADERS([inttypes.h stdint.h unistd.h string.h utime.h])
314AC_CHECK_HEADER(regex.h, [have_regex_h=yes],[have_regex_h=no],/* TEST_REGEX */)
315
316dnl ------ Check for data types
317dnl -- Regex-Check for MENU_COLOR
318if test "$have_regex_h" = "yes"; then
319  AC_CHECK_TYPE(regex_t,
320    [AC_DEFINE(MENU_COLOR_REGEX, [], [Use regular expressions])
321     AC_DEFINE(MENU_COLOR_REGEX_POSIX, [], [Posix regex is available])
322    ],
323    [AC_CHECK_TYPE(struct re_pattern_buffer,
324      [AC_DEFINE(MENU_COLOR_REGEX, [], [Use regular expressions])
325	AC_DEFINE(MENU_COLOR_REGEX_GNU, [], [GNU regex is available])
326      ],,
327      [AC_INCLUDES_DEFAULT([])
328	#include <regex.h>
329      ])
330    ],[AC_INCLUDES_DEFAULT([])
331	#include <regex.h>
332      ])
333fi
334AC_CHECK_TYPE(void,,AC_DEFINE(NOVOID, [], [No void type available]))
335
336
337dnl  ----- Check for library functions
338AC_CHECK_DECLS([strncmpi, strnicmp], AC_DEFINE(STRNCMPI, [], [Use strncmpi]))
339
340dnl ------ Check needed functions for TIMED_DELAY
341AC_CHECK_FUNC(msleep, cf_result=yes, cf_result=no)
342if test "$cf_result" = no; then
343	AC_CHECK_FUNC(usleep, AC_DEFINE(TIMED_DELAY, [], [Using usleep]), [])
344else
345	AC_DEFINE(TIMED_DELAY, [], [Using msleep])
346fi
347
348dnl ------ Check fcntl for USE_FCNTL
349AC_CHECK_FUNCS(fcntl)
350
351dnl ------ Check for 32 bit datatype
352AX_DEFINE_INTEGER_BITS(uint32_t, unsigned int, unsigned long, unsigned long long)
353
354dnl  ----- Check for program needed to build Guidebook
355AC_CHECK_PROG(HAVE_NROFF, nroff, "yes", "no")
356AC_CHECK_PROG(HAVE_TBL, tbl, "yes", "no")
357if test "$HAVE_NROFF" != "no" ; then
358if test "$HAVE_TBL" != "no" ; then
359	AC_SUBST(GUIDEBOOK,[Guidebook])
360	AC_SUBST(GUIDEBOOK_TXT,[Guidebook.txt])
361fi
362fi
363AC_CHECK_PROG(HAVE_COL, col, "yes", "no")
364if test "$HAVE_COL" != "yes" ; then
365        if test $host_os != mingw32; then
366                AC_MSG_ERROR([Couldn't find 'col'])
367        else
368                AC_MSG_ERROR([Couldn't find 'col' (install 'util-linux' in Cygwin)])
369        fi
370fi
371
372if test $host_os != mingw32; then
373  dnl searching for non blocking random device
374  AC_MSG_CHECKING(for pseudo random number device)
375  if test -r "/dev/urandom"; then
376	AC_DEFINE(DEV_RANDOM, ["/dev/urandom"], [Pseudo random number device])
377	AC_MSG_RESULT(/dev/urandom)
378  elif test -r "/dev/random"; then
379	AC_DEFINE(DEV_RANDOM, ["/dev/random"], [Pseudo random number device])
380	AC_MSG_RESULT(/dev/random)
381  else
382	AC_MSG_RESULT(not found);
383  fi
384
385  dnl check for GNU Scientific Library for Mersenne Twister RNG
386  dnl http://www.gnu.org/software/gsl/manual/html_node/Autoconf-Macros.html
387  AC_CHECK_LIB([gsl],[gsl_blas_dgemm],
388		[LFLAGS="$LDFLAGS -lgsl";
389		 AC_DEFINE(USE_MERSENNE_TWISTER, [], [Using Mersenne Twister as RNG])])
390fi
391
392dnl  ----- Check for compile-time options
393# We use auto for data librarian to avoid breaking the rule that autoconf
394# should use the same defaults as the manual configuration, but all platforms
395# that support autoconf also support DLB, so the automatic choice is always yes.
396NETHACK_ARG(data-librarian,[Data librarian],DLB,auto,
397  [enable_data_librarian=yes])
398NETHACK_ARG(sinks,[Kitchen sinks],SINKS,yes)
399# NETHACK_ARG(light-src-spell,[Spells are light sources],LIGHT_SRC_SPELL,yes)
400NETHACK_ARG(wallified-maze,[Fancy mazes],WALLIFIED_MAZE,yes)
401NETHACK_ARG(reincarnation,[Special Rogue-like levels],REINCARNATION,yes)
402NETHACK_ARG(blackmarket,[Blackmarket],BLACKMARKET,yes)
403NETHACK_ARG(kops,[Keystone Kops],KOPS,yes)
404NETHACK_ARG(seduce,[Succubi/incubi seduction],SEDUCE,yes)
405# NETHACK_ARG(invisible-objects,[Invisible objects],INVISIBLE_OBJECTS,yes)
406# NETHACK_ARG(unpolypile,[Object unpolymorphing],UNPOLYPILE,yes)
407# NETHACK_ARG(wallet-o-p,[Perseus' Wallet],WALLET_O_P,yes)
408# NETHACK_ARG(lightsabers,[Lightsabers],LIGHTSABERS,yes)
409# NETHACK_ARG(d-saber,[Dimsabers],LIGHTSABERS,yes)
410# NETHACK_ARG(p-spoon,[Spoon],P_SPOON,yes)
411# NETHACK_ARG(firearms,[Guns and Bullets],FIREARMS,yes)
412# NETHACK_ARG(eaten-memory,[Remember which monsters have been eaten],
413#  EATEN_MEMORY,yes)
414NETHACK_ARG(randomized-planes,[Shuffling order of Elemental Planes],RANDOMIZED_PLANES,yes)
415NETHACK_ARG(steed,[Ability to ride monsters],STEED,yes)
416# NETHACK_ARG(dwarf,[Dwarf race],DWARF,yes)
417NETHACK_ARG(tourist,[Tourist class],TOURIST,yes)
418NETHACK_ARG(convict,[Convict class],CONVICT,yes)
419# NETHACK_ARG(yeoman,[Yeoman class],YEOMAN,yes)
420# NETHACK_ARG(zouthern,[Zoutherner class],ZOUTHERN,no)
421NETHACK_ARG(redo,[Redo last command],REDO,yes)
422NETHACK_ARG(clipping,[Allow smaller screens],CLIPPING,yes)
423NETHACK_ARG(menu-color,[TTY graphics menu color],MENU_COLOR,yes)
424if test "$enable_tty_graphics" != "no"; then
425NETHACK_ARG(status-color,[TTY graphics status color],STATUS_COLORS,yes)
426fi
427NETHACK_ARG(auto-open,[Open doors by walking into them],AUTO_OPEN,yes)
428NETHACK_ARG(elbereth,[Engraving the E-word repels monsters],ELBERETH,yes)
429# NETHACK_ARG(noartifactwish,[Prevent wishing for special artifacts],
430#  NOARTIFACTWISH,no)
431# NETHACK_ARG(no-bones,[Disable loading and saving bones levels],NO_BONES,no)
432if test $host_os != mingw32; then
433 NETHACK_ARG(bones-pool,[Multiple bones per level],BONES_POOL,yes)
434fi
435NETHACK_ARG(user-sounds,
436  [Allow user-defined mapping from messages to sounds)],
437  USER_SOUNDS,no)
438NETHACK_ARG(exp-on-botl,[Show experience on bottom line],EXP_ON_BOTL,yes)
439NETHACK_ARG(score-on-botl,[Show score on bottom line],SCORE_ON_BOTL,no)
440NETHACK_ARG(realtime-on-botl,[Show elapsed time on bottom line],REALTIME_ON_BOTL,no)
441NETHACK_ARG(high-score-comparison-by-uid,[Compare High Score entries by user id instead of user name],PERS_IS_UID,no)
442#NETHACK_ARG(borg,[Borg player (only under DOS)],BORG,no)
443# NETHACK_ARG(keep-save,[Keep save files after restore],KEEP_SAVE,no)
444# NETHACK_ARG(charon,[Charon's boat, enables Cerebus (not implemented)],CHARON,no)
445# NETHACK_ARG(show-dmg,[Display damage reports],SHOW_DMG,yes)
446# NETHACK_ARG(show-weight,[Display object weight],SHOW_WEIGHT,yes)
447# NETHACK_ARG(other-services,[Shopkeeper services],OTHER_SERVICES,yes)
448NETHACK_ARG(paranoid,[Require some questions to be answered with 'yes' instead of 'y'],PARANOID,yes)
449NETHACK_ARG(shell,[Start a shell from within the game],SHELL,no)
450NETHACK_ARG(show-born,[Display number of created monsters at the end of game],SHOW_BORN,yes)
451NETHACK_ARG(show-extinct,[Display extinct monsters at the end of game],SHOW_EXTINCT,yes)
452NETHACK_ARG(sortloot,[Sort item lists alphabetically by description.],SORTLOOT,yes)
453NETHACK_ARG(dungeon-growth,[Dungeon growth],DUNGEON_GROWTH,yes)
454#NETHACK_ARG(shout,[Shouting and pet commands (not implemented)],SHOUT,no)
455# NETHACK_ARG(display-layers,[Support transparent tilesets],DISPLAY_LAYERS,yes)
456NETHACK_ARG(goldobj,[Gold is kept on object chains (experimental)],GOLDOBJ,no)
457NETHACK_ARG(autopickup-exceptions,[Exceptions to autopickup],
458  AUTOPICKUP_EXCEPTIONS,yes)
459NETHACK_ARG(quiver-fired,[Firing without anything quivered will ask you what to quiver],QUIVER_FIRED,yes)
460NETHACK_ARG(qwertz,[QWERTZ keyboard layout support],QWERTZ,yes)
461NETHACK_ARG(simple-mail,[simple mail dgamelaunch support],SIMPLE_MAIL,no)
462
463NETHACK_ARG_WITH_PARAM(xlogfile,[More verbose logfile],XLOGFILE,yes,FILE,[xlogfile])
464
465NETHACK_ARG_WITH_PARAM(livelog,[Live game progress logfile],LIVELOGFILE,no,FILE,[livelog])
466if test "$enable_livelog" != "no" ; then
467	NETHACK_ARG(livelog-shout,[Shoutting into the live game logfile],LIVELOG_SHOUT,no)
468	NETHACK_ARG(livelog-killing,[Reporting killing of uniques and ghosts of former players],LIVELOG_BONES_KILLER,no)
469fi
470
471NETHACK_ARG(dump,[Dumping character stats],DUMP_LOG,yes)
472if test "$enable_dump" != "no" ; then
473	NETHACK_ARG_WITH_PARAM(dump-file,[Name of character dump file],DUMP_FN,no,FILE,"/tmp/%n.nh")
474	NETHACK_ARG_WITH_PARAM(dump-messages,[Number of dumped messages],DUMPMSGS,yes,NUMBER,30)
475	NETHACK_ARG(dump-text,[Dump a text file],DUMP_TEXT_LOG,yes)
476	NETHACK_ARG(dump-html,[Dump an HTML file],DUMP_HTML_LOG,no)
477	if test "$enable_dump_html" != "no" ; then
478		NETHACK_ARG_WITH_PARAM(dump-html-css-file,[Path to the css dump file],DUMP_HTML_CSS_FILE,yes,FILE,"unnethack_dump.css")
479		NETHACK_ARG(dump-html-css-embedded,[CSS file should be included in the HTML dump],DUMP_HTML_CSS_EMBEDDED,no)
480	fi
481fi
482
483if test "$enable_tty_graphics" != "no"; then
484	NETHACK_ARG(utf8-glyphs,[Enable UTF-8 glyphs in TTY],UTF8_GLYPHS,yes)
485	if test "$enable_utf8_glyphs" != "no" ; then
486		dnl check for uint32_t
487		if test "$uint32_t" = no; then
488			AC_MSG_ERROR([unable to continue without a 4-bytes datatype that could hold unicode codepoints])
489		fi
490	fi
491fi
492
493
494NETHACK_ARG_WITH_PARAM(whereis-file,[Log information about running games],WHEREIS_FILE,no,FILE,[%n.whereis])
495
496NETHACK_ARG_WITH_PARAM(wizmode,[enable wizard mode for the specified user],WIZARD,yes,USER,[wizard])
497
498if test "$CHOWN" != "true"; then
499    AC_MSG_CHECKING([for owner of installed files])
500    AC_ARG_WITH([owner], [AS_HELP_STRING([--with-owner=USER],
501	    [Set the owner of installed files (default=games)])],
502	    [], [with_owner=games])
503    if test "$with_owner" != "no" ; then
504	NETHACK_COMMAND_IFELSE(
505		[find . -user "$with_owner" -prune -print > /dev/null],
506		[AC_MSG_RESULT([$with_owner])
507		 AC_SUBST(OWNER,[$with_owner])],
508		[AC_MSG_FAILURE([test for user $with_owner failed])])
509    else
510	CHOWN=true
511	AC_MSG_RESULT([not set])
512    fi
513fi
514
515if test "$CHGRP" != "true"; then
516    AC_MSG_CHECKING([for group of installed files])
517    AC_ARG_WITH([group], [AS_HELP_STRING([--with-group=GROUP],
518	    [Set the group of installed files (default=bin)])],
519	    [], [with_group=bin])
520    if test "$with_group" != "no" ; then
521	NETHACK_COMMAND_IFELSE(
522		[find . -group "$with_group" -prune -print > /dev/null],
523		[AC_MSG_RESULT([$with_group])
524		 AC_SUBST(GROUP,[$with_group])],
525		[AC_MSG_FAILURE([test for group $with_group failed])])
526    else
527	CHGRP=true
528	AC_MSG_RESULT([not set])
529    fi
530fi
531
532
533NETHACK_ARG(file-areas,[Place files in different directories],FILE_AREAS,yes)
534
535AC_DEFUN([NETHACK_DIR_SET],
536  [
537   AC_MSG_CHECKING([which directory is $1])
538   AC_ARG_WITH([$1], [AS_HELP_STRING([--with-$1=DIR],
539    [$7 (default=$3)])],
540    [autoconf_val='"'$withval'"'], [withval=$4;autoconf_val='$5'])
541   if test "$enable_file_areas" != "no" ; then
542     AC_SUBST($6,[$withval])
543     AC_DEFINE_UNQUOTED($6, [$autoconf_val], [$7])
544     AC_MSG_RESULT([$withval])
545   else
546     # set default value if FILE_AREAS is not defined
547     if test "$6" != "FILE_AREA_SAVE" ; then
548       tmp_installdir=[${datadir}/unnethack]
549     else
550       tmp_installdir=[${datadir}/unnethack/save]
551     fi
552     AC_SUBST($6,[${tmp_installdir}])
553     AC_MSG_RESULT([default value: ${tmp_installdir}])
554   fi
555  ])
556
557# set doc directory manually
558if test "$enable_file_areas" != "no" ; then
559  AC_SUBST(FILE_AREA_DOC,[${docdir}/unnethack])
560  AC_DEFINE_UNQUOTED(FILE_AREA_DOC, [AUTOCONF_DOCDIR"/unnethack"],
561    [Location of human-readable documentation])
562else
563  # ignore ${docdir} if FILE_AREAS is not defined
564  AC_SUBST(FILE_AREA_DOC,[${datadir}/unnethack])
565fi
566
567NETHACK_DIR_SET(gamesdir, gamesdir, [LOCALSTATEDIR/unnethack],
568		[${localstatedir}/unnethack],
569		[AUTOCONF_LOCALSTATEDIR"/unnethack"],
570		FILE_AREA_VAR, [Location of other files which may be modified])
571
572NETHACK_DIR_SET(bonesdir, bones, [GAMESDIR/bones],
573		[${FILE_AREA_VAR}/bones],
574		[FILE_AREA_VAR"/bones"],
575		FILE_AREA_BONES, [Location of bones files (rw)])
576
577NETHACK_DIR_SET(savesdir, saves, [GAMESDIR/saves],
578		[${FILE_AREA_VAR}/saves],
579		[FILE_AREA_VAR"/saves"],
580		FILE_AREA_SAVE, [Location of save files (rw)])
581
582NETHACK_DIR_SET(leveldir, level, [GAMESDIR/level],
583		[${FILE_AREA_VAR}/level],
584		[FILE_AREA_VAR"/level"],
585		FILE_AREA_LEVL, [Location of level files (rw)])
586
587NETHACK_DIR_SET(sharedir, share, [DATADIR/unnethack],
588		[${datadir}/unnethack],
589		[AUTOCONF_DATADIR"/unnethack"],
590		FILE_AREA_SHARE, [For read-only, architecture independent files])
591
592NETHACK_DIR_SET(unsharedir, unshare, [DATADIR/unnethack],
593		[${datadir}/unnethack],
594		[AUTOCONF_DATADIR"/unnethack"],
595		FILE_AREA_UNSHARE, [For read-only, architecture dependent files])
596
597
598NETHACK_LINKS=
599NETHACK_LINKS_ADD([dat/data.base])
600NETHACK_LINKS_ADD([dat/rumors.tru])
601NETHACK_LINKS_ADD([dat/rumors.fal])
602NETHACK_LINKS_ADD([dat/quest.txt])
603NETHACK_LINKS_ADD([dat/oracles.txt])
604NETHACK_LINKS_ADD([dat/dungeon.def])
605NETHACK_LINKS_ADD([dat/help])
606NETHACK_LINKS_ADD([dat/hh])
607NETHACK_LINKS_ADD([dat/cmdhelp])
608NETHACK_LINKS_ADD([dat/history])
609NETHACK_LINKS_ADD([dat/opthelp])
610NETHACK_LINKS_ADD([dat/wizhelp])
611NETHACK_LINKS_ADD([include/win32api.h:sys/winnt/win32api.h])
612
613AC_CONFIG_LINKS(${NETHACK_LINKS})
614
615dnl  ----- Process the Makefiles
616AC_CONFIG_FILES([Makefile:sys/autoconf/Makefile.top]
617	[src/Makefile:sys/autoconf/Makefile.src]
618	[doc/Makefile:sys/autoconf/Makefile.doc]
619	[dat/Makefile:sys/autoconf/Makefile.dat]
620	[util/Makefile:sys/autoconf/Makefile.utl]
621	[sys/autoconf/depend.awk:sys/autoconf/depend.in])
622
623AH_TOP([#ifndef AUTOCONF_H
624#define AUTOCONF_H])
625AH_BOTTOM([#endif /* AUTOCONF_H */])
626
627NETHACK_CONFIG_HEADER([include/autoconf.h:sys/autoconf/autoconf.hin])
628
629AC_OUTPUT
630