Fix various regression for building out of tree.
[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([gnushogi/gnushogi.h])
10 AC_CONFIG_HEADER(config.h)
11
12 ##########
13 AC_MSG_NOTICE([C compiler])
14 AC_PROG_CC
15
16 ##########
17 AC_MSG_NOTICE([yacc/bison, lex/flex, and install])
18 AC_PROG_YACC
19 AC_PROG_LEX
20 AC_PROG_INSTALL
21
22 ##########
23 AC_MSG_NOTICE([X])
24 AC_PATH_XTRA
25
26 ##########
27 AC_MSG_NOTICE([libs])
28
29 # curses
30 AC_ARG_WITH([curses],
31   [AS_HELP_STRING([--with-curses],
32     [enable curses UI (default: yes if available)])],
33   [],
34   [with_curses=check])
35
36 LIBCURSES=
37 AS_IF([test "x$with_curses" != xno],
38   [AC_CHECK_LIB([curses], [clrtoeol],
39     [AC_SUBST([LIBCURSES], [-lcurses])
40      AC_SUBST([CURSESDSP], [cursesdsp.o])
41      AC_DEFINE([HAVE_LIBCURSES], [1],
42                [Define if you have lib])
43     ],
44     [AS_IF([test "x$with_curses" = xyes],
45       [AC_MSG_ERROR(
46          [--with-curses was given, but test for curses failed])])],
47     [-ltermcap])])
48
49 # other libraries.
50 AC_CHECK_LIB(m, pow)
51 AC_CHECK_LIB(termcap, tgoto)
52
53
54
55 ##########
56 # C compiler warnings.
57
58 if [[ $ac_cv_c_compiler_gnu = yes ]]
59 then
60 WARNINGS="-Wall -Wno-implicit-int -Wstrict-prototypes -ansi -pedantic"
61 CEXTRAFLAGS="-fsigned-char -funroll-loops \$(HASH)"
62 # For profiling targets:
63 CEXTRAFLAGS2="-fsigned-char -pg -fprofile-arcs -ftest-coverage \$(HASH)"
64 else
65 # Who knows what warnings your compiler uses?
66 WARNINGS=
67 CEXTRAFLAGS="\$(HASH)"
68 fi
69
70 AC_SUBST(WARNINGS)
71 AC_SUBST(CEXTRAFLAGS)
72 AC_SUBST(CEXTRAFLAGS2)
73
74 ##########
75 AC_MSG_NOTICE([header files])
76
77 AC_HEADER_STDC
78 AC_HEADER_SYS_WAIT
79 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/file.h sys/ioctl.h])
80 AC_CHECK_HEADERS([sys/param.h sys/time.h unistd.h])
81 AC_CHECK_HEADERS(errno.h)
82 AC_HEADER_TIME
83
84 ##########
85 AC_MSG_NOTICE([typedefs])
86
87 AC_C_CONST
88 AC_HEADER_STDBOOL
89 AC_C_INLINE
90 AC_TYPE_PID_T
91 AC_TYPE_SIZE_T
92 AC_HEADER_TIME
93 AC_STRUCT_TM
94
95 ##########
96 AC_MSG_NOTICE([compiler characteristics])
97
98 AC_CHECK_SIZEOF(long)
99
100 ##########
101 AC_MSG_NOTICE([library functions])
102
103 AC_FUNC_FORK
104 AC_PROG_GCC_TRADITIONAL
105 AC_FUNC_MALLOC
106 AC_FUNC_SETVBUF_REVERSED
107 AC_TYPE_SIGNAL
108 AC_CHECK_FUNCS([dup2 gethostname gettimeofday memset pow strcasecmp])
109 AC_CHECK_FUNCS([strchr strerror strrchr strstr strtol])
110 AC_CHECK_FUNCS(memcpy bcopy)
111 AC_CHECK_FUNCS(setlinebuf setvbuf)
112
113
114 #
115 # Set various user-definable options.
116 #
117 # Valid OPT settings:
118 # --with-top-part-bitmaps
119 #
120 # Other settings:
121 # --with-first-shogi-program=PROGNAME
122 # --with-second-shogi-program=PROGNAME
123 # --with-first-host=HOSTNAME
124 # --with-second-host=HOSTNAME
125 #
126
127 OPT=
128 FIRST_SHOGI_PROGRAM=gnushogi
129 SECOND_SHOGI_PROGRAM=gnushogi
130 FIRST_HOST=localhost
131 SECOND_HOST=localhost
132
133 AC_ARG_ENABLE(xshogi,
134 AS_HELP_STRING([--enable-xshogi],
135   [compile the xshogi graphical interface to GNU shogi (default: no)]),
136 enable_xshogi=$enableval,
137 enable_xshogi=no)
138
139 AC_ARG_WITH(top-part-bitmaps,
140 AS_HELP_STRING([--with-top-part-bitmaps],
141   [use top part of Kanji bitmaps only in xshogi]),
142 OPT=-DTOP_PART_BITMAPS)
143
144 AC_ARG_WITH(first-shogi-program,
145 AS_HELP_STRING([--with-first-shogi-program=PROGNAME],
146   [use PROGNAME as the first shogi program in xshogi (default: gnushogi)]),
147 FIRST_SHOGI_PROGRAM=$withval)
148
149 AC_ARG_WITH(second-shogi-program,
150 AS_HELP_STRING([--with-second-shogi-program=PROGNAME],
151   [use PROGNAME as the second shogi program in xshogi (default: gnushogi)]),
152 SECOND_SHOGI_PROGRAM=$withval)
153
154 AC_ARG_WITH(first-host,
155 AS_HELP_STRING([--with-first-host=HOSTNAME],
156   [use HOSTNAME as the machine on which the first shogi program runs in xshogi (default: localhost)]),
157 FIRST_HOST=$withval)
158
159 AC_ARG_WITH(second-host,
160 AS_HELP_STRING([--with-second-host=HOSTNAME],
161   [use HOSTNAME as the machine on which the second shogi program runs in xshogi (default: localhost)]),
162 SECOND_HOST=$withval)
163
164 AC_SUBST(OPT)
165 AC_SUBST(FIRST_SHOGI_PROGRAM)
166 AC_SUBST(SECOND_SHOGI_PROGRAM)
167 AC_SUBST(FIRST_HOST)
168 AC_SUBST(SECOND_HOST)
169
170 if [[ $enable_xshogi = yes ]]
171 then
172 XSHOGI=xshogi_compile
173 XSHOGIINSTALL=xshogi_install
174 XSHOGICLEAN=xshogi_clean
175 else
176 XSHOGI=
177 XSHOGIINSTALL=
178 XSHOGICLEAN=
179 fi
180
181 AC_SUBST(XSHOGI)
182 AC_SUBST(XSHOGIINSTALL)
183 AC_SUBST(XSHOGICLEAN)
184
185 ##########
186 AC_CONFIG_FILES([Makefile
187                  gnushogi/Makefile
188                  gnushogi/Makefile.profile
189                  doc/Makefile
190                  xshogi/Makefile])
191 AC_OUTPUT