Stop hardcoding filenames inside pat2inc, use commandline parameters.
[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.1-rc1+],[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"
61 CEXTRAFLAGS="-fsigned-char -funroll-loops"
62 else
63 # Who knows what warnings your compiler uses?
64 WARNINGS=
65 CEXTRAFLAGS=
66 fi
67
68 AC_SUBST(WARNINGS)
69 AC_SUBST(CEXTRAFLAGS)
70
71 ##########
72 AC_MSG_NOTICE([header files])
73
74 AC_HEADER_STDC
75 AC_HEADER_SYS_WAIT
76 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/file.h sys/ioctl.h])
77 AC_CHECK_HEADERS([sys/param.h sys/time.h unistd.h])
78 AC_CHECK_HEADERS(errno.h)
79 AC_HEADER_TIME
80
81 ##########
82 AC_MSG_NOTICE([typedefs])
83
84 AC_C_CONST
85 AC_HEADER_STDBOOL
86 AC_C_INLINE
87 AC_TYPE_PID_T
88 AC_TYPE_SIZE_T
89 AC_HEADER_TIME
90 AC_STRUCT_TM
91
92 ##########
93 AC_MSG_NOTICE([compiler characteristics])
94
95 AC_CHECK_SIZEOF(long)
96
97 ##########
98 AC_MSG_NOTICE([library functions])
99
100 AC_FUNC_FORK
101 AC_PROG_GCC_TRADITIONAL
102 AC_FUNC_MALLOC
103 AC_TYPE_SIGNAL
104 AC_CHECK_FUNCS([dup2 gethostname gettimeofday memset pow strcasecmp])
105 AC_CHECK_FUNCS([strchr strerror strrchr strstr strtol])
106 AC_CHECK_FUNCS([memcpy bcopy])
107 AC_CHECK_FUNCS([setvbuf setlinebuf])
108
109
110 #
111 # Set various user-definable options.
112 #
113
114 AC_ARG_ENABLE([minishogi],
115 [  --enable-minishogi
116         Build gnuminishogi instead of gnushogi (default: no)],
117 [AC_DEFINE([MINISHOGI], [], [Define to build gnuminishogi instead of gnushogi])
118 AC_SUBST([PROGNAME], [gnuminishogi])
119 ],
120 [AC_SUBST([PROGNAME], [gnushogi])
121 ])
122
123 OPT=
124 FIRST_SHOGI_PROGRAM=gnushogi
125 SECOND_SHOGI_PROGRAM=gnushogi
126 FIRST_HOST=localhost
127 SECOND_HOST=localhost
128
129 AC_ARG_ENABLE([xshogi],
130 AS_HELP_STRING([--enable-xshogi],
131   [compile the xshogi graphical interface to GNU shogi (default: no)]),
132 [enable_xshogi=$enableval],
133 [enable_xshogi=no])
134
135 AC_ARG_WITH([top-part-bitmaps],
136 AS_HELP_STRING([--with-top-part-bitmaps],
137   [use top part of Kanji bitmaps only in xshogi]),
138 [OPT=-DTOP_PART_BITMAPS])
139
140 AC_ARG_WITH([first-shogi-program],
141 AS_HELP_STRING([--with-first-shogi-program=PROGNAME],
142   [use PROGNAME as the first shogi program in xshogi (default: gnushogi)]),
143 [FIRST_SHOGI_PROGRAM=$withval])
144
145 AC_ARG_WITH([second-shogi-program],
146 AS_HELP_STRING([--with-second-shogi-program=PROGNAME],
147   [use PROGNAME as the second shogi program in xshogi (default: gnushogi)]),
148 [SECOND_SHOGI_PROGRAM=$withval])
149
150 AC_ARG_WITH([first-host],
151 AS_HELP_STRING([--with-first-host=HOSTNAME],
152   [use HOSTNAME as the machine on which the first shogi program runs in xshogi (default: localhost)]),
153 [FIRST_HOST=$withval])
154
155 AC_ARG_WITH([second-host],
156 AS_HELP_STRING([--with-second-host=HOSTNAME],
157   [use HOSTNAME as the machine on which the second shogi program runs in xshogi (default: localhost)]),
158 [SECOND_HOST=$withval])
159
160 AC_SUBST(OPT)
161 AC_SUBST(FIRST_SHOGI_PROGRAM)
162 AC_SUBST(SECOND_SHOGI_PROGRAM)
163 AC_SUBST(FIRST_HOST)
164 AC_SUBST(SECOND_HOST)
165
166 if [[ $enable_xshogi = yes ]]
167 then
168 XSHOGI=xshogi_compile
169 XSHOGIINSTALL=xshogi_install
170 XSHOGICLEAN=xshogi_clean
171 else
172 XSHOGI=
173 XSHOGIINSTALL=
174 XSHOGICLEAN=
175 fi
176
177 AC_SUBST(XSHOGI)
178 AC_SUBST(XSHOGIINSTALL)
179 AC_SUBST(XSHOGICLEAN)
180
181 ##########
182 AC_CONFIG_FILES([Makefile
183                  gnushogi/Makefile
184                  win32/config.h
185                  doc/Makefile
186                  xshogi/Makefile])
187 AC_OUTPUT