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