#!/bin/sh
#**************************************************************************
#*                                                                        *
#*                                 OCaml                                  *
#*                                                                        *
#*                David Allsopp, MetaStack Solutions Ltd.                 *
#*                                                                        *
#*   Copyright 2019 MetaStack Solutions Ltd.                              *
#*                                                                        *
#*   All rights reserved.  This file is distributed under the terms of    *
#*   the GNU Lesser General Public License version 2.1, with the          *
#*   special exception on linking described in the file LICENSE.          *
#*                                                                        *
#**************************************************************************

set -e

# Remove the autom4te.cache directory to make sure we start in a clean state
rm -rf autom4te.cache

aclocal -I m4
${1-autoconf}

# - Workaround sr #110554 (https://savannah.gnu.org/support/index.php?110554)
# - sed -i without a backup file is not portable, hence configure.tmp
sed -e '/split(line, arg/s|" "|/[ \\r\\t]/|' \
    -e '/define|undef/s/|\\\$/|\\r?\\$/' \
    configure >> configure.tmp

mv -f configure.tmp configure
chmod +x configure
