f1ecb8ae5a642ab7811f424258a6d571d5f34225
[debian/amanda] / config / amanda / version.m4
1 # Amanda version handling macros
2
3 # SYNOPSIS
4 #
5 #   AMANDA_SNAPSHOT_STAMP
6 #
7 # DESCRIPTION
8 #
9 #   If srcdir contains a file named SNAPSHOT, with a line matching
10 #       Snapshot Date: [0-9]*
11 #   then set add the date to VERSION and set 
12 #   SNAPSHOT_STAMP=SNAPSHOT.
13 #
14 AC_DEFUN([AMANDA_SNAPSHOT_STAMP],
15 [
16     if test -f "$srcdir/SNAPSHOT"; then
17       cat < "$srcdir/SNAPSHOT"
18     changequote(,)
19       snapdate=`sed -n '/^Snapshot Date: \([0-9]*\)/ s//\1/p' < $srcdir/SNAPSHOT`
20     changequote([,])
21       test -z "$snapdate" || VERSION="$VERSION-$snapdate"
22       SNAPSHOT_STAMP=SNAPSHOT
23     else
24       SNAPSHOT_STAMP=
25     fi
26     AC_SUBST(SNAPSHOT_STAMP)
27 ])
28
29 # SYNOPSIS
30 #
31 #   AMANDA_SPLIT_VERSION
32 #
33 # DESCRIPTION
34 #
35 #   Set the version number of this release of Amanda from the VERSION
36 #   string, which is set in AM_INIT_AUTOMAKE.  Sets VERSION_MAJOR,
37 #   VERSION_MINOR, VERSION_PATCH, and VERSION_COMMENT to the 
38 #   corresponding components of VERSION, and VERSION_SUFFIX to a
39 #   version-specific filename suffix.
40 #
41 AC_DEFUN([AMANDA_SPLIT_VERSION],
42 [
43     changequote(,)
44     VERSION_MAJOR=`expr "$VERSION" : '\([0-9]*\)'`
45     VERSION_MINOR=`expr "$VERSION" : '[0-9]*\.\([0-9]*\)'`
46     VERSION_PATCH=`expr "$VERSION" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
47     VERSION_COMMENT=\"`expr "$VERSION" : '[0-9]*\.[0-9]*\.[0-9]*\(.*\)'`\"
48     changequote([,])
49
50     VERSION_SUFFIX="$VERSION"
51     AC_SUBST(VERSION_MAJOR)
52     AC_SUBST(VERSION_MINOR)
53     AC_SUBST(VERSION_PATCH)
54     AC_SUBST(VERSION_COMMENT)
55     AC_SUBST(VERSION_SUFFIX)
56 ])
57
58 # SYNOPSIS
59 #
60 #   AMANDA_WITH_SUFFIXES
61 #
62 # DESCRIPTION
63 #
64 #   Implement the --with-suffixes option.  If it is given, then set
65 #   program_transform_name appropriately and AC_DEFINE USE_VERSION_SUFFIXES to 1.
66 #   USE_VERSION_SUFFIXES is substituted with the value 'no' or 'yes'.
67 #
68 AC_DEFUN([AMANDA_WITH_SUFFIXES],
69 [
70     AC_ARG_WITH(suffixes,
71         [  --with-suffixes        install binaries with version string appended to name],
72         USE_VERSION_SUFFIXES=$withval,
73         : ${USE_VERSION_SUFFIXES=no}
74     )
75
76     case "$USE_VERSION_SUFFIXES" in
77     y | ye | yes) USE_VERSION_SUFFIXES=yes
78         AC_DEFINE(USE_VERSION_SUFFIXES, 1,
79             [Define to have programs use version suffixes when calling other programs.])
80
81         program_suffix="-$VERSION_SUFFIX"
82         # This is from the output of configure.in.
83         if test "x$program_transform_name" = xs,x,x,; then
84             program_transform_name=
85         else
86             # Double any \ or $.  echo might interpret backslashes.
87             cat <<\EOF_SED > conftestsed
88 s,\\,\\\\,g; s,\$,$$,g
89 EOF_SED
90             program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
91             rm -f conftestsed
92         fi
93         test "x$program_prefix" != xNONE &&
94             program_transform_name="s,^,${program_prefix},; $program_transform_name"
95         # Use a double $ so make ignores it.
96         test "x$program_suffix" != xNONE &&
97             program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
98
99         # sed with no file args requires a program.
100         test "x$program_transform_name" = "" && program_transform_name="xs,x,x,"
101         # Remove empty command
102         cat <<\EOF_SED > conftestsed
103 s,\;\;,\;,g; s,\; \$,,g; s,\;$,,g
104 EOF_SED
105         program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
106         rm -f conftestsed
107       ;;
108     n | no) USE_VERSION_SUFFIXES=no
109       ;;
110     *) AC_MSG_ERROR([*** You must not supply an argument to --with-suffixes option.])
111       ;;
112     esac
113
114     AC_SUBST(USE_VERSION_SUFFIXES)
115 ])