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