Link with libebml_pic if avaivable
[vlc.git] / bootstrap
blobb3680144a03f44bdb968b927f6bf8a7a332bf931
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"
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
51 # Check for autoconf
52 rm -f m4/autoconf260.m4
53 case "$(autoconf --version|head -1)" in
54 *2.5[012345678]*)
55 echo "Hey, your autoconf is quite old. Update it." >&2
56 exit 1
59 *2.59*)
60 echo "Enabling provisional autoconf 2.59 work-around. Update autoconf ASAP."
61 cp -f extras/m4/autoconf260.m4 m4/
63 esac
65 # Check for automake
66 amvers="no"
67 for v in "-1.9" "19" "-1.8" "18" "-1.7" "17"; do
68 if automake${v} --version >/dev/null 2>&1; then
69 amsuff="${v}"
70 amvers="${v}"
71 break
73 done
75 if test "${amvers}" = "no" && automake --version > /dev/null 2>&1; then
76 amvers="`automake --version | sed -e '1s/[^0-9]*//' -e q`"
77 amsuff=""
80 case "${amvers}" in
81 no|1.[0123456]|1.[0123456].*|1[0123456]|1.[0123456]-*)
82 set +x
83 echo "$0: you need automake version 1.7 or later"
84 exit 1
86 esac
88 # Check for libtool
89 libtoolize="no"
90 if glibtoolize --version >/dev/null 2>&1; then
91 libtoolize="glibtoolize"
92 elif libtoolize --version >/dev/null 2>&1; then
93 libtoolize="libtoolize"
96 if test "$libtoolize" = "no"; then
97 set +x
98 echo "$0: you need libtool"
99 exit 1
102 # Check for gettext
103 if gettextize --version >/dev/null 2>&1; then
104 # Autopoint is available from 0.11.3, but we need 0.11.5
105 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
106 '>=' 0.11.5 >/dev/null 2>&1; then
107 # We have gettext, and a recent version! Everything is cool.
108 autopoint=autopoint
109 GETTEXT=yes
110 else
111 # User's gettext is too old. try to continue anyway.
112 autopoint=:
113 GETTEXT=old
114 fi;else
115 set +x
116 echo "you need gettextize (package gettext-devel or gettext)"
117 exit 1
120 # Check for pkg-config
121 if pkg-config --version >/dev/null 2>&1; then
122 # We have pkg-config, everything is cool.
123 PKGCONFIG=yes
124 else
125 PKGCONFIG=no
128 aclocal=aclocal${amvers}
129 automake=automake${amvers}
130 autoconf=autoconf
131 autoheader=autoheader
134 ## Generate the modules makefile, by parsing modules/**/Modules.am
137 set +x
138 echo "generating modules/**/Makefile.am and m4/private.m4"
140 # Prepare m4/private.m4
141 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
142 dnl Private VLC macros - generated by bootstrap
146 if [ "${PKGCONFIG}" = "no" ]; then cat >> m4/private.m4 << EOF
147 dnl User does not have pkg-config, so assume package was not found
148 AC_DEFUN([PKG_CHECK_MODULES],[ifelse([\$4], , :, [\$4])])
153 if [ "${GETTEXT}" != "yes" ]; then cat >> m4/private.m4 << EOF
154 dnl User does not have gettext, so this is a no-op
155 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
160 rm -f m4/private.m4-tmp1 && cat > m4/private.m4-tmp1 << EOF
161 dnl The required AM_CONDITIONAL calls
162 dnl XXX: too many conditionals make the build very slow, disabled them
163 AC_DEFUN([VLC_CONDITIONALS], [
165 rm -f m4/private.m4-tmp2 && cat > m4/private.m4-tmp2 << EOF
166 dnl The required AC_SUBST calls
167 AC_DEFUN([VLC_SUBSTS], [
169 rm -f m4/private.m4-tmp3 && cat > m4/private.m4-tmp3 << EOF
170 dnl The required AC_OUTPUT calls
171 dnl XXX: this feature is only supported starting from automake-1.7
172 AC_DEFUN([VLC_MAKEFILES], [AC_OUTPUT([
174 rm -f m4/private.m4-tmp4 && cat > m4/private.m4-tmp4 << EOF
175 dnl Helper macro for vlc-config generation
176 AC_DEFUN([VLC_CONFIG_HELPER], [
177 cat >> vlc-config.in << BLAH
180 modules=""
182 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
183 # Autogenerated by bootstrap - DO NOT EDIT
184 EXTRA_DIST = LIST
185 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
188 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
190 printf "."
191 modf="modules/${dir}/Modules.am"
192 makf="modules/${dir}/Makefile.am"
193 basedir="`echo "${dir}" | cut -f1 -d/`"
194 # automake will not recurse for make dist if we don't define SUBDIRS = .
195 subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
196 mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | xargs`"
197 extra_libs=""
198 extra_ltlibs=""
199 for mod in $mods
201 extra_libs="${extra_libs} lib${mod}_plugin.a lib${mod}.a"
202 extra_ltlibs="${extra_ltlibs} lib${mod}_plugin.la"
203 done
204 rm -f "${makf}" && cat > "${makf}" << EOF
206 # ${makf} automatically generated from ${modf} by bootstrap
207 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
209 basedir = ${basedir}
210 mods = ${mods}
212 NULL =
213 libvlc_LTLIBRARIES =
214 noinst_LTLIBRARIES =
215 EXTRA_DIST = Modules.am
216 BUILT_SOURCES =
217 clean_modules =
218 SUBDIRS = ${subdirs}
219 SUFFIXES = _plugin\$(LIBEXT) _plugin.a
221 libvlcdir = \$(libdir)/vlc/\$(basedir)
223 EXTRA_LIBRARIES = ${extra_libs}
224 EXTRA_LTLIBRARIES = ${extra_ltlibs}
226 include Modules.am
228 LTLIBVLC = \$(top_builddir)/src/libvlc.la
230 if BUILD_SHARED
231 LIBVLC = -L\$(top_builddir)/src -lvlc
232 LIBADD = \$(LIBVLC)
233 endif
235 all: all-modules
237 nice:
238 \$(top_builddir)/compile
240 # Find out which modules were enabled and tell make to build them
241 all-modules:
242 if USE_LIBTOOL
243 @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
244 z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin.la;; esac; done; \\
245 \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
246 test -z "\$\$fail"
247 else
248 @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
249 z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin\$(LIBEXT);; esac; done; \\
250 z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}.a;; esac; done; \\
251 \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
252 test -z "\$\$fail"
253 endif
255 # Build a plugin with the adequate linker and linker's flags
256 _plugin.a_plugin\$(LIBEXT):
257 @mod="\$*" ; mod=\$\${mod#lib} ; \
258 ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` \$(LIBADD) -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
259 case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
260 c++) ld="\$(CXXLINK)" ;; \
261 objc) ld="\$(OBJCLINK)" ;; \
262 c|*) ld="\$(LINK)" ;; \
263 esac ; \
264 echo \$\$ld \$< \$\$ldfl ; \
265 \$\$ld \$< \$\$ldfl
266 #ifneq (,\$(findstring cygwin,\$(host)))
267 # mv -f "\$@.exe" "\$@"
268 #endif
269 @if test -f "\$@.exe"; then mv -f "\$@.exe" "\$@"; fi
271 if MAINTAINER_MODE
272 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
273 cd \$(top_srcdir) && \$(SHELL) ./bootstrap
274 endif
276 mostlyclean-local:
277 if USE_LIBTOOL
278 -rm -f *.la
279 else
280 -rm -f *.a *\$(LIBEXT)
281 endif
283 clean-local: \$(clean_modules)
285 ### automake creates libvlcdir after running install-*-local
286 ### so we have to create it ourselves first
287 install-exec-local: all-modules
288 if USE_LIBTOOL
289 @if test -z "\$(libvlc_LTLIBRARIES)"; then \
290 z=\$\$(\$(VLC_CONFIG) --list plugin); \
291 m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
292 test -z "\$\$m" || \
293 \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" install-libvlcLTLIBRARIES || exit \$\$? ; \
295 else
296 mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
297 @z=\$\$(\$(VLC_CONFIG) --list plugin); \
298 for mod in \$(mods); do \
299 case "\$\$z " \
300 in *\ \$\${mod}\ *) \
301 echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
302 \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || exit \$\$?; \
303 ;; \
304 esac; \
305 done
306 endif
308 uninstall-local:
309 if USE_LIBTOOL
310 @if test -z "\$(libvlc_LTLIBRARIES)"; then \
311 z=\$\$(\$(VLC_CONFIG) --list plugin); \
312 m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
313 test -z "\$\$m" || \
314 \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" uninstall-libvlcLTLIBRARIES || exit \$\$?; \
316 else
317 @z=\$\$(\$(VLC_CONFIG) --list plugin); \
318 for mod in \$(mods); do \
319 case "\$\$z " \
320 in *\ \$\${mod}\ *) \
321 echo rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" ; \
322 rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" || true; \
323 ;; \
324 esac; \
325 done
326 endif
329 for mod in $mods
331 if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
332 NODIST=''; else
333 NODIST='#'; fi
334 cat >> m4/private.m4-tmp4 << EOF
335 ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
337 # Generation of modules/**/Makefile.am
338 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
339 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
340 # S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
341 # the resulting file size.
342 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
343 # work properly with any automake version I tested.
344 cat >> "${makf}" << EOF
345 # The ${mod} plugin
348 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
349 clean_modules += clean-${mod}
350 clean-${mod}:
351 -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
355 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
356 BUILT_SOURCES += \$(B${mod})
359 cat >> "${makf}" << EOF
360 lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
361 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
363 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
364 nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
365 nodist_lib${mod}_plugin_la_SOURCES = \$(nodist_SOURCES_${mod})
368 cat >> "${makf}" << EOF
369 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
370 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
371 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
372 lib${mod}_plugin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
373 lib${mod}_plugin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
374 lib${mod}_plugin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
375 lib${mod}_plugin_la_LDFLAGS = \`\$(VLC_CONFIG) --libs plugin ${mod}\` \\
376 -rpath '\$(libvlcdir)' -avoid-version -module -shrext \$(LIBEXT) \\
377 -export-symbol-regex ^\$(VLC_ENTRY)\$\$ -no-undefined
378 lib${mod}_plugin_la_LIBADD = \$(LTLIBVLC)
380 lib${mod}_a_SOURCES = \$(SOURCES_${mod})
382 if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
383 nodist_lib${mod}_a_SOURCES = \$(nodist_SOURCES_${mod})
386 cat >> "${makf}" << EOF
387 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin pic ${mod}\`
388 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin pic ${mod}\`
389 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin pic ${mod}\`
392 done
393 done
395 cat >> m4/private.m4-tmp1 << EOF
398 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
399 cat >> m4/private.m4-tmp2 << EOF
402 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
403 cat >> m4/private.m4-tmp3 << EOF
404 ])])
406 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
407 cat >> m4/private.m4-tmp4 << EOF
408 BLAH
411 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
413 echo " done."
416 ### classic bootstrap stuff
418 set -x
420 # remove autotools cruft
421 rm -f aclocal.m4 configure config.log config.h config.h.in
422 rm -Rf autom4te*.cache
423 # remove old autotools extra cruft
424 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
425 # remove new autotools extra cruft
426 rm -Rf autotools
427 mkdir autotools
428 # remove libtool cruft
429 rm -f ltmain.sh libtool ltconfig
430 # remove gettext cruft
431 rm -f ABOUT-NLS
432 rm -Rf intl
433 # remove vlc cruft
434 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
436 # Automake complains if these are not present
437 rm -f vlc-config.in && printf "" > vlc-config.in
438 if [ "$GETTEXT" != "yes" ]; then
439 test -d intl || mkdir intl
440 printf "" > intl/Makefile.am
441 printf "" > ABOUT-NLS
444 # Libtoolize directory
445 ${libtoolize} --copy --force
446 if test -f "ltmain.sh"; then
447 echo "$0: working around a minor libtool issue"
448 mv ltmain.sh autotools/
451 # Do the rest
452 ${autopoint} -f
453 ${aclocal} ${ACLOCAL_ARGS}
454 ${autoconf}
455 ${autoheader}
456 ${automake} --add-missing --copy -Wall
459 ## files which need to be regenerated
461 rm -f vlc-config.in vlc-config
462 rm -f src/misc/modules_builtin.h
464 # Shut up
465 set +x
468 ## Tell the user about gettext, pkg-config and sed
470 if [ "${GETTEXT}" = "old" ]; then
471 cat << EOF
473 ==========================================================
474 NOTE: you have an old version of gettext installed on your
475 system. The vlc build will work, but if your system does not
476 have libintl you will not have internationalization support.
477 We suggest upgrading to gettext 0.11.5 or later.
481 if [ "$PKGCONFIG" = "no" ]; then
482 cat << EOF
484 ==============================================================
485 NOTE: you do not have the "pkg-config" utility on your system;
486 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
487 reliable.