1AC_INIT([rsnapshot],[m4_chomp_all(m4_esyscmd([git describe --tags --always --dirty]))],[rsnapshot-discuss@lists.sourceforge.net])
2AM_INIT_AUTOMAKE([foreign])
3AC_PROG_MAKE_SET
4AC_CONFIG_FILES(Makefile)
5
6dnl
7dnl get the current working directory for the regression test suite
8dnl
9CWD=`eval echo \`pwd\``
10AC_SUBST(CWD, "$CWD/")
11dnl general test-directory
12AC_SUBST(TEST, "$CWD/t/")
13dnl snapshot_root in conf-files
14AC_SUBST(SNAP, "$CWD/t/support/snapshots")
15dnl template-source to backup
16AC_SUBST(TEMP, "$CWD/t/support/files/template")
17
18
19dnl
20dnl PERL CHECK (required program)
21dnl
22dnl if the user specified a path, try that first
23AC_ARG_WITH(perl,
24	[  --with-perl=PATH	  Specify the path to perl ],
25	[
26		if test "x$withval" != "xno"; then
27			if test -x "$withval"; then
28				PERL=$withval
29			else
30				AC_MSG_ERROR(perl not found)
31			fi
32		else
33			AC_MSG_ERROR(perl is required)
34		fi
35	]
36)
37dnl if the user didn't specify a path, hunt for it
38if test "$PERL" = ""; then
39	AC_PATH_PROG(PERL, perl, no)
40fi
41dnl bail out if we can't find it
42if test "$PERL" = "no"; then
43	AC_MSG_ERROR(perl is required)
44fi
45
46
47dnl
48dnl RSYNC CHECK (required program)
49dnl
50dnl if the user specified a path, try that first
51AC_ARG_WITH(rsync,
52	[  --with-rsync=PATH       Specify the path to rsync ],
53	[
54		if test "x$withval" != "xno"; then
55			if test -x "$withval"; then
56				RSYNC=$withval
57				AC_SUBST(CMD_RSYNC, "cmd_rsync	$RSYNC")
58			else
59				AC_MSG_ERROR(rsync not found)
60			fi
61		else
62			AC_MSG_ERROR(rsync is required)
63		fi
64	]
65)
66dnl if the user didn't specify a path, hunt for it
67if test "$RSYNC" = ""; then
68	AC_PATH_PROG(RSYNC, rsync, no)
69	AC_SUBST(RSYNC, "$RSYNC")
70	AC_SUBST(CMD_RSYNC, "cmd_rsync	$RSYNC")
71fi
72dnl bail out if we can't find it
73if test "$RSYNC" = "no"; then
74	AC_MSG_ERROR(rsync is required)
75fi
76
77
78dnl
79dnl CP CHECK (optional program)
80dnl
81dnl if the user specified a path, try that first
82AC_ARG_WITH(cp,
83	[  --with-cp=PATH          Specify the path to cp ],
84	[
85		if test "x$withval" != "xno"; then
86			if test -x "$withval"; then
87				CP=$withval
88			else
89				AC_MSG_ERROR(cp not found)
90			fi
91		else
92			CP=no
93		fi
94	]
95)
96dnl save the program for testing
97AC_SUBST(TEST_CP, "$CP")
98dnl if the user didn't specify a path, hunt for it
99if test "$CP" != "no"; then
100	AC_PATH_PROG(CP, cp, no)
101fi
102dnl if we couldn't find it, provide an example
103if test "$CP" = "no"; then
104	CP=/bin/cp
105fi
106dnl either way, set the cmd_cp var
107AC_SUBST(CMD_CP, "cmd_cp		$CP")
108
109
110dnl
111dnl RM CHECK (optional program)
112dnl
113dnl if the user specified a path, try that first
114AC_ARG_WITH(rm,
115	[  --with-rm=PATH          Specify the path to rm ],
116	[
117		if test "x$withval" != "xno"; then
118			if test -x "$withval"; then
119				RM=$withval
120			else
121				AC_MSG_ERROR(rm not found)
122			fi
123		else
124			RM=no
125		fi
126	]
127)
128dnl if the user didn't specify a path, hunt for it
129if test "$RM" != "no"; then
130	AC_PATH_PROG(RM, rm, no)
131fi
132dnl save the program for testing
133AC_SUBST(TEST_RM, "$RM")
134dnl if we couldn't find it, provide an example
135if test "$RM" = "no"; then
136	RM=/bin/rm
137fi
138dnl either way, set the cmd_rm var
139AC_SUBST(CMD_RM, "cmd_rm		$RM")
140
141
142dnl
143dnl SSH CHECK (optional program)
144dnl
145dnl if the user specified a path, try that first
146AC_ARG_WITH(ssh,
147	[  --with-ssh=PATH         Specify the path to ssh ],
148	[
149		if test "x$withval" != "xno"; then
150			if test -x "$withval"; then
151				SSH=$withval
152			else
153				AC_MSG_ERROR(ssh not found)
154			fi
155		else
156			SSH=no
157		fi
158	]
159)
160dnl if the user didn't specify a path, hunt for it
161if test "$SSH" != "no"; then
162	AC_PATH_PROG(SSH, ssh, no)
163fi
164dnl save the program for testing
165AC_SUBST(TEST_SSH, "$SSH")
166dnl if we couldn't find it, provide an example
167if test "$SSH" = "no"; then
168	SSH=/path/to/ssh
169fi
170dnl either way, set the cmd_ssh var
171AC_SUBST(CMD_SSH, "cmd_ssh	$SSH")
172
173
174dnl
175dnl LVM COMMANDS CHECK (optional programs)
176dnl
177dnl lvcreate
178AC_PATH_PROG(LVCREATE, lvcreate, no)
179if test "$LVCREATE" = "no"; then
180	LVCREATE=/path/to/lvcreate
181fi
182AC_SUBST(CMD_LVCREATE, "$LVCREATE")
183
184dnl lvremove
185AC_PATH_PROG(LVREMOVE, lvremove, no)
186if test "$LVREMOVE" = "no"; then
187	LVREMOVE=/path/to/lvremove
188fi
189AC_SUBST(CMD_LVREMOVE, "$LVREMOVE")
190
191dnl mount
192AC_PATH_PROG(MOUNT, mount, no)
193if test "$MOUNT" = "no"; then
194	MOUNT=/path/to/mount
195fi
196AC_SUBST(CMD_MOUNT, "$MOUNT")
197
198dnl umount
199AC_PATH_PROG(UMOUNT, umount, no)
200if test "$UMOUNT" = "no"; then
201	UMOUNT=/path/to/umount
202fi
203AC_SUBST(CMD_UMOUNT, "$UMOUNT")
204
205
206dnl
207dnl LOGGER CHECK (optional program)
208dnl
209dnl if the user specified a path, try that first
210AC_ARG_WITH(logger,
211	[  --with-logger=PATH      Specify the path to logger ],
212	[
213		if test "x$withval" != "xno"; then
214			if test -x "$withval"; then
215				LOGGER=$withval
216			else
217				AC_MSG_ERROR(logger not found)
218			fi
219		else
220			LOGGER=no
221		fi
222	]
223)
224dnl if the user didn't specify a path, hunt for it
225if test "$LOGGER" != "no"; then
226	AC_PATH_PROG(LOGGER, logger, no)
227fi
228dnl save the program for testing
229AC_SUBST(TEST_LOGGER, "$LOGGER")
230dnl if we couldn't find it, provide an example
231if test "$LOGGER" = "no"; then
232	LOGGER=/path/to/logger
233fi
234dnl either way, set the cmd_logger var
235AC_SUBST(CMD_LOGGER, "cmd_logger	$LOGGER")
236
237
238dnl
239dnl DU CHECK (optional program)
240dnl
241dnl if the user specified a path, try that first
242AC_ARG_WITH(du,
243	[  --with-du=PATH          Specify the path to du ],
244	[
245		if test "x$withval" != "xno"; then
246			if test -x "$withval"; then
247				DU=$withval
248			else
249				AC_MSG_ERROR(du not found)
250			fi
251		else
252			DU=no
253		fi
254	]
255)
256dnl if the user didn't specify a path, hunt for it
257if test "$DU" != "no"; then
258	AC_PATH_PROG(DU, du, no)
259fi
260dnl save the program for testing
261AC_SUBST(TEST_DU, "$DU")
262dnl if we couldn't find it, provide an example
263if test "$DU" = "no"; then
264	DU=/path/to/du
265fi
266dnl either way, set the cmd_du var
267AC_SUBST(CMD_DU, "cmd_du		$DU")
268
269
270dnl
271dnl TEST_SSH_USER CHECK (optional param)
272dnl
273dnl if the user specified a path, try that first
274AC_ARG_WITH(test-ssh-user,
275	[  --with-test-ssh-user=USER       Specify ssh user for tests ],
276	[
277		if test "x$withval" != "xno"; then
278			TEST_SSH_USER="$withval"
279			AC_SUBST(TEST_SSH_USER, "$TEST_SSH_USER")
280		fi
281	]
282)
283dnl if the user didn't specify a test ssh user use current user
284if test "$TEST_SSH_USER" = ""; then
285	AC_SUBST(TEST_SSH_USER, "$USER")
286fi
287
288
289dnl
290dnl TRUE CHECK (required program in tests)
291dnl
292dnl if the user specified a path, try that first
293AC_ARG_WITH(test-true,
294	[  --with-test-true=PATH           Specify the path to true ],
295	[
296		if test "x$withval" != "xno"; then
297			if test -x "$withval"; then
298				TRUE=$withval
299			else
300				AC_MSG_ERROR(true not found)
301			fi
302		else
303			TRUE=no
304		fi
305	]
306)
307dnl if the user didn't specify a path, hunt for it
308if test "$TRUE" != "no"; then
309	AC_PATH_PROG(TRUE, true, no)
310fi
311dnl if we couldn't find it, provide an example
312if test "$TRUE" = "no"; then
313	TRUE=/bin/true
314fi
315
316
317dnl
318dnl FALSE CHECK (required program in tests)
319dnl
320dnl if the user specified a path, try that first
321AC_ARG_WITH(test-false,
322	[  --with-test-false=PATH          Specify the path to false ],
323	[
324		if test "x$withval" != "xno"; then
325			if test -x "$withval"; then
326				FALSE=$withval
327			else
328				AC_MSG_ERROR(false not found)
329			fi
330		else
331			FALSE=no
332		fi
333	]
334)
335dnl if the user didn't specify a path, hunt for it
336if test "$FALSE" != "no"; then
337	AC_PATH_PROG(FALSE, false, no)
338fi
339dnl if we couldn't find it, provide an example
340if test "$FALSE" = "no"; then
341	FALSE=/bin/false
342fi
343
344
345# replace perl paths
346AC_CONFIG_FILES(rsnapshot:rsnapshot-program.pl)
347AC_CONFIG_FILES(rsnapshot-diff:rsnapshot-diff.pl)
348dnl try to find dependent programs for the config file
349AC_CONFIG_FILES(rsnapshot.conf.default:rsnapshot.conf.default.in)
350
351dnl testsuite-files are following
352m4_include(t/include.ac)
353
354
355AC_OUTPUT
356
357echo ""
358echo "Now type  \"make test\"    to run the regression test suite."
359echo "Then type \"make install\" to install the program."
360echo ""
361
362if test ! -e "$RSNAPSHOT_SYSCONFDIR/rsnapshot.conf"; then
363	echo "After rsnapshot is installed, don't forget to copy"
364	echo "$RSNAPSHOT_SYSCONFDIR/rsnapshot.conf.default to $RSNAPSHOT_SYSCONFDIR/rsnapshot.conf"
365	echo ""
366fi
367