build.sh: Only build libAppleWM, libWindowsWM and protos on Darwin/Windows
[xorg-util-modular.git] / build.sh
blob68e7614870a1f6b27dd32111df88eb1c775ac3fb
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 case $HOST_OS in
182 Darwin*)
183 build proto applewmproto
185 CYGWIN*)
186 build proto windowswmproto
190 esac
191 build proto bigreqsproto
192 build proto compositeproto
193 build proto damageproto
194 build proto dmxproto
195 build proto dri2proto
196 build proto evieproto
197 build proto fixesproto
198 build proto fontcacheproto
199 build proto fontsproto
200 build proto glproto
201 build proto inputproto
202 build proto kbproto
203 build proto randrproto
204 build proto recordproto
205 build proto renderproto
206 build proto resourceproto
207 build proto scrnsaverproto
208 build proto trapproto
209 build proto videoproto
210 build proto x11proto
211 build proto xcmiscproto
212 build proto xextproto
213 build proto xf86bigfontproto
214 build proto xf86dgaproto
215 build proto xf86driproto
216 build proto xf86miscproto
217 build proto xf86vidmodeproto
218 build proto xineramaproto
219 if test x"$USE_XCB" != xNO ; then
220 build xcb proto
224 # bitmaps is needed for building apps, so has to be done separately first
225 # cursors depends on apps/xcursorgen
226 # xkbdata is obsolete - use xkbdesc from xkeyboard-config instead
227 build_data() {
228 # build data bitmaps
229 build data cursors
230 # build data xkbdata
233 # All protocol modules must be installed before the libs (okay, that's an
234 # overstatement, but all protocol modules should be installed anyway)
236 # the libraries have a dependency order:
237 # xtrans, Xau, Xdmcp before anything else
238 # fontenc before Xfont
239 # ICE before SM
240 # X11 before Xext
241 # (X11 and SM) before Xt
242 # Xt before Xmu and Xpm
243 # Xext before any other extension library
244 # Xfixes before Xcomposite
245 # Xp before XprintUtil before XprintAppUtil
247 # If xcb is being used for libX11, it must be built before libX11, but after
248 # Xau & Xdmcp
250 build_lib() {
251 build lib libxtrans
252 build lib libXau
253 build lib libXdmcp
254 if test x"$USE_XCB" != xNO ; then
255 build xcb pthread-stubs
256 build xcb libxcb
258 build lib libX11
259 build lib libXext
260 case $HOST_OS in
261 Darwin*)
262 build lib libAppleWM
264 CYGWIN*)
265 build lib libWindowsWM
269 esac
270 build lib libdmx
271 build lib libfontenc
272 build lib libFS
273 build lib libICE
274 #build lib liblbxutil
275 #build lib liboldX
276 build lib libSM
277 build lib libXt
278 build lib libXmu
279 build lib libXpm
280 build lib libXaw
281 build lib libXfixes
282 build lib libXcomposite
283 build lib libXrender
284 build lib libXdamage
285 build lib libXcursor
286 build lib libXevie
287 build lib libXfont
288 build lib libXfontcache
289 build lib libXft
290 build lib libXi
291 build lib libXinerama
292 build lib libxkbfile
293 build lib libxkbui
294 build lib libXrandr
295 build lib libXRes
296 build lib libXScrnSaver
297 build lib libXTrap
298 build lib libXtst
299 build lib libXv
300 build lib libXvMC
301 build lib libXxf86dga
302 build lib libXxf86misc
303 build lib libXxf86vm
304 build lib libpciaccess
305 build pixman ""
308 # Most apps depend at least on libX11.
310 # bdftopcf depends on libXfont
311 # mkfontscale depends on libfontenc and libfreetype
312 # mkfontdir depends on mkfontscale
314 # TODO: detailed breakdown of which apps require which libs
315 build_app() {
316 build app appres
317 build app bdftopcf
318 build app beforelight
319 build app bitmap
320 build app editres
321 build app fonttosfnt
322 build app fslsfonts
323 build app fstobdf
324 build app iceauth
325 build app ico
326 build app listres
327 build app luit
328 build app mkfontdir
329 build app mkfontscale
330 build app oclock
331 build app rgb
332 build app rendercheck
333 build app rstart
334 build app scripts
335 build app sessreg
336 build app setxkbmap
337 build app showfont
338 build app smproxy
339 build app twm
340 build app viewres
341 build app x11perf
342 build app xauth
343 build app xbacklight
344 build app xbiff
345 build app xcalc
346 build app xclipboard
347 build app xclock
348 build app xcmsdb
349 build app xconsole
350 build app xcursorgen
351 build app xdbedizzy
352 build app xditview
353 build app xdm
354 build app xdpyinfo
355 build app xdriinfo
356 build app xedit
357 build app xev
358 build app xeyes
359 build app xf86dga
360 build app xfd
361 build app xfontsel
362 build app xfs
363 build app xfsinfo
364 build app xgamma
365 build app xgc
366 build app xhost
367 build app xinit
368 build app xinput
369 build app xkbcomp
370 build app xkbevd
371 build app xkbprint
372 build app xkbutils
373 build app xkill
374 build app xload
375 build app xlogo
376 build app xlsatoms
377 build app xlsclients
378 build app xlsfonts
379 build app xmag
380 build app xman
381 build app xmessage
382 build app xmh
383 build app xmodmap
384 build app xmore
385 build app xprop
386 build app xrandr
387 build app xrdb
388 build app xrefresh
389 build app xset
390 build app xsetmode
391 build app xsetpointer
392 build app xsetroot
393 build app xsm
394 build app xstdcmap
395 build app xtrap
396 build app xvidtune
397 build app xvinfo
398 build app xwd
399 build app xwininfo
400 build app xwud
401 # if test x"$USE_XCB" != xNO ; then
402 # build xcb demo
403 # fi
406 build_mesa() {
407 build mesa drm
408 #build mesa mesa
411 # The server requires at least the following libraries:
412 # Xfont, Xau, Xdmcp, pciaccess
413 build_xserver() {
414 build xserver ""
417 build_driver_input() {
418 # Some drivers are only buildable on some OS'es
419 case $HOST_OS in
420 Linux)
421 build driver xf86-input-aiptek
422 build driver xf86-input-evdev
423 build driver xf86-input-joystick
424 #build driver xf86-input-ur98
426 *BSD*)
427 build driver xf86-input-joystick
431 esac
433 # And some drivers are only buildable on some CPUs.
434 case $HOST_CPU in
435 i*86* | amd64* | x86*64*)
436 build driver xf86-input-vmmouse
440 esac
442 build driver xf86-input-acecad
443 #build driver xf86-input-calcomp
444 #build driver xf86-input-citron
445 #build driver xf86-input-digitaledge
446 #build driver xf86-input-dmc
447 #build driver xf86-input-dynapro
448 #build driver xf86-input-elo2300
449 #build driver xf86-input-elographics
450 #build driver xf86-input-fpit
451 #build driver xf86-input-hyperpen
452 #build driver xf86-input-jamstudio
453 build driver xf86-input-keyboard
454 #build driver xf86-input-magellan
455 #build driver xf86-input-magictouch
456 #build driver xf86-input-microtouch
457 build driver xf86-input-mouse
458 #build driver xf86-input-mutouch
459 #build driver xf86-input-palmax
460 #build driver xf86-input-penmount
461 #build driver xf86-input-spaceorb
462 #build driver xf86-input-summa
463 build driver xf86-input-synaptics
464 #build driver xf86-input-tek4957
465 build driver xf86-input-void
468 build_driver_video() {
469 # Some drivers are only buildable on some OS'es
470 case $HOST_OS in
471 *FreeBSD*)
472 case $HOST_CPU in
473 sparc64)
474 build driver xf86-video-sunffb
478 esac
480 *NetBSD* | *OpenBSD*)
481 build driver xf86-video-wsfb
482 build driver xf86-video-sunffb
484 *Linux*)
485 build driver xf86-video-sisusb
486 build driver xf86-video-sunffb
487 build driver xf86-video-v4l
491 esac
493 # Some drivers are only buildable on some architectures
494 case $HOST_CPU in
495 *sparc*)
496 build driver xf86-video-sunbw2
497 build driver xf86-video-suncg14
498 build driver xf86-video-suncg3
499 build driver xf86-video-suncg6
500 build driver xf86-video-sunleo
501 build driver xf86-video-suntcx
503 i*86* | amd64* | x86*64*)
504 build driver xf86-video-i740
505 build driver xf86-video-intel
506 # build driver xf86-video-via
510 esac
512 build driver xf86-video-apm
513 build driver xf86-video-ark
514 build driver xf86-video-ast
515 build driver xf86-video-ati
516 build driver xf86-video-chips
517 build driver xf86-video-cirrus
518 build driver xf86-video-dummy
519 build driver xf86-video-fbdev
520 build driver xf86-video-geode
521 # build driver xf86-video-glide
522 build driver xf86-video-glint
523 build driver xf86-video-i128
524 build driver xf86-video-imstt
525 build driver xf86-video-mach64
526 build driver xf86-video-mga
527 build driver xf86-video-neomagic
528 build driver xf86-video-newport
529 build driver xf86-video-nouveau
530 build driver xf86-video-nv
531 build driver xf86-video-radeonhd
532 build driver xf86-video-rendition
533 build driver xf86-video-r128
534 build driver xf86-video-s3
535 build driver xf86-video-s3virge
536 build driver xf86-video-savage
537 build driver xf86-video-siliconmotion
538 build driver xf86-video-sis
539 build driver xf86-video-tdfx
540 build driver xf86-video-tga
541 build driver xf86-video-trident
542 build driver xf86-video-tseng
543 build driver xf86-video-vesa
544 build driver xf86-video-vmware
545 build driver xf86-video-voodoo
546 build driver xf86-video-xgi
547 build driver xf86-video-xgixp
550 # The server must be built before the drivers
551 build_driver() {
552 # XQuartz doesn't need these...
553 case $HOST_OS in
554 Darwin*) return 0 ;;
555 esac
557 build_driver_input
558 build_driver_video
561 # All fonts require mkfontscale and mkfontdir to be available
563 # The following fonts require bdftopcf to be available:
564 # adobe-100dpi, adobe-75dpi, adobe-utopia-100dpi, adobe-utopia-75dpi,
565 # arabic-misc, bh-100dpi, bh-75dpi, bh-lucidatypewriter-100dpi,
566 # bh-lucidatypewriter-75dpi, bitstream-100dpi, bitstream-75dpi,
567 # cronyx-cyrillic, cursor-misc, daewoo-misc, dec-misc, isas-misc,
568 # jis-misc, micro-misc, misc-cyrillic, misc-misc, mutt-misc,
569 # schumacher-misc, screen-cyrillic, sony-misc, sun-misc and
570 # winitzki-cyrillic
572 # Within the font module, the util component must be built before the
573 # following fonts:
574 # adobe-100dpi, adobe-75dpi, adobe-utopia-100dpi, adobe-utopia-75dpi,
575 # bh-100dpi, bh-75dpi, bh-lucidatypewriter-100dpi, bh-lucidatypewriter-75dpi,
576 # misc-misc and schumacher-misc
578 # The alias component is recommended to be installed after the other fonts
579 # since the fonts.alias files reference specific fonts installed from the
580 # other font components
581 build_font() {
582 build font util
583 build font encodings
584 build font adobe-100dpi
585 build font adobe-75dpi
586 build font adobe-utopia-100dpi
587 build font adobe-utopia-75dpi
588 build font adobe-utopia-type1
589 build font arabic-misc
590 build font bh-100dpi
591 build font bh-75dpi
592 build font bh-lucidatypewriter-100dpi
593 build font bh-lucidatypewriter-75dpi
594 build font bh-ttf
595 build font bh-type1
596 build font bitstream-100dpi
597 build font bitstream-75dpi
598 build font bitstream-speedo
599 build font bitstream-type1
600 build font cronyx-cyrillic
601 build font cursor-misc
602 build font daewoo-misc
603 build font dec-misc
604 build font ibm-type1
605 build font isas-misc
606 build font jis-misc
607 build font micro-misc
608 build font misc-cyrillic
609 build font misc-ethiopic
610 build font misc-meltho
611 build font misc-misc
612 build font mutt-misc
613 build font schumacher-misc
614 build font screen-cyrillic
615 build font sony-misc
616 build font sun-misc
617 build font winitzki-cyrillic
618 build font xfree86-type1
619 build font alias
622 # makedepend requires xproto
623 build_util() {
624 build util cf
625 build util imake
626 build util makedepend
627 build util gccmakedep
628 build util lndir
629 if test x"$USE_XCB" != xNO ; then
630 build xcb util
633 build xkeyboard-config ""
636 # xorg-docs requires xorg-sgml-doctools
637 build_doc() {
638 build doc xorg-sgml-doctools
639 build doc xorg-docs
642 usage() {
643 echo "Usage: $0 [options] prefix"
644 echo " where options are:"
645 echo " -a : do NOT run auto config tools (autogen.sh, configure)"
646 echo " -b : use .build.$HAVE_ARCH build directory"
647 echo " -c : run make clean in addition to others"
648 echo " -d : run make distcheck in addition to others"
649 echo " -D : run make dist in addition to others"
650 echo " -f file: append module being built to file. The last line of this"
651 echo " file can be used for resuming with -r."
652 echo " -g : build with debug information"
653 echo " -n : do not quit after error; just print error message"
654 echo " -o module/component : build just this component"
655 echo " -p : run git pull on each component"
656 echo " -r module/component : resume building with this comonent"
657 echo " -s sudo-command : sudo command to use"
660 HAVE_ARCH="`uname -i`"
661 DIR_ARCH=""
662 DIR_CONFIG="."
663 LIB_ONLY=0
665 # Process command line args
666 while test $# != 0
668 case $1 in
670 NOAUTOGEN=1
673 DIR_ARCH=".build.$HAVE_ARCH"
674 DIR_CONFIG=".."
677 CLEAN=1
680 DISTCHECK=1
683 DIST=1
686 shift
687 BUILT_MODULES_FILE=$1
690 CFLAGS="-g3 -O0"
691 export CFLAGS
692 CONFCFLAGS="CFLAGS=-g3 -O0"
695 LIB_ONLY=1
698 NOQUIT=1
701 shift
702 RESUME=$1
703 BUILD_ONE=1
706 PULL=1
709 shift
710 RESUME=$1
713 shift
714 SUDO=$1
717 PREFIX=$1
719 esac
721 shift
722 done
724 if test x"${PREFIX}" = x ; then
725 usage
726 exit
729 HOST_OS=`uname -s`
730 HOST_CPU=`uname -m`
732 if test x$LIBDIR = x ; then
733 LIBDIR=lib
736 export HOST_OS
737 export HOST_CPU
738 export LIBDIR
740 echo "Building to run $HOST_OS / $HOST_CPU ($HOST)"
742 # Must create local aclocal dir or aclocal fails
743 ACLOCAL_LOCALDIR="${DESTDIR}${PREFIX}/share/aclocal"
744 $SUDO mkdir -p ${ACLOCAL_LOCALDIR}
746 # The following is required to make aclocal find our .m4 macros
747 if test x"$ACLOCAL" = x; then
748 ACLOCAL="aclocal -I ${ACLOCAL_LOCALDIR}"
749 else
750 ACLOCAL="${ACLOCAL} -I ${ACLOCAL_LOCALDIR}"
752 export ACLOCAL
754 # The following is required to make pkg-config find our .pc metadata files
755 if test x"$PKG_CONFIG_PATH" = x; then
756 PKG_CONFIG_PATH=${DESTDIR}${PREFIX}/${LIBDIR}/pkgconfig
757 else
758 PKG_CONFIG_PATH=${DESTDIR}${PREFIX}/${LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}
760 export PKG_CONFIG_PATH
762 # Set the library path so that locally built libs will be found by apps
763 if test x"$LD_LIBRARY_PATH" = x; then
764 LD_LIBRARY_PATH=${DESTDIR}${PREFIX}/${LIBDIR}
765 else
766 LD_LIBRARY_PATH=${DESTDIR}${PREFIX}/${LIBDIR}:${LD_LIBRARY_PATH}
768 export LD_LIBRARY_PATH
770 # Set the path so that locally built apps will be found and used
771 if test x"$PATH" = x; then
772 PATH=${DESTDIR}${PREFIX}/bin
773 else
774 PATH=${DESTDIR}${PREFIX}/bin:${PATH}
776 export PATH
778 # Choose which make program to use
779 if test x"$MAKE" = x; then
780 MAKE=make
783 # Set the default font path for xserver/xorg unless it's already set
784 if test x"$FONTPATH" = x; then
785 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/"
786 export FONTPATH
789 # Create the log file directory
790 $SUDO mkdir -p ${DESTDIR}${PREFIX}/var/log
792 date
794 # We must install the global macros before anything else
795 build util macros
797 build_proto
798 build_lib
799 build_mesa
801 if test $LIB_ONLY -eq 0; then
802 build_doc
803 build data bitmaps
804 build_app
805 build_xserver
806 build_driver
807 build_data
808 build_font
809 build_util
812 date
814 if test "x$nonexistent_components" != x ; then
815 echo ""
816 echo "***** Skipped components (not available) *****"
817 echo "$nonexistent_components"
818 echo ""
821 if test "x$failed_components" != x ; then
822 echo ""
823 echo "***** Failed components *****"
824 echo "$failed_components"
825 echo ""