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