]> git.sesse.net Git - vlc/blob - bootstrap
* bootstrap: remove autom4te.cache before running autoconf
[vlc] / bootstrap
1 #! /bin/sh
2
3 ##  bootstrap file for the VLC media player
4 ##  $Id: bootstrap,v 1.82 2003/11/06 10:09:16 sam Exp $
5 ##
6 ##  Authors: Sam Hocevar <sam@zoy.org>
7
8 if test "$#" != "0"; then
9   echo "Usage: $0"
10   echo "  Calls automake, autoconf, autoheader, autopoint and other auto* to generate"
11   echo "  m4 macros and prepare Makefiles."
12   exit 1
13 fi
14
15 ###
16 ###  Get a sane environment, just in case
17 ###
18 LANG=C
19 export LANG
20 CYGWIN=binmode
21 export CYGWIN
22
23 set -e
24 set -x
25
26 ##
27 ## Check for various tools
28 ##
29 AUTOMAKESUCKS=no
30 INSTALLSUCKS=no
31
32 # Check for automake
33 amvers="none"
34 if automake-1.7 --version >/dev/null 2>&1; then
35   amvers="-1.7"
36   # If we also have 1.6 (>> 1.6.1), use it instead because it is faster
37   if automake-1.6 --version >/dev/null 2>&1; then
38     if expr "`automake-1.6 --version | sed -e '1s/[^0-9]*//' -e q`" ">" "1.6.1" > /dev/null 2>&1; then
39       amvers="-1.6"
40     fi
41   fi
42 elif automake-1.6 --version >/dev/null 2>&1; then
43   amvers="-1.6"
44   if expr "`automake-1.6 --version | sed -e '1s/[^0-9]*//' -e q`" "<=" "1.6.1" > /dev/null 2>&1; then
45     AUTOMAKESUCKS=yes
46   fi
47 elif automake-1.5 --version >/dev/null 2>&1; then
48   INSTALLSUCKS=yes
49   amvers="-1.5"
50 elif automake --version > /dev/null 2>&1; then
51   amvers=""
52   case "`automake --version | sed -e '1s/[^0-9]*//' -e q`" in
53     0|0.*|1|1.[01234]|1.[01234][-.]*)
54       amvers="none" ;;
55     1.5|1.5.*)
56       INSTALLSUCKS=yes ;;
57     1.6|1.6.0|1.6.1)
58       AUTOMAKESUCKS=yes ;;
59   esac
60 fi
61
62 if test "${amvers}" = "none"; then
63   set +x
64   echo "you need automake version 1.5 or later"
65   exit 1
66 fi
67
68 # Check for gettext
69 if gettextize --version >/dev/null 2>&1; then
70 # Autopoint is available from 0.11.3, but we need 0.11.5
71 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
72         '>=' 0.11.5 >/dev/null 2>&1; then
73   # We have gettext, and a recent version! Everything is cool.
74   autopoint=autopoint
75   GETTEXT=yes
76 else
77   # User's gettext is too old. try to continue anyway.
78   autopoint=:
79   GETTEXT=old
80 fi;else
81   # we don't have gettext. grmbl. try to continue anyway.
82   autopoint=:
83   GETTEXT=no
84 fi
85
86 # Check for pkg-config
87 if pkg-config --version >/dev/null 2>&1; then
88   # We have pkg-config, everything is cool.
89   PKGCONFIG=yes
90 else
91   PKGCONFIG=no
92 fi
93
94 aclocal=aclocal${amvers}
95 automake=automake${amvers}
96 autoconf=autoconf
97 autoheader=autoheader
98
99 ##
100 ## Generate the modules makefile, by parsing modules/**/Modules.am
101 ##
102
103 set +x
104 echo "generating modules/**/Makefile.am and m4/private.m4"
105
106 # Prepare m4/private.m4
107 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
108 dnl  Private VLC macros - generated by bootstrap
109
110 EOF
111
112 if [ "${PKGCONFIG}" = "no" ]; then cat >> m4/private.m4 << EOF
113 dnl  User does not have pkg-config, so this is a no-op
114 AC_DEFUN([PKG_CHECK_MODULES], [:], [], [], [])
115
116 EOF
117 fi
118
119 if [ "${GETTEXT}" != "yes" ]; then cat >> m4/private.m4 << EOF
120 dnl  User does not have gettext, so this is a no-op
121 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
122
123 EOF
124 fi
125
126 rm -f m4/private.m4-tmp1 && cat > m4/private.m4-tmp1 << EOF
127 dnl  The required AM_CONDITIONAL calls
128 dnl  XXX: too many conditionals make the build very slow, disabled them
129 AC_DEFUN([AX_VLC_CONDITIONALS], [
130 EOF
131 rm -f m4/private.m4-tmp2 && cat > m4/private.m4-tmp2 << EOF
132 dnl  The required AC_SUBST calls
133 AC_DEFUN([AX_VLC_SUBSTS], [
134 EOF
135 rm -f m4/private.m4-tmp3 && cat > m4/private.m4-tmp3 << EOF
136 dnl  The required AC_OUTPUT calls
137 dnl  XXX: this feature is only supported starting from automake-1.7
138 AC_DEFUN([AX_VLC_MAKEFILES], [AC_OUTPUT([
139 EOF
140 rm -f m4/private.m4-tmp4 && cat > m4/private.m4-tmp4 << EOF
141 dnl  Helper macro for vlc-config generation
142 AC_DEFUN([AX_VLC_CONFIG_HELPER], [
143   cat >> vlc-config.in << BLAH
144 EOF
145
146 modules=""
147
148 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
149 # Autogenerated by bootstrap - DO NOT EDIT
150 EXTRA_DIST = LIST
151 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
152 #DIST_SUBDIRS = \$(SUBDIRS)
153 EOF
154
155 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
156 do
157   printf "."
158   mf="modules/${dir}/Modules.am"
159   basedir="${dir%%\/*}"
160   # automake will not recurse for make dist if we don't define SUBDIRS = .
161   subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
162   rm -f modules/${dir}/Makefile.am && cat > modules/${dir}/Makefile.am << EOF
163
164 # Autogenerated by bootstrap - DO NOT EDIT - edit Modules.am instead
165
166 NULL =
167 libvlc_LIBRARIES =
168 noinst_LIBRARIES =
169 noinst_HEADERS =
170 EXTRA_DIST = Modules.am
171 BUILT_SOURCES =
172 SUBDIRS = ${subdirs}
173 #DIST_SUBDIRS = \$(SUBDIRS)
174 libvlcdir = \$(libdir)/vlc/${basedir}
175 include Modules.am
176
177 if BUILD_MOZILLA
178 if HAVE_WIN32
179 # There's no need for pic code on win32 so get rid of this to substantially
180 # reduce the compilation time.
181 pic = no
182 endif
183 else
184 pic = no
185 endif
186
187 clean-local:
188         -rm -f *.a *.so *.dll *.sl *.dylib
189
190 all: all-modules
191 all-modules:
192         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
193         if test "\$(plugin)" != "no"; then z=\$\$(\$(VLC_CONFIG) --target plugin); for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf} | xargs`; do case "\$\$z" in */lib\$\${mod}_plugin*) echo lib\$\${mod}_plugin\$(LIBEXT);; esac; done; fi; \\
194         if test "\$(builtin)" != "no"; then z=\$\$(\$(VLC_CONFIG) --target builtin); for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf} | xargs`; do case "\$\$z" in */lib\$\${mod}.a*) echo lib\$\${mod}.a;; esac; done; fi; \\
195         if test "\$(pic)" != "no"; then z=\$\$(\$(VLC_CONFIG) --target builtin pic); for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf} | xargs`; do case "\$\$z" in */lib\$\${mod}_pic.a*) echo lib\$\${mod}_pic.a;; esac; done; fi; \\
196         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
197         test -z "\$\$fail"
198
199 EOF
200   for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf}`
201   do
202     if grep '^SOURCES_'${mod}'.*=.*PRIVATE' < ${mf} >/dev/null 2>&1; then
203         PRIVATE='#'; else
204         PRIVATE=''; fi
205     if grep '^nodist_SOURCES_'${mod}'' < ${mf} >/dev/null 2>&1; then
206         NODIST=''; else
207         NODIST='#'; fi
208 #    cat >> m4/private.m4-tmp1 << EOF
209 #dnl  AM_CONDITIONAL(${mod}_p, test x\$${mod}_p = xyes)
210 #dnl  AM_CONDITIONAL(${mod}_b, test x\$${mod}_b = xyes)
211 #EOF
212     cat >> m4/private.m4-tmp4 << EOF
213     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
214 EOF
215 # Generation of modules/**/Makefile.am
216 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
217 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
218 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
219 #   the resulting file size.
220 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
221 #   work properly with any automake version I tested.
222     cat >> modules/${dir}/Makefile.am << EOF
223 # The ${mod} plugin
224
225 EOF
226     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
227 clean-local: clean-${mod}
228 clean-${mod}:
229         -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
230
231 EOF
232     fi
233     cat >> modules/${dir}/Makefile.am << EOF
234 if UNTRUE
235 L${mod}p = lib${mod}_plugin.a
236 D${mod}p = lib${mod}_plugin\$(LIBEXT)
237 L${mod}b = lib${mod}.a
238 L${mod}pic = lib${mod}_pic.a
239 EOF
240     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
241 B${mod} = \$(nodist_SOURCES_${mod})
242 EOF
243     fi
244     cat >> modules/${dir}/Makefile.am << EOF
245 endif
246
247 EOF
248     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
249 ${PRIVATE}BUILT_SOURCES += \$(B${mod})
250 EOF
251     fi
252     cat >> modules/${dir}/Makefile.am << EOF
253 ${PRIVATE}lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
254 EOF
255     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
256 ${PRIVATE}nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
257 EOF
258     fi
259     cat >> modules/${dir}/Makefile.am << EOF
260 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
261 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
262 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
263
264 lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
265 EOF
266     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
267 nodist_lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
268 EOF
269     fi
270     cat >> modules/${dir}/Makefile.am << EOF
271 lib${mod}_pic_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin pic ${mod}\`
272 lib${mod}_pic_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin pic ${mod}\`
273 lib${mod}_pic_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin pic ${mod}\`
274
275 lib${mod}_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
276 EOF
277     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
278 nodist_lib${mod}_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
279 EOF
280     fi
281     cat >> modules/${dir}/Makefile.am << EOF
282 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin ${mod}\`
283 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin ${mod}\`
284 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin ${mod}\`
285
286 libvlc_LIBRARIES += \$(L${mod}b) \$(L${mod}pic)
287 lib${mod}_DATA = \$(D${mod}p)
288
289 lib${mod}dir = \$(libdir)/vlc/${topdir}
290 ${PRIVATE}noinst_LIBRARIES += \$(L${mod}p)
291 ${PRIVATE}lib${mod}_plugin\$(LIBEXT): \$(lib${mod}_plugin_a_OBJECTS)
292 ${PRIVATE}      @case \`\$(VLC_CONFIG) --linkage ${mod}\` in \\
293 ${PRIVATE}        c++) echo \$(CXXLINK) \$(lib${mod}_plugin_a_OBJECTS) \\\`\$(VLC_CONFIG) --libs plugin ${mod}\\\` ; \$(CXXLINK) \$(lib${mod}_plugin_a_OBJECTS) \`\$(VLC_CONFIG) --libs plugin ${mod}\` ;; \\
294 ${PRIVATE}        objc) echo \$(OBJCLINK) \$(lib${mod}_plugin_a_OBJECTS) \\\`\$(VLC_CONFIG) --libs plugin ${mod}\\\` ; \$(OBJCLINK) \$(lib${mod}_plugin_a_OBJECTS) \`\$(VLC_CONFIG) --libs plugin ${mod}\` ;; \\
295 ${PRIVATE}        c|*) echo \$(LINK) \$(lib${mod}_plugin_a_OBJECTS) \\\`\$(VLC_CONFIG) --libs plugin ${mod}\\\` ; \$(LINK) \$(lib${mod}_plugin_a_OBJECTS) \`\$(VLC_CONFIG) --libs plugin ${mod}\` ;; \\
296 ${PRIVATE}      esac
297
298
299 EOF
300   done
301 done
302
303 cat >> m4/private.m4-tmp1 << EOF
304   AM_CONDITIONAL(UNTRUE, false)
305 ])
306 EOF
307 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
308 cat >> m4/private.m4-tmp2 << EOF
309 ])
310 EOF
311 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
312 cat >> m4/private.m4-tmp3 << EOF
313 ])])
314 EOF
315 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
316 cat >> m4/private.m4-tmp4 << EOF
317 BLAH
318 ])
319 EOF
320 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
321
322 echo " done."
323
324 ###
325 ###  classic bootstrap stuff
326 ###
327 set -x
328
329 # remove autotools cruft
330 rm -f aclocal.m4 configure config.log config.h config.h.in
331 rm -Rf autom4te.cache
332 # remove old autotools extra cruft
333 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
334 # remove new autotools extra cruft
335 (cd autotools && rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh)
336 # remove libtool cruft
337 rm -f ltmain.sh libtool ltconfig
338 # remove gettext cruft
339 rm -f ABOUT-NLS
340 rm -Rf intl
341 # remove old vlc cruft
342 rm -f m4/oldgettext.m4 stamp-pic configure.ac.in Modules.am
343 # remove new vlc cruft
344 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
345
346 # Automake complains if these are not present
347 rm -f vlc-config.in && printf "" > vlc-config.in
348 if [ "$GETTEXT" != "yes" ]; then
349   test -d intl || mkdir intl
350   printf "" > intl/Makefile.am
351   printf "" > ABOUT-NLS
352 fi
353
354 # Do the rest
355 ${autopoint} -f
356 ${aclocal} -I m4
357 ${autoconf}
358 ${autoheader}
359 ${automake} --add-missing --copy
360
361 ##
362 ##  files which need to be regenerated
363 ##
364 rm -f vlc-config.in vlc-config
365 rm -f src/misc/modules_builtin.h src/misc/modules_plugin.h
366 rm -f include/vlc_symbols.h
367 rm -f mozilla/vlcintf.h
368
369 # Shut up
370 set +x
371
372 ##
373 ##  Tell the user about gettext, pkg-config and sed
374 ##
375 case "${GETTEXT}" in
376   yes) ;;
377   no) cat << EOF
378
379 ===========================================================
380 IMPORTANT NOTE: you do not have gettext installed on your
381 system. The vlc build will work, but you will not have
382 internationalization support. We suggest installing gettext.
383 EOF
384   ;;
385   old) cat << EOF
386
387 ==========================================================
388 NOTE: you have an old version of gettext installed on your
389 system. The vlc build will work, but if your system does not
390 have libintl you will not have internationalization support.
391 We suggest upgrading to gettext 0.11.5 or later.
392 EOF
393   ;;
394 esac
395
396 case "$PKGCONFIG" in
397   yes) ;;
398   no) cat << EOF
399
400 ==============================================================
401 NOTE: you do not have the "pkg-config" utility on your system;
402 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
403 reliable.
404 EOF
405   ;;
406 esac
407
408 case "$AUTOMAKESUCKS" in
409   no) ;;
410   yes) cat << EOF
411
412 =============================================================
413 IMPORTANT NOTE: your version of automake has a bug which will
414 prevent proper plugin compilation. Either compile VLC with
415 the --disable-plugins flag, or use a version of automake newer
416 than 1.6.1 (1.6.2 is OK, and so are the 1.5 series).
417 EOF
418   ;;
419 esac
420
421 case "$INSTALLSUCKS" in
422   no) ;;
423   yes) cat << EOF
424
425 =============================================================
426 IMPORTANT NOTE: your version of automake has a bug which will
427 prevent proper installation. Do not use "make install" with this
428 version of automake, or use a version of automake newer than 1.5
429 (such as 1.6 or 1.7).
430 EOF
431   ;;
432 esac
433