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