OSDN Git Service

* configure.ac: updated version.
[lha/lha.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT([LHa for UNIX], 1.14i-ac20030713, jca02266@nifty.ne.jp, lha)
3 AC_CANONICAL_HOST
4 AC_CANONICAL_TARGET
5 AM_INIT_AUTOMAKE
6 AM_CONFIG_HEADER(config.h)
7
8 AC_DEFINE_UNQUOTED(PLATFORM, "$ac_cv_host",
9                    [the type of system on which the package will run.])
10
11 # Checks for programs.
12 AC_PROG_CC
13 AC_PROG_GCC_TRADITIONAL
14 AC_PROG_INSTALL
15 AC_PROG_MAKE_SET
16 AC_MINIX
17 AM_C_PROTOTYPES
18
19 # Checks for libraries.
20 AC_SEARCH_LIBS(opendir, [mingwex])
21
22 # Checks for header files.
23 AC_HEADER_DIRENT
24 AC_HEADER_STDC
25 AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/param.h sys/time.h)
26 AC_CHECK_HEADERS(pwd.h grp.h utime.h inttypes.h stdint.h fnmatch.h)
27
28 # Checks for typedefs, structures, and compiler characteristics.
29 AC_C_CONST
30 AC_HEADER_TIME
31 AC_STRUCT_TM
32 AC_STRUCT_TIMEZONE
33
34 AC_CHECK_SIZEOF(long)
35 AC_CHECK_TYPES([uid_t, gid_t, long long, uint64_t, ssize_t])
36 AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct stat.st_ino],,,
37 [
38 #if HAVE_SYS_TYPES_H
39 # include <sys/types.h>
40 #endif
41 #if HAVE_SYS_STAT_H
42 # include <sys/stat.h>
43 #endif
44 #if TIME_WITH_SYS_TIME
45 # include <sys/time.h>
46 # include <time.h>
47 #else
48 # if HAVE_SYS_TIME_H
49 #  include <sys/time.h>
50 # else
51 #  include <time.h>
52 # endif
53 #endif
54 ])
55
56 # Checks for library functions.
57 AC_TYPE_SIGNAL
58 AC_FUNC_UTIME_NULL
59 AC_FUNC_FNMATCH
60 AC_FUNC_FSEEKO
61 AC_CHECK_FUNCS(strchr strdup memcpy memset memmove strcasecmp)
62 AC_CHECK_FUNCS(mktime timelocal tzset ftime gettimeofday utime)
63 AC_CHECK_FUNCS(ftruncate chsize lchown mkstemp ftello)
64 AC_CHECK_FUNCS(getpwuid getgrgid getpwnam getgrnam)
65 AC_CHECK_FUNCS(iconv basename)
66 AC_REPLACE_FUNCS(vsnprintf fnmatch)
67
68 if test $ac_header_dirent = no; then
69   AC_LIBOBJ(lhdir)
70 fi
71
72 # checking whether 8 bit clean or not
73 AC_CACHE_CHECK([whether strchr()/strrchr() is 8bit clean],
74   [lha_cv_func_strchr_8bit_clean],
75   AC_TRY_RUN([
76 #if STDC_HEADERS
77 # include <string.h>
78 #else
79 # if !HAVE_STRCHR
80 #  define strchr index
81 #  define strrchr rindex
82 # endif
83 char *strchr (), *strrchr ();
84 #endif
85
86 main()
87 {
88   char *s = "\377";
89   if (strchr(s, 0xff) != s) exit(1);
90   if (strchr(s, '\377') != s) exit(1);
91   if (strrchr(s, 0xff) != s) exit(1);
92   if (strrchr(s, '\377') != s) exit(1);
93   exit(0); /* ok */
94 }
95 ], lha_cv_func_strchr_8bit_clean=yes,
96    lha_cv_func_strchr_8bit_clean=no,
97    lha_cv_func_strchr_8bit_clean=no))
98
99 if test x$lha_cv_func_strchr_8bit_clean = xyes; then
100   AC_DEFINE(STRCHR_8BIT_CLEAN, 1,
101             [Define to 1 if strchr()/strrchr() works correctly.])
102 fi
103
104 # checking whether the 2nd argument of gettimeofday() is effective or not.
105 # note that this timezone argument is obsolete.
106 AC_CACHE_CHECK([whether the 2nd argument of gettimeofday() is effective],
107   [lha_cv_func_gettimeofday_2nd_arg],
108   AC_TRY_RUN([
109 #if TIME_WITH_SYS_TIME
110 # include <sys/time.h>
111 # include <time.h>
112 #else
113 # if HAVE_SYS_TIME_H
114 #  include <sys/time.h>
115 # else
116 #  include <time.h>
117 # endif
118 #endif
119
120 main()
121 {
122     struct timeval tv;
123     struct timezone tz;
124
125     tz.tz_minuteswest = -1;
126     if (gettimeofday(&tv, &tz) == -1)
127         exit(1);
128
129     if (tz.tz_minuteswest == -1)
130         exit(1);        /* the timezone information is no given */
131
132     exit(0);
133 }], lha_cv_func_gettimeofday_2nd_arg=yes,
134    lha_cv_func_gettimeofday_2nd_arg=no,
135    lha_cv_func_gettimeofday_2nd_arg=no))
136
137 if test x$lha_cv_func_gettimeofday_2nd_arg = xyes; then
138   AC_DEFINE(GETTIMEOFDAY_HAS_2ND_ARG, 1,
139             [Define to 1 if the 2nd argument of gettimeofday() is effective.])
140 fi
141
142 # support kanji code conversion
143 AC_SUBST(DEF_KCODE)
144 AC_MSG_CHECKING(kanji code conversion on text file)
145 AC_ARG_ENABLE(text-conv,
146   AC_HELP_STRING([--enable-text-conv],
147                  [support text code convert from/to EUC [[default=yes]]]),
148   , enable_text_conv=yes)
149
150 AC_MSG_RESULT($enable_text_conv)
151 if test $enable_text_conv = yes; then
152   DEF_KCODE=-DEUC
153 fi
154
155 # force support -lh7-
156 AC_SUBST(SUPPORT_LZHUFF_METHOD)
157 SUPPORT_LZHUFF_METHOD=-DSUPPORT_LH7
158
159 # whether use the -lh567- method
160 AC_MSG_CHECKING(default archive method)
161 AC_ARG_WITH(default-method,
162   AC_HELP_STRING([--with-default-method=[[567]]],
163                  [create the -lh[[567]]- archive default [[default=5]]]),
164   [case $withval in
165    [567]) ;;
166    *) AC_MSG_ERROR(you should have specified 5, 6 or 7);;
167    esac],
168   with_default_method=5)
169 AC_MSG_RESULT(-lh$with_default_method-)
170 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])
171
172 # decide temporary path names
173 AC_MSG_CHECKING(template of the temporary file)
174 AC_ARG_WITH(tmp-file,
175   AC_HELP_STRING([--with-tmp-file=TEMPLATE],
176                  [temporary file template [[default=/tmp/lhXXXXXX]]]),
177   [case $withval in
178    yes)  with_tmp_file=/tmp/lhXXXXXX ;;
179    no)   ;;
180    esac],
181   with_tmp_file=/tmp/lhXXXXXX)
182
183 AC_MSG_RESULT($with_tmp_file)
184 if test x"$with_tmp_file" != xno; then
185   AC_DEFINE_UNQUOTED(TMP_FILENAME_TEMPLATE, "$with_tmp_file",
186     [temporary file template for mktemp/mkstemp])
187 fi
188
189 # incremental indicator
190 AC_MSG_CHECKING(whether incremental indicator is needed)
191 AC_ARG_ENABLE(indicator,
192   AC_HELP_STRING([--enable-indicator],
193                  [need incremental indicator [[default=yes]]]),
194   ,
195   # default
196   enable_indicator=yes)
197
198 AC_MSG_RESULT($enable_indicator)
199 if test "x$enable_indicator" = xyes; then
200   AC_DEFINE(NEED_INCREMENTAL_INDICATOR, 1,
201             [Define to 1 if you want to use the incremental indicator])
202 fi
203
204 # support multibyte filename
205 AC_MSG_CHECKING(kanji code of filename)
206 AC_ARG_ENABLE(multibyte-filename,
207   AC_HELP_STRING([--enable-multibyte-filename],
208                  [support multibyte filename. specify kanji code (euc, sjis, utf8 or auto) [[default=auto]]]),,
209   # default
210   enable_multibyte_filename=auto)
211
212 case $enable_multibyte_filename in
213 auto|yes)
214   AC_EGREP_CPP(SJIS,[
215 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__hpux)
216 SJIS
217 #endif], enable_multibyte_filename=CODE_SJIS,
218   AC_EGREP_CPP(UTF8,[
219 #if defined(__APPLE__)  /* for Mac OS X */
220 UTF8
221 #endif], enable_multibyte_filename=CODE_UTF8,
222          enable_multibyte_filename=CODE_EUC));;
223 sjis)    enable_multibyte_filename=CODE_SJIS;;
224 euc)     enable_multibyte_filename=CODE_EUC;;
225 utf8)    enable_multibyte_filename=CODE_UTF8;;
226 no)      ;;
227 *)       AC_MSG_ERROR([you should specify auto, sjis or euc as your system filename code.]);;
228 esac
229
230 AC_MSG_RESULT($enable_multibyte_filename)
231 if test x$enable_multibyte_filename != xno; then
232   AC_DEFINE_UNQUOTED(MULTIBYTE_FILENAME, $enable_multibyte_filename,
233       [Define to CODE_EUC or CODE_SJIS if you want to use multibyte filename])
234
235   case $target_os in
236   darwin*)
237         # for multibyte filename
238         LDFLAGS="$LDFLAGS -framework CoreFoundation"
239         ;;
240   esac
241 fi
242
243 # make user/group name extented header
244 AC_MSG_CHECKING(whether user/group name extended header is needed)
245 AC_ARG_ENABLE(user-name-header,
246   AC_HELP_STRING([--enable-user-name-header],
247                  [make user/group name extended header [[default=no]]]),
248   ,
249   # default
250   enable_user_name_header=no)
251
252 AC_MSG_RESULT($enable_user_name_header)
253 if test "x$enable_user_name_header" = xyes; then
254   AC_DEFINE(INCLUDE_OWNER_NAME_IN_HEADER, 1,
255             [Define to 1 if you want to use the user/group name extened header])
256 fi
257
258 # backup old archive file
259 AC_MSG_CHECKING(whether backup file for old archive is left)
260 AC_ARG_ENABLE(backup-archive,
261   AC_HELP_STRING([--enable-backup-archive],
262                  [backup old archive [[default=no]]]),
263   ,
264   # default
265   enable_backup_archive=no)
266
267 AC_MSG_RESULT($enable_backup_archive)
268 if test "x$enable_backup_archive" = xyes; then
269   AC_DEFINE(BACKUP_OLD_ARCHIVE, 1,
270             [Define to 1 if you want to leave an old archive])
271 fi
272
273 # enable this option if you need to ignore '.file' files
274 # (mainly for the Mac OS X) *experimental*
275 AC_MSG_CHECKING(whether enable -X option which ignore dot files)
276 AC_ARG_ENABLE(ignore-dot-files,
277   AC_HELP_STRING([--enable-ignore-dot-files],
278                  [enable -X option [[default=no]]]),
279   ,
280   # default
281   enable_ignore_dot_files=no)
282
283 AC_MSG_RESULT($enable_ignore_dot_files)
284 if test "x$enable_ignore_dot_files" = xyes; then
285   AC_DEFINE(IGNORE_DOT_FILES, 1,
286             [Define to 1 if you want to ignore dot files with -X command line switch])
287 fi
288
289 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile olddoc/Makefile])
290 AC_CONFIG_FILES([tests/Makefile tests/lha-test])
291 AC_OUTPUT