]> git.sesse.net Git - vlc/blob - bootstrap
bootstrap: Make sure we warn the user when no contrib is present on Mac OS X.
[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   # Make sure contrib has been built
51   if test ! -e ./extras/contrib/config.mak; then
52     set +x
53     echo ""
54     echo "ERR: Contribs haven't been built"
55     echo "ERR: Please run:"
56     echo "ERR: "
57     echo "ERR:    'cd extras/contrib && ./bootstrap && make && cd ../..'"
58     echo "ERR: "
59     echo "ERR: Make sure fink has been disabled too."
60     echo ""
61     set -x
62     exit 1
63   fi
64 fi
65
66 # Check for autoconf
67 rm -f m4/autoconf260.m4
68 case "$(autoconf --version|head -n 1)" in
69   *2.5[012345678]*)
70     echo "Hey, your autoconf is quite old. Update it." >&2
71     exit 1
72     ;;
73
74   *2.59*)
75     echo "Enabling provisional autoconf 2.59 work-around. Update autoconf ASAP."
76     cp -f extras/m4/autoconf260.m4 m4/
77     ;;
78 esac
79
80 # Check for automake
81 amvers="no"
82 for v in "-1.10" "110" "-1.9" "19"; do
83   if automake${v} --version >/dev/null 2>&1; then
84     amsuff="${v}"
85     amvers="`echo ${v} | sed -e 's/^-//'`"
86     break
87   fi
88 done
89
90 if test "${amvers}" = "no" && automake --version > /dev/null 2>&1; then
91   amvers="`automake --version | sed -e '1s/[^0-9]*//' -e q`"
92   amsuff=""
93 fi
94
95 case "${amvers}" in
96   no|1.[012345678]|1.[0123456].*|1[0123456]|1.[0123456]-*)
97     set +x
98     echo "$0: you need automake version 1.9 or later"
99     exit 1
100     ;;
101 esac
102
103 # Check for libtool
104 libtoolize="no"
105 if glibtoolize --version >/dev/null 2>&1; then
106   libtoolize="glibtoolize"
107 elif libtoolize --version >/dev/null 2>&1; then
108   libtoolize="libtoolize"
109 fi
110
111 if test "$libtoolize" = "no"; then
112   set +x
113   echo "$0: you need libtool"
114   exit 1
115 fi
116
117 # Check for gettext
118 if gettextize --version >/dev/null 2>&1; then
119 # Autopoint is available from 0.11.3, but we need 0.11.5
120 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
121         '>=' 0.11.5 >/dev/null 2>&1; then
122   # We have gettext, and a recent version! Everything is cool.
123   autopoint=autopoint
124   GETTEXT=yes
125 else
126   # User's gettext is too old. try to continue anyway.
127   autopoint=:
128   GETTEXT=old
129 fi;else
130   set +x
131   echo "you need gettextize (package gettext-devel or gettext)"
132   exit 1
133 fi
134
135 # Check for pkg-config
136 if pkg-config --version >/dev/null 2>&1; then
137   # We have pkg-config, everything is cool.
138   PKGCONFIG=yes
139 else
140   PKGCONFIG=no
141 fi
142
143 aclocal=aclocal${amsuff}
144 automake=automake${amsuff}
145 autoconf=autoconf
146 autoheader=autoheader
147
148 ##
149 ## Generate the modules makefile, by parsing modules/**/Modules.am
150 ##
151
152 set +x
153 echo "generating modules/**/Makefile.am and m4/private.m4"
154
155 # Prepare m4/private.m4
156 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
157 dnl  Private VLC macros - generated by bootstrap
158
159 EOF
160
161 if [ "${PKGCONFIG}" = "no" ]; then cat >> m4/private.m4 << EOF
162 dnl  User does not have pkg-config, so assume package was not found
163 AC_DEFUN([PKG_CHECK_MODULES],[ifelse([\$4], , :, [\$4])])
164
165 EOF
166 fi
167
168 if [ "${GETTEXT}" != "yes" ]; then cat >> m4/private.m4 << EOF
169 dnl  User does not have gettext, so this is a no-op
170 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
171
172 EOF
173 fi
174
175 rm -f m4/private.m4-tmp1 && cat > m4/private.m4-tmp1 << EOF
176 dnl  The required AM_CONDITIONAL calls
177 dnl  XXX: too many conditionals make the build very slow, disabled them
178 AC_DEFUN([VLC_CONDITIONALS], [
179 EOF
180 rm -f m4/private.m4-tmp2 && cat > m4/private.m4-tmp2 << EOF
181 dnl  The required AC_SUBST calls
182 AC_DEFUN([VLC_SUBSTS], [
183 EOF
184 rm -f m4/private.m4-tmp3 && cat > m4/private.m4-tmp3 << EOF
185 dnl  The required AC_OUTPUT calls
186 dnl  XXX: this feature is only supported starting from automake-1.7
187 AC_DEFUN([VLC_MAKEFILES], [AC_OUTPUT([
188 EOF
189 rm -f m4/private.m4-tmp4 && cat > m4/private.m4-tmp4 << EOF
190 dnl  Helper macro for vlc-config generation
191 AC_DEFUN([VLC_CONFIG_HELPER], [
192   cat >> vlc-config.in << BLAH
193 EOF
194
195 modules=""
196
197 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
198 # Autogenerated by bootstrap - DO NOT EDIT
199 EXTRA_DIST = LIST
200 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
201 EOF
202
203 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
204 do
205   printf "."
206   modf="modules/${dir}/Modules.am"
207   makf="modules/${dir}/Makefile.am"
208   basedir="`echo "${dir}" | cut -f1 -d/`"
209   # automake will not recurse for make dist if we don't define SUBDIRS = .
210   subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
211   mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | xargs`"
212   extra_libs=""
213   extra_ltlibs=""
214   for mod in $mods
215   do
216     extra_libs="${extra_libs} lib${mod}_plugin.a lib${mod}.a"
217     extra_ltlibs="${extra_ltlibs} lib${mod}_plugin.la"
218   done
219   rm -f "${makf}" && cat > "${makf}" << EOF
220
221 # ${makf} automatically generated from ${modf} by bootstrap
222 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
223
224 basedir = ${basedir}
225 mods = ${mods}
226
227 NULL =
228 libvlc_LTLIBRARIES =
229 noinst_LTLIBRARIES =
230 EXTRA_DIST = Modules.am
231 BUILT_SOURCES =
232 clean_modules =
233 SUBDIRS = ${subdirs}
234 SUFFIXES = _plugin\$(LIBEXT) _plugin.a
235
236 libvlcdir = \$(libdir)/vlc/\$(basedir)
237
238 EXTRA_LIBRARIES = ${extra_libs}
239 EXTRA_LTLIBRARIES = ${extra_ltlibs}
240
241 include Modules.am
242
243 LTLIBVLC = \$(top_builddir)/src/libvlc.la
244
245 if HAVE_WIN32
246 LIBVLC = -L\$(top_builddir)/src -lvlc
247 LIBADD = \$(LIBVLC)
248 endif
249
250 all: all-modules
251
252 nice:
253         \$(top_builddir)/compile
254
255 # Find out which modules were enabled and tell make to build them
256 all-modules:
257 if USE_LIBTOOL
258         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
259         z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin.la;; esac; done; \\
260         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
261         test -z "\$\$fail"
262 else
263         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
264         z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin\$(LIBEXT);; esac; done; \\
265         z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}.a;; esac; done; \\
266         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
267         test -z "\$\$fail"
268 endif
269
270 # Build a plugin with the adequate linker and linker's flags
271 _plugin.a_plugin\$(LIBEXT):
272         @mod="\$*" ; mod=\$\${mod#lib} ; \
273         ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` \$(LIBADD) -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
274         case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
275           c++)  ld="\$(CXXLINK)" ;; \
276           objc) ld="\$(OBJCLINK)" ;; \
277           c|*)  ld="\$(LINK)" ;; \
278         esac ; \
279         echo \$\$ld \$< \$\$ldfl ; \
280         \$\$ld \$< \$\$ldfl
281 #ifneq (,\$(findstring cygwin,\$(host)))
282 #       mv -f "\$@.exe" "\$@"
283 #endif
284         @if test -f "\$@.exe"; then mv -f "\$@.exe" "\$@"; fi
285
286 if MAINTAINER_MODE
287 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
288         cd \$(top_srcdir) && \$(SHELL) ./bootstrap
289 endif
290
291 mostlyclean-local:
292 if USE_LIBTOOL
293         -rm -f *.la
294 else
295         -rm -f *.a *\$(LIBEXT)
296 endif
297
298 clean-local: \$(clean_modules)
299
300 ### automake creates libvlcdir after running install-*-local
301 ### so we have to create it ourselves first
302 install-exec-local: all-modules
303 if USE_LIBTOOL
304         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
305           z=\$\$(\$(VLC_CONFIG) --list plugin); \
306           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
307           test -z "\$\$m" || \
308             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" install-libvlcLTLIBRARIES || exit \$\$? ; \
309         fi
310 else
311         mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
312         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
313         for mod in \$(mods); do \
314           case "\$\$z " \
315             in *\ \$\${mod}\ *) \
316               echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
317               \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || exit \$\$?; \
318               ;; \
319           esac; \
320         done
321 endif
322
323 uninstall-local:
324 if USE_LIBTOOL
325         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
326           z=\$\$(\$(VLC_CONFIG) --list plugin); \
327           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
328           test -z "\$\$m" || \
329             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" uninstall-libvlcLTLIBRARIES || exit \$\$?; \
330         fi
331 else
332         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
333         for mod in \$(mods); do \
334           case "\$\$z " \
335             in *\ \$\${mod}\ *) \
336               echo rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" ; \
337               rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" || true; \
338               ;; \
339           esac; \
340         done
341 endif
342
343 EOF
344   for mod in $mods
345   do
346     if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
347         NODIST=''; else
348         NODIST='#'; fi
349     cat >> m4/private.m4-tmp4 << EOF
350     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
351 EOF
352 # Generation of modules/**/Makefile.am
353 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
354 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
355 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
356 #   the resulting file size.
357 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
358 #   work properly with any automake version I tested.
359     cat >> "${makf}" << EOF
360 # The ${mod} plugin
361
362 EOF
363     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
364 clean_modules += clean-${mod}
365 clean-${mod}:
366         -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
367
368 EOF
369     fi
370     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
371 BUILT_SOURCES += \$(B${mod})
372 EOF
373     fi
374     cat >> "${makf}" << EOF
375 lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
376 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
377 EOF
378     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
379 nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
380 nodist_lib${mod}_plugin_la_SOURCES = \$(nodist_SOURCES_${mod})
381 EOF
382     fi
383     cat >> "${makf}" << EOF
384 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
385 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
386 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
387 lib${mod}_plugin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
388 lib${mod}_plugin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
389 lib${mod}_plugin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
390 lib${mod}_plugin_la_LDFLAGS = \`\$(VLC_CONFIG) --libs plugin ${mod}\` \\
391         -rpath '\$(libvlcdir)' -avoid-version -module -shrext \$(LIBEXT) \\
392         -export-symbol-regex ^\$(VLC_ENTRY)\$\$ -no-undefined
393 lib${mod}_plugin_la_LIBADD = \$(LTLIBVLC)
394
395 lib${mod}_a_SOURCES = \$(SOURCES_${mod})
396 EOF
397     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
398 nodist_lib${mod}_a_SOURCES = \$(nodist_SOURCES_${mod})
399 EOF
400     fi
401     cat >> "${makf}" << EOF
402 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin pic ${mod}\`
403 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin pic ${mod}\`
404 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin pic ${mod}\`
405
406 EOF
407   done
408 done
409
410 cat >> m4/private.m4-tmp1 << EOF
411 ])
412 EOF
413 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
414 cat >> m4/private.m4-tmp2 << EOF
415 ])
416 EOF
417 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
418 cat >> m4/private.m4-tmp3 << EOF
419 ])])
420 EOF
421 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
422 cat >> m4/private.m4-tmp4 << EOF
423 BLAH
424 ])
425 EOF
426 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
427
428 echo " done."
429
430 ###
431 ###  classic bootstrap stuff
432 ###
433 set -x
434
435 # remove autotools cruft
436 rm -f aclocal.m4 configure config.log config.h config.h.in
437 rm -Rf autom4te*.cache
438 # remove old autotools extra cruft
439 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
440 # remove new autotools extra cruft
441 rm -Rf autotools
442 mkdir autotools
443 # remove libtool cruft
444 rm -f ltmain.sh libtool ltconfig
445 # remove gettext cruft
446 rm -f ABOUT-NLS
447 rm -Rf intl
448 # remove vlc cruft
449 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
450
451 # Automake complains if these are not present
452 rm -f vlc-config.in && printf "" > vlc-config.in
453 if [ "$GETTEXT" != "yes" ]; then
454   test -d intl || mkdir intl
455   printf "" > intl/Makefile.am
456   printf "" > ABOUT-NLS
457 fi
458
459 # Libtoolize directory
460 ${libtoolize} --copy --force
461 if test -f "ltmain.sh"; then
462   echo "$0: working around a minor libtool issue"
463   mv ltmain.sh autotools/
464 fi
465
466 # patch for DLL link for libtool on cygwin (remove when fixed)
467 if test ".`uname -s|sed -n '/^CYGWIN/p'`" != "."; then
468 patch -s -p0 << 'EOF'
469 --- autotools/ltmain.orig       2006-12-05 15:15:42.064607000 +0000
470 +++ autotools/ltmain.sh 2006-12-05 15:16:24.705777800 +0000
471 @@ -4360,7 +4360,7 @@
472  
473      prog)
474        case $host in
475 -       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
476 +       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,;s,.dll.exe$,.dll,'` ;;
477        esac
478        if test -n "$vinfo"; then
479         $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
480 EOF
481 fi
482
483 # Do the rest
484 ${autopoint} -f
485 ${aclocal} ${ACLOCAL_ARGS}
486 ${autoconf}
487 ${autoheader}
488 ${automake} --add-missing --copy -Wall
489
490 ##
491 ##  files which need to be regenerated
492 ##
493 rm -f vlc-config.in vlc-config
494 rm -f src/misc/modules_builtin.h
495
496 # Shut up
497 set +x
498
499 ##
500 ##  Tell the user about gettext, pkg-config and sed
501 ##
502 if [ "${GETTEXT}" = "old" ]; then
503   cat << EOF
504
505 ==========================================================
506 NOTE: you have an old version of gettext installed on your
507 system. The vlc build will work, but if your system does not
508 have libintl you will not have internationalization support.
509 We suggest upgrading to gettext 0.11.5 or later.
510 EOF
511 fi
512
513 if [ "$PKGCONFIG" = "no" ]; then
514   cat << EOF
515
516 ==============================================================
517 NOTE: you do not have the "pkg-config" utility on your system;
518 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
519 reliable.
520 EOF
521 fi
522