Imported Upstream version 4.0.43
[platform/upstream/mtools.git] / configure.in
1 dnl Copyright 1996-2003,2005,2006,2008,2009,2022 Alain Knaff.
2 dnl This file is part of mtools.
3 dnl
4 dnl Mtools is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl
9 dnl Mtools is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 dnl Process this file with autoconf to produce a configure script.
18 AC_INIT
19 AC_CONFIG_SRCDIR([buffer.c])
20 AC_CONFIG_HEADERS([config.h])
21
22 dnl Checks for compiler
23 AC_PROG_CC
24 AC_PROG_INSTALL
25 AC_PROG_LN_S
26
27 AC_PATH_PROG(INSTALL_INFO, install-info, "")
28
29 dnl Check for Systems
30 AC_CANONICAL_TARGET
31
32 AC_C_CONST
33 AC_C_INLINE
34
35 dnl Check for configuration options
36 dnl Enable OS/2 extended density format disks
37 AC_ARG_ENABLE(xdf,
38 [  --enable-xdf           support for OS/2 extended density format disks],
39 [if test x$enableval = xyes; then
40   AC_DEFINE([USE_XDF],1,[Define this if you want to use Xdf])
41   XDF_IO_SRC=xdf_io.c
42   XDF_IO_OBJ=xdf_io.o
43 fi],[AC_DEFINE([USE_XDF],1,[Define this if you want to use Xdf])
44 XDF_IO_SRC=xdf_io.c
45 XDF_IO_OBJ=xdf_io.o
46 ]
47 )
48 AC_SUBST(XDF_IO_SRC)
49 AC_SUBST(XDF_IO_OBJ)
50
51 dnl Check for configuration options
52 dnl Enable usage of vold on Solaris
53 AC_ARG_ENABLE(vold,
54 [  --enable-vold          compatibility with Solaris' vold],
55 [if test x$enableval = xyes; then
56   AC_DEFINE([USING_VOLD],1,[Define this if you use mtools together with Solaris' vold])
57 fi])
58
59
60 dnl Check for configuration options
61 dnl Enable usage of vold on Solaris
62 AC_ARG_ENABLE(new-vold,
63 [  --enable-new-vold          compatibility with Solaris' vold, new version],
64 [newVold=x$enableval
65 if test x$enableval = xyes; then
66   AC_DEFINE([USING_NEW_VOLD],1,[Define this if you use mtools together with the new Solaris' vold support])
67 fi])
68
69
70 dnl Check for configuration options
71 dnl Debugging
72 AC_ARG_ENABLE(debug,
73 [  --enable-debug         debugging messages],
74 [if test x$enableval = xyes; then
75   AC_DEFINE([DEBUG],1,[Define for debugging messages])
76 fi])
77
78
79 dnl Check for configuration options
80 dnl Raw terminal code (enabled by default)
81 AC_ARG_ENABLE(raw_term,
82 [  --enable-raw-term      raw terminal (readkey behaviour, default)],
83 [if test x$enableval = xyes; then
84   AC_DEFINE([USE_RAWTERM],1,[Define on non Unix OS'es which don't have the concept of tty's])
85 fi],
86 AC_DEFINE([USE_RAWTERM],1,[Define on non Unix OS'es which don't have the concept of tty's]))
87
88
89 dnl Checks for libraries.
90
91 dnl AC_FUNC_GETMNTENT
92 AC_CHECK_LIB([sun],[getpwnam])
93
94 case $host_os in
95  solaris*)
96     AC_CHECK_FUNCS(media_oldaliases)
97     ;;
98  freebsd*)
99     AC_CHECK_LIB(cam, cam_open_device)
100     ;;
101 esac
102
103 AC_CHECK_LIB(iconv, iconv)
104
105
106 dnl Checks for header files.
107 AC_HEADER_SYS_WAIT
108 AC_HEADER_STDBOOL
109 AC_CHECK_HEADERS(getopt.h stdarg.h inttypes.h \
110 libc.h fcntl.h limits.h sys/file.h sys/ioctl.h time.h sys/time.h \
111 sys/param.h memory.h malloc.h io.h signal.h sys/signal.h utime.h sgtty.h \
112 sys/floppy.h mntent.h sys/sysmacros.h assert.h \
113 iconv.h wctype.h wchar.h locale.h xlocale.h dirent.h)
114 AC_CHECK_HEADERS(termio.h sys/termio.h, [break])
115 AC_CHECK_HEADERS(termios.h sys/termios.h, [break])
116
117 dnl Check for platform-specific header files
118 AC_CHECK_HEADERS(sys/fdio.h)
119
120 dnl Check for types
121 AC_SYS_LARGEFILE
122 AC_TYPE_INT8_T
123 AC_TYPE_INT16_T
124 AC_TYPE_INT32_T
125 AC_TYPE_UINT8_T
126 AC_TYPE_UINT16_T
127 AC_TYPE_UINT32_T
128 AC_TYPE_SSIZE_T
129 AC_TYPE_SIZE_T
130 AC_TYPE_OFF_T
131
132 AC_TYPE_UID_T
133 AC_TYPE_PID_T
134
135 AC_CHECK_TYPES(caddr_t)
136 AC_CHECK_TYPES(long long)
137 AC_CHECK_SIZEOF(size_t)
138 AC_CHECK_SIZEOF(off_t)
139 AC_CHECK_SIZEOF(time_t)
140 AC_CHECK_SIZEOF(long)
141 AC_CHECK_SIZEOF(int)
142
143 seek_function=
144
145 if test $ac_cv_sizeof_off_t -ge 8 ; then
146    seek_function=lseek
147 fi
148
149 dnl Fallback if we have no suitable 64 bit seek function yet
150 if test X$seek_function = X ; then
151   AC_DEFINE([_LARGEFILE64_SOURCE],1,[Needed for off64_t / lseek64 ])
152   AC_CHECK_TYPES(off64_t,
153     [ AC_CHECK_FUNCS(lseek64, [ seek_function=lseek64 ])
154     ])
155   AC_CHECK_FUNCS(stat64)
156   if test X$seek_function = Xlseek64 ; then
157     AC_MSG_CHECKING(whether lseek64 declared in unistd.h)
158     AC_CACHE_VAL(mtools_cv_have_lseek64_prototype,
159       AC_COMPILE_IFELSE(
160          [AC_LANG_PROGRAM([[
161               #define _LARGEFILE64_SOURCE
162               #include <sys/types.h>
163               #include <unistd.h>
164             ]], [[extern int lseek64(int);]])],
165         [mtools_cv_have_lseek64_prototype=no],
166         [mtools_cv_have_lseek64_prototype=yes]))
167     AC_MSG_RESULT($mtools_cv_have_lseek64_prototype)
168     if test "$mtools_cv_have_lseek64_prototype" = yes; then
169       AC_DEFINE([HAVE_LSEEK64_PROTOTYPE],1,[Define when you have an LSEEK64 prototype])
170     fi
171   fi
172 fi
173
174 dnl Fallback if we have no suitable 64 bit seek function yet
175 if test X$seek_function = X ; then
176   AC_DEFINE([_LARGEFILE_SOURCE],1,[Might be needed for loff_t / llseek64 ])
177   AC_CHECK_TYPES([loff_t, offset_t, long long],
178     [ AC_CHECK_FUNCS(llseek, [ seek_function=llseek ])
179     ])
180
181   if test X$seek_function = Xllseek ; then
182     dnl
183     dnl Check to see if llseek() is declared in unistd.h.  On some libc's
184     dnl it is, and on others it isn't..... Thank you glibc developers....
185     dnl
186     dnl Warning!  Use of --enable-gcc-wall may throw off this test.
187     dnl
188     dnl
189     AC_MSG_CHECKING(whether llseek declared in unistd.h)
190     AC_CACHE_VAL(mtools_cv_have_llseek_prototype,
191       AC_COMPILE_IFELSE(
192          [AC_LANG_PROGRAM([[
193               #define _LARGEFILE_SOURCE
194               #define _LARGEFILE64_SOURCE
195               #include <sys/types.h>
196               #include <unistd.h>
197            ]], [[extern int llseek(int);]])],
198         [mtools_cv_have_llseek_prototype=no],
199         [mtools_cv_have_llseek_prototype=yes]))
200     AC_MSG_RESULT($mtools_cv_have_llseek_prototype)
201     if test "$mtools_cv_have_llseek_prototype" = yes; then
202       AC_DEFINE([HAVE_LLSEEK_PROTOTYPE],1,[Define when you have an LLSEEK prototype])
203     fi
204   fi
205 fi
206
207 AC_CHECK_FUNCS(htons)
208
209 dnl Apparently termio before termios is preferred by A/UX, AIX and SCO
210
211 dnl Checks for typedefs, structures, and compiler characteristics.
212 AC_C_CONST
213 AC_C_INLINE
214 AC_TYPE_SIZE_T
215
216 AC_STRUCT_TM
217
218
219 dnl Checks for library functions.
220
221 AC_CHECK_FUNCS(strerror random srandom strchr strrchr lockf flock \
222 strcasecmp strncasecmp strnlen atexit on_exit getpass memmove \
223 strdup strndup strcspn strspn strtoul strtol strtoll strtoui \
224 memcpy strpbrk memset setenv seteuid setresuid \
225 tcsetattr tcflush basename  \
226 readdir snprintf setlocale strstr toupper_l strncasecmp_l \
227 wcsdup wcscasecmp wcsnlen putwc \
228 alarm sigaction usleep lstat unsetenv mkdir)
229
230
231 AC_CHECK_FUNCS(utimes utime, [break])
232 AC_CHECK_FUNCS(tzset gettimeofday)
233
234 AC_CHECK_DECLS([sys_errlist, optarg])
235
236 [
237 host_os0=`echo $host_os | sed 's/-/_/g'`
238 host_os1=`echo $host_os0 | sed 's/\./_/g'`
239 host_os2=`echo $host_os0 | sed 's/^\([^.]*\)\..*$/\1/g'`
240 host_os3=`echo $host_os2 | sed 's/^\([^0-9]*\)[0-9]*$/\1/g'`
241 host_cpu1=`echo $host_cpu | sed 's/\./_/g'`
242 host_vendor1=`echo $host_vendor | sed 's/\./_/g'`
243 HOST_ID="-DCPU_$host_cpu1 -DVENDOR_$host_vendor1 -DOS_$host_os1"
244 if [ $host_os1 != $host_os2 ] ; then
245         HOST_ID="$HOST_ID -DOS_$host_os2"
246 fi
247 if [ $host_os1 != $host_os3 ] && [ $host_os2 != $host_os3 ] ; then
248         HOST_ID="$HOST_ID -DOS_$host_os3"
249 fi
250
251 my_host_os=`echo $host_os1 $host_os2 $host_os3 | sort -u`
252 objs=`echo $srcdir/*.c | sed 's/\.c$/.o/' `
253 if [ "X$GCC" = "Xyes" ] ; then
254     if [ "$host_os3" = aux ] ; then
255             CFLAGS="$CFLAGS -ZP"
256             MACHDEPLIBS="-lposix -UTIL"
257     fi
258     case "${host}" in
259        arm*-*-linux) CFLAGS="$CFLAGS -mstructure-size-boundary=8";;
260     esac
261 else
262     if [ $host_os3 = hpux ] ; then
263             CPPFLAGS="$CPPFLAGS -Ae"
264     fi
265
266     if [ $host_os3 = xenix ] ; then
267             CFLAGS="$CFLAGS -M2e"
268     fi
269 fi
270
271 if [ $host_os3 = hpux ] ; then
272             LDFLAGS="$LDFLAGS -z"
273 fi
274
275 if [ $host_os3 = xenix ] ; then
276     LDFLAGS="$LDFLAGS -M2e -i -f 5000"
277 fi
278
279 if [ $host_os2 = sysv4 ] ; then
280     SHLIB="-lc -L/usr/ucblib -lucb"
281 else
282     SHLIB=""
283 fi
284
285 if [ $host_os3 = isc ] ; then
286     CFLAGS="$CFLAGS -D_SYSV3"
287     SHLIB="-lc_s"
288 fi
289
290 if [ $host_os3 = solaris -a x$newVold = xxyes ] ; then
291     SHLIB="$SHLIB -s -lvolmgt"
292 fi
293
294 if [ $host_os3 = nextstep ] ; then
295     CFLAGS="$CFLAGS -DBSD"
296     SHLIB=""
297 fi
298
299 if [ -d /usr/5lib ] ; then
300         extralibdir=-L/usr/5lib
301 fi
302
303 ]
304
305 AC_PATH_X
306
307 dnl Floppyd
308 AC_ARG_ENABLE(floppyd,
309 [  --enable-floppyd       floppy daemon support],
310 [if test x$enableval != x; then
311   use_floppyd=$enableval
312 fi])
313
314 if test X$use_floppyd = X -a X$no_x = X ; then
315     use_floppyd="yes"
316 fi
317
318 if test X$use_floppyd = Xyes; then
319     if test X$no_x = Xyes ; then
320         echo "Floppyd needs X support" >&2
321         echo "To compile without floppyd, use ./configure --disable-floppyd" >&2
322         exit 1
323     fi
324     FLOPPYD="floppyd floppyd_installtest"
325     BINFLOPPYD="\$(DESTDIR)\$(bindir)/floppyd \$(DESTDIR)\$(bindir)/floppyd_installtest"
326     FLOPPYD_IO_SRC=floppyd_io.c
327     FLOPPYD_IO_OBJ=floppyd_io.o
328     AC_DEFINE([USE_FLOPPYD],1,[Define when you want to include floppyd support])
329     AC_CHECK_FUNCS(setpgrp getuserid getgroupid)
330     AC_FUNC_SETPGRP
331
332     FLOPPYD_LIBS=""
333     AC_CHECK_LIB(X11, XOpenDisplay, [ FLOPPYD_LIBS="-lX11 $FLOPPYD_LIBS" ])
334     AC_CHECK_LIB(Xau, XauFileName, [ FLOPPYD_LIBS="-lXau $FLOPPYD_LIBS" ])
335     AC_PATH_XTRA
336     AC_CHECK_HEADERS(sys/socket.h arpa/inet.h netdb.h netinet/in.h \
337                      netinet/tcp.h X11/Xauth.h X11/Xlib.h)
338 else
339     FLOPPYD=
340     BINFLOPPYD=
341     FLOPPYD_IO_SRC=
342     FLOPPYD_IO_OBJ=
343     FLOPPYD_LIBS=
344 fi
345
346
347
348 AC_SUBST(FLOPPYD_LIBS)
349 AC_SUBST(FLOPPYD)
350 AC_SUBST(BINFLOPPYD)
351 AC_SUBST(FLOPPYD_IO_SRC)
352 AC_SUBST(FLOPPYD_IO_OBJ)
353
354 AC_SUBST(extraincludedir)
355 AC_SUBST(extralibdir)
356 AC_SUBST(MACHDEPLIBS)
357 AC_SUBST(SHLIB)
358 AC_SUBST(host_cpu)
359 AC_SUBST(HOST_ID)
360 AC_CONFIG_FILES([Makefile])
361 AC_OUTPUT