3 ## bootstrap file for vlc, the VideoLAN Client
4 ## $Id: bootstrap,v 1.30 2002/11/20 08:58:20 sam Exp $
6 ## Authors: Samuel Hocevar <sam@zoy.org>
9 ### Get a sane environment, just in case
21 if test "$do_help" = "yes"
25 --config create Makefile and configure scripts (read HACKING)
26 --update-vc update Microsoft Visual Studio files
27 --update-po update translation files
36 test "$EMAIL" = "sam@zoy.org" && do_help=yes || do_help=no
39 while test $# -gt 0; do
53 echo "$0: unknown option $1"
62 ## Give help if needed
67 ## Update the MSVC project files
69 if test "$do_vc" = "yes"
73 echo "no Makefile found, did you run ./configure?"
77 echo "generating Visual Studio files..."
82 # Sources that get built under Win32
83 LIBVLC_SOURCES=`make show-libvlc-sources | grep '^X: ' | cut -b3-`
84 LIBVLC_HEADERS=`make show-libvlc-headers | grep '^X: ' | cut -b3-`
85 LIBVLC_PKG_HEADERS=`make show-libvlc-pkg-headers | grep '^X: ' | cut -b3-`
88 rm -f evc/*.vcp msvc/*.dsp
91 for target in evc/libvlc.vcp msvc/libvlc.dsp
94 # Top of the project file
95 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
97 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
99 cat >> ${target} << EOF
100 # Begin Source File${M}
101 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
102 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\"plugins\\" /D DATA_PATH=\\"share\\"${M}
103 # End Source File${M}
106 for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
108 cat >> ${target} << EOF
109 # Begin Group "${subdir}"${M}
111 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
113 if test "${target}" = "evc/libvlc.vcp"
115 cat >> ${target} << EOF
116 # Begin Source File${M}
117 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
118 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\"plugins\\" /D DATA_PATH=\\"share\\"${M}
119 !IF "\$(CFG)" == "vlc - Win32 (WCE MIPS) Release"${M}
120 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
121 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
122 !ELSEIF "\$(CFG)" == "vlc - Win32 (WCE MIPS) Debug"${M}
123 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
124 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
125 !ELSEIF "\$(CFG)" == "vlc - Win32 (WCE SH4) Release"${M}
126 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
127 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
128 !ELSEIF "\$(CFG)" == "vlc - Win32 (WCE SH4) Debug"${M}
129 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
130 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
131 !ELSEIF "\$(CFG)" == "vlc - Win32 (WCE SH3) Release"${M}
132 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
133 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
134 !ELSEIF "\$(CFG)" == "vlc - Win32 (WCE SH3) Debug"${M}
135 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
136 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
137 !ELSEIF "\$(CFG)" == "vlc - Win32 (WCE ARM) Release"${M}
138 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
139 # PROP Output_Dir "ARMRel\\${subdir}"${M}
140 !ELSEIF "\$(CFG)" == "vlc - Win32 (WCE ARM) Debug"${M}
141 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
142 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
143 !ELSEIF "\$(CFG)" == "vlc - Win32 (WCE x86em) Release"${M}
144 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
145 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
146 !ELSEIF "\$(CFG)" == "vlc - Win32 (WCE x86em) Debug"${M}
147 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
148 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
150 # End Source File${M}
153 cat >> ${target} << EOF
154 # Begin Source File${M}
155 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
156 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\"plugins\\" /D DATA_PATH=\\"share\\"${M}
157 !IF "\$(CFG)" == "vlc - Win32 Release"${M}
158 # PROP Intermediate_Dir "Release\\${subdir}"${M}
159 # PROP Output_Dir "Release\\${subdir}"${M}
160 !ELSEIF "\$(CFG)" == "vlc - Win32 Debug"${M}
161 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
162 # PROP Output_Dir "Debug\\${subdir}"${M}
164 # End Source File${M}
168 cat >> ${target} << EOF
173 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
174 for file in ${LIBVLC_HEADERS}
176 cat >> ${target} << EOF
177 # Begin Source File${M}
178 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
179 # End Source File${M}
182 cat >> ${target} << EOF
183 # Begin Group "vlc"${M}
185 for file in ${LIBVLC_PKG_HEADERS}
187 cat >> ${target} << EOF
188 # Begin Source File${M}
189 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
190 # End Source File${M}
193 cat >> ${target} << EOF
196 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
200 grep '^L_[^ ]*_pic =' Modules.am | while read a b c
202 makefile="`echo $c | sed -e 's@/[^/]*$@/Modules.am@'`"
203 plugin="`echo $a | sed 's/L_\(.*\)_pic/\1/'`"
204 # this is an attempt at getting a list of plugin sources... we take the
205 # production and remove everything that does not contain "module", which
206 # means you miss $(NULL), but other variables too.
207 cfiles=`awk 'BEGIN{a=0}{if(!a&&/^SOURCES_'${plugin}'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < ${makefile} | tr '\\ ' '\n\n' | sed -ne 's,/,\\\\,g; s/.*modules/modules/p'`
208 hfiles=`for i in ${cfiles} ; do echo $i ; done | grep '\.h$'`
209 cfiles=`for i in ${cfiles} ; do echo $i ; done | grep -v '\.h$'`
212 test "${dir}" = "evc" && suf="vcp" || suf="dsp"
213 source="${dir}/plugins.${suf}.in"
214 target="${dir}/plugin_${plugin}.${suf}"
216 perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
217 for cfile in ${cfiles}
219 cat >> ${target} << EOF
220 # Begin Source File${M}
221 SOURCE="..\\${cfile}"${M}
222 # End Source File${M}
225 # sed is really nicer for this... unfortunately it's broken under cygwin
226 # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
227 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
228 for hfile in ${hfiles}
230 cat >> ${target} << EOF
231 # Begin Source File${M}
232 SOURCE="..\\${hfile}"${M}
233 # End Source File${M}
236 # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
237 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
242 for target in evc/vlc.vcp msvc/vlc.dsp
245 # Top of the project file
246 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
248 if test "${target}" = "evc/vlc.vcp"
250 cat >> ${target} << EOF
251 # Begin Source File${M}
252 SOURCE="..\\evc\\vlc.c"${M}
253 # End Source File${M}
256 cat >> ${target} << EOF
257 # Begin Source File${M}
258 SOURCE="..\\src\\vlc.c"${M}
259 # End Source File${M}
262 # Bottom of the project file - handles resource files too
263 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
271 ## Update the potfiles because no one ever does it
273 if test "$do_po" = "yes"
276 make update-po #2>&1 | grep '^[^:]*:$' | cut -f1 -d: | tr '\n' ' ' | sed 's/ $//'
283 ## Check that our tools don't suck
286 if test ! 20000 -eq `perl -e 'printf "%s\n","a"x20000' | sed -e 's/.//' 2>/dev/null | wc -c`
295 ## Generate the modules makefile, by parsing modules/**/Modules.am
298 printf "generating Modules.am and configure.ac"
303 ALL_FLAGS="`sed -n -e '/^[^=A-Z]*[A-Z]*FLAGS_[^=]*=/s/[^=A-Z]*\([A-Z]*FLAGS_[^=]*=\).*/\1/p' < configure.ac.in | sort | uniq`"
305 cat >> configure.ac << EOF
306 dnl ################################################################
307 dnl # Do not edit this file, it was generated from configure.ac.in #
308 dnl ################################################################
311 sed -n -e '/dnl do not touch this line/q;p' < configure.ac.in >> configure.ac
314 for mf in `sed -ne 's@[^a-z]*\([^ ]*\)am.*@modules/\1am@p' < modules/Makefile.am`
317 dir=`echo ${mf} | sed -e 's@\(.*\)/.*@\1@'`
318 topdir=`echo ${dir} | cut -f2 -d/`
319 sym=`echo ${dir} | sed -e 'y@/@_@'`
320 cat >> Modules.am << EOF
323 include ${dir}/Modules.am
326 sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf} | while read mod
329 if echo "$ALL_FLAGS" | grep '^CPPFLAGS_'${mod}'=$' >/dev/null 2>&1; then
330 echo "AC_SUBST(CPPFLAGS_${mod})" >> configure.ac; fi
331 if echo "$ALL_FLAGS" | grep '^CFLAGS_'${mod}'=$' >/dev/null 2>&1; then
332 echo "AC_SUBST(CFLAGS_${mod})" >> configure.ac; fi
333 if echo "$ALL_FLAGS" | grep '^CXXFLAGS_'${mod}'=$' >/dev/null 2>&1; then
335 echo "AC_SUBST(CXXFLAGS_${mod})" >> configure.ac; fi
336 if echo "$ALL_FLAGS" | grep '^OBJCFLAGS_'${mod}'=$' >/dev/null 2>&1; then
338 echo "AC_SUBST(OBJCFLAGS_${mod})" >> configure.ac; fi
339 if echo "$ALL_FLAGS" | grep '^LDFLAGS_'${mod}'=$' >/dev/null 2>&1; then
340 echo "AC_SUBST(LDFLAGS_${mod})" >> configure.ac; fi
341 if grep '^SOURCES_'${mod}'.*=.*PRIVATE' < ${mf} >/dev/null 2>&1; then
344 if grep '^nodist_SOURCES_'${mod}'' < ${mf} >/dev/null 2>&1; then
347 cat >> configure.ac << EOF
348 AM_CONDITIONAL(${mod}_plugin, test x\$${mod}_plugin = xyes)
349 AM_CONDITIONAL(${mod}_builtin, test x\$${mod}_builtin = xyes)
351 # Generation of Modules.am
352 # ~~~~~~~~~~~~~~~~~~~~~~~~
353 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
354 # S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
355 # the resulting file size.
356 # - *_CFLAGS, *_CXXFLAGS etc. include *_CPPFLAGS because per-object CPPFLAGS
357 # does not seem to work properly with any automake version I tested.
358 cat >> Modules.am << EOF
363 L_${mod}_p = ${dir}/lib${mod}_plugin.a
365 D_${mod}_p = ${dir}/lib${mod}_plugin\$(LIBEXT)
366 ${NODIST}B_${mod}_p = \$(nodist_SOURCES_${mod})
369 L_${mod}_b = ${dir}/lib${mod}.a
370 F_${mod}_b = \$(LDFLAGS_${mod})
372 L_${mod}_pic = ${dir}/lib${mod}_pic.a
374 ${NODIST}B_${mod}_b = \$(nodist_SOURCES_${mod})
377 L_builtin += \$(L_${mod}_b)
378 L_builtin_pic += \$(L_${mod}_pic)
379 LDFLAGS_builtin += \$(F_${mod}_b)
380 ${PRIVATE}BUILT_SOURCES += \$(B_${mod}_p) \$(B_${mod}_b)
381 PLUGIN_FILES += \$(D_${mod}_p)
383 ${PRIVATE}${sym}_lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
384 ${NODIST}${PRIVATE}nodist_${sym}_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
385 ${sym}_lib${mod}_plugin_a_CPPFLAGS = \$(CPPFLAGS_plugin) \$(CPPFLAGS_${mod}) -DMODULE_NAME=${mod} -DMODULE_NAME_IS_${mod}
386 ${sym}_lib${mod}_plugin_a_CFLAGS = \$(CFLAGS_plugin) \$(CFLAGS_${mod}) \$(${sym}_lib${mod}_plugin_a_CPPFLAGS)
387 ${sym}_lib${mod}_plugin_a_CXXFLAGS = \$(CXXFLAGS_plugin) \$(CXXFLAGS_${mod}) \$(${sym}_lib${mod}_plugin_a_CPPFLAGS)
388 ${sym}_lib${mod}_plugin_a_OBJCFLAGS = \$(OBJCFLAGS_plugin) \$(OBJCFLAGS_${mod}) \$(${sym}_lib${mod}_plugin_a_CPPFLAGS)
390 ${sym}_lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
391 ${NODIST}nodist_${sym}_lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
392 ${sym}_lib${mod}_pic_a_CPPFLAGS = \$(CPPFLAGS_builtin_pic) \$(CPPFLAGS_${mod}) -DMODULE_NAME=${mod} -DMODULE_NAME_IS_${mod}
393 ${sym}_lib${mod}_pic_a_CFLAGS = \$(CFLAGS_builtin_pic) \$(CFLAGS_${mod}) \$(${sym}_lib${mod}_pic_a_CPPFLAGS)
394 ${sym}_lib${mod}_pic_a_CXXFLAGS = \$(CXXFLAGS_builtin_pic) \$(CXXFLAGS_${mod}) \$(${sym}_lib${mod}_pic_a_CPPFLAGS)
395 ${sym}_lib${mod}_pic_a_OBJCFLAGS = \$(OBJCFLAGS_builtin_pic) \$(OBJCFLAGS_${mod}) \$(${sym}_lib${mod}_pic_a_CPPFLAGS)
397 ${sym}_lib${mod}_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
398 ${NODIST}nodist_${sym}_lib${mod}_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
399 ${sym}_lib${mod}_a_CPPFLAGS = \$(CPPFLAGS_builtin) \$(CPPFLAGS_${mod}) -DMODULE_NAME=${mod} -DMODULE_NAME_IS_${mod}
400 ${sym}_lib${mod}_a_CFLAGS = \$(CFLAGS_builtin) \$(CFLAGS_${mod}) \$(${sym}_lib${mod}_a_CPPFLAGS)
401 ${sym}_lib${mod}_a_CXXFLAGS = \$(CXXFLAGS_builtin) \$(CXXFLAGS_${mod}) \$(${sym}_lib${mod}_a_CPPFLAGS)
402 ${sym}_lib${mod}_a_OBJCFLAGS = \$(OBJCFLAGS_builtin) \$(OBJCFLAGS_${mod}) \$(${sym}_lib${mod}_a_CPPFLAGS)
404 libvlc_LIBRARIES += \$(L_${mod}_b) \$(L_${mod}_pic)
405 lib${mod}_DATA = \$(D_${mod}_p)
407 lib${mod}dir = \$(libdir)/vlc/${topdir}
408 ${PRIVATE}noinst_LIBRARIES += \$(L_${mod}_p)
409 ${PRIVATE}${dir}/lib${mod}_plugin\$(LIBEXT): \$(${sym}_lib${mod}_plugin_a_OBJECTS)
410 ${PRIVATE} \$(${LINKER}) \$^ -shared \$(LDFLAGS_plugins) \$(LDFLAGS_${mod})
417 echo "AM_CONDITIONAL(UNTRUE, false)" >> configure.ac
418 sed -n -e '/dnl do not touch this line/,//p' < configure.ac.in >> configure.ac
423 ### classic bootstrap stuff
426 rm -f aclocal.m4 m4/oldgettext.m4 configure config.guess config.log config.sub ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh
430 if gettextize --version >/dev/null 2>&1
432 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
433 '>' 0.11.2 >/dev/null 2>&1
435 # We have gettext, and a recent version! Everything is cool.
439 # User's gettext is too old. try to continue anyway.
441 echo > intl/Makefile.am
442 echo 'AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])' > m4/oldgettext.m4
445 # we don't have gettext. grmbl. try to continue anyway.
447 echo > intl/Makefile.am
448 echo 'AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])' > m4/oldgettext.m4
454 if automake-1.7 --version >/dev/null 2>&1
458 if automake-1.6 --version >/dev/null 2>&1
461 if expr "`automake-1.6 --version | sed -e '1s/[^0-9]*//' -e q`" "<=" "1.6.1" > /dev/null 2>&1
462 then AUTOMAKESUCKS=yes
465 if automake-1.5 --version >/dev/null 2>&1
469 if automake --version > /dev/null 2>&1
471 amvers=`automake --version | sed -e '1s/[^0-9]*//' -e q`
477 if expr "$amvers" "<" "1.5" > /dev/null 2>&1
486 if test x$amvers = xnone
489 echo "you need automake version 1.5 or later"
494 aclocal${amvers} -I m4 || exit 1
497 automake${amvers} --foreign --add-missing --copy || PERLSUCKS=yes
505 echo "==========================================================="
506 echo "IMPORTANT NOTE: automake failed. On certain systems this is"
507 echo "because of insufficient stack size. Please set the stack"
508 echo "size to something bigger or unlimited (\`unlimit stacksize')"
509 echo "and try again."
514 # Wrap automake's long lines, because the Solaris sed doesn't support lines
515 # longer than 3999 characters, and ./configure calls sed. We use Perl instead
516 # of sed for obvious reasons :)
517 perl -ne 'if(/^.{500}/) {s/(.{200}[^ ]* )/$1\\\n\t/g} print $_' < Makefile.in > Makefile.in.tmp && mv Makefile.in.tmp Makefile.in
522 ## headers which need to be regenerated
524 rm -f src/misc/modules_builtin.h src/misc/modules_plugin.h
525 rm -f include/vlc_symbols.h
526 rm -f mozilla/vlcintf.h
534 ## Glade sometimes sucks
536 echo "workarounds for annoying glade features"
537 for file in gnome_interface.c gtk_interface.c
539 if grep "DO NOT EDIT THIS FILE" modules/gui/gtk/$file 2>&1 > /dev/null
541 rm -f /tmp/$$.$file.bak
542 cat > /tmp/$$.$file.bak << EOF
543 /* This file was created automatically by glade and fixed by bootstrap */
548 -e 's#_("-:--:--")#"-:--:--"#' \
549 -e 's#_("---")#"---"#' \
550 -e 's#_("--")#"--"#' \
551 -e 's#_("/dev/dvd")#"/dev/dvd"#' \
552 -e 's#_(\("./."\))#\1#' \
553 < modules/gui/gtk/$file >> /tmp/$$.$file.bak
554 mv -f /tmp/$$.$file.bak modules/gui/gtk/$file
559 if grep "DO NOT EDIT THIS FILE" modules/gui/gtk/$file 2>&1 > /dev/null
561 rm -f /tmp/$$.$file.bak
562 sed -e 's/DO NOT EDIT THIS FILE.*/This file was created automatically by glade and fixed by bootstrap/ ; s/#if.*ENABLE_NLS.*/#if defined( ENABLE_NLS ) \&\& defined ( HAVE_GETTEXT )/' < modules/gui/gtk/$file > /tmp/$$.$file.bak
563 mv -f /tmp/$$.$file.bak modules/gui/gtk/$file
567 ## Tell the user about gettext and sed
574 echo "==========================================================="
575 echo "IMPORTANT NOTE: you do not have gettext installed on your"
576 echo "system. The vlc build will work, but you will not have"
577 echo "internationalization support. We suggest installing gettext."
581 echo "=========================================================="
582 echo "NOTE: you have an old version of gettext installed on your"
583 echo "system. We suggest upgrading to gettext 0.11.3 or later."
587 case "$AUTOMAKESUCKS" in
592 echo "============================================================="
593 echo "IMPORTANT NOTE: your version of automake has a bug which will"
594 echo "prevent proper plugin compilation. Either compile VLC with"
595 echo "the --disable-plugins flag, or use a version of automake newer"
596 echo "than 1.6.1 (1.6.2 is OK, and so are the 1.5 series)."
605 echo "============================================================="
606 echo "IMPORTANT NOTE: the version of 'sed' on your system is unable"
607 echo "to handle long lines. bootstrap will try its best to generate"
608 echo "a correct Makefile, but you should expect problems. We highly"
609 echo "recommend installing GNU sed."