forked from dennis-roof/Unangband
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.in
207 lines (174 loc) · 7.12 KB
/
configure.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
dnl Process this file with autoconf to produce a configure script.
dnl Initialize autoconf - look for the existance of a file to make sure
dnl the source distribution is installed correctly.
AC_INIT
AC_CONFIG_SRCDIR([src/main.c])
dnl write the resulting #defines into a header file
AM_CONFIG_HEADER(src/autoconf.h)
AM_INIT_AUTOMAKE(UnAngband, 0.6.3)
AC_ARG_WITH(setgid,
[ --with-setgid=NAME install unangband as group NAME],
[case "${withval}" in
no) GAMEGROUP="";;
yes) AC_MSG_ERROR(missing argument for --with-setgid);;
*) GAMEGROUP="$withval";;
esac])
AC_SUBST(GAMEGROUP)
AM_CONDITIONAL(SET_GID, test "$GAMEGROUP" != "")
AC_LANG([C])
dnl generate the installation path for the ./lib/ folder
if test "$GAMEGROUP" != ""; then
MY_EXPAND_DIR([game_datadir], "$datadir/games/$PACKAGE/lib/")
else
MY_EXPAND_DIR([game_datadir], "./lib/")
bindir=".."
fi
dnl overwrite the path with an user-specified value
AC_ARG_WITH(libpath,
[ --with-libpath=path specify the path to the UnAngband lib folder],
[case "/$withval" in
*/) game_datadir="$withval" ;;
*) game_datadir="$withval/" ;;
esac])
AC_DEFINE_UNQUOTED([DEFAULT_PATH], "$game_datadir",
[Path to the game's lib directory])
DEFAULT_PATH="$game_datadir"
AC_SUBST(DEFAULT_PATH)
dnl Checks for programs.
AC_PROG_CC
AC_CHECK_TOOL(RANLIB, ranlib)
dnl -fno-strength-reduce prevents a bug in some versions of gcc
if test "$GCC" = yes; then
CFLAGS="$CFLAGS -fno-strength-reduce"
fi
dnl Checks for libraries.
AC_CANONICAL_HOST()
AC_DIAGNOSE([obsolete],[AC_CYGWIN is obsolete: use AC_CANONICAL_HOST and $host_os])case $host_os in
*cygwin* ) CYGWIN=yes;;
* ) CYGWIN=no;;
esac
AC_DIAGNOSE([obsolete],[AC_MINGW32 is obsolete: use AC_CANONICAL_HOST and $host_os])case $host_os in
*mingw32* ) MINGW32=yes;;
* ) MINGW32=no;;
esac
AC_EXEEXT
if test "$CYGWIN" = "yes"; then
AC_DEFINE([WINDOWS], 1, [Use the Windows front-end])
LIBS="$LIBS -lwinmm"
LDFLAGS="$LDFLAGS -s -mno-cygwin -mwindows -e _mainCRTStartup"
CFLAGS="$CFLAGS -mno-cygwin"
UNANGBAND_OBJS="readdib.o angband.res"
AC_SUBST(UNANGBAND_OBJS)
else
dnl SGI (IRIX) may need -lsun for the NIS version of getpwnam
AC_CHECK_LIB(sun, getpwnam)
dnl Check for ncurses, curses, or termcap
dnl Try -lncurses, -lcurses, -lcurses -ltermcap, and finally plain -ltermcap
use_ncurses=no
AC_CHECK_LIB(ncurses, initscr,
[AC_CHECK_HEADER(ncurses.h, use_ncurses=yes,
[AC_CHECK_HEADER(/usr/include/ncurses/ncurses.h,
[CFLAGS="-I/usr/include/ncurses $CFLAGS" use_ncurses=yes])])])
if test "$use_ncurses" = yes; then
AC_DEFINE([USE_GCU], 1, [Use the curses front-end])
AC_DEFINE([USE_NCURSES], 1, [Use the ncurses library])
LIBS="-lncurses $LIBS"
else
AC_CHECK_LIB(curses, initscr,
[AC_DEFINE([USE_GCU], 1, [Use the curses front-end])
LIBS="-lcurses $LIBS"],
[AC_CHECK_LIB(curses, endwin,
[AC_DEFINE([USE_GCU], 1, [Use the curses front-end])
LIBS="-lcurses -ltermcap $LIBS"],
[AC_CHECK_LIB(termcap, tgetent,
[AC_DEFINE([USE_CAP], 1, [Use the libtermcap front-end])
LIBS="-ltermcap $LIBS"])],
-ltermcap)])
fi
dnl Check for GTK
if test "X${enable_gtk-no}" != Xno ; then
AC_DEFINE([USE_GTK], 1, [Use the GTK front-end])
AC_CACHE_CHECK(gtk-config --libs, ac_cv_gtk_libs,
[ac_cv_gtk_libs=`( gtk-config --libs ) 2>&5` || ac_cv_gtk_libs=""])
AC_CACHE_CHECK(gtk-config --cflags, ac_cv_gtk_cflags,
[ac_cv_gtk_cflags=`(gtk-config --cflags) 2>&5` || ac_cv_gtk_cflags="no"])
if test "X$ac_cv_gtk_libs" = X || test "X$ac_cv_gtk_cflags" = Xno; then
AC_MSG_ERROR([Could not find GTK.])
fi
CFLAGS="$ac_cv_gtk_cflags $CFLAGS"
LIBS="$ac_cv_gtk_libs $LIBS"
AC_CACHE_CHECK(for gtk_widget_show, ac_cv_lib_gtk_gtk_widget_show,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <X11/Xlib.h>]], [[gtk_widget_show((GtkWidget *)0);]])],[ac_cv_lib_gtk_gtk_widget_show=yes],[AC_MSG_ERROR([Failed to link GTK.])])])
fi
if test "x${enable_gtk-no}" = xno ||
test "x${with_x+set}" != x ||
test "x$x_includes" != xNONE || test "x$x_libraries" != xNONE
then
dnl Checks for X window system.
AC_PATH_XTRA
fi
AC_ARG_ENABLE(gtk, [ --enable-gtk enable the GTK X11 module])
if test "x${enable_gtk-no}" != xno || test "$no_x" != "yes"; then
UNANGBAND_OBJS="maid-x11.o"
AC_SUBST(UNANGBAND_OBJS)
fi
if test "$no_x" != "yes"; then
AC_DEFINE([USE_X11], 1, [Use the X11 front-end])
AC_DEFINE([USE_XPJ], 1, [Use the isometric X11 front-end])
LIBS="-lX11 $X_EXTRA_LIBS $LIBS"
CFLAGS="$CFLAGS $X_CFLAGS"
LDFLAGS="$LDFLAGS $X_LIBS"
dnl X_PRE_LIBS is prepended to LIBS below.
dnl Check for the Athena widget set
dnl
dnl Does anyone know if it is OK to put '-lXmu -lXt' *before* X_PRE_LIBS?
dnl If so this code can be simplified by inserting X_PRE_LIBS in LIBS above.
dnl Today libraries come in the same sequence as in the old src/Makefile.std,
dnl since that is presumably the way which has been tested most.
x_more_libs="$X_PRE_LIBS -lXt"
AC_CHECK_LIB(Xmu, main, x_more_libs="$X_PRE_LIBS -lXmu -lXt", , $x_more_libs)
AC_CHECK_LIB(Xext, main, x_more_libs="-lXext $x_more_libs", , $x_more_libs)
dnl Note: Both Xaw libraries and includes may be in nostandard places.
ac_save_LIBS="$LIBS"
LIBS="-lXaw $x_more_libs $LIBS"
AC_CACHE_CHECK(for X11 Athena widget set, ac_cv_athena_widget,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <X11/IntrinsicP.h>
#include <X11/Xaw/SimpleP.h>
#include <X11/Xaw/Simple.h>
#include <X11/Xaw/XawInit.h>]], [[XawInitializeWidgetSet();]])],[ac_cv_athena_widget=yes],[ac_cv_athena_widget=no])])
case "$ac_cv_athena_widget" in
yes) AC_DEFINE([USE_XAW], 1, [Use the Athena Widget set front-end]) ;;
*) LIBS="$X_PRE_LIBS $ac_save_LIBS" ;;
esac
fi
fi
dnl add some warning flags
CFLAGS="$CFLAGS -Wall -Wextra -Wformat=0 -Wlogical-op -Wredundant-decls -Wnested-externs -std=gnu99"
dnl some other warnings to test: -Wc++-compat -Wno-multichar
dnl generates lots of warnings: -Wconversion -Wshadow
dnl unimportant: -Wpointer-arith -Waddress
dnl don't bother: -Waggregate-return -Wstrict-prototypes -Wpointer-sign
dnl produces lots of dodgy warnings: -Wunreachable-code
AM_CONDITIONAL(CYGWIN, test "$CYGWIN" = "yes")
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h limits.h strings.h sys/file.h sys/ioctl.h \
sys/time.h termio.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(gethostname mkdir select strstr strtol usleep mkstemp setegid can_change_color)
AC_CONFIG_FILES([Makefile src/Makefile lib/Makefile lib/apex/Makefile lib/bone/Makefile lib/data/Makefile lib/edit/Makefile lib/file/Makefile lib/help/Makefile lib/info/Makefile lib/pref/Makefile lib/save/Makefile lib/todo/Makefile lib/user/Makefile lib/xtra/Makefile
lib/xtra/font/Makefile lib/xtra/graf/Makefile lib/xtra/music/Makefile lib/xtra/sound/Makefile])
AC_OUTPUT