summaryrefslogtreecommitdiff
path: root/util/mm-common-prepare.in
blob: 3a0a7de0affc343d76d1920fef5704b351e117b7 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#! /bin/sh -e

# Copyright (c) 2009  Openismus GmbH  <http://www.openismus.com/>
#
# @configure_input@
#
# mm-common is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License,
# or (at your option) any later version.
#
# mm-common is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with mm-common.  If not, see <http://www.gnu.org/licenses/>.

prefix="@prefix@"
datarootdir="@datarootdir@"
datadir="@datadir@"
pkgdatadir="${datadir}/@PACKAGE_TARNAME@"

progname=${0##*/}
installcmd='ln -s'
instaction=symlinking
forceflag=
target=.

for arg
do
  case $arg in
  '-?'|--help)
    cat <<EOF
Usage: $progname [OPTION]... [DIRECTORY | CONFIGURE-FILE]

Prepare a C++ binding module to use mm-common and Autotools.

 -c, --copy          copy files rather than symlinking them
 -f, --force         replace existing files
     --help          display this help message
     --version       print version information
EOF
    exit 0
    ;;
  --version)
    echo "$progname @PACKAGE_VERSION@"
    exit 0
    ;;
  -c|--copy)
    installcmd=cp
    instaction=copying
    ;;
  -f|--force)
    forceflag=' -f'
    ;;
  -cf|-fc)
    installcmd=cp
    instaction=copying
    forceflag=' -f'
    ;;
  -*)
    echo "$progname: error: unrecognized option '$arg'" >&2
    exit 1
    ;;
  ?*)
    target=${arg%/}
    ;;
  esac
done

if test -d "$target"; then
  srcdir=$target
  acfile=$target/configure.ac
else
  srcdir=${target%/*}
  acfile=$target
fi

if test ! -f "$acfile"; then
  echo "$progname: error: $acfile not found" >&2
  exit 1
fi

# Extract the directory macro arguments from configure.ac
s='	 ' # tab+space
auxdir=`sed -n "s/^[$s]*AC_CONFIG_AUX_DIR([[$s]*\\([^])\$,$s]*\\).*/\\1/p" "$acfile"`
doctooldir=`sed -n "s/^[$s]*MM_CONFIG_DOCTOOL_DIR([[$s]*\\([^])\$,$s]*\\).*/\\1/p" "$acfile"`

auxdir=$srcdir${auxdir:+/}$auxdir
echo "$progname: putting auxiliary files in '$auxdir'."
test -d "$auxdir" || mkdir "$auxdir"

for file in compile-binding.am dist-changelog.am doc-reference.am generate-binding.am
do
  if test -n "$forceflag" || test ! -f "$auxdir/$file"; then
    echo "$progname: $instaction file '$file'"
    $installcmd$forceflag "$pkgdatadir/build/$file" "$auxdir/$file"
  fi
done

if test -n "$doctooldir"
then
  doctooldir=$srcdir/$doctooldir
  echo "$progname: putting documentation utilities in '$doctooldir'."
  test -d "$doctooldir" || mkdir "$doctooldir"

  for file in doc-install.pl doc-postprocess.pl doxygen.css doxygen-extra.css tagfile-to-devhelp2.xsl
  do
    if test -n "$forceflag" || test ! -f "$doctooldir/$file"; then
      echo "$progname: $instaction file '$file'"
      $installcmd$forceflag "$pkgdatadir/doctool/$file" "$doctooldir/$file"
    fi
  done
fi

exit 0