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