OSDN Git Service

* configure.ac: Checking whether strrchr() is 8 bit clean or not.
[lha/lha.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT([LHa for UNIX], 1.14i-ac20020710, 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)
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_TYPES([uid_t, gid_t])
34 AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct stat.st_ino],,,
35 [
36 #if HAVE_SYS_TYPES_H
37 # include <sys/types.h>
38 #endif
39 #if HAVE_SYS_STAT_H
40 # include <sys/stat.h>
41 #endif
42 #if TIME_WITH_SYS_TIME
43 # include <sys/time.h>
44 # include <time.h>
45 #else
46 # if HAVE_SYS_TIME_H
47 #  include <sys/time.h>
48 # else
49 #  include <time.h>
50 # endif
51 #endif
52 ])
53
54 # Checks for library functions.
55 AC_TYPE_SIGNAL
56 AC_FUNC_FORK
57 AC_FUNC_UTIME_NULL
58 AC_CHECK_FUNCS(strchr strdup memcpy memset memmove strcasecmp)
59 AC_CHECK_FUNCS(mktime timelocal tzset ftime gettimeofday utime)
60 AC_CHECK_FUNCS(mkdir rmdir ftruncate lchown mkstemp link)
61 AC_CHECK_FUNCS(getpwuid getgrgid getpwnam getgrnam)
62 AC_REPLACE_FUNCS(vsnprintf)
63
64 if test $ac_header_dirent = no; then
65   AC_LIBOBJ(lhdir)
66 fi
67
68 # checking whether 8 bit clean or not
69 AC_CACHE_CHECK([whether strchr()/strrchr() is 8bit clean],
70   [lha_cv_strchr_8bit_clean],
71   AC_TRY_RUN([
72 #if STDC_HEADERS
73 # include <string.h>
74 #else
75 # if !HAVE_STRCHR
76 #  define strchr index
77 #  define strrchr rindex
78 # endif
79 char *strchr (), *strrchr ();
80 #endif
81
82 main()
83 {
84   char *s = "\377";
85   if (strchr(s, 0xff) != s) return 1;
86   if (strchr(s, '\377') != s) return 1;
87   if (strrchr(s, 0xff) != s) return 1;
88   if (strrchr(s, '\377') != s) return 1;
89   return 0; /* ok */
90 }
91 ], lha_cv_strchr_8bit_clean=yes,
92    lha_cv_strchr_8bit_clean=no,
93    lha_cv_strchr_8bit_clean=no))
94
95 if test x$lha_cv_strchr_8bit_clean = xyes; then
96   AC_DEFINE(STRCHR_8BIT_CLEAN, 1,
97             [Define to 1 if strchr()/strrchr() works correctly.])
98 fi
99
100 # support kanji code conversion
101 AC_SUBST(DEF_KCODE)
102 AC_ARG_ENABLE(text_conv,
103   AC_HELP_STRING([--enable-text-conv],
104                  [support text code convert from/to EUC [[default=yes]]]),
105   , enable_text_conv=yes)
106
107 if test $enable_text_conv = yes; then
108   DEF_KCODE=-DEUC
109 fi
110
111 # force support -lh7-
112 AC_SUBST(SUPPORT_LZHUFF_METHOD)
113 SUPPORT_LZHUFF_METHOD=-DSUPPORT_LH7
114
115 # whether use the -lh567- method
116 AC_MSG_CHECKING(default archive method is )
117 AC_ARG_WITH(default_method,
118   AC_HELP_STRING([--with-default-method=[[567]]],
119                  [create the -lh[[567]]- archive default [[default=5]]]),
120   [case $withval in
121    [567]) ;;
122    *) AC_MSG_ERROR(you should have specified 5, 6 or 7);;
123    esac],
124   with_default_method=5)
125 AC_MSG_RESULT(-lh$with_default_method-)
126 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])
127
128 # decide temporary path names
129 AC_MSG_CHECKING(template of the temporary file is )
130 AC_ARG_WITH(tmp_file,
131   AC_HELP_STRING([--with-tmp-file=TEMPLATE],
132                  [temporary file template [[default=/tmp/lhXXXXXX]]]),
133   [case $withval in
134    yes)  with_tmp_file=/tmp/lhXXXXXX ;;
135    no)   ;;
136    esac],
137   with_tmp_file=/tmp/lhXXXXXX)
138 AC_MSG_RESULT($with_tmp_file)
139 if test x"$with_tmp_file" != xno; then
140   AC_DEFINE_UNQUOTED(TMP_FILENAME_TEMPLATE, "$with_tmp_file",
141     [temporary file template for mktemp/mkstemp])
142 fi
143
144 # incremental indicator
145 AC_ARG_ENABLE(indicator,
146   AC_HELP_STRING([--enable-indicator],
147                  [need incremental indicator [[default=yes]]]),
148   ,
149   # default
150   enable_indicator=yes)
151 if test "x$enable_indicator" = xyes; then
152   AC_DEFINE(NEED_INCREMENTAL_INDICATOR, 1,
153             [Define to 1 if you want to use the incremental indicator])
154 fi
155
156 # support multibyte filename
157 AC_MSG_CHECKING(kanji code for filename is )
158 AC_ARG_ENABLE(multibyte-filename,
159   AC_HELP_STRING([--enable-multibyte-filename],
160                  [support multibyte filename. specify kanji code (euc, sjis, utf8 or auto) [[default=auto]]]),,
161   # default
162   enable_multibyte_filename=auto)
163
164 case $enable_multibyte_filename in
165 auto|yes)
166   AC_EGREP_CPP(SJIS,[
167 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__hpux)
168 SJIS
169 #endif], enable_multibyte_filename=CODE_SJIS,
170   AC_EGREP_CPP(UTF8,[
171 #if defined(__APPLE__)  /* for Mac OS X */
172 UTF8
173 #endif], enable_multibyte_filename=CODE_UTF8,
174          enable_multibyte_filename=CODE_EUC));;
175 sjis)    enable_multibyte_filename=CODE_SJIS;;
176 euc)     enable_multibyte_filename=CODE_EUC;;
177 utf8)    enable_multibyte_filename=CODE_UTF8;;
178 no)      ;;
179 *)       AC_MSG_ERROR([you should specify auto, sjis or euc as your system filename code.]);;
180 esac
181
182 AC_MSG_RESULT($enable_multibyte_filename)
183 if test x$enable_multibyte_filename != xno; then
184   AC_DEFINE_UNQUOTED(MULTIBYTE_FILENAME, $enable_multibyte_filename,
185       [Define to CODE_EUC or CODE_SJIS if you want to use multibyte filename])
186
187   case $target_os in
188   darwin*)
189         # for multibyte filename
190         LDFLAGS="$LDFLAGS -framework CoreFoundation"
191         ;;
192   esac
193 fi
194
195 # make user/group name extented header
196 AC_ARG_ENABLE(user-name-header,
197   AC_HELP_STRING([--enable-user-name-header],
198                  [make user/group name extended header [[default=no]]]),
199   ,
200   # default
201   enable_user_name_header=no)
202 if test "x$user_name_header" = xyes; then
203   AC_DEFINE(INCLUDE_OWNER_NAME_IN_HEADER, 1,
204             [Define to 1 if you want to use the user/group name extened header])
205 fi
206
207 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
208 AC_CONFIG_FILES([tests/Makefile tests/lha-test])
209 AC_OUTPUT