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