fix breakqge introduce in [16152]
[vlc.git] / bootstrap
blobf4e17d00c45521bc59cf46a1648889575016913d
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>
9 ##
10 ## Muahaha! no annoying dollar I dee dollar that causes rebuild at commit
12 if test "$#" != "0"; then
13 echo "Usage: $0"
14 echo " Calls automake, autoconf, autoheader, autopoint and other auto* to generate"
15 echo " m4 macros and prepare Makefiles."
16 exit 1
19 ###
20 ### Get a sane environment, just in case
21 ###
22 LANG=C
23 export LANG
24 CYGWIN=binmode
25 export CYGWIN
27 set -e
28 set -x
31 ## Check for various tools
33 AUTOMAKESUCKS=no
34 INSTALLSUCKS=no
36 ACLOCAL_ARGS="-I m4"
38 # Check for contrib directory
39 if test -d extras/contrib/bin; then
40 export PATH=./extras/contrib/bin:$PATH
41 if test -d extras/contrib/share/aclocal; then
42 ACLOCAL_ARGS="${ACLOCAL_ARGS} -I extras/contrib/share/aclocal"
44 if test ".`uname -s`" = ".Darwin"; then
45 export LD_LIBRARY_PATH=./extras/contrib/lib:$LD_LIBRARY_PATH
46 export DYLD_LIBRARY_PATH=./extras/contrib/lib:$DYLD_LIBRARY_PATH
47 elif test ".`uname -s`" = ".BeOS"; then
48 export LIBRARY_PATH=./extras/contrib/lib:$LIBRARY_PATH
49 export BELIBRARIES=./extras/contrib/lib:$BELIBRARIES
53 # Check for automake
54 amvers="no"
55 for v in "-1.9" "19" "-1.8" "18" "-1.7" "17"; do
56 if automake${v} --version >/dev/null 2>&1; then
57 amsuff="${v}"
58 amvers="${v}"
59 break
61 done
63 if test "${amvers}" = "no" && automake --version > /dev/null 2>&1; then
64 amvers="`automake --version | sed -e '1s/[^0-9]*//' -e q`"
65 amsuff=""
68 case "${amvers}" in
69 no|1.[0123456]|1.[0123456].*|1[0123456])
70 set +x
71 echo "$0: you need automake version 1.7 or later"
72 exit 1
74 esac
76 # Check for libtool
77 libtoolize="no"
78 if glibtoolize --version >/dev/null 2>&1; then
79 libtoolize="glibtoolize"
80 elif libtoolize --version >/dev/null 2>&1; then
81 libtoolize="libtoolize"
84 if test "$libtoolize" = "no"; then
85 set +x
86 echo "$0: you need libtool"
87 exit 1
90 # Check for gettext
91 if gettextize --version >/dev/null 2>&1; then
92 # Autopoint is available from 0.11.3, but we need 0.11.5
93 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
94 '>=' 0.11.5 >/dev/null 2>&1; then
95 # We have gettext, and a recent version! Everything is cool.
96 autopoint=autopoint
97 GETTEXT=yes
98 else
99 # User's gettext is too old. try to continue anyway.
100 autopoint=:
101 GETTEXT=old
102 fi;else
103 set +x
104 echo "you need gettextize (package gettext-devel or gettext)"
105 exit 1
108 # Check for pkg-config
109 if pkg-config --version >/dev/null 2>&1; then
110 # We have pkg-config, everything is cool.
111 PKGCONFIG=yes
112 else
113 PKGCONFIG=no
116 aclocal=aclocal${amvers}
117 automake=automake${amvers}
118 autoconf=autoconf
119 autoheader=autoheader
122 ## Generate the modules makefile, by parsing modules/**/Modules.am
125 set +x
126 echo "generating modules/**/Makefile.am and m4/private.m4"
128 # Prepare m4/private.m4
129 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
130 dnl Private VLC macros - generated by bootstrap
134 if [ "${PKGCONFIG}" = "no" ]; then cat >> m4/private.m4 << EOF
135 dnl User does not have pkg-config, so assume package was not found
136 AC_DEFUN([PKG_CHECK_MODULES],[ifelse([\$4], , :, [\$4])])
141 if [ "${GETTEXT}" != "yes" ]; then cat >> m4/private.m4 << EOF
142 dnl User does not have gettext, so this is a no-op
143 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
148 rm -f m4/private.m4-tmp1 && cat > m4/private.m4-tmp1 << EOF
149 dnl The required AM_CONDITIONAL calls
150 dnl XXX: too many conditionals make the build very slow, disabled them
151 AC_DEFUN([VLC_CONDITIONALS], [
153 rm -f m4/private.m4-tmp2 && cat > m4/private.m4-tmp2 << EOF
154 dnl The required AC_SUBST calls
155 AC_DEFUN([VLC_SUBSTS], [
157 rm -f m4/private.m4-tmp3 && cat > m4/private.m4-tmp3 << EOF
158 dnl The required AC_OUTPUT calls
159 dnl XXX: this feature is only supported starting from automake-1.7
160 AC_DEFUN([VLC_MAKEFILES], [AC_OUTPUT([
162 rm -f m4/private.m4-tmp4 && cat > m4/private.m4-tmp4 << EOF
163 dnl Helper macro for vlc-config generation
164 AC_DEFUN([VLC_CONFIG_HELPER], [
165 cat >> vlc-config.in << BLAH
168 modules=""
170 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
171 # Autogenerated by bootstrap - DO NOT EDIT
172 EXTRA_DIST = LIST
173 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
176 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
178 printf "."
179 modf="modules/${dir}/Modules.am"
180 makf="modules/${dir}/Makefile.am"
181 basedir="`echo "${dir}" | cut -f1 -d/`"
182 # automake will not recurse for make dist if we don't define SUBDIRS = .
183 subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
184 mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | xargs`"
185 extra_libs=""
186 extra_ltlibs=""
187 for mod in $mods
189 extra_libs="${extra_libs} lib${mod}_plugin.a lib${mod}.a"
190 extra_ltlibs="${extra_ltlibs} lib${mod}_plugin.la lib${mod}_builtin.la"
191 done
192 rm -f "${makf}" && cat > "${makf}" << EOF
194 # ${makf} automatically generated from ${modf} by bootstrap
195 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
197 basedir = ${basedir}
198 mods = ${mods}
200 NULL =
201 libvlc_LTLIBRARIES =
202 noinst_LTLIBRARIES =
203 EXTRA_DIST = Modules.am
204 BUILT_SOURCES =
205 clean_modules =
206 SUBDIRS = ${subdirs}
207 SUFFIXES = _plugin\$(LIBEXT) _plugin.a
209 libvlcdir = \$(libdir)/vlc/\$(basedir)
211 EXTRA_LIBRARIES = ${extra_libs}
212 EXTRA_LTLIBRARIES = ${extra_ltlibs}
214 include Modules.am
216 LTLIBVLC = \$(top_builddir)/src/libvlc.la
218 if BUILD_SHARED
219 LIBVLC = \$(top_builddir)/src/libvlc\$(LIBEXT)
220 LIBADD = \$(LIBVLC)
221 endif
223 all: all-modules
225 nice:
226 \$(top_builddir)/compile
228 # Find out which modules were enabled and tell make to build them
229 all-modules:
230 if USE_LIBTOOL
231 @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
232 if test "\$(plugin)" != "no"; then z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin.la;; esac; done; fi; \\
233 if test "\$(builtin)" != "no"; then z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_builtin.la;; esac; done; fi; \\
234 \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
235 test -z "\$\$fail"
236 else
237 @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
238 if test "\$(plugin)" != "no"; then z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin\$(LIBEXT);; esac; done; fi; \\
239 if test "\$(builtin)" != "no"; then z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}.a;; esac; done; fi; \\
240 \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
241 test -z "\$\$fail"
242 endif
244 # Build a plugin with the adequate linker and linker's flags
245 _plugin.a_plugin\$(LIBEXT):
246 @mod="\$*" ; mod=\$\${mod#lib} ; \
247 ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` \$(LIBADD) -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
248 case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
249 c++) ld="\$(CXXLINK)" ;; \
250 objc) ld="\$(OBJCLINK)" ;; \
251 c|*) ld="\$(LINK)" ;; \
252 esac ; \
253 echo \$\$ld \$< \$\$ldfl ; \
254 \$\$ld \$< \$\$ldfl
255 #ifneq (,\$(findstring cygwin,\$(host)))
256 # mv -f "\$@.exe" "\$@"
257 #endif
258 @if test -f "\$@.exe"; then mv -f "\$@.exe" "\$@"; fi
260 if MAINTAINER_MODE
261 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
262 cd \$(top_srcdir) && \$(SHELL) ./bootstrap
263 endif
265 mostlyclean-local:
266 if USE_LIBTOOL
267 -rm -f *.la
268 else
269 -rm -f *.a *\$(LIBEXT)
270 endif
272 clean-local: \$(clean_modules)
274 ### automake creates libvlcdir after running install-*-local
275 ### so we have to create it ourselves first
276 install-exec-local: all-modules
277 if USE_LIBTOOL
278 @if test -z "\$(libvlc_LTLIBRARIES)"; then \
279 z=\$\$(\$(VLC_CONFIG) --list plugin); \
280 m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
281 test -z "\$\$m" || \
282 \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" install-libvlcLTLIBRARIES || exit \$\$? ; \
284 else
285 mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
286 @z=\$\$(\$(VLC_CONFIG) --list plugin); \
287 for mod in \$(mods); do \
288 case "\$\$z " \
289 in *\ \$\${mod}\ *) \
290 echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
291 \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || exit \$\$?; \
292 ;; \
293 esac; \
294 done
295 @z=\$\$(\$(VLC_CONFIG) --list builtin); \
296 for mod in \$(mods); do \
297 case "\$\$z " \
298 in *\ \$\${mod}\ *) \
299 echo \$(INSTALL_DATA) "lib\$\${mod}.a" "\$(DESTDIR)\$(libdir)/vlc/" ; \
300 \$(INSTALL_DATA) "lib\$\${mod}.a" "\$(DESTDIR)\$(libdir)/vlc/" || exit \$\$?; \
301 ;; \
302 esac; \
303 done
304 endif
306 uninstall-local:
307 if USE_LIBTOOL
308 @if test -z "\$(libvlc_LTLIBRARIES)"; then \
309 z=\$\$(\$(VLC_CONFIG) --list plugin); \
310 m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
311 test -z "\$\$m" || \
312 \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" uninstall-libvlcLTLIBRARIES || exit \$\$?; \
314 else
315 @z=\$\$(\$(VLC_CONFIG) --list plugin); \
316 for mod in \$(mods); do \
317 case "\$\$z " \
318 in *\ \$\${mod}\ *) \
319 echo rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" ; \
320 rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" || true; \
321 ;; \
322 esac; \
323 done
324 @z=\$\$(\$(VLC_CONFIG) --list builtin); \
325 for mod in \$(mods); do \
326 case "\$\$z " \
327 in *\ \$\${mod}\ *) \
328 echo rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}.a" ; \
329 rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}.a" || true; \
330 ;; \
331 esac; \
332 done
333 endif
336 for mod in $mods
338 if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
339 NODIST=''; else
340 NODIST='#'; fi
341 cat >> m4/private.m4-tmp4 << EOF
342 ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
344 # Generation of modules/**/Makefile.am
345 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
346 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
347 # S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
348 # the resulting file size.
349 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
350 # work properly with any automake version I tested.
351 cat >> "${makf}" << EOF
352 # The ${mod} plugin
355 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
356 clean_modules += clean-${mod}
357 clean-${mod}:
358 -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
362 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
363 BUILT_SOURCES += \$(B${mod})
366 cat >> "${makf}" << EOF
367 lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
368 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
370 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
371 nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
372 nodist_lib${mod}_plugin_la_SOURCES = \$(nodist_SOURCES_${mod})
375 cat >> "${makf}" << EOF
376 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
377 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
378 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
379 lib${mod}_plugin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
380 lib${mod}_plugin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
381 lib${mod}_plugin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
382 lib${mod}_plugin_la_LDFLAGS = \`\$(VLC_CONFIG) --libs plugin ${mod}\` \\
383 -rpath '\$(libvlcdir)' -avoid-version -module -shrext \$(LIBEXT)
384 lib${mod}_plugin_la_LIBADD = \$(LTLIBVLC)
386 lib${mod}_a_SOURCES = \$(SOURCES_${mod})
387 lib${mod}_builtin_la_SOURCES = \$(SOURCES_${mod})
389 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
390 nodist_lib${mod}_a_SOURCES = \$(nodist_SOURCES_${mod})
391 nodist_lib${mod}_builtin_la_SOURCES = \$(nodist_SOURCES_${mod})
394 cat >> "${makf}" << EOF
395 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin \$(pic) ${mod}\`
396 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin \$(pic) ${mod}\`
397 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin \$(pic) ${mod}\`
398 lib${mod}_builtin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin ${mod}\`
399 lib${mod}_builtin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin ${mod}\`
400 lib${mod}_builtin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin ${mod}\`
403 done
404 done
406 cat >> m4/private.m4-tmp1 << EOF
409 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
410 cat >> m4/private.m4-tmp2 << EOF
413 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
414 cat >> m4/private.m4-tmp3 << EOF
415 ])])
417 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
418 cat >> m4/private.m4-tmp4 << EOF
419 BLAH
422 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
424 echo " done."
427 ### classic bootstrap stuff
429 set -x
431 # remove autotools cruft
432 rm -f aclocal.m4 configure config.log config.h config.h.in
433 rm -Rf autom4te*.cache
434 # remove old autotools extra cruft
435 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
436 # remove new autotools extra cruft
437 rm -Rf autotools
438 mkdir autotools
439 # remove libtool cruft
440 rm -f ltmain.sh libtool ltconfig
441 # remove gettext cruft
442 rm -f ABOUT-NLS
443 rm -Rf intl
444 # remove vlc cruft
445 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
447 # Automake complains if these are not present
448 rm -f vlc-config.in && printf "" > vlc-config.in
449 if [ "$GETTEXT" != "yes" ]; then
450 test -d intl || mkdir intl
451 printf "" > intl/Makefile.am
452 printf "" > ABOUT-NLS
455 # Libtoolize directory
456 ${libtoolize} --copy --force
457 if test -f "ltmain.sh"; then
458 echo "$0: working around a minor libtool issue"
459 mv ltmain.sh autotools/
462 # Do the rest
463 ${autopoint} -f
464 ${aclocal} ${ACLOCAL_ARGS}
465 ${autoconf}
466 ${autoheader}
467 ${automake} --add-missing --copy -Wall
470 ## files which need to be regenerated
472 rm -f vlc-config.in vlc-config
473 rm -f src/misc/modules_builtin.h
474 rm -f mozilla/vlcintf.h
476 # Shut up
477 set +x
480 ## Tell the user about gettext, pkg-config and sed
482 if [ "${GETTEXT}" = "old" ]; then
483 cat << EOF
485 ==========================================================
486 NOTE: you have an old version of gettext installed on your
487 system. The vlc build will work, but if your system does not
488 have libintl you will not have internationalization support.
489 We suggest upgrading to gettext 0.11.5 or later.
493 if [ "$PKGCONFIG" = "no" ]; then
494 cat << EOF
496 ==============================================================
497 NOTE: you do not have the "pkg-config" utility on your system;
498 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
499 reliable.