build.sh: add --check parameter to run make check after build.
[xorg-util-modular.git] / build.sh
blobffb53b7080d36d57eee5ce8482688551707bfbce
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)
10 # GITROOT: Path to freedesktop.org git root (default: git://anongit.freedesktop.org/git). Only needed for --clone
12 failed_components=""
13 nonexistent_components=""
14 clonefailed_components=""
16 failed() {
17 if test x"$NOQUIT" = x1; then
18 echo "***** $1 failed on $2/$3"
19 failed_components="$failed_components $2/$3"
20 else
21 exit 1
25 checkfortars() {
26 M=$1
27 C=$2
28 case $M in
29 "data")
30 case $C in
31 "cursors") C="xcursor-themes" ;;
32 "bitmaps") C="xbitmaps" ;;
33 esac
35 "font")
36 if [ "$C" != "encodings" ]; then
37 C="font-$C"
40 "lib")
41 case $C in
42 "libXRes") C="libXres" ;;
43 "libxtrans") C="xtrans" ;;
44 esac
46 "pixman")
47 M="lib"
48 C="pixman"
50 "proto")
51 case $C in
52 "evieproto") C="evieext" ;;
53 "x11proto") C="xproto" ;;
54 esac
56 "util")
57 case $C in
58 "cf") C="xorg-cf-files" ;;
59 "macros") C="util-macros" ;;
60 esac
62 "xcb")
63 case $C in
64 "proto") C="xcb-proto" ;;
65 "pthread-stubs") M="lib"; C="libpthread-stubs" ;;
66 "util") C="xcb-util" ;;
67 esac
69 "xserver")
70 C="xorg-server"
72 esac
73 for ii in $M .; do
74 for jj in bz2 gz; do
75 TARFILE=`ls -1rt $ii/$C-*.tar.$jj 2> /dev/null | tail -n 1`
76 if [ -n "$TARFILE" ]; then
77 SRCDIR=`echo $TARFILE | sed "s,.tar.$jj,,"`
78 if [ ! -d $SRCDIR ]; then
79 TAROPTS=xjf
80 if [ "$jj" = "gz" ]; then
81 TAROPTS=xzf
83 tar $TAROPTS $TARFILE -C $ii || failed tar $1 $2
85 return
87 done
88 done
91 clone() {
92 case $1 in
93 "pixman")
94 BASEDIR=""
96 "xcb")
97 BASEDIR=""
99 "mesa")
100 BASEDIR=""
102 "xkeyboard-config")
103 BASEDIR=""
106 BASEDIR="xorg/"
108 esac
110 DIR="$1/$2"
112 if ! test -d "$DIR"; then
113 mkdir -p "$DIR"
116 if test -z "$GITROOT"; then
117 GITROOT="git://anongit.freedesktop.org/git"
120 git clone "$GITROOT/$BASEDIR$DIR" "$DIR"
122 if test "$?" -ne 0 && ! test -d "$DIR"; then
123 return 1
126 return 0
129 build() {
130 if [ -n "$RESUME" ]; then
131 if [ "$RESUME" = "$1/$2" ]; then
132 unset RESUME
133 # Resume build at this module
134 else
135 echo "Skipping $1 module component $2..."
136 return 0
140 SRCDIR=""
141 CONFCMD=""
142 if [ -f $1/$2/autogen.sh ]; then
143 SRCDIR="$1/$2"
144 CONFCMD="autogen.sh"
145 elif [ "x$CLONE" != "x" ]; then
146 clone $1 $2
147 if [ $? -ne 0 ]; then
148 echo "Failed to clone $1 component $2. Ignoring."
149 clonefailed_components="$clonefailed_components $1/$2"
150 if test x"$BUILD_ONE" = x1; then
151 exit 1
153 return
155 SRCDIR="$1/$2"
156 CONFCMD="autogen.sh"
157 else
158 checkfortars $1 $2
159 CONFCMD="configure"
162 if [ -z $SRCDIR ]; then
163 echo "$1 module component $2 does not exist, skipping."
164 nonexistent_components="$nonexistent_components $1/$2"
165 return
168 echo "Building $1 module component $2..."
170 if test x"$BUILT_MODULES_FILE" != "x"; then
171 echo "$1/$2" >> $BUILT_MODULES_FILE
174 old_pwd=`pwd`
175 cd $SRCDIR || failed cd1 $1 $2
177 if test x"$PULL" = x1; then
178 git pull --rebase || failed "git pull" $1 $2
181 # Build outside source directory
182 if [ "x$DIR_ARCH" != x ] ; then
183 mkdir -p "$DIR_ARCH" || failed mkdir $1 $2
184 if cd "$DIR_ARCH" ; then :; else
185 failed cd2 $1 $2
186 cd ${old_pwd}
187 return
191 # Special configure flags for certain modules
192 MOD_SPECIFIC=
194 if test "$1" = "lib" && test "$2" = "libX11" && test x"$USE_XCB" = xNO; then
195 MOD_SPECIFIC="--with-xcb=no"
198 LIB_FLAGS=
199 if test x$LIBDIR != x ; then
200 LIB_FLAGS="--libdir=${PREFIX}/${LIBDIR}"
203 # Use "sh autogen.sh" since some scripts are not executable in CVS
204 if test "x$NOAUTOGEN" != x1 ; then
205 sh ${DIR_CONFIG}/${CONFCMD} --prefix=${PREFIX} ${LIB_FLAGS} \
206 ${MOD_SPECIFIC} ${QUIET:+--quiet} \
207 ${CACHE:+--cache-file=}${CACHE} ${CONFFLAGS} "$CONFCFLAGS" || \
208 failed ${CONFCMD} $1 $2
210 ${MAKE} $MAKEFLAGS || failed make $1 $2
211 if test x"$CHECK" = x1; then
212 ${MAKE} $MAKEFLAGS check || failed check $1 $2
214 if test x"$CLEAN" = x1; then
215 ${MAKE} $MAKEFLAGS clean || failed clean $1 $2
217 if test x"$DIST" = x1; then
218 ${MAKE} $MAKEFLAGS dist || failed dist $1 $2
220 if test x"$DISTCHECK" = x1; then
221 ${MAKE} $MAKEFLAGS distcheck || failed distcheck $1 $2
223 $SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install || \
224 failed install $1 $2
226 cd ${old_pwd}
228 if test x"$BUILD_ONE" = x1; then
229 echo "Single-component build complete"
230 exit 0
234 # protocol headers have no build order dependencies
235 build_proto() {
236 case $HOST_OS in
237 Darwin*)
238 build proto applewmproto
240 CYGWIN*)
241 build proto windowswmproto
245 esac
246 build proto bigreqsproto
247 build proto compositeproto
248 build proto damageproto
249 build proto dmxproto
250 build proto dri2proto
251 build proto evieproto
252 build proto fixesproto
253 build proto fontcacheproto
254 build proto fontsproto
255 build proto glproto
256 build proto inputproto
257 build proto kbproto
258 build proto randrproto
259 build proto recordproto
260 build proto renderproto
261 build proto resourceproto
262 build proto scrnsaverproto
263 build proto trapproto
264 build proto videoproto
265 build proto x11proto
266 build proto xcmiscproto
267 build proto xextproto
268 build proto xf86bigfontproto
269 build proto xf86dgaproto
270 build proto xf86driproto
271 build proto xf86miscproto
272 build proto xf86vidmodeproto
273 build proto xineramaproto
274 if test x"$USE_XCB" != xNO ; then
275 build xcb proto
279 # bitmaps is needed for building apps, so has to be done separately first
280 # cursors depends on apps/xcursorgen
281 # xkbdata is obsolete - use xkbdesc from xkeyboard-config instead
282 build_data() {
283 # build data bitmaps
284 build data cursors
285 # build data xkbdata
288 # All protocol modules must be installed before the libs (okay, that's an
289 # overstatement, but all protocol modules should be installed anyway)
291 # the libraries have a dependency order:
292 # xtrans, Xau, Xdmcp before anything else
293 # fontenc before Xfont
294 # ICE before SM
295 # X11 before Xext
296 # (X11 and SM) before Xt
297 # Xt before Xmu and Xpm
298 # Xext before any other extension library
299 # Xfixes before Xcomposite
300 # Xp before XprintUtil before XprintAppUtil
302 # If xcb is being used for libX11, it must be built before libX11, but after
303 # Xau & Xdmcp
305 build_lib() {
306 build lib libxtrans
307 build lib libXau
308 build lib libXdmcp
309 if test x"$USE_XCB" != xNO ; then
310 build xcb pthread-stubs
311 build xcb libxcb
313 build lib libX11
314 build lib libXext
315 case $HOST_OS in
316 Darwin*)
317 build lib libAppleWM
319 CYGWIN*)
320 build lib libWindowsWM
324 esac
325 build lib libdmx
326 build lib libfontenc
327 build lib libFS
328 build lib libICE
329 #build lib liblbxutil
330 #build lib liboldX
331 build lib libSM
332 build lib libXt
333 build lib libXmu
334 build lib libXpm
335 build lib libXaw
336 build lib libXfixes
337 build lib libXcomposite
338 build lib libXrender
339 build lib libXdamage
340 build lib libXcursor
341 build lib libXevie
342 build lib libXfont
343 build lib libXfontcache
344 build lib libXft
345 build lib libXi
346 build lib libXinerama
347 build lib libxkbfile
348 build lib libxkbui
349 build lib libXrandr
350 build lib libXRes
351 build lib libXScrnSaver
352 build lib libXTrap
353 build lib libXtst
354 build lib libXv
355 build lib libXvMC
356 build lib libXxf86dga
357 build lib libXxf86misc
358 build lib libXxf86vm
359 build lib libpciaccess
360 build pixman ""
363 # Most apps depend at least on libX11.
365 # bdftopcf depends on libXfont
366 # mkfontscale depends on libfontenc and libfreetype
367 # mkfontdir depends on mkfontscale
369 # TODO: detailed breakdown of which apps require which libs
370 build_app() {
371 build app appres
372 build app bdftopcf
373 build app beforelight
374 build app bitmap
375 build app editres
376 build app fonttosfnt
377 build app fslsfonts
378 build app fstobdf
379 build app iceauth
380 build app ico
381 build app listres
382 build app luit
383 build app mkfontdir
384 build app mkfontscale
385 build app oclock
386 build app rgb
387 build app rendercheck
388 build app rstart
389 build app scripts
390 build app sessreg
391 build app setxkbmap
392 build app showfont
393 build app smproxy
394 build app twm
395 build app viewres
396 build app x11perf
397 build app xauth
398 build app xbacklight
399 build app xbiff
400 build app xcalc
401 build app xclipboard
402 build app xclock
403 build app xcmsdb
404 build app xconsole
405 build app xcursorgen
406 build app xdbedizzy
407 build app xditview
408 build app xdm
409 build app xdpyinfo
410 build app xdriinfo
411 build app xedit
412 build app xev
413 build app xeyes
414 build app xf86dga
415 build app xfd
416 build app xfontsel
417 build app xfs
418 build app xfsinfo
419 build app xgamma
420 build app xgc
421 build app xhost
422 build app xinit
423 build app xinput
424 build app xkbcomp
425 build app xkbevd
426 build app xkbprint
427 build app xkbutils
428 build app xkill
429 build app xload
430 build app xlogo
431 build app xlsatoms
432 build app xlsclients
433 build app xlsfonts
434 build app xmag
435 build app xman
436 build app xmessage
437 build app xmh
438 build app xmodmap
439 build app xmore
440 build app xprop
441 build app xrandr
442 build app xrdb
443 build app xrefresh
444 build app xset
445 build app xsetmode
446 build app xsetpointer
447 build app xsetroot
448 build app xsm
449 build app xstdcmap
450 build app xtrap
451 build app xvidtune
452 build app xvinfo
453 build app xwd
454 build app xwininfo
455 build app xwud
456 # if test x"$USE_XCB" != xNO ; then
457 # build xcb demo
458 # fi
461 build_mesa() {
462 build mesa drm
463 #build mesa mesa
466 # The server requires at least the following libraries:
467 # Xfont, Xau, Xdmcp, pciaccess
468 build_xserver() {
469 build xserver ""
472 build_driver_input() {
473 # Some drivers are only buildable on some OS'es
474 case $HOST_OS in
475 Linux)
476 build driver xf86-input-aiptek
477 build driver xf86-input-evdev
478 build driver xf86-input-joystick
479 #build driver xf86-input-ur98
481 *BSD*)
482 build driver xf86-input-joystick
486 esac
488 # And some drivers are only buildable on some CPUs.
489 case $HOST_CPU in
490 i*86* | amd64* | x86*64*)
491 build driver xf86-input-vmmouse
495 esac
497 build driver xf86-input-acecad
498 #build driver xf86-input-calcomp
499 #build driver xf86-input-citron
500 #build driver xf86-input-digitaledge
501 #build driver xf86-input-dmc
502 #build driver xf86-input-dynapro
503 #build driver xf86-input-elo2300
504 #build driver xf86-input-elographics
505 #build driver xf86-input-fpit
506 #build driver xf86-input-hyperpen
507 #build driver xf86-input-jamstudio
508 build driver xf86-input-keyboard
509 #build driver xf86-input-magellan
510 #build driver xf86-input-magictouch
511 #build driver xf86-input-microtouch
512 build driver xf86-input-mouse
513 #build driver xf86-input-mutouch
514 #build driver xf86-input-palmax
515 #build driver xf86-input-penmount
516 #build driver xf86-input-spaceorb
517 #build driver xf86-input-summa
518 build driver xf86-input-synaptics
519 #build driver xf86-input-tek4957
520 build driver xf86-input-void
523 build_driver_video() {
524 # Some drivers are only buildable on some OS'es
525 case $HOST_OS in
526 *FreeBSD*)
527 case $HOST_CPU in
528 sparc64)
529 build driver xf86-video-sunffb
533 esac
535 *NetBSD* | *OpenBSD*)
536 build driver xf86-video-wsfb
537 build driver xf86-video-sunffb
539 *Linux*)
540 build driver xf86-video-sisusb
541 build driver xf86-video-sunffb
542 build driver xf86-video-v4l
546 esac
548 # Some drivers are only buildable on some architectures
549 case $HOST_CPU in
550 *sparc*)
551 build driver xf86-video-sunbw2
552 build driver xf86-video-suncg14
553 build driver xf86-video-suncg3
554 build driver xf86-video-suncg6
555 build driver xf86-video-sunleo
556 build driver xf86-video-suntcx
558 i*86* | amd64* | x86*64*)
559 build driver xf86-video-i740
560 build driver xf86-video-intel
561 # build driver xf86-video-via
565 esac
567 build driver xf86-video-apm
568 build driver xf86-video-ark
569 build driver xf86-video-ast
570 build driver xf86-video-ati
571 build driver xf86-video-chips
572 build driver xf86-video-cirrus
573 build driver xf86-video-dummy
574 build driver xf86-video-fbdev
575 build driver xf86-video-geode
576 # build driver xf86-video-glide
577 build driver xf86-video-glint
578 build driver xf86-video-i128
579 # build driver xf86-video-imstt
580 build driver xf86-video-mach64
581 build driver xf86-video-mga
582 build driver xf86-video-neomagic
583 build driver xf86-video-newport
584 build driver xf86-video-nouveau
585 build driver xf86-video-nv
586 build driver xf86-video-radeonhd
587 build driver xf86-video-rendition
588 build driver xf86-video-r128
589 build driver xf86-video-s3
590 build driver xf86-video-s3virge
591 build driver xf86-video-savage
592 build driver xf86-video-siliconmotion
593 build driver xf86-video-sis
594 build driver xf86-video-tdfx
595 build driver xf86-video-tga
596 build driver xf86-video-trident
597 build driver xf86-video-tseng
598 build driver xf86-video-vesa
599 build driver xf86-video-vmware
600 build driver xf86-video-voodoo
601 build driver xf86-video-xgi
602 build driver xf86-video-xgixp
605 # The server must be built before the drivers
606 build_driver() {
607 # XQuartz doesn't need these...
608 case $HOST_OS in
609 Darwin*) return 0 ;;
610 esac
612 build_driver_input
613 build_driver_video
616 # All fonts require mkfontscale and mkfontdir to be available
618 # The following fonts require bdftopcf to be available:
619 # adobe-100dpi, adobe-75dpi, adobe-utopia-100dpi, adobe-utopia-75dpi,
620 # arabic-misc, bh-100dpi, bh-75dpi, bh-lucidatypewriter-100dpi,
621 # bh-lucidatypewriter-75dpi, bitstream-100dpi, bitstream-75dpi,
622 # cronyx-cyrillic, cursor-misc, daewoo-misc, dec-misc, isas-misc,
623 # jis-misc, micro-misc, misc-cyrillic, misc-misc, mutt-misc,
624 # schumacher-misc, screen-cyrillic, sony-misc, sun-misc and
625 # winitzki-cyrillic
627 # Within the font module, the util component must be built before the
628 # following fonts:
629 # adobe-100dpi, adobe-75dpi, adobe-utopia-100dpi, adobe-utopia-75dpi,
630 # bh-100dpi, bh-75dpi, bh-lucidatypewriter-100dpi, bh-lucidatypewriter-75dpi,
631 # misc-misc and schumacher-misc
633 # The alias component is recommended to be installed after the other fonts
634 # since the fonts.alias files reference specific fonts installed from the
635 # other font components
636 build_font() {
637 build font util
638 build font encodings
639 build font adobe-100dpi
640 build font adobe-75dpi
641 build font adobe-utopia-100dpi
642 build font adobe-utopia-75dpi
643 build font adobe-utopia-type1
644 build font arabic-misc
645 build font bh-100dpi
646 build font bh-75dpi
647 build font bh-lucidatypewriter-100dpi
648 build font bh-lucidatypewriter-75dpi
649 build font bh-ttf
650 build font bh-type1
651 build font bitstream-100dpi
652 build font bitstream-75dpi
653 build font bitstream-speedo
654 build font bitstream-type1
655 build font cronyx-cyrillic
656 build font cursor-misc
657 build font daewoo-misc
658 build font dec-misc
659 build font ibm-type1
660 build font isas-misc
661 build font jis-misc
662 build font micro-misc
663 build font misc-cyrillic
664 build font misc-ethiopic
665 build font misc-meltho
666 build font misc-misc
667 build font mutt-misc
668 build font schumacher-misc
669 build font screen-cyrillic
670 build font sony-misc
671 build font sun-misc
672 build font winitzki-cyrillic
673 build font xfree86-type1
674 build font alias
677 # makedepend requires xproto
678 build_util() {
679 build util cf
680 build util imake
681 build util makedepend
682 build util gccmakedep
683 build util lndir
684 if test x"$USE_XCB" != xNO ; then
685 build xcb util
688 build xkeyboard-config ""
691 # xorg-docs requires xorg-sgml-doctools
692 build_doc() {
693 build doc xorg-sgml-doctools
694 build doc xorg-docs
697 usage() {
698 echo "Usage: $0 [options] prefix"
699 echo " where options are:"
700 echo " -a : do NOT run auto config tools (autogen.sh, configure)"
701 echo " -b : use .build.$HAVE_ARCH build directory"
702 echo " -c : run make clean in addition to others"
703 echo " -d : run make distcheck in addition to others"
704 echo " -D : run make dist in addition to others"
705 echo " -f file: append module being built to file. The last line of this"
706 echo " file can be used for resuming with -r."
707 echo " -g : build with debug information"
708 echo " -n : do not quit after error; just print error message"
709 echo " -o module/component : build just this component"
710 echo " -p : run git pull on each component"
711 echo " -r module/component : resume building with this comonent"
712 echo " -s sudo-command : sudo command to use"
713 echo " --clone : clone non-existing repositories (uses \$GITROOT if set)"
714 echo " --check : run make check in addition to others"
717 HAVE_ARCH="`uname -i`"
718 DIR_ARCH=""
719 DIR_CONFIG="."
720 LIB_ONLY=0
722 # Process command line args
723 while test $# != 0
725 case $1 in
727 NOAUTOGEN=1
730 DIR_ARCH=".build.$HAVE_ARCH"
731 DIR_CONFIG=".."
734 CLEAN=1
737 DISTCHECK=1
740 DIST=1
743 shift
744 BUILT_MODULES_FILE=$1
747 CFLAGS="-g3 -O0"
748 export CFLAGS
749 CONFCFLAGS="CFLAGS=-g3 -O0"
752 LIB_ONLY=1
755 NOQUIT=1
758 shift
759 RESUME=$1
760 BUILD_ONE=1
763 PULL=1
765 --clone)
766 CLONE=1
768 --check)
769 CHECK=1
772 shift
773 RESUME=$1
776 shift
777 SUDO=$1
780 PREFIX=$1
782 esac
784 shift
785 done
787 if test x"${PREFIX}" = x ; then
788 usage
789 exit
792 HOST_OS=`uname -s`
793 HOST_CPU=`uname -m`
795 if test x$LIBDIR = x ; then
796 LIBDIR=lib
799 export HOST_OS
800 export HOST_CPU
801 export LIBDIR
803 echo "Building to run $HOST_OS / $HOST_CPU ($HOST)"
805 # Must create local aclocal dir or aclocal fails
806 ACLOCAL_LOCALDIR="${DESTDIR}${PREFIX}/share/aclocal"
807 $SUDO mkdir -p ${ACLOCAL_LOCALDIR}
809 # The following is required to make aclocal find our .m4 macros
810 if test x"$ACLOCAL" = x; then
811 ACLOCAL="aclocal -I ${ACLOCAL_LOCALDIR}"
812 else
813 ACLOCAL="${ACLOCAL} -I ${ACLOCAL_LOCALDIR}"
815 export ACLOCAL
817 # The following is required to make pkg-config find our .pc metadata files
818 if test x"$PKG_CONFIG_PATH" = x; then
819 PKG_CONFIG_PATH=${DESTDIR}${PREFIX}/${LIBDIR}/pkgconfig
820 else
821 PKG_CONFIG_PATH=${DESTDIR}${PREFIX}/${LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}
823 export PKG_CONFIG_PATH
825 # Set the library path so that locally built libs will be found by apps
826 if test x"$LD_LIBRARY_PATH" = x; then
827 LD_LIBRARY_PATH=${DESTDIR}${PREFIX}/${LIBDIR}
828 else
829 LD_LIBRARY_PATH=${DESTDIR}${PREFIX}/${LIBDIR}:${LD_LIBRARY_PATH}
831 export LD_LIBRARY_PATH
833 # Set the path so that locally built apps will be found and used
834 if test x"$PATH" = x; then
835 PATH=${DESTDIR}${PREFIX}/bin
836 else
837 PATH=${DESTDIR}${PREFIX}/bin:${PATH}
839 export PATH
841 # Choose which make program to use
842 if test x"$MAKE" = x; then
843 MAKE=make
846 # Set the default font path for xserver/xorg unless it's already set
847 if test x"$FONTPATH" = x; then
848 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/"
849 export FONTPATH
852 # Create the log file directory
853 $SUDO mkdir -p ${DESTDIR}${PREFIX}/var/log
855 date
857 # We must install the global macros before anything else
858 build util macros
860 build_proto
861 build_lib
862 build_mesa
864 if test $LIB_ONLY -eq 0; then
865 build_doc
866 build data bitmaps
867 build_app
868 build_xserver
869 build_driver
870 build_data
871 build_font
872 build_util
875 date
877 if test "x$nonexistent_components" != x ; then
878 echo ""
879 echo "***** Skipped components (not available) *****"
880 echo "$nonexistent_components"
881 echo ""
884 if test "x$failed_components" != x ; then
885 echo ""
886 echo "***** Failed components *****"
887 echo "$failed_components"
888 echo ""
891 if test "x$CLONE" != x && test "x$clonefailed_components" != x ; then
892 echo ""
893 echo "***** Components failed to clone *****"
894 echo "$clonefailed_components"
895 echo ""