Refresh patch.
[vlc/vlc-skelet.git] / bootstrap
blobc29edb9984f690a410a3cf49c8d8d07d29a49a85
1 #! /bin/sh
3 ## bootstrap file for the VLC media player
4 ##
5 ## Copyright (C) 2005-2006 the VideoLAN team
6 ##
7 ## Authors: Sam Hocevar <sam@zoy.org>
8 ## RĂ©mi Denis-Courmont <rem # videolan # org>
10 if test "$#" != "0"; then
11 echo "Usage: $0"
12 echo " Calls automake, autoconf, autoheader, autopoint and other auto* to generate"
13 echo " m4 macros and prepare Makefiles."
14 exit 1
17 ###
18 ### Get a sane environment, just in case
19 ###
20 LANG=C
21 export LANG
22 CYGWIN=binmode
23 export CYGWIN
25 set -e
26 set -x
29 ## Check for various tools
31 AUTOMAKESUCKS=no
32 INSTALLSUCKS=no
34 ACLOCAL_ARGS="-I m4 ${ACLOCAL_ARGS}"
36 # Check for contrib directory
37 if test -d extras/contrib/bin; then
38 export PATH="`pwd`/extras/contrib/bin:$PATH"
39 if test -d extras/contrib/share/aclocal; then
40 ACLOCAL_ARGS="${ACLOCAL_ARGS} -I extras/contrib/share/aclocal"
42 if test ".`uname -s`" = ".Darwin"; then
43 export LD_LIBRARY_PATH=./extras/contrib/lib:$LD_LIBRARY_PATH
44 export DYLD_LIBRARY_PATH=./extras/contrib/lib:$DYLD_LIBRARY_PATH
45 elif test ".`uname -s`" = ".BeOS"; then
46 export LIBRARY_PATH=./extras/contrib/lib:$LIBRARY_PATH
47 export BELIBRARIES=./extras/contrib/lib:$BELIBRARIES
49 elif test ".`uname -s`" = ".Darwin"; then
50 set +x
51 echo ""
52 echo "ERR: Contribs haven't been built"
53 echo "ERR: Please run:"
54 echo "ERR: "
55 echo "ERR: 'cd extras/contrib && ./bootstrap && make && cd ../..'"
56 echo "ERR: "
57 echo "ERR: Make sure fink has been disabled too."
58 echo ""
59 set -x
60 exit 1
63 # Check for autoconf
64 rm -f m4/autoconf260.m4
65 case "$(autoconf --version|head -n 1)" in
66 *2.5[012345678]*)
67 echo "Hey, your autoconf is quite old. Update it." >&2
68 exit 1
71 *2.59*)
72 echo "Enabling provisional autoconf 2.59 work-around. Update autoconf ASAP."
73 cp -f extras/m4/autoconf260.m4 m4/
75 esac
77 # Check for automake
78 amvers="no"
79 for v in "-1.10" "110" "-1.9" "19"; do
80 if automake${v} --version >/dev/null 2>&1; then
81 amsuff="${v}"
82 amvers="`echo ${v} | sed -e 's/^-//'`"
83 break
85 done
87 if test "${amvers}" = "no" && automake --version > /dev/null 2>&1; then
88 amvers="`automake --version | sed -e '1s/[^0-9]*//' -e q`"
89 amsuff=""
92 case "${amvers}" in
93 no|1.[012345678]|1.[0123456].*|1[0123456]|1.[0123456]-*)
94 set +x
95 echo "$0: you need automake version 1.9 or later"
96 exit 1
98 esac
100 # Check for libtool
101 libtoolize="no"
102 if glibtoolize --version >/dev/null 2>&1; then
103 libtoolize="glibtoolize"
104 elif libtoolize --version >/dev/null 2>&1; then
105 libtoolize="libtoolize"
108 if test "$libtoolize" = "no"; then
109 set +x
110 echo "$0: you need libtool"
111 exit 1
114 # Check for gettext
115 if gettextize --version >/dev/null 2>&1; then
116 # Autopoint is available from 0.11.3, but we need 0.11.5
117 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
118 '>=' 0.11.5 >/dev/null 2>&1; then
119 # We have gettext, and a recent version! Everything is cool.
120 autopoint=autopoint
121 GETTEXT=yes
122 else
123 # User's gettext is too old. try to continue anyway.
124 autopoint=:
125 GETTEXT=old
126 fi;else
127 set +x
128 echo "you need gettextize (package gettext-devel or gettext)"
129 exit 1
132 # Check for pkg-config
133 if pkg-config --version >/dev/null 2>&1; then
134 # We have pkg-config, everything is cool.
135 PKGCONFIG=yes
136 else
137 PKGCONFIG=no
140 aclocal=aclocal${amsuff}
141 automake=automake${amsuff}
142 autoconf=autoconf
143 autoheader=autoheader
146 ## Generate the modules makefile, by parsing modules/**/Modules.am
149 set +x
150 echo "generating modules/**/Makefile.am and m4/private.m4"
152 # Prepare m4/private.m4
153 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
154 dnl Private VLC macros - generated by bootstrap
158 if [ "${PKGCONFIG}" = "no" ]; then cat >> m4/private.m4 << EOF
159 dnl User does not have pkg-config, so assume package was not found
160 AC_DEFUN([PKG_CHECK_MODULES],[ifelse([\$4], , :, [\$4])])
165 if [ "${GETTEXT}" != "yes" ]; then cat >> m4/private.m4 << EOF
166 dnl User does not have gettext, so this is a no-op
167 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
172 rm -f m4/private.m4-tmp1 && cat > m4/private.m4-tmp1 << EOF
173 dnl The required AM_CONDITIONAL calls
174 dnl XXX: too many conditionals make the build very slow, disabled them
175 AC_DEFUN([VLC_CONDITIONALS], [
177 rm -f m4/private.m4-tmp2 && cat > m4/private.m4-tmp2 << EOF
178 dnl The required AC_SUBST calls
179 AC_DEFUN([VLC_SUBSTS], [
181 rm -f m4/private.m4-tmp3 && cat > m4/private.m4-tmp3 << EOF
182 dnl The required AC_OUTPUT calls
183 dnl XXX: this feature is only supported starting from automake-1.7
184 AC_DEFUN([VLC_MAKEFILES], [AC_OUTPUT([
186 rm -f m4/private.m4-tmp4 && cat > m4/private.m4-tmp4 << EOF
187 dnl Helper macro for vlc-config generation
188 AC_DEFUN([VLC_CONFIG_HELPER], [
189 cat >> vlc-config.in << BLAH
192 modules=""
194 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
195 # Autogenerated by bootstrap - DO NOT EDIT
196 EXTRA_DIST = LIST
197 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
200 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
202 printf "."
203 modf="modules/${dir}/Modules.am"
204 makf="modules/${dir}/Makefile.am"
205 basedir="`echo "${dir}" | cut -f1 -d/`"
206 # automake will not recurse for make dist if we don't define SUBDIRS = .
207 subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
208 mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | xargs`"
209 extra_libs=""
210 extra_ltlibs=""
211 for mod in $mods
213 extra_libs="${extra_libs} lib${mod}_plugin.a lib${mod}.a"
214 extra_ltlibs="${extra_ltlibs} lib${mod}_plugin.la"
215 done
216 rm -f "${makf}" && cat > "${makf}" << EOF
218 # ${makf} automatically generated from ${modf} by bootstrap
219 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
221 basedir = ${basedir}
222 mods = ${mods}
224 NULL =
225 libvlc_LTLIBRARIES =
226 noinst_LTLIBRARIES =
227 EXTRA_DIST = Modules.am
228 BUILT_SOURCES =
229 clean_modules =
230 SUBDIRS = ${subdirs}
231 SUFFIXES = _plugin\$(LIBEXT) _plugin.a
233 libvlcdir = \$(libdir)/vlc/\$(basedir)
235 EXTRA_LIBRARIES = ${extra_libs}
236 EXTRA_LTLIBRARIES = ${extra_ltlibs}
238 include Modules.am
240 LTLIBVLC = \$(top_builddir)/src/libvlc.la
242 if HAVE_WIN32
243 LIBVLC = -L\$(top_builddir)/src -lvlc
244 LIBADD = \$(LIBVLC)
245 endif
247 all: all-modules
249 nice:
250 \$(top_builddir)/compile
252 # Find out which modules were enabled and tell make to build them
253 all-modules:
254 if USE_LIBTOOL
255 @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
256 z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin.la;; esac; done; \\
257 \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
258 test -z "\$\$fail"
259 else
260 @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
261 z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin\$(LIBEXT);; esac; done; \\
262 z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}.a;; esac; done; \\
263 \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
264 test -z "\$\$fail"
265 endif
267 # Build a plugin with the adequate linker and linker's flags
268 _plugin.a_plugin\$(LIBEXT):
269 @mod="\$*" ; mod=\$\${mod#lib} ; \
270 ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` \$(LIBADD) -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
271 case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
272 c++) ld="\$(CXXLINK)" ;; \
273 objc) ld="\$(OBJCLINK)" ;; \
274 c|*) ld="\$(LINK)" ;; \
275 esac ; \
276 echo \$\$ld \$< \$\$ldfl ; \
277 \$\$ld \$< \$\$ldfl
278 #ifneq (,\$(findstring cygwin,\$(host)))
279 # mv -f "\$@.exe" "\$@"
280 #endif
281 @if test -f "\$@.exe"; then mv -f "\$@.exe" "\$@"; fi
283 if MAINTAINER_MODE
284 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
285 cd \$(top_srcdir) && \$(SHELL) ./bootstrap
286 endif
288 mostlyclean-local:
289 if USE_LIBTOOL
290 -rm -f *.la
291 else
292 -rm -f *.a *\$(LIBEXT)
293 endif
295 clean-local: \$(clean_modules)
297 ### automake creates libvlcdir after running install-*-local
298 ### so we have to create it ourselves first
299 install-exec-local: all-modules
300 if USE_LIBTOOL
301 @if test -z "\$(libvlc_LTLIBRARIES)"; then \
302 z=\$\$(\$(VLC_CONFIG) --list plugin); \
303 m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
304 test -z "\$\$m" || \
305 \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" install-libvlcLTLIBRARIES || exit \$\$? ; \
307 else
308 mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
309 @z=\$\$(\$(VLC_CONFIG) --list plugin); \
310 for mod in \$(mods); do \
311 case "\$\$z " \
312 in *\ \$\${mod}\ *) \
313 echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
314 \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || exit \$\$?; \
315 ;; \
316 esac; \
317 done
318 endif
320 uninstall-local:
321 if USE_LIBTOOL
322 @if test -z "\$(libvlc_LTLIBRARIES)"; then \
323 z=\$\$(\$(VLC_CONFIG) --list plugin); \
324 m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
325 test -z "\$\$m" || \
326 \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" uninstall-libvlcLTLIBRARIES || exit \$\$?; \
328 else
329 @z=\$\$(\$(VLC_CONFIG) --list plugin); \
330 for mod in \$(mods); do \
331 case "\$\$z " \
332 in *\ \$\${mod}\ *) \
333 echo rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" ; \
334 rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" || true; \
335 ;; \
336 esac; \
337 done
338 endif
341 for mod in $mods
343 if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
344 NODIST=''; else
345 NODIST='#'; fi
346 cat >> m4/private.m4-tmp4 << EOF
347 ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
349 # Generation of modules/**/Makefile.am
350 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
351 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
352 # S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
353 # the resulting file size.
354 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
355 # work properly with any automake version I tested.
356 cat >> "${makf}" << EOF
357 # The ${mod} plugin
360 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
361 clean_modules += clean-${mod}
362 clean-${mod}:
363 -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
367 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
368 BUILT_SOURCES += \$(B${mod})
371 cat >> "${makf}" << EOF
372 lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
373 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
375 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
376 nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
377 nodist_lib${mod}_plugin_la_SOURCES = \$(nodist_SOURCES_${mod})
380 cat >> "${makf}" << EOF
381 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
382 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
383 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
384 lib${mod}_plugin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
385 lib${mod}_plugin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
386 lib${mod}_plugin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
387 lib${mod}_plugin_la_LDFLAGS = \`\$(VLC_CONFIG) --libs plugin ${mod}\` \\
388 -rpath '\$(libvlcdir)' -avoid-version -module -shrext \$(LIBEXT) \\
389 -export-symbol-regex ^\$(VLC_ENTRY)\$\$ -no-undefined
390 lib${mod}_plugin_la_LIBADD = \$(LTLIBVLC)
392 lib${mod}_a_SOURCES = \$(SOURCES_${mod})
394 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
395 nodist_lib${mod}_a_SOURCES = \$(nodist_SOURCES_${mod})
398 cat >> "${makf}" << EOF
399 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin pic ${mod}\`
400 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin pic ${mod}\`
401 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin pic ${mod}\`
404 done
405 done
407 cat >> m4/private.m4-tmp1 << EOF
410 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
411 cat >> m4/private.m4-tmp2 << EOF
414 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
415 cat >> m4/private.m4-tmp3 << EOF
416 ])])
418 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
419 cat >> m4/private.m4-tmp4 << EOF
420 BLAH
423 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
425 echo " done."
428 ### classic bootstrap stuff
430 set -x
432 # remove autotools cruft
433 rm -f aclocal.m4 configure config.log config.h config.h.in
434 rm -Rf autom4te*.cache
435 # remove old autotools extra cruft
436 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
437 # remove new autotools extra cruft
438 rm -Rf autotools
439 mkdir autotools
440 # remove libtool cruft
441 rm -f ltmain.sh libtool ltconfig
442 # remove gettext cruft
443 rm -f ABOUT-NLS
444 rm -Rf intl
445 # remove vlc cruft
446 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
448 # Automake complains if these are not present
449 rm -f vlc-config.in && printf "" > vlc-config.in
450 if [ "$GETTEXT" != "yes" ]; then
451 test -d intl || mkdir intl
452 printf "" > intl/Makefile.am
453 printf "" > ABOUT-NLS
456 # Libtoolize directory
457 ${libtoolize} --copy --force
458 if test -f "ltmain.sh"; then
459 echo "$0: working around a minor libtool issue"
460 mv ltmain.sh autotools/
463 # patch for DLL link for libtool on cygwin (remove when fixed)
464 if test ".`uname -s|sed -n '/^CYGWIN/p'`" != "."; then
465 patch -s -p0 << 'EOF'
466 --- autotools/ltmain.orig 2006-12-05 15:15:42.064607000 +0000
467 +++ autotools/ltmain.sh 2006-12-05 15:16:24.705777800 +0000
468 @@ -4360,7 +4360,7 @@
470 prog)
471 case $host in
472 - *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
473 + *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,;s,.dll.exe$,.dll,'` ;;
474 esac
475 if test -n "$vinfo"; then
476 $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
480 # Do the rest
481 ${autopoint} -f
482 ${aclocal} ${ACLOCAL_ARGS}
483 ${autoconf}
484 ${autoheader}
485 ${automake} --add-missing --copy -Wall
488 ## files which need to be regenerated
490 rm -f vlc-config.in vlc-config
491 rm -f src/misc/modules_builtin.h
493 # Shut up
494 set +x
497 ## Tell the user about gettext, pkg-config and sed
499 if [ "${GETTEXT}" = "old" ]; then
500 cat << EOF
502 ==========================================================
503 NOTE: you have an old version of gettext installed on your
504 system. The vlc build will work, but if your system does not
505 have libintl you will not have internationalization support.
506 We suggest upgrading to gettext 0.11.5 or later.
510 if [ "$PKGCONFIG" = "no" ]; then
511 cat << EOF
513 ==============================================================
514 NOTE: you do not have the "pkg-config" utility on your system;
515 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
516 reliable.