summaryrefslogtreecommitdiff
path: root/autogen.sh
blob: 08a0120942a544012be1aeebc89dba980f6c0838 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
# This was lifted from the Gimp, and adapted slightly by
# Raph Levien.
# Since then, it has been rewritten quite a lot by misc. people.

# Call this file with AUTOCONF_SUFFIX and AUTOMAKE_SUFFIX set
# if you want us to call a specific version of autoconf or automake. 
# E.g. if you want us to call automake-1.6 instead of automake (which
# seems to be quite advisable if your automake is not already version 
# 1.6) then call this file with AUTOMAKE_SUFFIX set to "-1.6".

# Cases which are known to work:
# 2002-07-14: Debian GNU/Linux unstable with:
#   autoconf 2.53
#   automake 1.4-p5 and 1.6 (both)
#   gettext  0.10.40
#   libtool  1.4.2a
# 2002-07-14: Redhat Linux 7.3 with:
#   autoconf 2.53
#   automake 1.5 (not 1.4-p5)
#   gettext  0.11.1
#   libtool  1.4.2

DIE=0
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
test "$srcdir" = "." && srcdir=`pwd`

PROJECT=gphoto2

# failure subroutine.
# syntax: do-something || fail
fail() {
    status=$?
    echo "Last command failed with status $status in directory $(pwd)."
    echo "Aborting."
    exit $status
}

(autoconf${AUTOCONF_SUFFIX} --version) < /dev/null > /dev/null 2>&1 || {
    echo
    echo "You must have autoconf installed to compile $PROJECT."
    echo "Download the appropriate package for your distribution,"
    echo "or get the source tarball at ftp://ftp.gnu.org/gnu/autoconf/"
    DIE=1
}

(libtool --version) < /dev/null > /dev/null 2>&1 || {
    echo
    echo "You must have libtool installed to compile $PROJECT."
    echo "Download the appropriate package for your distribution,"
    echo "or get the source tarball at ftp://ftp.gnu.org/gnu/libtool/"
    DIE=1
}

(automake${AUTOMAKE_SUFFIX} --version) < /dev/null > /dev/null 2>&1 || {
    echo
    echo "You must have automake installed to compile $PROJECT."
    echo "Download the appropriate package for your distribution,"
    echo "or get the source tarball at ftp://ftp.gnu.org/gnu/automake/"
    DIE=1
}

(gettextize --version) < /dev/null > /dev/null 2>&1 || {
    echo
    echo "You must have gettext installed to compile $PROJECT."
    echo "Download the appropriate package for your distribution,"
    echo "or get the source tarball at ftp://ftp.gnu.org/gnu/gettext/"
    DIE=1
}

if test "$DIE" -eq 1; then
    exit 1
fi

test -f libgphoto2/gphoto2.h || {
        echo "You must run this script in the top-level gphoto2 directory"
        exit 1
}

case "$CC" in
*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
esac

ACLOCAL_FLAGS="-I ${srcdir}/libgphoto2_port/m4 ${ACLOCAL_FLAGS}"

gettext_version=`gettextize --version 2>&1 | sed -n 's/^.*GNU gettext.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
case $gettext_version in
0.11.*)
	gettext_opt="$gettext_opt --intl";;
esac

# do not change the sequence without understanding the implications
for dir in libgphoto2_port .
do 
(
    cd "$dir" || fail
    echo "Processing ${dir} aka $(pwd)"

    # We explicitly delete files and directories which are not contained 
    # in the CVS repository and which are generated by the build tools
    # called here.
    # This makes changing build tool versions much easier, and removes
    # the need for any --force parameters to the build tools which may
    # do something we do want or something we do not.

    echo "Cleaning stuff generated by gettextize"
    rm -f po/Makevars.template po/Makevars po/Makefile.in.in ABOUT-NLS
    for file in codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 \
		lcmessage.m4 progtest.m4
    do
	rm -f "m4/$file"
    done
    rm -rf intl/

    echo "Running gettextize --copy $gettext_opt"
    gettextize --copy $gettext_opt || fail
    if test -f po/Makevars.template
    then
	cp po/Makevars.template po/Makevars
    fi

    echo "Cleaning stuff generated by libtoolize"
    rm -f ltmain.sh config.guess config.sub

    echo "Running libtoolize --copy"
    libtoolize --copy || fail

    echo "Cleaning stuff generated by aclocal"
    rm -f aclocal.m4

    echo "Running aclocal${AUTOMAKE_SUFFIX} $ACLOCAL_FLAGS"
    aclocal${AUTOMAKE_SUFFIX} $ACLOCAL_FLAGS || echo fail

    echo "Cleaning stuff generated by autoheader"
    rm -f config.h.in libgphoto2/config.h.in

    echo "Running autoheader${AUTOCONF_SUFFIX}"
    autoheader${AUTOCONF_SUFFIX} || fail

    echo "Cleaning stuff generated by automake"
    find . -name '*.am' | 
	while read file
	do # remove all .in files with a corresponding .am file
	    rm -f "$(sed s/\.am$/.in/g)"
	done
    rm -f depcomp install-sh missing mkinstalldirs
    rm -f stamp-h* libgphoto2/stamp-h*

    echo "Running automake${AUTOMAKE_SUFFIX} --add-missing --gnu $am_opt"
    automake${AUTOMAKE_SUFFIX} --add-missing --gnu $am_opt || fail

    echo "Cleaning stuff generated by autoconf"
    rm -f configure
    rm -rf autom4te-*.cache/

    echo "Running autoconf${AUTOCONF_SUFFIX}"
    autoconf${AUTOCONF_SUFFIX} || fail

    echo "Finished in directory $(pwd)"
) || fail
done

echo 
echo "$PROJECT is now ready for configuration."