ncurses 5.3
[ncurses.git] / test / configure.in
1 dnl***************************************************************************
2 dnl Copyright (c) 1998-2000,2002 Free Software Foundation, Inc.              *
3 dnl                                                                          *
4 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
5 dnl copy of this software and associated documentation files (the            *
6 dnl "Software"), to deal in the Software without restriction, including      *
7 dnl without limitation the rights to use, copy, modify, merge, publish,      *
8 dnl distribute, distribute with modifications, sublicense, and/or sell       *
9 dnl copies of the Software, and to permit persons to whom the Software is    *
10 dnl furnished to do so, subject to the following conditions:                 *
11 dnl                                                                          *
12 dnl The above copyright notice and this permission notice shall be included  *
13 dnl in all copies or substantial portions of the Software.                   *
14 dnl                                                                          *
15 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 dnl                                                                          *
23 dnl Except as contained in this notice, the name(s) of the above copyright   *
24 dnl holders shall not be used in advertising or otherwise to promote the     *
25 dnl sale, use or other dealings in this Software without prior written       *
26 dnl authorization.                                                           *
27 dnl***************************************************************************
28 dnl
29 dnl Author: Thomas E. Dickey 1996, etc.
30 dnl
31 dnl $Id: configure.in,v 1.36 2002/09/07 16:55:23 tom Exp $
32 dnl This is a simple configuration-script for the ncurses test programs that
33 dnl allows the test-directory to be separately configured against a reference
34 dnl system (i.e., sysvr4 curses)
35 dnl
36 dnl If you're configuring ncurses, you shouldn't need to use this script.
37 dnl It's only for testing purposes.
38 dnl
39 dnl See http://invisible-island.net/autoconf/ for additional information.
40 dnl ---------------------------------------------------------------------------
41 AC_PREREQ(2.13.20000819)
42 AC_INIT(ncurses.c)
43 AC_CONFIG_HEADER(ncurses_cfg.h:ncurses_tst.hin)
44
45 AC_PROG_CC
46
47 dnl Things that we don't need (or must override) if we're not building ncurses
48 CC_G_OPT="-g"                           AC_SUBST(CC_G_OPT)
49 CC_SHARED_OPTS=unknown                  AC_SUBST(CC_SHARED_OPTS)
50 CPPFLAGS="$CPPFLAGS"                    AC_SUBST(CPPFLAGS)
51 DFT_DEP_SUFFIX=""                       AC_SUBST(DFT_DEP_SUFFIX)
52 DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'`    AC_SUBST(DFT_OBJ_SUBDIR)
53 DFT_UPR_MODEL="NORMAL"                  AC_SUBST(DFT_UPR_MODEL)
54 ECHO_LINK='@ echo linking $@ ... ;'     AC_SUBST(ECHO_LINK)
55 EXTRA_LIBS=""                           AC_SUBST(EXTRA_LIBS)
56 LD="ld"                                 AC_SUBST(LD)
57 LDFLAGS_SHARED=""                       AC_SUBST(LDFLAGS_SHARED)
58 LD_MODEL=""                             AC_SUBST(LD_MODEL)
59 LD_SHARED_OPTS=""                       AC_SUBST(LD_SHARED_OPTS)
60 LIBTOOL=""                              AC_SUBST(LIBTOOL)
61 LIB_NAME=curses                         AC_SUBST(LIB_NAME)
62 LIB_PREFIX="-l"                         AC_SUBST(LIB_PREFIX)
63 LINK_TESTS=""                           AC_SUBST(LINK_TESTS)
64 LINT=lint                               AC_SUBST(LINT)
65 LINT_OPTS=""                            AC_SUBST(LINT_OPTS)
66 LOCAL_LDFLAGS=""                        AC_SUBST(LOCAL_LDFLAGS)
67 MATH_LIB="-lm"                          AC_SUBST(MATH_LIB)
68 PROG_EXT=""                             AC_SUBST(PROG_EXT)
69 TEST_ARGS=""                            AC_SUBST(TEST_ARGS)
70 TEST_DEPS=""                            AC_SUBST(TEST_DEPS)
71 cf_cv_abi_version=""                    AC_SUBST(cf_cv_abi_version)
72 cf_cv_rel_version=""                    AC_SUBST(cf_cv_rel_version)
73
74 dnl SunOS 4.x
75 AC_ARG_WITH(5lib,
76         [  --with-5lib             use SunOS sysv-libraries],
77         [LIBS="-L/usr/5lib $LIBS"
78          CPPFLAGS="$CPPFLAGS -I/usr/5include"])
79
80 dnl ---------------------------------------------------------------------------
81 dnl Check for libutf8
82 AC_DEFUN([CF_LIBUTF8],
83 [
84 AC_CACHE_CHECK(for putwc in libutf8,cf_cv_libutf8,[
85         cf_save_LIBS="$LIBS"
86         LIBS="-lutf8 $LIBS"
87 AC_TRY_LINK([
88 #include <libutf8.h>],[putwc(0,0);],
89         [cf_cv_libutf8=yes],
90         [cf_cv_libutf8=no])
91         LIBS="$cf_save_LIBS"
92 ])
93
94 if test "$cf_cv_libutf8" = yes ; then
95         AC_DEFINE(HAVE_LIBUTF8_H)
96         LIBS="-lutf8 $LIBS"
97 fi
98 ])dnl
99
100 dnl ---------------------------------------------------------------------------
101 dnl NcursesW, installed in conventional location
102 AC_ARG_WITH(ncursesw,
103         [  --with-ncursesw         use wide ncurses-libraries (installed)],
104         [
105          AC_DEFINE(_GNU_SOURCE)
106          AC_DEFINE(_XOPEN_SOURCE_EXTENDED)
107          AC_CHECK_FUNC(initscr,,[
108          AC_CHECK_LIB(gpm,Gpm_Open)
109          LIB_NAME=ncursesw
110          AC_CHECK_FUNC(putwc,,[CF_LIBUTF8])
111          for p in $HOME /usr/local /usr
112          do
113                 if test -f $p/include/ncursesw/curses.h
114                 then
115                         CPPFLAGS="$CPPFLAGS -I$p/include/ncursesw"
116                         test $p != /usr && CPPFLAGS="$CPPFLAGS -I$p/include"
117                         test $p != /usr && LIBS="-L$p/lib $LIBS"
118                         break
119                 elif test $p != /usr
120                 then
121                         if test -f $p/include/curses.h
122                         then
123                                 CPPFLAGS="$CPPFLAGS -I$p/include"
124                                 LIBS="-L$p/lib $LIBS"
125                                 break
126                         fi
127                 fi
128          done
129         ],[test -d /usr/ccs/lib && LIBS="-L/usr/ccs/lib $LIBS"])])
130
131 dnl Ncurses, installed in conventional location
132 AC_ARG_WITH(ncurses,
133         [  --with-ncurses          use ncurses-libraries (installed)],
134         [AC_CHECK_FUNC(initscr,,[
135          AC_CHECK_LIB(gpm,Gpm_Open)
136          LIB_NAME=ncurses
137          for p in $HOME /usr/local /usr
138          do
139                 if test -f $p/include/ncurses/curses.h
140                 then
141                         CPPFLAGS="$CPPFLAGS -I$p/include/ncurses"
142                         test $p != /usr && CPPFLAGS="$CPPFLAGS -I$p/include"
143                         test $p != /usr && LIBS="-L$p/lib $LIBS"
144                         break
145                 elif test $p != /usr
146                 then
147                         if test -f $p/include/curses.h
148                         then
149                                 CPPFLAGS="$CPPFLAGS -I$p/include"
150                                 LIBS="-L$p/lib $LIBS"
151                                 break
152                         fi
153                 fi
154          done
155         ],[test -d /usr/ccs/lib && LIBS="-L/usr/ccs/lib $LIBS"])])
156
157 dnl If we've not specified a library, assume we're using sysvr4 libraries
158 dnl installed conventionally (e.g., SunOS 5.x - solaris).
159
160 dnl Autoconf builds up the $LIBS in reverse order
161
162 AC_CHECK_FUNC(initscr,,[
163 AC_CHECK_LIB($LIB_NAME,initscr)])
164 AC_CHECK_LIB(form,form_driver)
165 AC_CHECK_LIB(menu,menu_driver)
166 AC_CHECK_LIB(panel,new_panel)
167
168 AC_TYPE_SIGNAL
169
170 AC_STDC_HEADERS
171 AC_HEADER_TIME
172 AC_CHECK_HEADERS( \
173 form.h \
174 getopt.h \
175 locale.h \
176 menu.h \
177 nc_alloc.h \
178 nomacros.h \
179 panel.h \
180 sys/ioctl.h \
181 sys/select.h \
182 sys/time.h \
183 termios.h \
184 unistd.h \
185 )
186
187 AC_CHECK_FUNCS( \
188 getnstr \
189 gettimeofday \
190 napms \
191 resize_term \
192 resizeterm \
193 strdup \
194 use_default_colors \
195 vsscanf \
196 wresize \
197 )
198
199 dnl ---------------------------------------------------------------------------
200 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
201 dnl It's a character string "SVR4", not documented.
202 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
203 AC_TRY_RUN([
204 #include <curses.h>
205 int main()
206 {
207         char temp[1024];
208         sprintf(temp, "%s\n", curses_version());
209         exit(0);
210 }]
211 ,[cf_cv_func_curses_version=yes]
212 ,[cf_cv_func_curses_version=no]
213 ,[cf_cv_func_curses_version=unknown])
214 rm -f core])
215 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
216
217 dnl ---------------------------------------------------------------------------
218 dnl Check for likely values of acs_map[]:
219 AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
220 cf_cv_curses_acs_map=unknown
221 for name in acs_map _acs_map __acs_map _nc_acs_map
222 do
223 AC_TRY_LINK([
224 #include <curses.h>
225 ],[
226 $name['k'] = ACS_PLUS
227 ],[cf_cv_curses_acs_map=$name; break])
228 done
229 ])
230
231 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map)
232
233 dnl ---------------------------------------------------------------------------
234 dnl Check for likely values of wacs_map[]:
235 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
236 cf_cv_curses_wacs_map=unknown
237 for name in wacs_map _wacs_map __wacs_map _nc_wacs
238 do
239 AC_TRY_LINK([
240 #ifndef _XOPEN_SOURCE_EXTENDED
241 #define _XOPEN_SOURCE_EXTENDED
242 #endif
243 #include <curses.h>
244 ],[
245 $name['k'] = *WACS_PLUS 
246 ],[cf_cv_curses_wacs_map=$name; break])
247 done
248 ])
249
250 test "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map)
251
252 dnl --------------------------------------------------------------------------- 
253 dnl Make an uppercase version of a variable 
254 dnl $1=uppercase($2) 
255 AC_DEFUN([CF_UPPER], 
256
257 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
258 ])dnl 
259
260 dnl ---------------------------------------------------------------------------
261 dnl Check if curses.h defines the given type
262 AC_DEFUN([CF_CURSES_TYPE],
263 [
264 AC_MSG_CHECKING(for type $1 in curses.h)
265 AC_TRY_COMPILE([
266 #ifndef _XOPEN_SOURCE_EXTENDED
267 #define _XOPEN_SOURCE_EXTENDED
268 #endif
269 #include <curses.h>],[
270 $1 foo
271 ],cf_result=yes,cf_result=no)
272 AC_MSG_RESULT($cf_result)
273 if test $cf_result = yes ; then
274         CF_UPPER(cf_result,have_type_$1)
275         AC_DEFINE_UNQUOTED($cf_result)
276 else
277         AC_DEFINE_UNQUOTED($1,$2)
278 fi
279 ])dnl
280
281 CF_CURSES_TYPE(attr_t,long)
282 CF_CURSES_TYPE(mbstate_t,long)
283
284 dnl ---------------------------------------------------------------------------
285 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
286 dnl older SCO configurations.
287 dnl [CF_SYS_TIME_SELECT]
288
289 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
290 AC_CACHE_VAL(cf_cv_sys_time_select,[
291 AC_TRY_COMPILE([
292 #include <sys/types.h>
293 #ifdef HAVE_SYS_TIME_H
294 #include <sys/time.h>
295 #endif
296 #ifdef HAVE_SYS_SELECT_H
297 #include <sys/select.h>
298 #endif
299 ],[],[cf_cv_sys_time_select=yes],
300      [cf_cv_sys_time_select=no])
301      ])
302 AC_MSG_RESULT($cf_cv_sys_time_select)
303 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
304
305 dnl ---------------------------------------------------------------------------
306
307 AC_OUTPUT(Makefile,[
308         cat >>Makefile <<TEST_EOF
309
310 # These rules are generated so we do not rely on suffix rules, which do not
311 # work consistently for different make-programs (the '\$(MODEL)/' confuses
312 # some, and the '\$x' confuses others).
313 TEST_EOF
314 LIST=`make echo_tests`
315 LAST=`make echo_suffix`
316 for n in $LIST
317 do
318         N=`echo $n | sed -e s/${LAST}\$//`
319         cat >>Makefile <<TEST_EOF
320
321 \$(MODEL)/$N.o : $N.c \\
322         test.priv.h \\
323         ncurses_cfg.h
324         @echo compiling $N; \$(CC) -c \$(CFLAGS_DEFAULT) $N.c
325 TEST_EOF
326 done
327 ],[],sort)