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