summaryrefslogtreecommitdiffstats
path: root/bin/switch_maint_mode
blob: 7f894ffff87caca876a8220c06293f97967ad687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
#
# Copyright by The HDF Group.
# All rights reserved.
#
# This file is part of HDF5.  The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
# Switch AM_MAINTAINER_MODE value in configure.ac
# Usage: See USAGE()

USAGE()
{
cat <<EOF

switch_maint_mode reverses the status of AM_MAINTAINER_MODE in
configure.ac from enable to disable or vice-versa. When enabled,
this feature forces the autotools to run when the input files are
older than the output files. This is the default for development
branches. When disabled, the autotools will NOT be re-run regardless
of their timestamps or any modifications. This is the default for
tarballs and release branches since it avoids having end-users
requiring the autotools.

Command Syntax
==============
switch_maint_mode [-help] [-enable|disable] <path-to-configure.ac>

EOF
}

MODE="notset"
CONFIG_AC_PATH=

# Display help/usage if any options were passed in
while [ $# -gt 0 ]; do
    case "$1" in
    -enable)
        MODE="enable"
        ;;
    -disable)
        MODE="disable"
        ;;
	-help)
	    USAGE
	    exit 0
	    ;;
    *)
	    CONFIG_AC_PATH="$1"
	    ;;
    esac
    shift
done

# Did we get a file path?
if test -z $CONFIG_AC_PATH ; then
    USAGE
    exit 1
fi

# Did we get a mode?
if test -z $MODE ; then
    USAGE
    exit 1
fi

# Run perl over configure.ac
if test "X-$MODE" = "X-enable" ; then
    perl -pi -e 's/^(AM_MAINTAINER_MODE\(\[)([a-z]+)(\]\))/$1enable$3/g' $CONFIG_AC_PATH
fi
if test "X-$MODE" = "X-disable" ; then
    perl -pi -e 's/^(AM_MAINTAINER_MODE\(\[)([a-z]+)(\]\))/$1disable$3/g' $CONFIG_AC_PATH
fi