OSDN Git Service

Workaround for Zsh bug? on Cygwin.
[lha/lha.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT([LHa for UNIX], 1.14i-ac20081023, arai@users.sourceforge.jp, lha)
3 AC_DEFINE_UNQUOTED(LHA_CONFIGURE_OPTIONS, "$ac_configure_args",
4             [specified options for the configure script.])
5 AC_CANONICAL_HOST
6 AC_CANONICAL_TARGET
7 AM_INIT_AUTOMAKE
8 AM_CONFIG_HEADER(config.h)
9
10 AC_DEFINE_UNQUOTED(PLATFORM, "$ac_cv_host",
11                    [the type of system on which the package will run.])
12
13 # Checks for programs.
14 AC_PROG_CC
15 AC_PROG_GCC_TRADITIONAL
16 AC_PROG_INSTALL
17 AC_PROG_MAKE_SET
18 AC_MINIX
19 AM_C_PROTOTYPES
20 AC_SYS_LARGEFILE
21 dnl Workaround for Zsh bug? on Cygwin:
22 dnl
23 dnl  Environment to trouble
24 dnl    Cygwin version 1.1.5.25
25 dnl    Zsh version 4.3.4
26 dnl
27 dnl  Examples:
28 dnl
29 dnl  o One machine(no problem)
30 dnl    $ uname -srvmpio
31 dnl    -> CYGWIN_NT-5.1 1.5.25(0.156/4/2) 2007-12-09 09:47 i686 unknown unknown Cygwin
32 dnl    $ zsh -c 'echo | diff - /dev/null' >/dev/null
33 dnl    -> $? set to 1
34 dnl  o Another machine(problem)
35 dnl    $ uname -srvmpio
36 dnl    -> CYGWIN_NT-5.1 1.5.25(0.156/4/2) 2008-05-26 20:37 i686 unknown unknown Cygwin
37 dnl    zsh -c 'echo | diff - /dev/null' >/dev/null
38 dnl    -> diff: -: Illegal seek
39 dnl    -> $? set to 2
40 dnl
41 dnl  I don't know why this problem happend.
42 dnl
43 # AC_CHECK_PROGS(sh_for_lha_test, [zsh bash ksh pdksh], [sh])
44 AC_CACHE_VAL([lha_cv_prog_sh_for_lha_test],[
45 AC_CHECK_PROG(sh_for_lha_test, [zsh], [zsh])
46
47 if test -n "$sh_for_lha_test"; then
48   $sh_for_lha_test -c 'echo | diff - /dev/null' >/dev/null 2>&1
49   if test $? -eq 2; then
50     sh_for_lha_test=''   # cannot use Zsh
51     $as_unset ac_cv_prog_sh_for_lha_test
52   fi
53 fi
54
55 if test -z "$sh_for_lha_test"; then
56   AC_CHECK_PROGS(sh_for_lha_test, [bash ksh pdksh], [sh])
57 fi
58 ])
59
60 # Checks for libraries.
61 AC_SEARCH_LIBS(opendir, [mingwex])
62 AC_CHECK_LIB(applefile, af_open)
63
64 # Checks for header files.
65 AC_HEADER_DIRENT
66 AC_HEADER_STDC
67 AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/param.h sys/time.h)
68 AC_CHECK_HEADERS(pwd.h grp.h utime.h inttypes.h stdint.h fnmatch.h)
69
70 # Checks for typedefs, structures, and compiler characteristics.
71 AC_C_CONST
72 AC_HEADER_TIME
73 AC_STRUCT_TM
74 AC_STRUCT_TIMEZONE
75
76 AC_CHECK_SIZEOF(long)
77 AC_CHECK_SIZEOF(off_t)
78 AC_CHECK_TYPES([uid_t, gid_t, long long, uint64_t, ssize_t])
79 AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct stat.st_ino],,,
80 [
81 #if HAVE_SYS_TYPES_H
82 # include <sys/types.h>
83 #endif
84 #if HAVE_SYS_STAT_H
85 # include <sys/stat.h>
86 #endif
87 #if TIME_WITH_SYS_TIME
88 # include <sys/time.h>
89 # include <time.h>
90 #else
91 # if HAVE_SYS_TIME_H
92 #  include <sys/time.h>
93 # else
94 #  include <time.h>
95 # endif
96 #endif
97 ])
98
99 # Checks for library functions.
100 AC_TYPE_SIGNAL
101 AC_FUNC_UTIME_NULL
102 AC_FUNC_FNMATCH
103 AC_FUNC_FSEEKO
104 AC_CHECK_FUNCS(strchr strdup memcpy memset memmove strcasecmp)
105 AC_CHECK_FUNCS(mktime timelocal tzset ftime gettimeofday utime)
106 AC_CHECK_FUNCS(ftruncate chsize lchown mkstemp ftello)
107 AC_CHECK_FUNCS(getpwuid getgrgid getpwnam getgrnam)
108 AC_CHECK_FUNCS(iconv basename)
109 AC_REPLACE_FUNCS(vsnprintf fnmatch)
110
111 if test $ac_header_dirent = no; then
112   AC_LIBOBJ(lhdir)
113 fi
114
115 AC_CHECK_DECLS([basename])
116
117 # checking whether 8 bit clean or not
118 AC_CACHE_CHECK([whether strchr()/strrchr() is 8bit clean],
119   [lha_cv_func_strchr_8bit_clean],
120   AC_TRY_RUN([
121 #if STDC_HEADERS
122 # include <string.h>
123 #else
124 # if !HAVE_STRCHR
125 #  define strchr index
126 #  define strrchr rindex
127 # endif
128 char *strchr (), *strrchr ();
129 #endif
130
131 main()
132 {
133   char *s = "\377";
134   if (strchr(s, 0xff) != s) exit(1);
135   if (strchr(s, '\377') != s) exit(1);
136   if (strrchr(s, 0xff) != s) exit(1);
137   if (strrchr(s, '\377') != s) exit(1);
138   exit(0); /* ok */
139 }
140 ], lha_cv_func_strchr_8bit_clean=yes,
141    lha_cv_func_strchr_8bit_clean=no,
142    lha_cv_func_strchr_8bit_clean=no))
143
144 if test x$lha_cv_func_strchr_8bit_clean = xyes; then
145   AC_DEFINE(STRCHR_8BIT_CLEAN, 1,
146             [Define to 1 if strchr()/strrchr() works correctly.])
147 fi
148
149 # checking whether the 2nd argument of gettimeofday() is effective or not.
150 # note that this timezone argument is obsolete.
151 AC_CACHE_CHECK([whether the 2nd argument of gettimeofday() is effective],
152   [lha_cv_func_gettimeofday_2nd_arg],
153   AC_TRY_RUN([
154 #if TIME_WITH_SYS_TIME
155 # include <sys/time.h>
156 # include <time.h>
157 #else
158 # if HAVE_SYS_TIME_H
159 #  include <sys/time.h>
160 # else
161 #  include <time.h>
162 # endif
163 #endif
164
165 main()
166 {
167     struct timeval tv;
168     struct timezone tz;
169
170     tz.tz_minuteswest = -1;
171     if (gettimeofday(&tv, &tz) == -1)
172         exit(1);
173
174     if (tz.tz_minuteswest == -1)
175         exit(1);        /* the timezone information is no given */
176
177     exit(0);
178 }], lha_cv_func_gettimeofday_2nd_arg=yes,
179    lha_cv_func_gettimeofday_2nd_arg=no,
180    lha_cv_func_gettimeofday_2nd_arg=no))
181
182 if test x$lha_cv_func_gettimeofday_2nd_arg = xyes; then
183   AC_DEFINE(GETTIMEOFDAY_HAS_2ND_ARG, 1,
184             [Define to 1 if the 2nd argument of gettimeofday() is effective.])
185 fi
186
187 # support kanji code conversion
188 AC_SUBST(DEF_KCODE)
189 AC_MSG_CHECKING(kanji code conversion on text file)
190 AC_ARG_ENABLE(text-conv,
191   AC_HELP_STRING([--enable-text-conv],
192                  [support text code convert from/to EUC [[default=yes]]]),
193   , enable_text_conv=yes)
194
195 AC_MSG_RESULT($enable_text_conv)
196 if test $enable_text_conv = yes; then
197   DEF_KCODE=-DEUC
198 fi
199
200 # force support -lh7-
201 AC_SUBST(SUPPORT_LZHUFF_METHOD)
202 SUPPORT_LZHUFF_METHOD=-DSUPPORT_LH7
203
204 # whether use the -lh567- method
205 AC_MSG_CHECKING(default archive method)
206 AC_ARG_WITH(default-method,
207   [AC_HELP_STRING([[[[--with-default-method=[567]]]]],
208                  [create the -lh[567]- archive default [default=5]])],
209   [case $withval in
210    [[567]]) ;;
211    *) AC_MSG_ERROR([you should have specified 5, 6 or 7]);;
212    esac],
213   with_default_method=5)
214 AC_MSG_RESULT(-lh$with_default_method-)
215 AC_DEFINE_UNQUOTED(DEFAULT_LZHUFF_METHOD, LZHUFF${with_default_method}_METHOD_NUM, [Define it to 5, 6 or 7 which you want to use -lhX- method, default])
216
217 # decide temporary path names
218 AC_MSG_CHECKING(template of the temporary file)
219 AC_ARG_WITH(tmp-file,
220   AC_HELP_STRING([--with-tmp-file=TEMPLATE],
221                  [temporary file template [[default=/tmp/lhXXXXXX]]]),
222   [case $withval in
223    yes)  with_tmp_file=/tmp/lhXXXXXX ;;
224    no)   ;;
225    esac],
226   with_tmp_file=/tmp/lhXXXXXX)
227
228 AC_MSG_RESULT($with_tmp_file)
229 if test x"$with_tmp_file" != xno; then
230   AC_DEFINE_UNQUOTED(TMP_FILENAME_TEMPLATE, "$with_tmp_file",
231     [temporary file template for mktemp/mkstemp])
232 fi
233
234 # incremental indicator
235 AC_MSG_CHECKING(whether incremental indicator is needed)
236 AC_ARG_ENABLE(indicator,
237   AC_HELP_STRING([--enable-indicator],
238                  [need incremental indicator [[default=yes]]]),
239   ,
240   # default
241   enable_indicator=yes)
242
243 AC_MSG_RESULT($enable_indicator)
244 if test "x$enable_indicator" = xyes; then
245   AC_DEFINE(NEED_INCREMENTAL_INDICATOR, 1,
246             [Define to 1 if you want to use the incremental indicator])
247 fi
248
249 # support multibyte filename
250 AC_MSG_CHECKING(kanji code of filename)
251 AC_ARG_ENABLE(multibyte-filename,
252   AC_HELP_STRING([--enable-multibyte-filename],
253                  [support multibyte filename. specify kanji code (euc, sjis, utf8 or auto) [[default=auto]]]),,
254   # default
255   enable_multibyte_filename=auto)
256
257 case $enable_multibyte_filename in
258 auto|yes)
259   AC_EGREP_CPP(SJIS,[
260 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__hpux)
261 SJIS
262 #endif], enable_multibyte_filename=CODE_SJIS,
263   AC_EGREP_CPP(UTF8,[
264 #if defined(__APPLE__)  /* for Mac OS X */
265 UTF8
266 #endif], enable_multibyte_filename=CODE_UTF8,
267          enable_multibyte_filename=CODE_EUC));;
268 sjis)    enable_multibyte_filename=CODE_SJIS;;
269 euc)     enable_multibyte_filename=CODE_EUC;;
270 utf8)    enable_multibyte_filename=CODE_UTF8;;
271 no)      ;;
272 *)       AC_MSG_ERROR([you should specify auto, sjis or euc as your system filename code.]);;
273 esac
274
275 AC_MSG_RESULT($enable_multibyte_filename)
276 if test x$enable_multibyte_filename != xno; then
277   AC_DEFINE_UNQUOTED(MULTIBYTE_FILENAME, $enable_multibyte_filename,
278       [Define to CODE_EUC or CODE_SJIS if you want to use multibyte filename])
279
280   case $target_os in
281   darwin*)
282         # for multibyte filename
283         LDFLAGS="$LDFLAGS -framework CoreFoundation"
284         ;;
285   esac
286 fi
287
288 # make user/group name extented header
289 AC_MSG_CHECKING(whether user/group name extended header is needed)
290 AC_ARG_ENABLE(user-name-header,
291   AC_HELP_STRING([--enable-user-name-header],
292                  [make user/group name extended header [[default=no]]]),
293   ,
294   # default
295   enable_user_name_header=no)
296
297 AC_MSG_RESULT($enable_user_name_header)
298 if test "x$enable_user_name_header" = xyes; then
299   AC_DEFINE(INCLUDE_OWNER_NAME_IN_HEADER, 1,
300             [Define to 1 if you want to use the user/group name extened header])
301 fi
302
303 # backup old archive file
304 AC_MSG_CHECKING(whether backup file for old archive is left)
305 AC_ARG_ENABLE(backup-archive,
306   AC_HELP_STRING([--enable-backup-archive],
307                  [backup old archive [[default=no]]]),
308   ,
309   # default
310   enable_backup_archive=no)
311
312 AC_MSG_RESULT($enable_backup_archive)
313 if test "x$enable_backup_archive" = xyes; then
314   AC_DEFINE(BACKUP_OLD_ARCHIVE, 1,
315             [Define to 1 if you want to leave an old archive])
316 fi
317
318 # additional suffixes of archive filename.
319 AC_MSG_CHECKING(additional suffixes of archive filename)
320 AC_ARG_WITH(additional-suffixes,
321   [AC_HELP_STRING([[[--with-additional-suffixes=foo,bar]]],
322                  [additional suffixes of archive filename, default is empty string])],
323   ,
324   with_additional_suffixes="")
325
326 AC_MSG_RESULT($with_additional_suffixes)
327 AC_DEFINE_UNQUOTED(ADDITIONAL_SUFFIXES, "$with_additional_suffixes",
328             [Define to comma separated suffixes list if you wish to regard it as implicit archive suffixes.])
329
330 case $host_os in
331 *msdosdjgpp*)
332 CFLAGS="$CFLAGS -DNOT_COMPATIBLE_MODE"
333 ;;
334 esac
335
336 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile olddoc/Makefile])
337 AC_CONFIG_FILES([tests/Makefile tests/lha-test])
338 AC_OUTPUT