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