Start of a "make dist" target.
[gnushogi.git] / configure.ac
1 # ------------------------------------------------------------
2 # GNU shogi and xshogi configuration script.
3 # ------------------------------------------------------------
4
5 dnl Process this file with autoconf to produce a configure script.
6
7 AC_PREREQ(2.57)
8 AC_INIT([gnushogi],[1.4.0+],[https://savannah.gnu.org/bugs/?group=gnushogi])
9 AC_CONFIG_SRCDIR([version.h])
10 AC_CONFIG_HEADER(config.h)
11
12
13 #
14 # Check for C compiler.
15 #
16
17 echo
18 AC_MSG_CHECKING(for C compiler)
19 echo
20
21 AC_PROG_CC
22
23
24 #
25 # Check for parser generators.
26 #
27
28 echo
29 AC_MSG_CHECKING([for yacc/bison, lex/flex, and install])
30 echo
31
32 AC_PROG_YACC
33 AC_PROG_LEX
34 AC_PROG_INSTALL
35
36
37 #
38 # Check for X windows.
39 #
40
41 echo
42 AC_PATH_XTRA
43
44 #
45 # Check for ncurses.
46 #
47
48 AC_ARG_WITH([curses],
49   [AS_HELP_STRING([--with-curses],
50     [enable curses UI])],
51   [],
52   [with_curses=check])
53
54 LIBCURSES=
55 AS_IF([test "x$with_curses" != xno],
56   [AC_CHECK_LIB([curses], [clrtoeol],
57     [AC_SUBST([LIBCURSES], ["-lcurses"])
58      AC_DEFINE([HAVE_LIBCURSES], [1],
59                [Define if you have lib])
60     ],
61     [AC_MSG_FAILURE(
62        [--with-curses was given, but test for curses failed])],
63     [-ltermcap])])
64
65 #
66 # Check for other libraries.
67 #
68
69 AC_CHECK_LIB(m, pow)
70 dnl Replace `main' with a function in -ltermcap:
71 AC_CHECK_LIB(termcap, tgoto)
72
73
74 #
75 # C compiler warnings.
76 #
77
78 if [[ $ac_cv_c_compiler_gnu = yes ]]
79 then
80 WARNINGS="-Wall -Wno-implicit-int -Wstrict-prototypes -ansi -pedantic"
81 CEXTRAFLAGS="-fsigned-char -funroll-loops \$(HASH)"
82 # For profiling targets:
83 CEXTRAFLAGS2="-fsigned-char -pg -fprofile-arcs -ftest-coverage \$(HASH)"
84 else
85 # Who knows what warnings your compiler uses?
86 WARNINGS=
87 CEXTRAFLAGS="\$(HASH)"
88 fi
89
90 AC_SUBST(WARNINGS)
91 AC_SUBST(CEXTRAFLAGS)
92 AC_SUBST(CEXTRAFLAGS2)
93
94
95 #
96 # Check for header files.
97 #
98
99 echo
100 AC_MSG_CHECKING(for header files)
101 echo
102
103 AC_HEADER_STDC
104 AC_HEADER_SYS_WAIT
105 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/file.h sys/ioctl.h])
106 AC_CHECK_HEADERS([sys/param.h sys/time.h unistd.h])
107 AC_CHECK_HEADERS(errno.h)
108 AC_HEADER_TIME
109
110
111 #
112 # Check for typedefs, structures, and compiler characteristics.
113 #
114
115 echo 
116 AC_MSG_CHECKING(for typedefs)
117 echo
118
119 AC_C_CONST
120 AC_HEADER_STDBOOL
121 AC_C_INLINE
122 AC_TYPE_PID_T
123 AC_TYPE_SIZE_T
124 AC_HEADER_TIME
125 AC_STRUCT_TM
126
127 echo 
128 AC_MSG_CHECKING(for compiler characteristics)
129 echo
130
131 AC_CHECK_SIZEOF(long)
132
133
134 #
135 # Check for library functions.
136 #
137
138 echo
139 AC_MSG_CHECKING(for library functions)
140 echo
141
142 AC_FUNC_FORK
143 AC_PROG_GCC_TRADITIONAL
144 AC_FUNC_MALLOC
145 AC_FUNC_SETVBUF_REVERSED
146 AC_TYPE_SIGNAL
147 AC_CHECK_FUNCS([dup2 gethostname gettimeofday memset pow strcasecmp])
148 AC_CHECK_FUNCS([strchr strerror strrchr strstr strtol])
149 AC_CHECK_FUNCS(memcpy bcopy)
150 AC_CHECK_FUNCS(setlinebuf setvbuf)
151
152
153 #
154 # Set various user-definable options.
155 #
156 # Valid OPT settings:
157 # --with-top-part-bitmaps
158 #
159 # Other settings:
160 # --with-first-shogi-program=PROGNAME
161 # --with-second-shogi-program=PROGNAME
162 # --with-first-host=HOSTNAME
163 # --with-second-host=HOSTNAME
164 #
165
166 OPT=
167 FIRST_SHOGI_PROGRAM=gnushogi
168 SECOND_SHOGI_PROGRAM=gnushogi
169 FIRST_HOST=localhost
170 SECOND_HOST=localhost
171
172 AC_ARG_WITH(xshogi,
173 [  --with-xshogi
174         Compile the xshogi graphical interface to GNU shogi (default: no)],
175 with_xshogi=$withval,
176 with_xshogi=no)
177
178 AC_ARG_WITH(top-part-bitmaps,
179 [  --with-top-part-bitmaps    Use top part of Kanji bitmaps only in xshogi.],
180 OPT=-DTOP_PART_BITMAPS)
181
182 AC_ARG_WITH(first-shogi-program,
183 [  --with-first-shogi-program=PROGNAME    
184         Use PROGNAME as the first shogi program in xshogi (default: gnushogi)],
185 FIRST_SHOGI_PROGRAM=$withval)
186
187 AC_ARG_WITH(second-shogi-program,
188 [  --with-second-shogi-program=PROGNAME    
189         Use PROGNAME as the second shogi program in xshogi (default: gnushogi)],
190 SECOND_SHOGI_PROGRAM=$withval)
191
192 AC_ARG_WITH(first-host,
193 [  --with-first-host=HOSTNAME    
194         Use HOSTNAME as the machine on which the first shogi program 
195         runs in xshogi (default: localhost)],
196 FIRST_HOST=$withval)
197
198 AC_ARG_WITH(second-host,
199 [  --with-second-host=HOSTNAME    
200         Use HOSTNAME as the machine on which the second shogi program 
201         runs in xshogi (default: localhost)],
202 SECOND_HOST=$withval)
203
204 AC_SUBST(OPT)
205 AC_SUBST(FIRST_SHOGI_PROGRAM)
206 AC_SUBST(SECOND_SHOGI_PROGRAM)
207 AC_SUBST(FIRST_HOST)
208 AC_SUBST(SECOND_HOST)
209
210 if [[ $with_xshogi = yes ]]
211 then
212 XSHOGI=xshogi_compile
213 XSHOGIINSTALL=xshogi_install
214 XSHOGICLEAN=xshogi_clean
215 else
216 XSHOGI=
217 XSHOGIINSTALL=
218 XSHOGICLEAN=
219 fi
220
221 AC_SUBST(XSHOGI)
222 AC_SUBST(XSHOGIINSTALL)
223 AC_SUBST(XSHOGICLEAN)
224
225
226 echo
227 echo outputting files...
228
229 AC_CONFIG_FILES([Makefile
230                  gnushogi/Makefile
231                                  gnushogi/Makefile.profile
232                  xshogi/Makefile])
233 AC_OUTPUT
234