]> git.sesse.net Git - vlc/blob - bootstrap
Don't duplicate check for automake 1.7
[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 # Find out which modules were enabled and tell make to build them
226 all-modules:
227 if USE_LIBTOOL
228         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
229         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; \\
230         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; \\
231         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
232         test -z "\$\$fail"
233 else
234         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
235         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; \\
236         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; \\
237         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
238         test -z "\$\$fail"
239 endif
240
241 # Build a plugin with the adequate linker and linker's flags
242 _plugin.a_plugin\$(LIBEXT):
243         @mod="\$*" ; mod=\$\${mod#lib} ; \
244         ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` \$(LIBADD) -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
245         case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
246           c++)  ld="\$(CXXLINK)" ;; \
247           objc) ld="\$(OBJCLINK)" ;; \
248           c|*)  ld="\$(LINK)" ;; \
249         esac ; \
250         echo \$\$ld \$< \$\$ldfl ; \
251         \$\$ld \$< \$\$ldfl
252 #ifneq (,\$(findstring cygwin,\$(host)))
253 #       mv -f "\$@.exe" "\$@"
254 #endif
255         @if test -f "\$@.exe"; then mv -f "\$@.exe" "\$@"; fi
256
257 if MAINTAINER_MODE
258 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
259         cd \$(top_srcdir) && \$(SHELL) ./bootstrap
260 endif
261
262 mostlyclean-local:
263 if USE_LIBTOOL
264         -rm -f *.la
265 else
266         -rm -f *.a *\$(LIBEXT)
267 endif
268
269 clean-local: \$(clean_modules)
270
271 ### automake creates libvlcdir after running install-*-local
272 ### so we have to create it ourselves first
273 install-exec-local: all-modules
274 if USE_LIBTOOL
275         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
276           z=\$\$(\$(VLC_CONFIG) --list plugin); \
277           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
278           test -z "\$\$m" || \
279             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" install-libvlcLTLIBRARIES || exit \$\$? ; \
280         fi
281 else
282         mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
283         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
284         for mod in \$(mods); do \
285           case "\$\$z " \
286             in *\ \$\${mod}\ *) \
287               echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
288               \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || exit \$\$?; \
289               ;; \
290           esac; \
291         done
292         @z=\$\$(\$(VLC_CONFIG) --list builtin); \
293         for mod in \$(mods); do \
294           case "\$\$z " \
295             in *\ \$\${mod}\ *) \
296               echo \$(INSTALL_DATA) "lib\$\${mod}.a" "\$(DESTDIR)\$(libdir)/vlc/" ; \
297               \$(INSTALL_DATA) "lib\$\${mod}.a" "\$(DESTDIR)\$(libdir)/vlc/" || exit \$\$?; \
298               ;; \
299           esac; \
300         done
301 endif
302
303 uninstall-local:
304 if USE_LIBTOOL
305         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
306           z=\$\$(\$(VLC_CONFIG) --list plugin); \
307           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
308           test -z "\$\$m" || \
309             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" uninstall-libvlcLTLIBRARIES || exit \$\$?; \
310         fi
311 else
312         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
313         for mod in \$(mods); do \
314           case "\$\$z " \
315             in *\ \$\${mod}\ *) \
316               echo rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" ; \
317               rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" || true; \
318               ;; \
319           esac; \
320         done
321         @z=\$\$(\$(VLC_CONFIG) --list builtin); \
322         for mod in \$(mods); do \
323           case "\$\$z " \
324             in *\ \$\${mod}\ *) \
325               echo rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}.a" ; \
326               rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}.a" || true; \
327               ;; \
328           esac; \
329         done
330 endif
331
332 EOF
333   for mod in $mods
334   do
335     if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
336         NODIST=''; else
337         NODIST='#'; fi
338     cat >> m4/private.m4-tmp4 << EOF
339     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
340 EOF
341 # Generation of modules/**/Makefile.am
342 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
343 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
344 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
345 #   the resulting file size.
346 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
347 #   work properly with any automake version I tested.
348     cat >> "${makf}" << EOF
349 # The ${mod} plugin
350
351 EOF
352     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
353 clean_modules += clean-${mod}
354 clean-${mod}:
355         -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
356
357 EOF
358     fi
359     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
360 BUILT_SOURCES += \$(B${mod})
361 EOF
362     fi
363     cat >> "${makf}" << EOF
364 lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
365 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
366 EOF
367     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
368 nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
369 nodist_lib${mod}_plugin_la_SOURCES = \$(nodist_SOURCES_${mod})
370 EOF
371     fi
372     cat >> "${makf}" << EOF
373 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
374 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
375 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
376 lib${mod}_plugin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
377 lib${mod}_plugin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
378 lib${mod}_plugin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
379 lib${mod}_plugin_la_LDFLAGS = \`\$(VLC_CONFIG) --libs plugin ${mod}\` \\
380         -rpath '\$(libvlcdir)' -avoid-version -module -shrext \$(LIBEXT)
381 lib${mod}_plugin_la_LIBADD = \$(LTLIBVLC)
382
383 lib${mod}_a_SOURCES = \$(SOURCES_${mod})
384 lib${mod}_builtin_la_SOURCES = \$(SOURCES_${mod})
385 EOF
386     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
387 nodist_lib${mod}_a_SOURCES = \$(nodist_SOURCES_${mod})
388 nodist_lib${mod}_builtin_la_SOURCES = \$(nodist_SOURCES_${mod})
389 EOF
390     fi
391     cat >> "${makf}" << EOF
392 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin \$(pic) ${mod}\`
393 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin \$(pic) ${mod}\`
394 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin \$(pic) ${mod}\`
395 lib${mod}_builtin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin ${mod}\`
396 lib${mod}_builtin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin ${mod}\`
397 lib${mod}_builtin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin ${mod}\`
398
399 EOF
400   done
401 done
402
403 cat >> m4/private.m4-tmp1 << EOF
404 ])
405 EOF
406 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
407 cat >> m4/private.m4-tmp2 << EOF
408 ])
409 EOF
410 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
411 cat >> m4/private.m4-tmp3 << EOF
412 ])])
413 EOF
414 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
415 cat >> m4/private.m4-tmp4 << EOF
416 BLAH
417 ])
418 EOF
419 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
420
421 echo " done."
422
423 ###
424 ###  classic bootstrap stuff
425 ###
426 set -x
427
428 # remove autotools cruft
429 rm -f aclocal.m4 configure config.log config.h config.h.in
430 rm -Rf autom4te*.cache
431 # remove old autotools extra cruft
432 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
433 # remove new autotools extra cruft
434 rm -Rf autotools
435 mkdir autotools
436 # remove libtool cruft
437 rm -f ltmain.sh libtool ltconfig
438 # remove gettext cruft
439 rm -f ABOUT-NLS
440 rm -Rf intl
441 # remove vlc cruft
442 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
443
444 # Automake complains if these are not present
445 rm -f vlc-config.in && printf "" > vlc-config.in
446 if [ "$GETTEXT" != "yes" ]; then
447   test -d intl || mkdir intl
448   printf "" > intl/Makefile.am
449   printf "" > ABOUT-NLS
450 fi
451
452 # Libtoolize directory
453 ${libtoolize} --copy --force
454 if test -f "ltmain.sh"; then
455   echo "$0: working around a minor libtool issue"
456   mv ltmain.sh autotools/
457 fi
458
459 # Do the rest
460 ${autopoint} -f
461 ${aclocal} ${ACLOCAL_ARGS}
462 ${autoconf}
463 ${autoheader}
464 ${automake} --add-missing --copy -Wall
465
466 ##
467 ##  files which need to be regenerated
468 ##
469 rm -f vlc-config.in vlc-config
470 rm -f src/misc/modules_builtin.h
471 rm -f mozilla/vlcintf.h
472
473 # Shut up
474 set +x
475
476 ##
477 ##  Tell the user about gettext, pkg-config and sed
478 ##
479 if [ "${GETTEXT}" = "old" ]; then
480   cat << EOF
481
482 ==========================================================
483 NOTE: you have an old version of gettext installed on your
484 system. The vlc build will work, but if your system does not
485 have libintl you will not have internationalization support.
486 We suggest upgrading to gettext 0.11.5 or later.
487 EOF
488 fi
489
490 if [ "$PKGCONFIG" = "no" ]; then
491   cat << EOF
492
493 ==============================================================
494 NOTE: you do not have the "pkg-config" utility on your system;
495 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
496 reliable.
497 EOF
498 fi
499