summaryrefslogtreecommitdiff
path: root/mk/std-autogen.sh
blob: 93ba852ffccb8a56b03047da3ad58cad79324970 (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
#! /bin/sh

# autogen for non-automake trees
#
# - it installs files: config.sub, config.guess, install-sh
# - it installs ltmain.sh, if LT_INIT or *LIBTOOL macro is used
#

set -e

USUAL_DIR="$1"
test -n "${USUAL_DIR}" || USUAL_DIR="."

test -f "${USUAL_DIR}/m4/usual.m4" || {
  echo usage: $0 USUAL_DIR
  exit 1
}

# default programs
ACLOCAL=${ACLOCAL:-aclocal}
AUTOCONF=${AUTOCONF:-autoconf}
AUTOHEADER=${AUTOHEADER:-autoheader}

# detect first glibtoolize then libtoolize
if test "x$LIBTOOLIZE" = "x"; then
  LIBTOOLIZE=glibtoolize
  which $LIBTOOLIZE >/dev/null 2>&1 \
    || LIBTOOLIZE=libtoolize
fi

# 
# Workarounds for libtoolize randomness - it does not update
# the files if they exist, except it requires install-sh.
#
rm -f config.guess config.sub install-sh ltmain.sh libtool
cp -p ${USUAL_DIR}/mk/install-sh .
if ${LIBTOOLIZE} --help | grep "[-][-]install" > /dev/null; then
  ${LIBTOOLIZE} -i -f -q -c
else
  ${LIBTOOLIZE} -c
fi

# drop ltmain.sh if libtool is not used
grep -E 'LT_INIT|LIBTOOL' configure.ac > /dev/null \
  || rm -f ltmain.sh

# Now generate configure & config.h
${ACLOCAL} -I ${USUAL_DIR}/m4

grep AC_CONFIG_HEADER configure.ac > /dev/null \
  && ${AUTOHEADER}

${AUTOCONF}

# clean junk
rm -rf autom4te.* aclocal*