Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / ncurses / test / configure.in
1 dnl***************************************************************************
2 dnl Copyright (c) 1998,1999,2000 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,1997,1998,2000
30 dnl
31 dnl $Id: configure.in,v 1.30 2000/08/12 22:43:08 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 dickey@herndon4.his.com (Thomas Dickey)
40 AC_PREREQ(2.12)
41 AC_INIT(ncurses.c)
42 AC_CONFIG_HEADER(ncurses_cfg.h:ncurses_tst.hin)
43
44 AC_PROG_CC
45
46 dnl Things that we don't need (or must override) if we're not building ncurses
47 CC_G_OPT="-g"                           AC_SUBST(CC_G_OPT)
48 CC_SHARED_OPTS=unknown                  AC_SUBST(CC_SHARED_OPTS)
49 CPPFLAGS="$CPPFLAGS"                    AC_SUBST(CPPFLAGS)
50 DFT_DEP_SUFFIX=""                       AC_SUBST(DFT_DEP_SUFFIX)
51 DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'`    AC_SUBST(DFT_OBJ_SUBDIR)
52 DFT_UPR_MODEL="NORMAL"                  AC_SUBST(DFT_UPR_MODEL)
53 ECHO_LINK='@ echo linking $@ ... ;'     AC_SUBST(ECHO_LINK)
54 EXTRA_LIBS=""                           AC_SUBST(EXTRA_LIBS)
55 LD="ld"                                 AC_SUBST(LD)
56 LDFLAGS_SHARED=""                       AC_SUBST(LDFLAGS_SHARED)
57 LD_MODEL=""                             AC_SUBST(LD_MODEL)
58 LD_SHARED_OPTS=""                       AC_SUBST(LD_SHARED_OPTS)
59 LIB_NAME=curses                         AC_SUBST(LIB_NAME)
60 LIB_PREFIX="-l"                         AC_SUBST(LIB_PREFIX)
61 LINK_TESTS=""                           AC_SUBST(LINK_TESTS)
62 LINT=lint                               AC_SUBST(LINT)
63 LINT_OPTS=""                            AC_SUBST(LINT_OPTS)
64 LOCAL_LDFLAGS=""                        AC_SUBST(LOCAL_LDFLAGS)
65 MATH_LIB="-lm"                          AC_SUBST(MATH_LIB)
66 PROG_EXT=""                             AC_SUBST(PROG_EXT)
67 TEST_ARGS=""                            AC_SUBST(TEST_ARGS)
68 TEST_DEPS=""                            AC_SUBST(TEST_DEPS)
69 cf_cv_abi_version=""                    AC_SUBST(cf_cv_abi_version)
70 cf_cv_rel_version=""                    AC_SUBST(cf_cv_rel_version)
71
72 dnl SunOS 4.x
73 AC_ARG_WITH(5lib,
74         [  --with-5lib             use SunOS sysv-libraries],
75         [LIBS="-L/usr/5lib $LIBS"
76          CPPFLAGS="$CPPFLAGS -I/usr/5include"])
77
78 dnl Ncurses, installed in conventional location
79 AC_ARG_WITH(ncurses,
80         [  --with-ncurses          use ncurses-libraries (installed)],
81         [AC_CHECK_FUNC(initscr,,[
82          AC_CHECK_LIB(gpm,Gpm_Open)
83          LIB_NAME=ncurses
84          for p in $HOME /usr/local /usr
85          do
86                 if test -f $p/include/ncurses/curses.h
87                 then
88                         CPPFLAGS="$CPPFLAGS -I$p/include/ncurses"
89                         test $p != /usr && CPPFLAGS="$CPPFLAGS -I$p/include"
90                         test $p != /usr && LIBS="-L$p/lib $LIBS"
91                         break
92                 elif test $p != /usr
93                 then
94                         if test -f $p/include/curses.h
95                         then
96                                 CPPFLAGS="$CPPFLAGS -I$p/include"
97                                 LIBS="-L$p/lib $LIBS"
98                                 break
99                         fi
100                 fi
101          done
102         ],[test -d /usr/ccs/lib && LIBS="-L/usr/ccs/lib $LIBS"])])
103
104 dnl If we've not specified a library, assume we're using sysvr4 libraries
105 dnl installed conventionally (e.g., SunOS 5.x - solaris).
106
107 dnl Autoconf builds up the $LIBS in reverse order
108
109 AC_CHECK_FUNC(initscr,,[
110 AC_CHECK_LIB($LIB_NAME,initscr)])
111 AC_CHECK_LIB(form,form_driver)
112 AC_CHECK_LIB(menu,menu_driver)
113 AC_CHECK_LIB(panel,new_panel)
114
115 AC_TYPE_SIGNAL
116
117 AC_STDC_HEADERS
118 AC_HEADER_TIME
119 AC_CHECK_HEADERS( \
120 form.h \
121 getopt.h \
122 menu.h \
123 nc_alloc.h \
124 panel.h \
125 sys/ioctl.h \
126 sys/select.h \
127 sys/time.h \
128 termios.h \
129 unistd.h \
130 )
131
132 AC_CHECK_FUNCS( \
133 gettimeofday \
134 napms \
135 resizeterm \
136 strdup \
137 use_default_colors \
138 vsscanf \
139 wresize \
140 )
141
142 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
143 dnl It's a character string "SVR4", not documented.
144 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
145 AC_TRY_RUN([
146 #include <curses.h>
147 int main()
148 {
149         char temp[1024];
150         sprintf(temp, "%s\n", curses_version());
151         exit(0);
152 }]
153 ,[cf_cv_func_curses_version=yes]
154 ,[cf_cv_func_curses_version=no]
155 ,[cf_cv_func_curses_version=unknown])
156 rm -f core])
157 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
158
159 dnl ---------------------------------------------------------------------------
160 dnl [CF_SYS_TIME_SELECT]
161 AC_MSG_CHECKING(if sys/time.h conflicts with sys/select.h)
162 AC_CACHE_VAL(cf_cv_sys_time_select,[
163 AC_TRY_COMPILE([
164 #if HAVE_SYS_TIME_H
165 #include <sys/time.h>
166 #endif
167 #if HAVE_SYS_SELECT_H
168 #include <sys/select.h>
169 #endif
170 ],[],[cf_cv_sys_time_select=yes],
171      [cf_cv_sys_time_select=no])
172      ])
173 AC_MSG_RESULT($cf_cv_sys_time_select)
174 test $cf_cv_sys_time_select = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
175 dnl ---------------------------------------------------------------------------
176
177 AC_OUTPUT(Makefile,[
178         cat >>Makefile <<TEST_EOF
179
180 # These rules are generated so we do not rely on suffix rules, which do not
181 # work consistently for different make-programs (the '\$(MODEL)/' confuses
182 # some, and the '\$x' confuses others).
183 TEST_EOF
184 LIST=`make echo_tests`
185 LAST=`make echo_suffix`
186 for n in $LIST
187 do
188         N=`echo $n | sed -e s/${LAST}\$//`
189         cat >>Makefile <<TEST_EOF
190
191 \$(MODEL)/$N.o : $N.c \\
192         test.priv.h \\
193         ncurses_cfg.h
194         @echo compiling $N; \$(CC) -c \$(CFLAGS_DEFAULT) $N.c
195 TEST_EOF
196 done
197 ],[],sort)