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