]> git.sesse.net Git - vlc/blob - bootstrap
Don't use undefined variables - should make automake 1.6 happy
[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 #DIST_SUBDIRS = \$(SUBDIRS)
188 EOF
189
190 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
191 do
192   printf "."
193   modf="modules/${dir}/Modules.am"
194   makf="modules/${dir}/Makefile.am"
195   basedir="`echo "${dir}" | cut -f1 -d/`"
196   # automake will not recurse for make dist if we don't define SUBDIRS = .
197   subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
198   mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | xargs`"
199   extra_libs=""
200   for mod in $mods
201   do
202     extra_libs="${extra_libs} lib${mod}_plugin.a"
203     extra_libs="${extra_libs} lib${mod}.a lib${mod}_pic.a"
204   done
205   rm -f "${makf}" && cat > "${makf}" << EOF
206
207 # ${makf} automatically generated from ${modf} by bootstrap
208 # DO NOT EDIT - edit Modules.am instead
209
210 NULL =
211 libvlc_LIBRARIES =
212 noinst_LIBRARIES =
213 noinst_HEADERS =
214 EXTRA_DIST = Modules.am
215 BUILT_SOURCES =
216 SUBDIRS = ${subdirs}
217 #DIST_SUBDIRS = \$(SUBDIRS)
218 libvlcdir = \$(libdir)/vlc/${basedir}
219
220 EXTRA_LIBRARIES = ${extra_libs}
221 include Modules.am
222
223 if !BUILD_MOZILLA
224 pic = no
225 else
226 if HAVE_WIN32
227 dnl There's no need for pic code on win32 so get rid of this to substantially
228 dnl reduce the compilation time.
229 pic = no
230 endif
231 endif
232
233 clean-local:
234         -rm -f *.a *.so *.dll *.sl *.dylib
235
236 all: all-modules
237 all-modules:
238         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
239         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; \\
240         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; \\
241         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; \\
242         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
243         test -z "\$\$fail"
244
245 \$(srcdir)Makefile.am: \$(srcdir)Modules.am \$(top_srcdir)bootstrap
246         cd \$(top_srcdir) && \$(SHELL) ./bootstrap
247
248 EOF
249   for mod in $mods
250   do
251     if grep '^SOURCES_'${mod}'.*=.*PRIVATE' < "${modf}" >/dev/null 2>&1; then
252         PRIVATE='#'; else
253         PRIVATE=''; fi
254     if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
255         NODIST=''; else
256         NODIST='#'; fi
257     cat >> m4/private.m4-tmp4 << EOF
258     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
259 EOF
260 # Generation of modules/**/Makefile.am
261 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
262 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
263 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
264 #   the resulting file size.
265 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
266 #   work properly with any automake version I tested.
267     cat >> "${makf}" << EOF
268 # The ${mod} plugin
269
270 EOF
271     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
272 clean-local: clean-${mod}
273 clean-${mod}:
274         -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
275
276 EOF
277     fi
278     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
279 ${PRIVATE}BUILT_SOURCES += \$(B${mod})
280 EOF
281     fi
282     cat >> "${makf}" << EOF
283 ${PRIVATE}lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
284 EOF
285     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
286 ${PRIVATE}nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
287 EOF
288     fi
289     cat >> "${makf}" << EOF
290 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
291 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
292 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
293
294 lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
295 EOF
296     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
297 nodist_lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
298 EOF
299     fi
300     cat >> "${makf}" << EOF
301 lib${mod}_pic_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin pic ${mod}\`
302 lib${mod}_pic_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin pic ${mod}\`
303 lib${mod}_pic_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin pic ${mod}\`
304
305 lib${mod}_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
306 EOF
307     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
308 nodist_lib${mod}_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
309 EOF
310     fi
311     cat >> "${makf}" << EOF
312 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin ${mod}\`
313 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin ${mod}\`
314 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin ${mod}\`
315
316 lib${mod}dir = \$(libdir)/vlc/${topdir}
317 ${PRIVATE}lib${mod}_plugin\$(LIBEXT): \$(lib${mod}_plugin_a_OBJECTS)
318 ${PRIVATE}      @case \`\$(VLC_CONFIG) --linkage ${mod}\` in \\
319 ${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}\` ;; \\
320 ${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}\` ;; \\
321 ${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}\` ;; \\
322 ${PRIVATE}      esac
323
324
325 EOF
326   done
327 done
328
329 cat >> m4/private.m4-tmp1 << EOF
330 ])
331 EOF
332 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
333 cat >> m4/private.m4-tmp2 << EOF
334 ])
335 EOF
336 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
337 cat >> m4/private.m4-tmp3 << EOF
338 ])])
339 EOF
340 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
341 cat >> m4/private.m4-tmp4 << EOF
342 BLAH
343 ])
344 EOF
345 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
346
347 echo " done."
348
349 ###
350 ###  classic bootstrap stuff
351 ###
352 set -x
353
354 # remove autotools cruft
355 rm -f aclocal.m4 configure config.log config.h config.h.in
356 rm -Rf autom4te.cache
357 # remove old autotools extra cruft
358 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
359 # remove new autotools extra cruft
360 rm -Rf autotools
361 mkdir autotools
362 # remove libtool cruft
363 rm -f ltmain.sh libtool ltconfig
364 # remove gettext cruft
365 rm -f ABOUT-NLS
366 rm -Rf intl
367 # remove old vlc cruft
368 rm -f m4/oldgettext.m4 stamp-pic configure.ac.in Modules.am
369 # remove new vlc cruft
370 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
371
372 # Automake complains if these are not present
373 rm -f vlc-config.in && printf "" > vlc-config.in
374 if [ "$GETTEXT" != "yes" ]; then
375   test -d intl || mkdir intl
376   printf "" > intl/Makefile.am
377   printf "" > ABOUT-NLS
378 fi
379
380 # Do the rest
381 ${autopoint} -f
382 ${aclocal} ${ACLOCAL_ARGS}
383 ${autoconf}
384 ${autoheader}
385 ${automake} --add-missing --copy
386
387 ##
388 ##  files which need to be regenerated
389 ##
390 rm -f vlc-config.in vlc-config
391 rm -f src/misc/modules_builtin.h
392 rm -f mozilla/vlcintf.h
393
394 # Shut up
395 set +x
396
397 ##
398 ##  Tell the user about gettext, pkg-config and sed
399 ##
400 case "${GETTEXT}" in
401   yes) ;;
402   no) cat << EOF
403
404 ===========================================================
405 IMPORTANT NOTE: you do not have gettext installed on your
406 system. The vlc build will work, but you will not have
407 internationalization support. We suggest installing gettext.
408 EOF
409   ;;
410   old) cat << EOF
411
412 ==========================================================
413 NOTE: you have an old version of gettext installed on your
414 system. The vlc build will work, but if your system does not
415 have libintl you will not have internationalization support.
416 We suggest upgrading to gettext 0.11.5 or later.
417 EOF
418   ;;
419 esac
420
421 case "$PKGCONFIG" in
422   yes) ;;
423   no) cat << EOF
424
425 ==============================================================
426 NOTE: you do not have the "pkg-config" utility on your system;
427 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
428 reliable.
429 EOF
430   ;;
431 esac
432
433 case "$AUTOMAKESUCKS" in
434   no) ;;
435   yes) cat << EOF
436
437 =============================================================
438 IMPORTANT NOTE: your version of automake has a bug which will
439 prevent proper plugin compilation. Either compile VLC with
440 the --disable-plugins flag, or use a version of automake newer
441 than 1.6.1 (1.6.2 is OK, and so are the 1.5 series).
442 EOF
443   ;;
444 esac
445
446 case "$INSTALLSUCKS" in
447   no) ;;
448   yes) cat << EOF
449
450 =============================================================
451 IMPORTANT NOTE: your version of automake has a bug which will
452 prevent proper installation. Do not use "make install" with this
453 version of automake, or use a version of automake newer than 1.5
454 (such as 1.6 or 1.7).
455 EOF
456   ;;
457 esac
458