1AC_INIT(types.h)
2AC_CANONICAL_BUILD
3AC_CANONICAL_HOST
4AC_CANONICAL_TARGET
5AM_CONFIG_HEADER(config.h)
6AM_INIT_AUTOMAKE(rvm,1.11)
7
8AC_ARG_WITH(
9	default-config-file,
10	[  --with-default-config-file=FILE   Default rvm config file (/etc/rvm.conf)],
11	ac_cv_default_config_file=$with_default_config_file,
12	)
13
14AC_ARG_WITH(
15	default-log-dir,
16	[  --with-default-log-dir=DIR        Default rvm log directory (/var/log/rvm)],
17	ac_cv_default_log_dir=$with_default_log_dir,
18	)
19
20AC_ARG_WITH(
21	rsync,
22	[  --with-rsync=FILE                 Default path to the rsync program],
23	local_rsync=$with_rsync,
24	)
25
26AC_ARG_WITH(
27	ssh,
28	[  --with-ssh=FILE                   Default path to the ssh program],
29	local_ssh=$with_ssh,
30	)
31
32AC_ARG_ENABLE(
33	[assume-stl-memory-exception],
34	AC_HELP_STRING(
35		[--enable-assume-stl-memory-exception],
36		[Assume that the STL will throw an exception on memory allocation failure
37		and skip the test (which can take a long time on modern machines and bring
38		things to a crawl while the test attempts to find out)]
39		),
40	[assume_stl_memory_exception=yes],
41	)
42
43ac_cv_with_asserts=yes
44dnl AC_ARG_WITH(
45dnl 	asserts,
46dnl 	[  --with-asserts                    Enable debugging assert code],
47dnl 	ac_cv_with_asserts=$with_asserts,
48dnl 	ac_cv_with_asserts=no
49dnl 	)
50
51ac_cv_with_debug=yes
52dnl AC_ARG_WITH(
53dnl 	debug,
54dnl 	[  --with-debug                      Enable debugging code],
55dnl 	ac_cv_with_debug=$with_debug,
56dnl 	ac_cv_with_debug=no
57dnl 	)
58
59AC_ARG_WITH(
60	osx-workaround,
61	[  --with-osx-workaround             Enable OSX compilation workaround],
62	ac_cv_with_osx_workaround=yes,
63	ac_cv_with_osx_workaround=no
64	)
65
66AC_PROG_CC
67
68AC_CHECK_HEADERS( \
69	stdlib.h \
70	unistd.h \
71	errno.h \
72	string.h \
73	pwd.h \
74	grp.h \
75	ctype.h \
76	fnmatch.h \
77	sys/wait.h \
78	signal.h \
79	sys/select.h \
80	fcntl.h \
81 	,,AC_MSG_ERROR([One or more required header files are missing]))
82
83AC_CHECK_HEADER(sys/time.h,
84	AC_DEFINE(HAVE_SYS_TIME_H,1,[Define if OS has sys/time.h]))
85
86AC_CHECK_HEADER(sys/vfs.h,
87	AC_DEFINE(HAVE_SYS_VFS_H,1,[Define if OS has sys/vfs.h]))
88AC_CHECK_HEADER(sys/statvfs.h,
89	AC_DEFINE(HAVE_SYS_STATVFS_H,1,[Define if OS has sys/statvfs.h]))
90AC_CHECK_HEADER(sys/param.h,
91	AC_DEFINE(HAVE_SYS_PARAM_H,1,[Define if OS has sys/param.h]))
92AC_CHECK_HEADER(sys/mount.h,
93	AC_DEFINE(HAVE_SYS_MOUNT_H,1,[Define if OS has sys/mount.h]))
94AC_CHECK_HEADER(sys/mkdev.h,
95	AC_DEFINE(HAVE_SYS_MKDEV_H,1,[Define if OS has sys/mkdev.h]))
96
97dnl
98dnl The following tests for Large File support reverse-engineered from
99dnl the GNU core utilities: ftp://alpha.gnu.org/gnu/coreutils/
100dnl
101AC_MSG_CHECKING([if filesystem supports Large Files natively])
102if test "${ac_cv_c_native_large_file_support+set}" = set; then
103	AC_MSG_RESULT([(cached)] $ac_cv_c_native_large_file_support)
104else
105	AC_TRY_COMPILE(
106		[
107#include <sys/types.h>
108#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
109		]
110		,
111		[
112  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
113		       && LARGE_OFF_T % 2147483647 == 1)
114		      ? 1 : -1];
115		]
116		,
117		ac_cv_c_native_large_file_support=yes
118		,
119		ac_cv_c_native_large_file_support=no
120	)
121	AC_MSG_RESULT($ac_cv_c_native_large_file_support)
122fi
123
124if test $ac_cv_c_native_large_file_support = no; then
125	AC_MSG_CHECKING([if _FILE_OFFSET_BITS needed for Large Files])
126	AC_TRY_COMPILE(
127		[
128#define _FILE_OFFSET_BITS 64
129#include <sys/types.h>
130#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
131		]
132		,
133		[
134  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
135		       && LARGE_OFF_T % 2147483647 == 1)
136		      ? 1 : -1];
137		]
138		,
139		ac_cv_c_need_file_offset_bits=yes
140		AC_DEFINE(_FILE_OFFSET_BITS,64,[Define if OS needs it for Large Files])
141		AC_MSG_RESULT([yes])
142		,
143		ac_cv_c_need_file_offset_bits=no
144		AC_MSG_RESULT([no])
145	)
146fi
147
148dnl if test $ac_cv_c_native_large_file_support = no; then
149dnl 	AC_MSG_CHECKING([if _LARGE_FILES needed for Large Files])
150dnl 	AC_TRY_COMPILE(
151dnl 		[
152dnl #define _LARGE_FILES 1
153dnl #include <sys/types.h>
154dnl #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
155dnl 		]
156dnl 		,
157dnl 		[
158dnl   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
159dnl 		       && LARGE_OFF_T % 2147483647 == 1)
160dnl 		      ? 1 : -1];
161dnl 		]
162dnl 		,
163dnl 		ac_cv_c_need_large_files=yes
164dnl 		AC_DEFINE(_LARGE_FILES,1,[Define if OS needs it for Large Files])
165dnl 		AC_MSG_RESULT([yes])
166dnl 		,
167dnl 		ac_cv_c_need_large_files=no
168dnl 		AC_MSG_RESULT([no])
169dnl 	)
170dnl fi
171if test $ac_cv_c_native_large_file_support = no; then
172	AC_MSG_CHECKING([if _LARGE_FILES needed for Large Files])
173	if test $ac_cv_c_need_file_offset_bits = yes; then
174		ac_cv_c_need_large_files=no
175		AC_MSG_RESULT([no])
176	else
177		AC_TRY_COMPILE(
178			[
179#define _LARGE_FILES 1
180#include <sys/types.h>
181#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
182			]
183			,
184			[
185  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
186		       && LARGE_OFF_T % 2147483647 == 1)
187		      ? 1 : -1];
188			]
189			,
190			ac_cv_c_need_large_files=yes
191			AC_DEFINE(_LARGE_FILES,1,[Define if OS needs it for Large Files])
192			AC_MSG_RESULT([yes])
193			,
194			ac_cv_c_need_large_files=no
195			AC_MSG_RESULT([no])
196		)
197	fi
198fi
199
200AC_CHECK_FUNCS( \
201	getcwd \
202	,,AC_MSG_ERROR([One or more required functions are missing]))
203
204AC_HEADER_DIRENT
205AC_STRUCT_ST_RDEV
206AC_HEADER_STAT
207AC_HEADER_TIME
208AC_STRUCT_TM
209
210AC_CHECK_SIZEOF(unsigned char)
211AC_CHECK_SIZEOF(unsigned short)
212AC_CHECK_SIZEOF(unsigned int)
213AC_CHECK_SIZEOF(unsigned long)
214AC_CHECK_SIZEOF(unsigned long long)
215AC_CHECK_SIZEOF(size_t)
216
217AC_PROG_CXX
218AC_LANG_CPLUSPLUS
219AC_CHECK_HEADERS( \
220	iostream \
221	string \
222	vector \
223	map \
224	exception \
225	cstdio \
226	cassert \
227	cerrno \
228	cctype \
229 	,,AC_MSG_ERROR([One or more required header files are missing]))
230
231AC_CHECK_HEADER(streambuf,
232	AC_DEFINE(HAVE_STREAMBUF,1,[Define if C++ compiler has streambuf]))
233
234AC_CHECK_HEADER(limits,
235	AC_DEFINE(HAVE_LIMITS,1,[Define if C++ compiler has numeric limits]))
236
237if test "${assume_stl_memory_exception+set}" = set; then
238	ac_cv_cxx_exception_on_failed_alloc=yes
239fi
240AC_MSG_CHECKING([if the stl throws an exception at memory allocation failure])
241if test "${ac_cv_cxx_exception_on_failed_alloc+set}" = set; then
242	AC_MSG_RESULT([(cached)] $ac_cv_cxx_exception_on_failed_alloc)
243else
244	AC_TRY_RUN(
245#include <string>
246#include <exception>
247
248int main(int argc, char **argv)
249{
250	std::string str;
251
252	str = "a";
253	while (true) {
254		try {
255			str += str;
256		}
257		catch(...) {
258			return(0);
259		}
260	}
261	return(0);
262}
263		,
264		AC_MSG_RESULT([yes])
265		ac_cv_cxx_exception_on_failed_alloc=yes
266		,
267		AC_MSG_RESULT([no])
268		ac_cv_cxx_exception_on_failed_alloc=no
269	)
270fi
271if test $ac_cv_cxx_exception_on_failed_alloc = yes; then
272	AC_DEFINE(HAVE_EXCEPTION_ON_ALLOC_FAILURE,1,[Define if stl throws an exception in the event that memory allocation fails])
273else
274	AC_MSG_WARN([
275
276*** NOTICE: This implementation of the STL does not throw an exception for
277memory allocation failure.  (This feature is known to be lacking in at least
278some pre 3.x versions of the gcc compiler suite.)  Memory allocation failure
279should not mean program termination, but without this feature in the STL, the
280author of this software package cannot guarentee the ability to handle memory
281allocation failure gracefully.
282
283	])
284fi
285
286AC_PATH_PROG(local_rsync,rsync)
287AC_DEFINE_UNQUOTED(
288	LOCAL_RSYNC,
289	"$local_rsync",
290	[The default location of the local rsync program]
291	)
292LOCAL_RSYNC=$local_rsync
293AC_SUBST(LOCAL_RSYNC)
294
295AC_PATH_PROG(local_ssh,ssh)
296AC_DEFINE_UNQUOTED(
297	LOCAL_SSH,
298	"$local_ssh",
299	[The default location of the local ssh program]
300	)
301LOCAL_SSH=$local_ssh
302AC_SUBST(LOCAL_SSH)
303
304if test "$assume_stl_memory_exception" = "yes"; then
305AC_DEFINE_UNQUOTED(
306	ASSUME_STL_MEMORY_EXCEPTION,
307	"$assume_stl_memory_exception",
308	[Assume that the STL throws an exception on memory allocation failure, and skip the associated tests.  (These tests can be very time consuming and can bring a machine to its knees.)  Note that not all implementations of the C++ STL may throw an exception (Solaris-8!)]
309	)
310fi
311
312AC_CACHE_CHECK(
313	[default config file],
314	ac_cv_default_config_file,
315	ac_cv_default_config_file=/etc/rvm.conf
316	)
317AC_DEFINE_UNQUOTED(
318	CONFIGFILE,
319	"$ac_cv_default_config_file",
320	[Default rvm config file]
321	)
322CONFIGFILE=$ac_cv_default_config_file
323AC_SUBST(CONFIGFILE)
324
325AC_CACHE_CHECK(
326	[default log dir],
327	ac_cv_default_log_dir,
328	ac_cv_default_log_dir=/var/log/rvm
329	)
330AC_DEFINE_UNQUOTED(
331	LOGDIR,
332	"$ac_cv_default_log_dir",
333	[Default rvm log directory]
334	)
335LOGDIR=$ac_cv_default_log_dir
336AC_SUBST(LOGDIR)
337
338if test $ac_cv_with_asserts = yes; then
339	AC_DEFINE(WITH_ASSERTS,1,[Define to compile with debugging assert support (--with-asserts)])
340fi
341
342if test $ac_cv_with_debug = yes; then
343	AC_DEFINE(DEBUG,1,[Define to compile with debugging support (--with-debug)])
344fi
345
346if test $ac_cv_with_osx_workaround = yes; then
347	AC_DEFINE(OSX_WORKAROUND,1,[Define for OSX compilation workarounds (--with-osx-workaround)])
348fi
349
350dnl if test $ac_cv_with_osx_workaround=yes
351dnl 	AC_DEFINE(OSX_WORKAROUND,1,[Define to compile properly for some flavors of OSX (--with-osx-workaround)])
352dnl fi
353
354AC_OUTPUT(Makefile rvm.1)
355
356