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