Fix CFLAGS/LDFLAGS syntax
[platform/upstream/lrzsz.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(src/crctab.c)
3 AM_INIT_AUTOMAKE(lrzsz, 0.12.20)
4 AM_CONFIG_HEADER(config.h)
5
6
7 dnl AC_C_CROSS is in AC_PROG_CC since 2.12
8 AC_PREREQ(2.12)
9
10 PACKAGE_VERSION="$PACKAGE-$VERSION"
11 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
12 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
13 AC_DEFINE_UNQUOTED(PACKAGE_VERSION, "$PACKAGE_VERSION")
14 AC_SUBST(PACKAGE)
15 AC_SUBST(VERSION)
16 AC_SUBST(PACKAGE_VERSION)
17
18 ALL_LINGUAS="de"
19
20 AC_SUBST(PACKAGE)
21 AC_SUBST(VERSION)
22
23 changequote(,)dnl
24 case $VERSION in
25         [0-9]*.[0-9]*.[0-9]*) README_ALPHA="README-alpha";;
26         *) README_ALPHA=;;
27 esac
28 changequote([, ])dnl
29
30
31 AC_ARG_ENABLE(timesync,
32         [--disable-timesync   exclude support for timesync protocol],
33         [if test "$enableval" = "no" ; then 
34                 :
35           else
36                 AC_DEFINE(ENABLE_TIMESYNC)
37           fi],
38         [AC_DEFINE(ENABLE_TIMESYNC)])
39 AC_SUBST(ENABLE_TIMESYNC)
40 AC_ARG_ENABLE(pubdir,
41         [--enable-pubdir=/path   include support for a public writeable directory],
42         [if test "$enableval" = "no" ; then 
43                 : 
44           else 
45             AC_DEFINE_UNQUOTED(PUBDIR,"$enableval")
46           fi])
47 AC_ARG_ENABLE(mkdir,
48         [--disable-mkdir   disable support for creating directories (lrz)],
49         [if test "$enableval" = "no" ; then 
50                 :
51           else
52                 AC_DEFINE(ENABLE_MKDIR)
53           fi],
54         [AC_DEFINE(ENABLE_MKDIR)])
55 AC_ARG_ENABLE(syslog,
56         [--enable-syslog=FACILITY,{force,default,optional} include syslogsupport],
57         [
58           if test "$enableval" = "no" ; then 
59                 :
60           else
61             case "$enableval" in
62             *,*)
63                         level=`echo $enableval|sed -e 's/^.*,//'`
64                         fac=`echo $enableval|sed -e 's/,.*$//'`
65                         AC_DEFINE_UNQUOTED(ENABLE_SYSLOG,$fac)
66                         ;;
67                 *)
68                         lookup_facility=LOG_UUCP
69                         level="$enableval"
70                         ;;
71                 esac
72                 if test "$level" = "force" ; then
73                   AC_DEFINE(ENABLE_SYSLOG_FORCE)
74                 else 
75                   if test "$level" = "optional" ; then
76                     :
77                   else
78                     AC_DEFINE(ENABLE_SYSLOG_DEFAULT)
79                   fi
80                 fi
81           fi],[
82                 AC_DEFINE(ENABLE_SYSLOG_DEFAULT)
83                 lookup_facility=LOG_UUCP
84           ])
85
86 dnl Checks for programs.
87 AC_PROG_CC
88 AC_PROG_GCC_TRADITIONAL
89 dnl AC_PROG_INSTALL  included in AM_INIT_AUTOMAKE
90 dnl AC_PROG_MAKE_SET included in AM_INIT_AUTOMAKE
91 AC_PROG_RANLIB
92 AC_ISC_POSIX
93 AC_AIX
94 AC_MINIX
95 AM_C_PROTOTYPES
96 AC_C_CONST
97 AC_C_INLINE
98
99 if test `hostname` = tirka.ohse.de -a "$cross_compiling" = no ; then
100     test $prefix = NONE && prefix=/usr
101         if test -z "$CFLAGS" ; then 
102             case "$CC" in 
103                 *gcc*)
104                         CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes"
105                         # -Wnested_externs entfernt wegen dcgettext()
106                         CFLAGS="$CFLAGS -Wpointer-arith -Wcast-qual -Wcast-align"
107                         CFLAGS="$CFLAGS -Winline -Wwrite-strings -Wshadow -Wmissing-braces"
108                         CFLAGS="$CFLAGS -Wcomments -fforce-mem -fforce-addr -O2 -m486 -pipe"
109                         CFLAGS="$CFLAGS -malign-loops=2 -malign-jumps=2 -malign-functions=2 -g3"
110                         ;;
111                 esac
112         fi
113 fi
114 case "$CFLAGS" in
115 *-Wstrict-prototypes*)
116         AC_DEFINE(STRICT_PROTOTYPES)
117         ;;
118 esac
119
120 dnl Checks for libraries.
121 dnl SCO needs this.
122 AC_CHECK_LIB(socket,syslog,,,)
123 dnl BeOS needs this
124 AC_CHECK_LIB(be,syslog,,,)
125 dnl slowlartis needs this
126 AC_CHECK_LIB(nsl,gethostbyname,,,)
127
128 dnl Checks for header files.
129 AC_HEADER_STDC
130 AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h unistd.h sys/times.h)
131 LRZSZ_HEADERS_TERM_IO
132 AC_CHECK_HEADERS(termios.h sys/termios.h termio.h sys/termio.h sgtty.h)
133 AC_CHECK_HEADERS(sys/mman.h utime.h syslog.h sys/syslog.h sys/param.h)
134 AC_CHECK_HEADERS(sys/select.h strings.h arpa/inet.h)
135
136 dnl Checks for typedefs, structures, and compiler characteristics.
137 AC_TYPE_SIZE_T
138 AC_TYPE_MODE_T
139 AC_TYPE_OFF_T
140 LRZSZ_TYPE_SPEED_T
141 AC_STRUCT_ST_RDEV
142 AC_HEADER_TIME
143 lrzsz_HEADER_SYS_SELECT
144 AC_STRUCT_TM
145 LRZSZ_ERRNO_DECL
146
147 dnl Checks for library functions.
148 if test $cross_compiling = no ; then
149         AC_FUNC_SETVBUF_REVERSED
150 fi
151 AC_TYPE_SIGNAL
152 dnl suggested by autoscan, but not really needed.
153 dnl AC_FUNC_UTIME_NULL
154 AC_FUNC_MMAP
155 AC_FUNC_ALLOCA
156 AC_EGREP_HEADER([struct.*utimbuf], utime.h, AC_DEFINE(HAVE_STRUCT_UTIMBUF))
157
158 AC_CHECK_FUNCS(gettimeofday settimeofday)
159 AC_CHECK_FUNCS(strchr memcpy select vprintf)
160 AC_CHECK_FUNCS(times rdchk utime syslog siginterrupt)
161 AC_REPLACE_FUNCS(mkdir mktime strerror strstr strdup strtoul strtol strpbrk)
162 AC_REPLACE_FUNCS(stpcpy strftime vasprintf)
163
164 AC_REPLACE_GNU_GETOPT
165
166 dnl for lib/error.c
167 AC_DEFINE(HAVE_STRERROR)
168
169
170 dnl special tests
171
172 dnl this is taken from taylor uucp.
173 dnl Check for the SCO buggy ftime; the code can cope with the bug,
174 dnl though it would prefer not to, so if we're cross-configuring we
175 dnl accept that ftime exists.
176 AC_CHECK_FUNC(ftime,
177 [AC_MSG_CHECKING(that ftime works correctly)
178 AC_CACHE_VAL(lrzsz_cv_sys_ftime_ok,
179 [AC_TRY_RUN([
180 #include <sys/types.h>
181 #include <sys/timeb.h>
182 #include <stdio.h>
183 main ()
184 {
185   struct timeb s, slast;
186   int c = 0;
187   ftime (&slast);
188   while (c < 10)
189     {
190       ftime (&s);
191       if (s.time < slast.time
192       || (s.time == slast.time && s.millitm < slast.millitm)) {
193       fprintf(stderr,"s: %ld, %ld, slast: %ld, %ld\n",
194         s.time,s.millitm, slast.time,slast.millitm);
195     exit (1);
196         }
197       if (s.time != slast.time)
198     ++c;
199       slast.time = s.time;
200       slast.millitm = s.millitm;
201     }
202   exit (0);
203 }
204 ],
205 lrzsz_cv_sys_ftime_ok=yes,
206 lrzsz_cv_sys_ftime_ok=no,
207 lrzsz_cv_sys_ftime_ok=runtime)])
208 case $lrzsz_cv_sys_ftime_ok in
209 yes) AC_DEFINE(HAVE_FTIME) AC_MSG_RESULT(yes) ;;
210 no)  AC_MSG_RESULT(no)
211         AC_MSG_WARN(ftime seems to be buggy) ;;
212 runtime) AC_DEFINE(HAVE_FTIME)
213         AC_MSG_RESULT(will check at run time) ;;
214 esac
215 ])
216
217 dnl
218 AC_MSG_CHECKING([for timezone variable])
219 AC_CACHE_VAL(libquark_cv_var_timezone,[
220 AC_TRY_LINK([#include <time.h>],[return(int)(timezone/2);],
221         [libquark_cv_var_timezone=yes],
222         [libquark_cv_var_timezone=no])
223 ])
224 if test $libquark_cv_var_timezone = yes ; then
225         AC_MSG_RESULT(yes)
226         AC_DEFINE(HAVE_TIMEZONE_VAR)
227 else
228         AC_MSG_RESULT(no)
229 fi
230 if test "x$lookup_facility" = x ; then
231         :
232 else
233         AC_MSG_CHECKING([for $lookup_facility])
234         AC_CACHE_VAL(lrzsz_cv_lookup_facility,[
235                 AC_EGREP_CPP(ihave$lookup_facility, [
236 #ifdef HAVE_SYSLOG_H
237 #include <syslog.h>
238 #else
239 #include <sys/syslog.h>
240 #endif
241 #ifdef $lookup_facility
242 ihave$lookup_facility
243 #endif
244                 ], lrzsz_cv_lookup_facility=yes, lrzsz_cv_lookup_facility=no)
245         ])
246         if test $lrzsz_cv_lookup_facility = yes ; then
247                 AC_MSG_RESULT(yes)
248                 AC_DEFINE_UNQUOTED(ENABLE_SYSLOG,$lookup_facility)
249         else
250                 AC_DEFINE(ENABLE_SYSLOG,LOG_USER)
251                 AC_MSG_RESULT(no)
252         fi
253 fi
254
255
256 AC_SUBST(CFLAGS)
257 AC_SUBST(LDFLAGS)
258 AC_SUBST(LIBS)
259
260 AM_GNU_GETTEXT
261
262 AC_DEFINE_UNQUOTED(LOCALEDIR,"$prefix/$DATADIRNAME")
263 AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
264
265 AC_OUTPUT([Makefile intl/Makefile lib/Makefile testsuite/Makefile \
266 man/Makefile po/Makefile.in src/Makefile debian/rules Specfile systype \
267 src/lrzszbug],
268 [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile; 
269 chmod +x debian/rules;
270 test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h])