]> git.sesse.net Git - vlc/blob - bootstrap
* Fix a number of encoding bugs
[vlc] / bootstrap
1 #! /bin/sh
2
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
11
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
17 fi
18
19 ###
20 ###  Get a sane environment, just in case
21 ###
22 LANG=C
23 export LANG
24 CYGWIN=binmode
25 export CYGWIN
26
27 set -e
28 set -x
29
30 ##
31 ## Check for various tools
32 ##
33 AUTOMAKESUCKS=no
34 INSTALLSUCKS=no
35
36 ACLOCAL_ARGS="-I m4"
37
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"
43   fi
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
50   fi
51 fi
52
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
60   fi
61 done
62
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=""
66 fi
67
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
73     ;;
74 esac
75
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"
82 fi
83
84 if test "$libtoolize" = "no"; then
85   set +x
86   echo "$0: you need libtool"
87   exit 1
88 fi
89
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
106 fi
107
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
114 fi
115
116 aclocal=aclocal${amvers}
117 automake=automake${amvers}
118 autoconf=autoconf
119 autoheader=autoheader
120
121 ##
122 ## Generate the modules makefile, by parsing modules/**/Modules.am
123 ##
124
125 set +x
126 echo "generating modules/**/Makefile.am and m4/private.m4"
127
128 # Prepare m4/private.m4
129 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
130 dnl  Private VLC macros - generated by bootstrap
131
132 EOF
133
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])])
137
138 EOF
139 fi
140
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], [])
144
145 EOF
146 fi
147
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], [
152 EOF
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], [
156 EOF
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([
161 EOF
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
166 EOF
167
168 modules=""
169
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`
174 EOF
175
176 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
177 do
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
188   do
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
193
194 # ${makf} automatically generated from ${modf} by bootstrap
195 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
196
197 basedir = ${basedir}
198 mods = ${mods}
199
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
208
209 libvlcdir = \$(libdir)/vlc/\$(basedir)
210
211 EXTRA_LIBRARIES = ${extra_libs}
212 EXTRA_LTLIBRARIES = ${extra_ltlibs}
213
214 include Modules.am
215
216 LTLIBVLC = \$(top_builddir)/src/libvlc.la
217
218 if BUILD_SHARED
219 LIBVLC = \$(top_builddir)/src/libvlc\$(LIBEXT)
220 LIBADD = \$(LIBVLC)
221 endif
222
223 all: all-modules
224
225 nice:
226         \$(top_builddir)/compile
227
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
243
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
259
260 if MAINTAINER_MODE
261 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
262         cd \$(top_srcdir) && \$(SHELL) ./bootstrap
263 endif
264
265 mostlyclean-local:
266 if USE_LIBTOOL
267         -rm -f *.la
268 else
269         -rm -f *.a *\$(LIBEXT)
270 endif
271
272 clean-local: \$(clean_modules)
273
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 \$\$? ; \
283         fi
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
305
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 \$\$?; \
313         fi
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
334
335 EOF
336   for mod in $mods
337   do
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}" ;;
343 EOF
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
353
354 EOF
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})
359
360 EOF
361     fi
362     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
363 BUILT_SOURCES += \$(B${mod})
364 EOF
365     fi
366     cat >> "${makf}" << EOF
367 lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
368 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
369 EOF
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})
373 EOF
374     fi
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)
385
386 lib${mod}_a_SOURCES = \$(SOURCES_${mod})
387 lib${mod}_builtin_la_SOURCES = \$(SOURCES_${mod})
388 EOF
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})
392 EOF
393     fi
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}\`
401
402 EOF
403   done
404 done
405
406 cat >> m4/private.m4-tmp1 << EOF
407 ])
408 EOF
409 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
410 cat >> m4/private.m4-tmp2 << EOF
411 ])
412 EOF
413 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
414 cat >> m4/private.m4-tmp3 << EOF
415 ])])
416 EOF
417 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
418 cat >> m4/private.m4-tmp4 << EOF
419 BLAH
420 ])
421 EOF
422 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
423
424 echo " done."
425
426 ###
427 ###  classic bootstrap stuff
428 ###
429 set -x
430
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
446
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
453 fi
454
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/
460 fi
461
462 # Do the rest
463 ${autopoint} -f
464 ${aclocal} ${ACLOCAL_ARGS}
465 ${autoconf}
466 ${autoheader}
467 ${automake} --add-missing --copy -Wall
468
469 ##
470 ##  files which need to be regenerated
471 ##
472 rm -f vlc-config.in vlc-config
473 rm -f src/misc/modules_builtin.h
474 rm -f mozilla/vlcintf.h
475
476 # Shut up
477 set +x
478
479 ##
480 ##  Tell the user about gettext, pkg-config and sed
481 ##
482 if [ "${GETTEXT}" = "old" ]; then
483   cat << EOF
484
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.
490 EOF
491 fi
492
493 if [ "$PKGCONFIG" = "no" ]; then
494   cat << EOF
495
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.
500 EOF
501 fi
502