]> git.sesse.net Git - vlc/blob - bootstrap
817f370329482f623bf7e8474c033a967f77ba8c
[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 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
15 fi
16
17 ###
18 ###  Get a sane environment, just in case
19 ###
20 LANG=C
21 export LANG
22 CYGWIN=binmode
23 export CYGWIN
24
25 set -e
26 set -x
27
28 ##
29 ## Check for various tools
30 ##
31 AUTOMAKESUCKS=no
32 INSTALLSUCKS=no
33
34 ACLOCAL_ARGS="-I m4 ${ACLOCAL_ARGS}"
35
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"
41   fi
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
48   fi
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
61 fi
62
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
69     ;;
70
71   *2.59*)
72     echo "Enabling provisional autoconf 2.59 work-around. Update autoconf ASAP."
73     cp -f extras/m4/autoconf260.m4 m4/
74     ;;
75 esac
76
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
84   fi
85 done
86
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=""
90 fi
91
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
97     ;;
98 esac
99
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"
106 fi
107
108 if test "$libtoolize" = "no"; then
109   set +x
110   echo "$0: you need libtool"
111   exit 1
112 fi
113
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
130 fi
131
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
138 fi
139
140 aclocal=aclocal${amsuff}
141 automake=automake${amsuff}
142 autoconf=autoconf
143 autoheader=autoheader
144
145 ##
146 ## Generate the modules makefile, by parsing modules/**/Modules.am
147 ##
148
149 set +x
150 echo "generating modules/**/Makefile.am and m4/private.m4"
151
152 # Prepare m4/private.m4
153 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
154 dnl  Private VLC macros - generated by bootstrap
155
156 EOF
157
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])])
161
162 EOF
163 fi
164
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], [])
168
169 EOF
170 fi
171
172 cat >> m4/private.m4 << EOF
173 dnl  Helper macro for vlc-config generation
174 AC_DEFUN([VLC_CONFIG_HELPER], [
175   cat >> vlc-config.in << BLAH
176 EOF
177
178 modules=""
179
180 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
181 # Autogenerated by bootstrap - DO NOT EDIT
182 EXTRA_DIST = LIST
183 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
184 EOF
185
186 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
187 do
188   printf "."
189   modf="modules/${dir}/Modules.am"
190   makf="modules/${dir}/Makefile.am"
191   basedir="`echo "${dir}" | cut -f1 -d/`"
192   # automake will not recurse for make dist if we don't define SUBDIRS = .
193   subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
194   mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | xargs`"
195   extra_libs=""
196   extra_ltlibs=""
197   for mod in $mods
198   do
199     extra_libs="${extra_libs} lib${mod}_plugin.a lib${mod}.a"
200     extra_ltlibs="${extra_ltlibs} lib${mod}_plugin.la"
201   done
202   rm -f "${makf}" && cat > "${makf}" << EOF
203
204 # ${makf} automatically generated from ${modf} by bootstrap
205 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
206
207 basedir = ${basedir}
208 mods = ${mods}
209
210 NULL =
211 libvlc_LTLIBRARIES =
212 noinst_LTLIBRARIES =
213 EXTRA_DIST = Modules.am
214 BUILT_SOURCES =
215 clean_modules =
216 SUBDIRS = ${subdirs}
217 SUFFIXES = _plugin\$(LIBEXT) _plugin.a
218
219 libvlcdir = \$(libdir)/vlc/\$(basedir)
220
221 EXTRA_LIBRARIES = ${extra_libs}
222 EXTRA_LTLIBRARIES = ${extra_ltlibs}
223
224 include Modules.am
225
226 LTLIBVLC = \$(top_builddir)/src/libvlc.la
227
228 if HAVE_WIN32
229 LIBVLC = -L\$(top_builddir)/src -lvlc
230 LIBADD = \$(LIBVLC)
231 endif
232
233 all: all-modules
234
235 nice:
236         \$(top_builddir)/compile
237
238 # Find out which modules were enabled and tell make to build them
239 all-modules:
240 if USE_LIBTOOL
241         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
242         z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin.la;; esac; done; \\
243         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
244         test -z "\$\$fail"
245 else
246         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
247         z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin\$(LIBEXT);; esac; done; \\
248         z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}.a;; esac; done; \\
249         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
250         test -z "\$\$fail"
251 endif
252
253 # Build a plugin with the adequate linker and linker's flags
254 _plugin.a_plugin\$(LIBEXT):
255         @mod="\$*" ; mod=\$\${mod#lib} ; \
256         ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` \$(LIBADD) -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
257         case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
258           c++)  ld="\$(CXXLINK)" ;; \
259           objc) ld="\$(OBJCLINK)" ;; \
260           c|*)  ld="\$(LINK)" ;; \
261         esac ; \
262         echo \$\$ld \$< \$\$ldfl ; \
263         \$\$ld \$< \$\$ldfl
264 #ifneq (,\$(findstring cygwin,\$(host)))
265 #       mv -f "\$@.exe" "\$@"
266 #endif
267         @if test -f "\$@.exe"; then mv -f "\$@.exe" "\$@"; fi
268
269 if MAINTAINER_MODE
270 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
271         cd \$(top_srcdir) && \$(SHELL) ./bootstrap
272 endif
273
274 mostlyclean-local:
275 if USE_LIBTOOL
276         -rm -f *.la
277 else
278         -rm -f *.a *\$(LIBEXT)
279 endif
280
281 clean-local: \$(clean_modules)
282
283 ### automake creates libvlcdir after running install-*-local
284 ### so we have to create it ourselves first
285 install-exec-local: all-modules
286 if USE_LIBTOOL
287         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
288           z=\$\$(\$(VLC_CONFIG) --list plugin); \
289           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
290           test -z "\$\$m" || \
291             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" install-libvlcLTLIBRARIES || exit \$\$? ; \
292         fi
293 else
294         mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
295         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
296         for mod in \$(mods); do \
297           case "\$\$z " \
298             in *\ \$\${mod}\ *) \
299               echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
300               \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || 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 endif
325
326 EOF
327   for mod in $mods
328   do
329     if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
330         NODIST=''; else
331         NODIST='#'; fi
332     cat >> m4/private.m4 << EOF
333     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
334 EOF
335 # Generation of modules/**/Makefile.am
336 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
337 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
338 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
339 #   the resulting file size.
340 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
341 #   work properly with any automake version I tested.
342     cat >> "${makf}" << EOF
343 # The ${mod} plugin
344
345 EOF
346     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
347 clean_modules += clean-${mod}
348 clean-${mod}:
349         -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
350
351 EOF
352     fi
353     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
354 BUILT_SOURCES += \$(B${mod})
355 EOF
356     fi
357     cat >> "${makf}" << EOF
358 lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
359 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
360 EOF
361     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
362 nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
363 nodist_lib${mod}_plugin_la_SOURCES = \$(nodist_SOURCES_${mod})
364 EOF
365     fi
366     cat >> "${makf}" << EOF
367 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
368 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
369 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
370 lib${mod}_plugin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
371 lib${mod}_plugin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
372 lib${mod}_plugin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
373 lib${mod}_plugin_la_LDFLAGS = \`\$(VLC_CONFIG) --libs plugin ${mod}\` \\
374         -rpath '\$(libvlcdir)' -avoid-version -module -shrext \$(LIBEXT) \\
375         -export-symbol-regex ^\$(VLC_ENTRY)\$\$ -no-undefined
376 lib${mod}_plugin_la_LIBADD = \$(LTLIBVLC)
377
378 lib${mod}_a_SOURCES = \$(SOURCES_${mod})
379 EOF
380     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
381 nodist_lib${mod}_a_SOURCES = \$(nodist_SOURCES_${mod})
382 EOF
383     fi
384     cat >> "${makf}" << EOF
385 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin pic ${mod}\`
386 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin pic ${mod}\`
387 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin pic ${mod}\`
388
389 EOF
390   done
391 done
392
393 cat >> m4/private.m4 << EOF
394 BLAH
395 ])
396 EOF
397
398 ###
399 ###  classic bootstrap stuff
400 ###
401 set -x
402
403 # remove autotools cruft
404 rm -f aclocal.m4 configure config.log config.h config.h.in
405 rm -Rf autom4te*.cache
406 # remove old autotools extra cruft
407 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
408 # remove new autotools extra cruft
409 rm -Rf autotools
410 mkdir autotools
411 # remove libtool cruft
412 rm -f ltmain.sh libtool ltconfig
413 # remove gettext cruft
414 rm -f ABOUT-NLS
415 rm -Rf intl
416 # remove vlc cruft
417 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
418
419 # Automake complains if these are not present
420 rm -f vlc-config.in && printf "" > vlc-config.in
421 if [ "$GETTEXT" != "yes" ]; then
422   test -d intl || mkdir intl
423   printf "" > intl/Makefile.am
424   printf "" > ABOUT-NLS
425 fi
426
427 # Libtoolize directory
428 ${libtoolize} --copy --force
429 if test -f "ltmain.sh"; then
430   echo "$0: working around a minor libtool issue"
431   mv ltmain.sh autotools/
432 fi
433
434 # patch for DLL link for libtool on cygwin (remove when fixed)
435 if test ".`uname -s|sed -n '/^CYGWIN/p'`" != "."; then
436 patch -s -p0 << 'EOF'
437 --- autotools/ltmain.orig       2006-12-05 15:15:42.064607000 +0000
438 +++ autotools/ltmain.sh 2006-12-05 15:16:24.705777800 +0000
439 @@ -4360,7 +4360,7 @@
440  
441      prog)
442        case $host in
443 -       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
444 +       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,;s,.dll.exe$,.dll,'` ;;
445        esac
446        if test -n "$vinfo"; then
447         $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
448 EOF
449 fi
450
451 # Do the rest
452 ${autopoint} -f
453 ${aclocal} ${ACLOCAL_ARGS}
454 ${autoconf}
455 ${autoheader}
456 ${automake} --add-missing --copy -Wall
457
458 ##
459 ##  files which need to be regenerated
460 ##
461 rm -f vlc-config.in vlc-config
462 rm -f src/misc/modules_builtin.h
463
464 # Shut up
465 set +x
466
467 ##
468 ##  Tell the user about gettext, pkg-config and sed
469 ##
470 if [ "${GETTEXT}" = "old" ]; then
471   cat << EOF
472
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.
478 EOF
479 fi
480
481 if [ "$PKGCONFIG" = "no" ]; then
482   cat << EOF
483
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.
488 EOF
489 fi
490