]> git.sesse.net Git - vlc/blob - bootstrap
Revert lame revert from [16628].
[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"
35
36 # Check for contrib directory
37 if test -d extras/contrib/bin; then
38   export PATH=./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 fi
50
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
57     ;;
58
59   *2.59*)
60     echo "Enabling provisional autoconf 2.59 work-around. Update autoconf ASAP."
61     cp -f extras/m4/autoconf260.m4 m4/
62     ;;
63 esac
64
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
72   fi
73 done
74
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=""
78 fi
79
80 case "${amvers}" in
81   no|1.[0123456]|1.[0123456].*|1[0123456])
82     set +x
83     echo "$0: you need automake version 1.7 or later"
84     exit 1
85     ;;
86 esac
87
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"
94 fi
95
96 if test "$libtoolize" = "no"; then
97   set +x
98   echo "$0: you need libtool"
99   exit 1
100 fi
101
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
118 fi
119
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
126 fi
127
128 aclocal=aclocal${amvers}
129 automake=automake${amvers}
130 autoconf=autoconf
131 autoheader=autoheader
132
133 ##
134 ## Generate the modules makefile, by parsing modules/**/Modules.am
135 ##
136
137 set +x
138 echo "generating modules/**/Makefile.am and m4/private.m4"
139
140 # Prepare m4/private.m4
141 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
142 dnl  Private VLC macros - generated by bootstrap
143
144 EOF
145
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])])
149
150 EOF
151 fi
152
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], [])
156
157 EOF
158 fi
159
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], [
164 EOF
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], [
168 EOF
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([
173 EOF
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
178 EOF
179
180 modules=""
181
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`
186 EOF
187
188 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
189 do
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
200   do
201     extra_libs="${extra_libs} lib${mod}_plugin.a lib${mod}.a"
202     extra_ltlibs="${extra_ltlibs} lib${mod}_plugin.la lib${mod}_builtin.la"
203   done
204   rm -f "${makf}" && cat > "${makf}" << EOF
205
206 # ${makf} automatically generated from ${modf} by bootstrap
207 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
208
209 basedir = ${basedir}
210 mods = ${mods}
211
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
220
221 libvlcdir = \$(libdir)/vlc/\$(basedir)
222
223 EXTRA_LIBRARIES = ${extra_libs}
224 EXTRA_LTLIBRARIES = ${extra_ltlibs}
225
226 include Modules.am
227
228 LTLIBVLC = \$(top_builddir)/src/libvlc.la
229
230 if BUILD_SHARED
231 LIBVLC = -L\$(top_builddir)/src -lvlc
232 LIBADD = \$(LIBVLC)
233 endif
234
235 all: all-modules
236
237 nice:
238         \$(top_builddir)/compile
239
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         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; \\
245         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; \\
246         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
247         test -z "\$\$fail"
248 else
249         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
250         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; \\
251         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; \\
252         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
253         test -z "\$\$fail"
254 endif
255
256 # Build a plugin with the adequate linker and linker's flags
257 _plugin.a_plugin\$(LIBEXT):
258         @mod="\$*" ; mod=\$\${mod#lib} ; \
259         ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` \$(LIBADD) -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
260         case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
261           c++)  ld="\$(CXXLINK)" ;; \
262           objc) ld="\$(OBJCLINK)" ;; \
263           c|*)  ld="\$(LINK)" ;; \
264         esac ; \
265         echo \$\$ld \$< \$\$ldfl ; \
266         \$\$ld \$< \$\$ldfl
267 #ifneq (,\$(findstring cygwin,\$(host)))
268 #       mv -f "\$@.exe" "\$@"
269 #endif
270         @if test -f "\$@.exe"; then mv -f "\$@.exe" "\$@"; fi
271
272 if MAINTAINER_MODE
273 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
274         cd \$(top_srcdir) && \$(SHELL) ./bootstrap
275 endif
276
277 mostlyclean-local:
278 if USE_LIBTOOL
279         -rm -f *.la
280 else
281         -rm -f *.a *\$(LIBEXT)
282 endif
283
284 clean-local: \$(clean_modules)
285
286 ### automake creates libvlcdir after running install-*-local
287 ### so we have to create it ourselves first
288 install-exec-local: all-modules
289 if USE_LIBTOOL
290         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
291           z=\$\$(\$(VLC_CONFIG) --list plugin); \
292           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
293           test -z "\$\$m" || \
294             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" install-libvlcLTLIBRARIES || exit \$\$? ; \
295         fi
296 else
297         mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
298         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
299         for mod in \$(mods); do \
300           case "\$\$z " \
301             in *\ \$\${mod}\ *) \
302               echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
303               \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || exit \$\$?; \
304               ;; \
305           esac; \
306         done
307         @z=\$\$(\$(VLC_CONFIG) --list builtin); \
308         for mod in \$(mods); do \
309           case "\$\$z " \
310             in *\ \$\${mod}\ *) \
311               echo \$(INSTALL_DATA) "lib\$\${mod}.a" "\$(DESTDIR)\$(libdir)/vlc/" ; \
312               \$(INSTALL_DATA) "lib\$\${mod}.a" "\$(DESTDIR)\$(libdir)/vlc/" || exit \$\$?; \
313               ;; \
314           esac; \
315         done
316 endif
317
318 uninstall-local:
319 if USE_LIBTOOL
320         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
321           z=\$\$(\$(VLC_CONFIG) --list plugin); \
322           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
323           test -z "\$\$m" || \
324             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" uninstall-libvlcLTLIBRARIES || exit \$\$?; \
325         fi
326 else
327         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
328         for mod in \$(mods); do \
329           case "\$\$z " \
330             in *\ \$\${mod}\ *) \
331               echo rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" ; \
332               rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" || true; \
333               ;; \
334           esac; \
335         done
336         @z=\$\$(\$(VLC_CONFIG) --list builtin); \
337         for mod in \$(mods); do \
338           case "\$\$z " \
339             in *\ \$\${mod}\ *) \
340               echo rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}.a" ; \
341               rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}.a" || true; \
342               ;; \
343           esac; \
344         done
345 endif
346
347 EOF
348   for mod in $mods
349   do
350     if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
351         NODIST=''; else
352         NODIST='#'; fi
353     cat >> m4/private.m4-tmp4 << EOF
354     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
355 EOF
356 # Generation of modules/**/Makefile.am
357 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
359 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
360 #   the resulting file size.
361 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
362 #   work properly with any automake version I tested.
363     cat >> "${makf}" << EOF
364 # The ${mod} plugin
365
366 EOF
367     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
368 clean_modules += clean-${mod}
369 clean-${mod}:
370         -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
371
372 EOF
373     fi
374     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
375 BUILT_SOURCES += \$(B${mod})
376 EOF
377     fi
378     cat >> "${makf}" << EOF
379 lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
380 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
381 EOF
382     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
383 nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
384 nodist_lib${mod}_plugin_la_SOURCES = \$(nodist_SOURCES_${mod})
385 EOF
386     fi
387     cat >> "${makf}" << EOF
388 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
389 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
390 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
391 lib${mod}_plugin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
392 lib${mod}_plugin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
393 lib${mod}_plugin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
394 lib${mod}_plugin_la_LDFLAGS = \`\$(VLC_CONFIG) --libs plugin ${mod}\` \\
395         -rpath '\$(libvlcdir)' -avoid-version -module -shrext \$(LIBEXT) \\
396         -export-symbol-regex ^\$(VLC_ENTRY)\$\$
397 lib${mod}_plugin_la_LIBADD = \$(LTLIBVLC)
398
399 lib${mod}_a_SOURCES = \$(SOURCES_${mod})
400 lib${mod}_builtin_la_SOURCES = \$(SOURCES_${mod})
401 EOF
402     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
403 nodist_lib${mod}_a_SOURCES = \$(nodist_SOURCES_${mod})
404 nodist_lib${mod}_builtin_la_SOURCES = \$(nodist_SOURCES_${mod})
405 EOF
406     fi
407     cat >> "${makf}" << EOF
408 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin pic ${mod}\`
409 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin pic ${mod}\`
410 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin pic ${mod}\`
411 lib${mod}_builtin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin ${mod}\`
412 lib${mod}_builtin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin ${mod}\`
413 lib${mod}_builtin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin ${mod}\`
414
415 EOF
416   done
417 done
418
419 cat >> m4/private.m4-tmp1 << EOF
420 ])
421 EOF
422 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
423 cat >> m4/private.m4-tmp2 << EOF
424 ])
425 EOF
426 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
427 cat >> m4/private.m4-tmp3 << EOF
428 ])])
429 EOF
430 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
431 cat >> m4/private.m4-tmp4 << EOF
432 BLAH
433 ])
434 EOF
435 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
436
437 echo " done."
438
439 ###
440 ###  classic bootstrap stuff
441 ###
442 set -x
443
444 # remove autotools cruft
445 rm -f aclocal.m4 configure config.log config.h config.h.in
446 rm -Rf autom4te*.cache
447 # remove old autotools extra cruft
448 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
449 # remove new autotools extra cruft
450 rm -Rf autotools
451 mkdir autotools
452 # remove libtool cruft
453 rm -f ltmain.sh libtool ltconfig
454 # remove gettext cruft
455 rm -f ABOUT-NLS
456 rm -Rf intl
457 # remove vlc cruft
458 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
459
460 # Automake complains if these are not present
461 rm -f vlc-config.in && printf "" > vlc-config.in
462 if [ "$GETTEXT" != "yes" ]; then
463   test -d intl || mkdir intl
464   printf "" > intl/Makefile.am
465   printf "" > ABOUT-NLS
466 fi
467
468 # Libtoolize directory
469 ${libtoolize} --copy --force
470 if test -f "ltmain.sh"; then
471   echo "$0: working around a minor libtool issue"
472   mv ltmain.sh autotools/
473 fi
474
475 # Do the rest
476 ${autopoint} -f
477 ${aclocal} ${ACLOCAL_ARGS}
478 ${autoconf}
479 ${autoheader}
480 ${automake} --add-missing --copy -Wall
481
482 ##
483 ##  files which need to be regenerated
484 ##
485 rm -f vlc-config.in vlc-config
486 rm -f src/misc/modules_builtin.h
487
488 # Shut up
489 set +x
490
491 ##
492 ##  Tell the user about gettext, pkg-config and sed
493 ##
494 if [ "${GETTEXT}" = "old" ]; then
495   cat << EOF
496
497 ==========================================================
498 NOTE: you have an old version of gettext installed on your
499 system. The vlc build will work, but if your system does not
500 have libintl you will not have internationalization support.
501 We suggest upgrading to gettext 0.11.5 or later.
502 EOF
503 fi
504
505 if [ "$PKGCONFIG" = "no" ]; then
506   cat << EOF
507
508 ==============================================================
509 NOTE: you do not have the "pkg-config" utility on your system;
510 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
511 reliable.
512 EOF
513 fi
514