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