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