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