build.sh: add -f flag to append list of modules to a file.
[xorg-util-modular.git] / build.sh
blob6b4f7521335a22ade6b8f4cc2e1274a151972871
1 #!/bin/sh
3 # global environment variables you may set:
4 # CACHE: absolute path to a global autoconf cache
5 # QUIET: hush the configure script noise
6 # CONFFLAGS: flags to pass to all configure scripts
7 # CONFCFLAGS: flags to pass to all configure scripts in ""
8 # MAKEFLAGS: flags to pass to all make calls
9 # LIBDIR: Path under $prefix for libraries (e.g., lib64)
11 failed_components=""
12 nonexistent_components=""
14 failed() {
15 if test x"$NOQUIT" = x1; then
16 echo "***** $1 failed on $2/$3"
17 failed_components="$failed_components $2/$3"
18 else
19 exit 1
23 checkfortars() {
24 M=$1
25 C=$2
26 case $M in
27 "data")
28 case $C in
29 "cursors") C="xcursor-themes" ;;
30 "bitmaps") C="xbitmaps" ;;
31 esac
33 "font")
34 if [ "$C" != "encodings" ]; then
35 C="font-$C"
38 "lib")
39 case $C in
40 "libXRes") C="libXres" ;;
41 "libxtrans") C="xtrans" ;;
42 esac
44 "pixman")
45 M="lib"
46 C="pixman"
48 "proto")
49 case $C in
50 "evieproto") C="evieext" ;;
51 "x11proto") C="xproto" ;;
52 esac
54 "util")
55 case $C in
56 "cf") C="xorg-cf-files" ;;
57 "macros") C="util-macros" ;;
58 esac
60 "xcb")
61 case $C in
62 "proto") C="xcb-proto" ;;
63 "pthread-stubs") M="lib"; C="libpthread-stubs" ;;
64 "util") C="xcb-util" ;;
65 esac
67 "xserver")
68 C="xorg-server"
70 esac
71 for ii in $M .; do
72 for jj in bz2 gz; do
73 TARFILE=`ls -1rt $ii/$C-*.tar.$jj 2> /dev/null | tail -n 1`
74 if [ -n "$TARFILE" ]; then
75 SRCDIR=`echo $TARFILE | sed "s,.tar.$jj,,"`
76 if [ ! -d $SRCDIR ]; then
77 TAROPTS=xjf
78 if [ "$jj" = "gz" ]; then
79 TAROPTS=xzf
81 tar $TAROPTS $TARFILE -C $ii || failed tar $1 $2
83 return
85 done
86 done
89 build() {
90 if [ -n "$RESUME" ]; then
91 if [ "$RESUME" = "$1/$2" ]; then
92 unset RESUME
93 # Resume build at this module
94 else
95 echo "Skipping $1 module component $2..."
96 return 0
100 SRCDIR=""
101 CONFCMD=""
102 if [ -f $1/$2/autogen.sh ]; then
103 SRCDIR="$1/$2"
104 CONFCMD="autogen.sh"
105 else
106 checkfortars $1 $2
107 CONFCMD="configure"
110 if [ -z $SRCDIR ]; then
111 echo "$1 module component $2 does not exist, skipping."
112 nonexistent_components="$nonexistent_components $1/$2"
113 return
116 echo "Building $1 module component $2..."
118 if test x"$BUILT_MODULES_FILE" != "x"; then
119 echo "$1/$2" >> $BUILT_MODULES_FILE
122 old_pwd=`pwd`
123 cd $SRCDIR || failed cd1 $1 $2
125 if test x"$PULL" = x1; then
126 git pull --rebase || failed "git pull" $1 $2
129 # Build outside source directory
130 if [ "x$DIR_ARCH" != x ] ; then
131 mkdir -p "$DIR_ARCH" || failed mkdir $1 $2
132 if cd "$DIR_ARCH" ; then :; else
133 failed cd2 $1 $2
134 cd ${old_pwd}
135 return
139 # Special configure flags for certain modules
140 MOD_SPECIFIC=
142 if test "$1" = "lib" && test "$2" = "libX11" && test x"$USE_XCB" = xNO; then
143 MOD_SPECIFIC="--with-xcb=no"
146 LIB_FLAGS=
147 if test x$LIBDIR != x ; then
148 LIB_FLAGS="--libdir=${PREFIX}/${LIBDIR}"
151 # Use "sh autogen.sh" since some scripts are not executable in CVS
152 if test "x$NOAUTOGEN" != x1 ; then
153 sh ${DIR_CONFIG}/${CONFCMD} --prefix=${PREFIX} ${LIB_FLAGS} \
154 ${MOD_SPECIFIC} ${QUIET:+--quiet} \
155 ${CACHE:+--cache-file=}${CACHE} ${CONFFLAGS} "$CONFCFLAGS" || \
156 failed ${CONFCMD} $1 $2
158 ${MAKE} $MAKEFLAGS || failed make $1 $2
159 if test x"$CLEAN" = x1; then
160 ${MAKE} $MAKEFLAGS clean || failed clean $1 $2
162 if test x"$DIST" = x1; then
163 ${MAKE} $MAKEFLAGS dist || failed dist $1 $2
165 if test x"$DISTCHECK" = x1; then
166 ${MAKE} $MAKEFLAGS distcheck || failed distcheck $1 $2
168 $SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install || \
169 failed install $1 $2
171 cd ${old_pwd}
173 if test x"$BUILD_ONE" = x1; then
174 echo "Single-component build complete"
175 exit 0
179 # protocol headers have no build order dependencies
180 build_proto() {
181 build proto applewmproto
182 build proto bigreqsproto
183 build proto compositeproto
184 build proto damageproto
185 build proto dmxproto
186 build proto dri2proto
187 build proto evieproto
188 build proto fixesproto
189 build proto fontcacheproto
190 build proto fontsproto
191 build proto glproto
192 build proto inputproto
193 build proto kbproto
194 build proto randrproto
195 build proto recordproto
196 build proto renderproto
197 build proto resourceproto
198 build proto scrnsaverproto
199 build proto trapproto
200 build proto videoproto
201 build proto windowswmproto
202 build proto x11proto
203 build proto xcmiscproto
204 build proto xextproto
205 build proto xf86bigfontproto
206 build proto xf86dgaproto
207 build proto xf86driproto
208 build proto xf86miscproto
209 build proto xf86vidmodeproto
210 build proto xineramaproto
211 if test x"$USE_XCB" != xNO ; then
212 build xcb proto
216 # bitmaps is needed for building apps, so has to be done separately first
217 # cursors depends on apps/xcursorgen
218 # xkbdata is obsolete - use xkbdesc from xkeyboard-config instead
219 build_data() {
220 # build data bitmaps
221 build data cursors
222 # build data xkbdata
225 # All protocol modules must be installed before the libs (okay, that's an
226 # overstatement, but all protocol modules should be installed anyway)
228 # the libraries have a dependency order:
229 # xtrans, Xau, Xdmcp before anything else
230 # fontenc before Xfont
231 # ICE before SM
232 # X11 before Xext
233 # (X11 and SM) before Xt
234 # Xt before Xmu and Xpm
235 # Xext before any other extension library
236 # Xfixes before Xcomposite
237 # Xp before XprintUtil before XprintAppUtil
239 # If xcb is being used for libX11, it must be built before libX11, but after
240 # Xau & Xdmcp
242 build_lib() {
243 build lib libxtrans
244 build lib libXau
245 build lib libXdmcp
246 if test x"$USE_XCB" != xNO ; then
247 build xcb pthread-stubs
248 build xcb libxcb
250 build lib libX11
251 build lib libXext
252 build lib libAppleWM
253 build lib libWindowsWM
254 build lib libdmx
255 build lib libfontenc
256 build lib libFS
257 build lib libICE
258 #build lib liblbxutil
259 #build lib liboldX
260 build lib libSM
261 build lib libXt
262 build lib libXmu
263 build lib libXpm
264 build lib libXaw
265 build lib libXfixes
266 build lib libXcomposite
267 build lib libXrender
268 build lib libXdamage
269 build lib libXcursor
270 build lib libXevie
271 build lib libXfont
272 build lib libXfontcache
273 build lib libXft
274 build lib libXi
275 build lib libXinerama
276 build lib libxkbfile
277 build lib libxkbui
278 build lib libXrandr
279 build lib libXRes
280 build lib libXScrnSaver
281 build lib libXTrap
282 build lib libXtst
283 build lib libXv
284 build lib libXvMC
285 build lib libXxf86dga
286 build lib libXxf86misc
287 build lib libXxf86vm
288 build lib libpciaccess
289 build pixman ""
292 # Most apps depend at least on libX11.
294 # bdftopcf depends on libXfont
295 # mkfontscale depends on libfontenc and libfreetype
296 # mkfontdir depends on mkfontscale
298 # TODO: detailed breakdown of which apps require which libs
299 build_app() {
300 build app appres
301 build app bdftopcf
302 build app beforelight
303 build app bitmap
304 build app editres
305 build app fonttosfnt
306 build app fslsfonts
307 build app fstobdf
308 build app iceauth
309 build app ico
310 build app listres
311 build app luit
312 build app mkfontdir
313 build app mkfontscale
314 build app oclock
315 build app rgb
316 build app rendercheck
317 build app rstart
318 build app scripts
319 build app sessreg
320 build app setxkbmap
321 build app showfont
322 build app smproxy
323 build app twm
324 build app viewres
325 build app x11perf
326 build app xauth
327 build app xbacklight
328 build app xbiff
329 build app xcalc
330 build app xclipboard
331 build app xclock
332 build app xcmsdb
333 build app xconsole
334 build app xcursorgen
335 build app xdbedizzy
336 build app xditview
337 build app xdm
338 build app xdpyinfo
339 build app xdriinfo
340 build app xedit
341 build app xev
342 build app xeyes
343 build app xf86dga
344 build app xfd
345 build app xfontsel
346 build app xfs
347 build app xfsinfo
348 build app xgamma
349 build app xgc
350 build app xhost
351 build app xinit
352 build app xinput
353 build app xkbcomp
354 build app xkbevd
355 build app xkbprint
356 build app xkbutils
357 build app xkill
358 build app xload
359 build app xlogo
360 build app xlsatoms
361 build app xlsclients
362 build app xlsfonts
363 build app xmag
364 build app xman
365 build app xmessage
366 build app xmh
367 build app xmodmap
368 build app xmore
369 build app xprop
370 build app xrandr
371 build app xrdb
372 build app xrefresh
373 build app xset
374 build app xsetmode
375 build app xsetpointer
376 build app xsetroot
377 build app xsm
378 build app xstdcmap
379 build app xtrap
380 build app xvidtune
381 build app xvinfo
382 build app xwd
383 build app xwininfo
384 build app xwud
385 # if test x"$USE_XCB" != xNO ; then
386 # build xcb demo
387 # fi
390 build_mesa() {
391 build mesa drm
392 #build mesa mesa
395 # The server requires at least the following libraries:
396 # Xfont, Xau, Xdmcp, pciaccess
397 build_xserver() {
398 build xserver ""
401 build_driver_input() {
402 # Some drivers are only buildable on some OS'es
403 case $HOST_OS in
404 Linux)
405 build driver xf86-input-aiptek
406 build driver xf86-input-evdev
407 build driver xf86-input-joystick
408 #build driver xf86-input-ur98
410 *BSD*)
411 build driver xf86-input-joystick
415 esac
417 # And some drivers are only buildable on some CPUs.
418 case $HOST_CPU in
419 i*86* | amd64* | x86*64*)
420 build driver xf86-input-vmmouse
424 esac
426 build driver xf86-input-acecad
427 #build driver xf86-input-calcomp
428 #build driver xf86-input-citron
429 #build driver xf86-input-digitaledge
430 #build driver xf86-input-dmc
431 #build driver xf86-input-dynapro
432 #build driver xf86-input-elo2300
433 #build driver xf86-input-elographics
434 #build driver xf86-input-fpit
435 #build driver xf86-input-hyperpen
436 #build driver xf86-input-jamstudio
437 build driver xf86-input-keyboard
438 #build driver xf86-input-magellan
439 #build driver xf86-input-magictouch
440 #build driver xf86-input-microtouch
441 build driver xf86-input-mouse
442 #build driver xf86-input-mutouch
443 #build driver xf86-input-palmax
444 #build driver xf86-input-penmount
445 #build driver xf86-input-spaceorb
446 #build driver xf86-input-summa
447 build driver xf86-input-synaptics
448 #build driver xf86-input-tek4957
449 build driver xf86-input-void
452 build_driver_video() {
453 # Some drivers are only buildable on some OS'es
454 case $HOST_OS in
455 *FreeBSD*)
456 case $HOST_CPU in
457 sparc64)
458 build driver xf86-video-sunffb
462 esac
464 *NetBSD* | *OpenBSD*)
465 build driver xf86-video-wsfb
466 build driver xf86-video-sunffb
468 *Linux*)
469 build driver xf86-video-sisusb
470 build driver xf86-video-sunffb
471 build driver xf86-video-v4l
475 esac
477 # Some drivers are only buildable on some architectures
478 case $HOST_CPU in
479 *sparc*)
480 build driver xf86-video-sunbw2
481 build driver xf86-video-suncg14
482 build driver xf86-video-suncg3
483 build driver xf86-video-suncg6
484 build driver xf86-video-sunleo
485 build driver xf86-video-suntcx
487 i*86* | amd64* | x86*64*)
488 build driver xf86-video-i740
489 build driver xf86-video-intel
490 # build driver xf86-video-via
494 esac
496 build driver xf86-video-apm
497 build driver xf86-video-ark
498 build driver xf86-video-ast
499 build driver xf86-video-ati
500 build driver xf86-video-chips
501 build driver xf86-video-cirrus
502 build driver xf86-video-dummy
503 build driver xf86-video-fbdev
504 build driver xf86-video-geode
505 # build driver xf86-video-glide
506 build driver xf86-video-glint
507 build driver xf86-video-i128
508 build driver xf86-video-imstt
509 build driver xf86-video-mga
510 build driver xf86-video-neomagic
511 build driver xf86-video-newport
512 build driver xf86-video-nouveau
513 build driver xf86-video-nv
514 build driver xf86-video-radeonhd
515 build driver xf86-video-rendition
516 build driver xf86-video-s3
517 build driver xf86-video-s3virge
518 build driver xf86-video-savage
519 build driver xf86-video-siliconmotion
520 build driver xf86-video-sis
521 build driver xf86-video-tdfx
522 build driver xf86-video-tga
523 build driver xf86-video-trident
524 build driver xf86-video-tseng
525 build driver xf86-video-vesa
526 build driver xf86-video-vmware
527 build driver xf86-video-voodoo
528 build driver xf86-video-xgi
529 build driver xf86-video-xgixp
532 # The server must be built before the drivers
533 build_driver() {
534 # XQuartz doesn't need these...
535 case $HOST_OS in
536 Darwin*) return 0 ;;
537 esac
539 build_driver_input
540 build_driver_video
543 # All fonts require mkfontscale and mkfontdir to be available
545 # The following fonts require bdftopcf to be available:
546 # adobe-100dpi, adobe-75dpi, adobe-utopia-100dpi, adobe-utopia-75dpi,
547 # arabic-misc, bh-100dpi, bh-75dpi, bh-lucidatypewriter-100dpi,
548 # bh-lucidatypewriter-75dpi, bitstream-100dpi, bitstream-75dpi,
549 # cronyx-cyrillic, cursor-misc, daewoo-misc, dec-misc, isas-misc,
550 # jis-misc, micro-misc, misc-cyrillic, misc-misc, mutt-misc,
551 # schumacher-misc, screen-cyrillic, sony-misc, sun-misc and
552 # winitzki-cyrillic
554 # Within the font module, the util component must be built before the
555 # following fonts:
556 # adobe-100dpi, adobe-75dpi, adobe-utopia-100dpi, adobe-utopia-75dpi,
557 # bh-100dpi, bh-75dpi, bh-lucidatypewriter-100dpi, bh-lucidatypewriter-75dpi,
558 # misc-misc and schumacher-misc
560 # The alias component is recommended to be installed after the other fonts
561 # since the fonts.alias files reference specific fonts installed from the
562 # other font components
563 build_font() {
564 build font util
565 build font encodings
566 build font adobe-100dpi
567 build font adobe-75dpi
568 build font adobe-utopia-100dpi
569 build font adobe-utopia-75dpi
570 build font adobe-utopia-type1
571 build font arabic-misc
572 build font bh-100dpi
573 build font bh-75dpi
574 build font bh-lucidatypewriter-100dpi
575 build font bh-lucidatypewriter-75dpi
576 build font bh-ttf
577 build font bh-type1
578 build font bitstream-100dpi
579 build font bitstream-75dpi
580 build font bitstream-speedo
581 build font bitstream-type1
582 build font cronyx-cyrillic
583 build font cursor-misc
584 build font daewoo-misc
585 build font dec-misc
586 build font ibm-type1
587 build font isas-misc
588 build font jis-misc
589 build font micro-misc
590 build font misc-cyrillic
591 build font misc-ethiopic
592 build font misc-meltho
593 build font misc-misc
594 build font mutt-misc
595 build font schumacher-misc
596 build font screen-cyrillic
597 build font sony-misc
598 build font sun-misc
599 build font winitzki-cyrillic
600 build font xfree86-type1
601 build font alias
604 # makedepend requires xproto
605 build_util() {
606 build util cf
607 build util imake
608 build util makedepend
609 build util gccmakedep
610 build util lndir
611 if test x"$USE_XCB" != xNO ; then
612 build xcb util
615 build xkeyboard-config ""
618 # xorg-docs requires xorg-sgml-doctools
619 build_doc() {
620 build doc xorg-sgml-doctools
621 build doc xorg-docs
624 usage() {
625 echo "Usage: $0 [options] prefix"
626 echo " where options are:"
627 echo " -a : do NOT run auto config tools (autogen.sh, configure)"
628 echo " -b : use .build.$HAVE_ARCH build directory"
629 echo " -c : run make clean in addition to others"
630 echo " -d : run make distcheck in addition to others"
631 echo " -D : run make dist in addition to others"
632 echo " -f file: append module being built to file. The last line of this"
633 echo " file can be used for resuming with -r."
634 echo " -g : build with debug information"
635 echo " -n : do not quit after error; just print error message"
636 echo " -o module/component : build just this component"
637 echo " -p : run git pull on each component"
638 echo " -r module/component : resume building with this comonent"
639 echo " -s sudo-command : sudo command to use"
642 HAVE_ARCH="`uname -i`"
643 DIR_ARCH=""
644 DIR_CONFIG="."
645 LIB_ONLY=0
647 # Process command line args
648 while test $# != 0
650 case $1 in
652 NOAUTOGEN=1
655 DIR_ARCH=".build.$HAVE_ARCH"
656 DIR_CONFIG=".."
659 CLEAN=1
662 DISTCHECK=1
665 DIST=1
668 shift
669 BUILT_MODULES_FILE=$1
672 CFLAGS="-g3 -O0"
673 export CFLAGS
674 CONFCFLAGS="CFLAGS=-g3 -O0"
677 LIB_ONLY=1
680 NOQUIT=1
683 shift
684 RESUME=$1
685 BUILD_ONE=1
688 PULL=1
691 shift
692 RESUME=$1
695 shift
696 SUDO=$1
699 PREFIX=$1
701 esac
703 shift
704 done
706 if test x"${PREFIX}" = x ; then
707 usage
708 exit
711 HOST_OS=`uname -s`
712 HOST_CPU=`uname -m`
714 if test x$LIBDIR = x ; then
715 LIBDIR=lib
718 export HOST_OS
719 export HOST_CPU
720 export LIBDIR
722 echo "Building to run $HOST_OS / $HOST_CPU ($HOST)"
724 # Must create local aclocal dir or aclocal fails
725 ACLOCAL_LOCALDIR="${DESTDIR}${PREFIX}/share/aclocal"
726 $SUDO mkdir -p ${ACLOCAL_LOCALDIR}
728 # The following is required to make aclocal find our .m4 macros
729 if test x"$ACLOCAL" = x; then
730 ACLOCAL="aclocal -I ${ACLOCAL_LOCALDIR}"
731 else
732 ACLOCAL="${ACLOCAL} -I ${ACLOCAL_LOCALDIR}"
734 export ACLOCAL
736 # The following is required to make pkg-config find our .pc metadata files
737 if test x"$PKG_CONFIG_PATH" = x; then
738 PKG_CONFIG_PATH=${DESTDIR}${PREFIX}/${LIBDIR}/pkgconfig
739 else
740 PKG_CONFIG_PATH=${DESTDIR}${PREFIX}/${LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}
742 export PKG_CONFIG_PATH
744 # Set the library path so that locally built libs will be found by apps
745 if test x"$LD_LIBRARY_PATH" = x; then
746 LD_LIBRARY_PATH=${DESTDIR}${PREFIX}/${LIBDIR}
747 else
748 LD_LIBRARY_PATH=${DESTDIR}${PREFIX}/${LIBDIR}:${LD_LIBRARY_PATH}
750 export LD_LIBRARY_PATH
752 # Set the path so that locally built apps will be found and used
753 if test x"$PATH" = x; then
754 PATH=${DESTDIR}${PREFIX}/bin
755 else
756 PATH=${DESTDIR}${PREFIX}/bin:${PATH}
758 export PATH
760 # Choose which make program to use
761 if test x"$MAKE" = x; then
762 MAKE=make
765 # Set the default font path for xserver/xorg unless it's already set
766 if test x"$FONTPATH" = x; then
767 FONTPATH="${PREFIX}/${LIBDIR}/X11/fonts/misc/,${PREFIX}/${LIBDIR}/X11/fonts/Type1/,${PREFIX}/${LIBDIR}/X11/fonts/75dpi/,${PREFIX}/${LIBDIR}/X11/fonts/100dpi/,${PREFIX}/${LIBDIR}/X11/fonts/cyrillic/,${PREFIX}/${LIBDIR}/X11/fonts/TTF/"
768 export FONTPATH
771 # Create the log file directory
772 $SUDO mkdir -p ${DESTDIR}${PREFIX}/var/log
774 date
776 # We must install the global macros before anything else
777 build util macros
779 build_proto
780 build_lib
781 build_mesa
783 if test $LIB_ONLY -eq 0; then
784 build_doc
785 build data bitmaps
786 build_app
787 build_xserver
788 build_driver
789 build_data
790 build_font
791 build_util
794 date
796 if test "x$nonexistent_components" != x ; then
797 echo ""
798 echo "***** Skipped components (not available) *****"
799 echo "$nonexistent_components"
800 echo ""
803 if test "x$failed_components" != x ; then
804 echo ""
805 echo "***** Failed components *****"
806 echo "$failed_components"
807 echo ""