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