OSDN Git Service

*** empty log message ***
[lha/lha.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT([LHa for UNIX], 1.14i-ac20030721, 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 AC_CHECK_DECLS([basename])
73
74 # checking whether 8 bit clean or not
75 AC_CACHE_CHECK([whether strchr()/strrchr() is 8bit clean],
76   [lha_cv_func_strchr_8bit_clean],
77   AC_TRY_RUN([
78 #if STDC_HEADERS
79 # include <string.h>
80 #else
81 # if !HAVE_STRCHR
82 #  define strchr index
83 #  define strrchr rindex
84 # endif
85 char *strchr (), *strrchr ();
86 #endif
87
88 main()
89 {
90   char *s = "\377";
91   if (strchr(s, 0xff) != s) exit(1);
92   if (strchr(s, '\377') != s) exit(1);
93   if (strrchr(s, 0xff) != s) exit(1);
94   if (strrchr(s, '\377') != s) exit(1);
95   exit(0); /* ok */
96 }
97 ], lha_cv_func_strchr_8bit_clean=yes,
98    lha_cv_func_strchr_8bit_clean=no,
99    lha_cv_func_strchr_8bit_clean=no))
100
101 if test x$lha_cv_func_strchr_8bit_clean = xyes; then
102   AC_DEFINE(STRCHR_8BIT_CLEAN, 1,
103             [Define to 1 if strchr()/strrchr() works correctly.])
104 fi
105
106 # checking whether the 2nd argument of gettimeofday() is effective or not.
107 # note that this timezone argument is obsolete.
108 AC_CACHE_CHECK([whether the 2nd argument of gettimeofday() is effective],
109   [lha_cv_func_gettimeofday_2nd_arg],
110   AC_TRY_RUN([
111 #if TIME_WITH_SYS_TIME
112 # include <sys/time.h>
113 # include <time.h>
114 #else
115 # if HAVE_SYS_TIME_H
116 #  include <sys/time.h>
117 # else
118 #  include <time.h>
119 # endif
120 #endif
121
122 main()
123 {
124     struct timeval tv;
125     struct timezone tz;
126
127     tz.tz_minuteswest = -1;
128     if (gettimeofday(&tv, &tz) == -1)
129         exit(1);
130
131     if (tz.tz_minuteswest == -1)
132         exit(1);        /* the timezone information is no given */
133
134     exit(0);
135 }], lha_cv_func_gettimeofday_2nd_arg=yes,
136    lha_cv_func_gettimeofday_2nd_arg=no,
137    lha_cv_func_gettimeofday_2nd_arg=no))
138
139 if test x$lha_cv_func_gettimeofday_2nd_arg = xyes; then
140   AC_DEFINE(GETTIMEOFDAY_HAS_2ND_ARG, 1,
141             [Define to 1 if the 2nd argument of gettimeofday() is effective.])
142 fi
143
144 # support kanji code conversion
145 AC_SUBST(DEF_KCODE)
146 AC_MSG_CHECKING(kanji code conversion on text file)
147 AC_ARG_ENABLE(text-conv,
148   AC_HELP_STRING([--enable-text-conv],
149                  [support text code convert from/to EUC [[default=yes]]]),
150   , enable_text_conv=yes)
151
152 AC_MSG_RESULT($enable_text_conv)
153 if test $enable_text_conv = yes; then
154   DEF_KCODE=-DEUC
155 fi
156
157 # force support -lh7-
158 AC_SUBST(SUPPORT_LZHUFF_METHOD)
159 SUPPORT_LZHUFF_METHOD=-DSUPPORT_LH7
160
161 # whether use the -lh567- method
162 AC_MSG_CHECKING(default archive method)
163 AC_ARG_WITH(default-method,
164   AC_HELP_STRING([--with-default-method=[[567]]],
165                  [create the -lh[[567]]- archive default [[default=5]]]),
166   [case $withval in
167    [567]) ;;
168    *) AC_MSG_ERROR(you should have specified 5, 6 or 7);;
169    esac],
170   with_default_method=5)
171 AC_MSG_RESULT(-lh$with_default_method-)
172 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])
173
174 # decide temporary path names
175 AC_MSG_CHECKING(template of the temporary file)
176 AC_ARG_WITH(tmp-file,
177   AC_HELP_STRING([--with-tmp-file=TEMPLATE],
178                  [temporary file template [[default=/tmp/lhXXXXXX]]]),
179   [case $withval in
180    yes)  with_tmp_file=/tmp/lhXXXXXX ;;
181    no)   ;;
182    esac],
183   with_tmp_file=/tmp/lhXXXXXX)
184
185 AC_MSG_RESULT($with_tmp_file)
186 if test x"$with_tmp_file" != xno; then
187   AC_DEFINE_UNQUOTED(TMP_FILENAME_TEMPLATE, "$with_tmp_file",
188     [temporary file template for mktemp/mkstemp])
189 fi
190
191 # incremental indicator
192 AC_MSG_CHECKING(whether incremental indicator is needed)
193 AC_ARG_ENABLE(indicator,
194   AC_HELP_STRING([--enable-indicator],
195                  [need incremental indicator [[default=yes]]]),
196   ,
197   # default
198   enable_indicator=yes)
199
200 AC_MSG_RESULT($enable_indicator)
201 if test "x$enable_indicator" = xyes; then
202   AC_DEFINE(NEED_INCREMENTAL_INDICATOR, 1,
203             [Define to 1 if you want to use the incremental indicator])
204 fi
205
206 # support multibyte filename
207 AC_MSG_CHECKING(kanji code of filename)
208 AC_ARG_ENABLE(multibyte-filename,
209   AC_HELP_STRING([--enable-multibyte-filename],
210                  [support multibyte filename. specify kanji code (euc, sjis, utf8 or auto) [[default=auto]]]),,
211   # default
212   enable_multibyte_filename=auto)
213
214 case $enable_multibyte_filename in
215 auto|yes)
216   AC_EGREP_CPP(SJIS,[
217 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__hpux)
218 SJIS
219 #endif], enable_multibyte_filename=CODE_SJIS,
220   AC_EGREP_CPP(UTF8,[
221 #if defined(__APPLE__)  /* for Mac OS X */
222 UTF8
223 #endif], enable_multibyte_filename=CODE_UTF8,
224          enable_multibyte_filename=CODE_EUC));;
225 sjis)    enable_multibyte_filename=CODE_SJIS;;
226 euc)     enable_multibyte_filename=CODE_EUC;;
227 utf8)    enable_multibyte_filename=CODE_UTF8;;
228 no)      ;;
229 *)       AC_MSG_ERROR([you should specify auto, sjis or euc as your system filename code.]);;
230 esac
231
232 AC_MSG_RESULT($enable_multibyte_filename)
233 if test x$enable_multibyte_filename != xno; then
234   AC_DEFINE_UNQUOTED(MULTIBYTE_FILENAME, $enable_multibyte_filename,
235       [Define to CODE_EUC or CODE_SJIS if you want to use multibyte filename])
236
237   case $target_os in
238   darwin*)
239         # for multibyte filename
240         LDFLAGS="$LDFLAGS -framework CoreFoundation"
241         ;;
242   esac
243 fi
244
245 # make user/group name extented header
246 AC_MSG_CHECKING(whether user/group name extended header is needed)
247 AC_ARG_ENABLE(user-name-header,
248   AC_HELP_STRING([--enable-user-name-header],
249                  [make user/group name extended header [[default=no]]]),
250   ,
251   # default
252   enable_user_name_header=no)
253
254 AC_MSG_RESULT($enable_user_name_header)
255 if test "x$enable_user_name_header" = xyes; then
256   AC_DEFINE(INCLUDE_OWNER_NAME_IN_HEADER, 1,
257             [Define to 1 if you want to use the user/group name extened header])
258 fi
259
260 # backup old archive file
261 AC_MSG_CHECKING(whether backup file for old archive is left)
262 AC_ARG_ENABLE(backup-archive,
263   AC_HELP_STRING([--enable-backup-archive],
264                  [backup old archive [[default=no]]]),
265   ,
266   # default
267   enable_backup_archive=no)
268
269 AC_MSG_RESULT($enable_backup_archive)
270 if test "x$enable_backup_archive" = xyes; then
271   AC_DEFINE(BACKUP_OLD_ARCHIVE, 1,
272             [Define to 1 if you want to leave an old archive])
273 fi
274
275 # enable this option if you need to ignore '.file' files
276 # (mainly for the Mac OS X) *experimental*
277 AC_MSG_CHECKING(whether enable -X option which ignore dot files)
278 AC_ARG_ENABLE(ignore-dot-files,
279   AC_HELP_STRING([--enable-ignore-dot-files],
280                  [enable -X option [[default=no]]]),
281   ,
282   # default
283   enable_ignore_dot_files=no)
284
285 AC_MSG_RESULT($enable_ignore_dot_files)
286 if test "x$enable_ignore_dot_files" = xyes; then
287   AC_DEFINE(IGNORE_DOT_FILES, 1,
288             [Define to 1 if you want to ignore dot files with -X command line switch])
289 fi
290
291 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile olddoc/Makefile])
292 AC_CONFIG_FILES([tests/Makefile tests/lha-test])
293 AC_OUTPUT