Fix configure.in automodifications
[platform/upstream/libexif.git] / autogen.sh
1 #!/bin/sh
2 # Run this to generate all the initial makefiles, etc.
3 # This was lifted from the Gimp, and adapted slightly by
4 # Raph Levien.
5 # Since then, it has been rewritten quite a lot by misc. people.
6
7 # Call this file with AUTOCONF_SUFFIX and AUTOMAKE_SUFFIX set
8 # if you want us to call a specific version of autoconf or automake. 
9 # E.g. if you want us to call automake-1.6 instead of automake (which
10 # seems to be quite advisable if your automake is not already version 
11 # 1.6) then call this file with AUTOMAKE_SUFFIX set to "-1.6".
12
13 # Cases which are known to work:
14 # 2002-07-14: Debian GNU/Linux unstable with:
15 #   autoconf 2.53
16 #   automake 1.4-p5 and 1.6 (both)
17 #   gettext  0.10.40
18 #   libtool  1.4.2a
19 # 2002-07-14: Redhat Linux 7.3 with:
20 #   autoconf 2.53
21 #   automake 1.5 (not 1.4-p5)
22 #   gettext  0.11.1
23 #   libtool  1.4.2
24
25 DIE=0
26 srcdir=`dirname $0`
27 test -z "$srcdir" && srcdir=.
28 test "$srcdir" = "." && srcdir=`pwd`
29
30 PROJECT=libexif
31
32 # failure subroutine.
33 # syntax: do-something || fail
34 fail() {
35     status=$?
36     echo "Last command failed with status $status in directory $(pwd)."
37     echo "Aborting."
38     exit $status
39 }
40
41 (autoconf${AUTOCONF_SUFFIX} --version) < /dev/null > /dev/null 2>&1 || {
42     echo
43     echo "You must have autoconf installed to compile $PROJECT."
44     echo "Download the appropriate package for your distribution,"
45     echo "or get the source tarball at ftp://ftp.gnu.org/gnu/autoconf/"
46     DIE=1
47 }
48
49 (libtool --version) < /dev/null > /dev/null 2>&1 || {
50     echo
51     echo "You must have libtool installed to compile $PROJECT."
52     echo "Download the appropriate package for your distribution,"
53     echo "or get the source tarball at ftp://ftp.gnu.org/gnu/libtool/"
54     DIE=1
55 }
56
57 (automake${AUTOMAKE_SUFFIX} --version) < /dev/null > /dev/null 2>&1 || {
58     echo
59     echo "You must have automake installed to compile $PROJECT."
60     echo "Download the appropriate package for your distribution,"
61     echo "or get the source tarball at ftp://ftp.gnu.org/gnu/automake/"
62     DIE=1
63 }
64
65 (gettextize --version) < /dev/null > /dev/null 2>&1 || {
66     echo
67     echo "You must have gettext installed to compile $PROJECT."
68     echo "Download the appropriate package for your distribution,"
69     echo "or get the source tarball at ftp://ftp.gnu.org/gnu/gettext/"
70     DIE=1
71 }
72
73 if test "$DIE" -eq 1; then
74     exit 1
75 fi
76
77 test -f libexif/exif.c || {
78         echo "You must run this script in the top-level $PROJECT directory"
79         exit 1
80 }
81
82 case "$CC" in
83 *xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
84 esac
85
86 gettext_version=`gettextize --version 2>&1 | sed -n 's/^.*GNU gettext.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
87 case $gettext_version in
88 0.11.*)
89         gettext_opt="$gettext_opt --intl";;
90 esac
91
92 # do not change the sequence without understanding the implications
93 for dir in .
94 do 
95 (
96     cd "$dir" || fail
97     echo "Processing ${dir} aka $(pwd)"
98
99     # We explicitly delete files and directories which are not contained 
100     # in the CVS repository and which are generated by the build tools
101     # called here.
102     # This makes changing build tool versions much easier, and removes
103     # the need for any --force parameters to the build tools which may
104     # do something we do want or something we do not.
105
106     echo "Cleaning stuff generated by gettextize"
107     rm -f po/Makevars.template po/Makevars po/Makefile.in.in ABOUT-NLS
108     for file in codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 \
109                 lcmessage.m4 progtest.m4
110     do
111         rm -f "m4/$file"
112     done
113     rm -rf intl/
114
115     echo "Running gettextize --copy $gettext_opt"
116     gettextize --copy $gettext_opt || fail
117     if test -f po/Makevars.template
118     then
119         cp po/Makevars.template po/Makevars
120     fi
121
122     case $gettext_version in
123     0.10.*)
124         grep "intl/Makefile" configure.in > /dev/null ||
125         ( sed -e 's#^AC_OUTPUT(\[#AC_OUTPUT(\[ intl/Makefile po/Makefile.in#' \
126         configure.in >configure.in.new && mv configure.in.new configure.in )
127     esac
128
129     echo "Cleaning stuff generated by libtoolize"
130     rm -f ltmain.sh config.guess config.sub
131
132     echo "Running libtoolize --copy"
133     libtoolize --copy || fail
134
135     echo "Cleaning stuff generated by aclocal"
136     rm -f aclocal.m4
137
138     echo "Running aclocal${AUTOMAKE_SUFFIX} $ACLOCAL_FLAGS"
139     aclocal${AUTOMAKE_SUFFIX} $ACLOCAL_FLAGS || fail
140
141     echo "Cleaning stuff generated by autoheader"
142     rm -f config.h.in libgphoto2/config.h.in
143
144     echo "Running autoheader${AUTOCONF_SUFFIX}"
145     autoheader${AUTOCONF_SUFFIX} || fail
146
147     echo "Cleaning stuff generated by automake"
148     find . -name '*.am' | 
149         while read file
150         do # remove all .in files with a corresponding .am file
151             rm -f "$(sed s/\.am$/.in/g)"
152         done
153     rm -f depcomp install-sh missing mkinstalldirs
154     rm -f stamp-h* libgphoto2/stamp-h*
155
156     echo "Running automake${AUTOMAKE_SUFFIX} --add-missing --gnu $am_opt"
157     automake${AUTOMAKE_SUFFIX} --add-missing --gnu $am_opt || fail
158
159     echo "Cleaning stuff generated by autoconf"
160     rm -f configure
161     rm -rf autom4te-*.cache/
162
163     echo "Running autoconf${AUTOCONF_SUFFIX}"
164     autoconf${AUTOCONF_SUFFIX} || fail
165
166     echo "Finished in directory $(pwd)"
167 ) || fail
168 done
169
170 echo
171 echo "$PROJECT is now ready for configuration."