#!/bin/bash # x11.SlackBuild # Heavily based on the original Slackware build scripts, # Modified by Stuart Winter # 15-Jul-2004 # # Note: This build script is incompatible with scratchbox - it may # build but the permissions/ownerships will be wrong. # I have no plans to make this scratchbox-compatible at least for # the time being. # Record toolchain & other info for the build log: slackbuildinfo # Paths to skeleton port's source & real Slackware source tree: export CWD=$SLACKSOURCE/$PKGSERIES/$PACKAGE export PORTCWD=$PWD # Temporary build locations: export TMPBUILD=$TMP/build-$PACKAGE export PKG=$TMP/package-$PACKAGE mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD BLOC=$TMPBUILD/x11-build mkdir -p $BLOC # Determine the CFLAGS for the known architectures: # For ARM I specify the -Optimisation separately from the main arch flags # due to a bug in arm-linux-gcc that causes freetype to break. case $PORTARCH in arm) export ARCH_CFLAGS="-march=armv3 -mtune=xscale" ;; esac # Extract source: for file in $CWD/X11R${VERSION}-src*.tar.bz2 ; do echo "[***] X11 build: --- Extracting $file --- [***]" tar xjf $file done cd xc slackhousekeeping # Apply patches - these are in Slackware: zcat $CWD/site.def.diff.gz | patch -p1 --backup --verbose --suffix=.orig -E || failpatch zcat $CWD/Xlib.h.diff.gz | patch -p1 --backup --verbose --suffix=.orig -E || failpatch zcat $CWD/linux.cf.zlib.diff.gz | patch -p1 --backup --verbose --suffix=.orig -E || failpatch zcat $CWD/xorgconfig.diff.gz | patch -p1 --backup --verbose --suffix=.orig -E || failpatch zcat $CWD/x11.libxf86config-monitor-freq.diff.gz | patch -p1 --backup --verbose --suffix=.orig -E || failpatch zcat $CWD/x11.startwithblackscreen.diff.gz | patch -p1 --backup --verbose --suffix=.orig -E || failpatch zcat $CWD/x11.pixmap.overflow.diff.gz | patch -p1 --backup --verbose --suffix=.orig -E || failpatch zcat $CWD/x11.hr.diff.gz | patch -p1 --backup --verbose --suffix=.orig -E || failpatch # # These are ARM specific patches or patches required to build against glibc>2.3.2. # They are taken from Debian's diff for xfree86-4.3.0 with some modifications by me # to apply to xorg. # ( # Acorn StrongARM RiscPC keyboard scancodes: zcat $PORTCWD/sources/riscpc_xkb_keycodes.diff.gz | patch --verbose -p1 # compiler.h diff for glibc-2.3.3+ #zcat $PORTCWD/sources/302_arm_compiler.h.diff | patch --verbose -p1 # Acorn/RiscPC/ARM specific patches: zcat $PORTCWD/sources/021_riscpc_ioport_fix.diff.gz | patch --verbose -p1 zcat $PORTCWD/sources/315_arm_is_not_x86_and_has_no_vga.diff.gz | patch --verbose -lp1 zcat $PORTCWD/sources/303_arm_flush_cache.diff.gz | patch --verbose -lp1 ) || failpatch # -O3 chokes gcc 3.4 for ARM in certain conditions (Internal compiler errors) so we'll # drop to -O2 instead for the time being. if [ "$PORTARCH" = "arm" ]; then grep -lr -- "-O3" . | xargs sed -i '/\-O3/ s/\-O3/\-O2/g' fi # Fix sloppiness: find . -type f -name configure -print0 | xargs -0 chmod 755 find . -type f -name mkinstalldirs -print0 | xargs -0 chmod 755 cat << EOF > config/cf/host.def /* * By default, the sample config files for xinit, xdm and xfs are installed * only when there is no pre-existing version installed. Uncommenting the * following lines will force the sample versions to be installed even if * it means over-writing existing versions. */ #define InstallXinitConfig YES #define InstallXdmConfig YES #define InstallFSConfig YES /* Other Slackware defaults */ #define FSUseSyslog YES #define HasPam NO #define UseUtempter YES #define HasZlib YES #define SharedLibGlu YES /* Xprint is not the way to go on Linux which already has */ /* much better print facilities. I'm especially */ /* unimpressed with all the junk it drops in /etc/X11/... */ /* I can't imagine anyone actually using this on Linux. */ #define BuildXprint NO #define BuildXprintClients NO /* Support lagacy apps that link with libXp.so */ #define BuildXprintLib YES /* This won't build without the all the other Xprint */ /* clutter, but was probably rather useless anyway. */ /* I've noticed that since all the unwanted Xprint junk */ /* was merged into X.Org that everyone else has also */ /* dropped support for Xprt... time to follow suit. */ #define XprtServer NO /* Build static libs, too */ #define ForceNormalLib YES /* Let X provide freetype2 at first, or it might not build correctly */ /* Later we can replace this with a newer version (if it passes our test suite) */ /* #define BuildFreetype2 YES */ /* We use our own expat */ #define HasExpat YES /* We will allow X to build fontconfig, but will later upgrade it. */ /* #define HasFontconfig YES */ /* These are just examples if you use Glide... */ /* #define HasGlide3 YES */ /* #define Glide3IncDir /usr/include/glide3 */ EOF # Always build fonts: cat << EOF >> config/cf/host.def /* Build the X fonts from source */ #define BuildFonts YES EOF # pkgconfig files (like alocal files) are best placed in a single location, like /usr/lib/pkgconfig. # First make sure the pkgconfig directories exist: mkdir -p /usr/lib/pkgconfig /usr/X11R6/lib/pkgconfig # Then, move any existing files. This may (and probably will) produce an error if # /usr/X11R6/lib/pkgconfig is empty, so we'll silence stderr: mv /usr/X11R6/lib/pkgconfig/* /usr/lib/pkgconfig 2> /dev/null # Finally, make a link from the old location to the system-wide one: ( cd /usr/X11R6/lib ; rm -rf pkgconfig ) ( cd /usr/X11R6/lib ; ln -sf ../../lib/pkgconfig . ) # Now set up the same structure in the target install location: mkdir -p $PKG/usr/lib/pkgconfig $PKG/usr/X11R6/lib ( cd $PKG/usr/X11R6/lib ; rm -rf pkgconfig ) ( cd $PKG/usr/X11R6/lib ; ln -sf ../../lib/pkgconfig . ) # It's VERY important to build freetype2 ourselves first (or some functions are left # out), but also to use the X supplied sources. # # Step one is to remove existing freetype2 cruft: rm -rf /usr/include/freetype2 \ /usr/X11R6/include/freetype2 \ /usr/X11R6/include/ft2build.h \ /usr/lib/libfreetype.* \ /usr/X11R6/lib/libfreetype.* ( cd extras/freetype2 CFLAGS="-O $ARCH_CFLAGS" make setup CFG="--prefix=/usr $ARCH-slackware-linux" echo "[***] Building X/freetype2 [***]" make || failmake # This only needs to go to the main system for now echo "[***] Installing X/freetype2 [***]" make install ) ldconfig # This shouldn't be needed (apps should pick up -I/usr/include/freetype2 from # `freetype-config --cflags` while compiling), but it's so often reported as a bug that # I'll give in to the point. Now that Freetype1 is pretty much gone having this link # shouldn't hurt anything. Try not to rely on it, though. ( cd /usr/include rm -rf freetype ln -sf freetype2/freetype . ) # Build and install X: echo "[***] Building X [***]" make World -i CDEBUGFLAGS="-O2 $ARCH_CFLAGS" || failmake echo "[***] Installing X into the package [***]" make install DESTDIR=$PKG # Save the fonts so we don't need to build them the next time. #if [ ! -r $PORTCWD/fonts.tar.bz2 ]; then # ( cd $PKG/usr/X11R6/lib/X11/fonts && find . -type f | xargs chmod 644 ) # ( cd $PKG/usr/X11R6/lib/X11 && tar cjvf $PORTCWD/fonts.tar.bz2 fonts ) #fi # OK, now we must spam your development box to ensure that the our rebuild of # fontconfig links against the correct libraries. We'll also be doing this # with the freetype rebuild. It saves many problems that could crop up with # the compile, and besides, that's what a development box is for. It should # be disposable. :-) echo "[***] Installing X onto the filesystem [***]" make install ldconfig # Install man pages: echo "[***] Installing man pages into the package [***]" make install.man DESTDIR=$PKG # More useless Xprint clutter. Great to see new cruft. rm -rf $PKG/usr/X11R6/include/X11/Xprint* rm -f $PKG/usr/X11R6/lib/libXprint*.a rm -f $PKG/usr/X11R6/man/man7/Xprint* # These are currently broken with Qt, but we'll install them anyway. # Someday they might work in Konsole again. mkdir -p $PKG/usr/X11R6/lib/X11/fonts/misc cat $CWD/linux8x16.pcf.gz > $PKG/usr/X11R6/lib/X11/fonts/misc/linux8x16.pcf.gz cat $CWD/linux8x8.pcf.gz > $PKG/usr/X11R6/lib/X11/fonts/misc/linux8x8.pcf.gz # Don't need this rm -f /usr/X11R6/lib/X11/config/host.def rm -f $PKG/usr/X11R6/lib/X11/config/host.def mkdir -p $PKG/etc/X11/xinit cat $CWD/xinit/README.Xmodmap > $PKG/etc/X11/xinit/README.Xmodmap # obsolete #cat $CWD/xinit/.Xmodmap > $PKG/etc/X11/xinit/.Xmodmap # Perms needed for ordinary users to start X: chown root:bin $PKG/usr/X11R6/bin/Xorg chmod 4711 $PKG/usr/X11R6/bin/Xorg cp -a $PKG/etc/X11/xdm/Xsession $PKG/etc/X11/xdm/Xsession.orig cp -a $PKG/etc/X11/xdm/Xsetup_0 $PKG/etc/X11/xdm/Xsetup_0.orig cat $CWD/xdm/Xsession > $PKG/etc/X11/xdm/Xsession cat $CWD/xdm/Xsetup_0 > $PKG/etc/X11/xdm/Xsetup_0 # Treat some of these as config files: mv $PKG/etc/X11/xdm/Xsession $PKG/etc/X11/xdm/Xsession.new mv $PKG/etc/X11/xdm/xdm-config $PKG/etc/X11/xdm/xdm-config.new mv $PKG/etc/X11/xdm/Xservers $PKG/etc/X11/xdm/Xservers.new rm -rf $PKG/install mkdir $PKG/install zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh # Cruft. rm -f /usr/X11R6/lib/libz.a rm -f $PKG/usr/X11R6/lib/libz.a # We'll use the encodings on the system, so hopefully they are the right ones... ( cd $PKG/usr/X11R6/lib/X11/fonts/misc mkfontdir -e /usr/X11R6/lib/X11/fonts/encodings -e /usr/X11R6/lib/X11/fonts/encodings/large . ) mv $PKG/etc/X11/xinit/xinitrc $PKG/etc/X11/xinit/xinitrc.twm chmod 755 $PKG/etc/X11/xinit/xinitrc.twm mkdir -p $PKG/var/log/setup cat $CWD/setup.05.fontconfig > $PKG/var/log/setup/setup.05.fontconfig chmod 755 $PKG/var/log/setup/setup.05.fontconfig cat $CWD/x11-devel/doinst.sh > $PKG/install/doinst.sh.devel cp $CWD/slack-desc/slack-desc.* $PKG/install cat << EOF >> $PKG/install/doinst.sh.fonts #!/bin/sh # Update the X font indexes: if [ -x /usr/X11R6/bin/fc-cache ]; then /usr/X11R6/bin/fc-cache -f fi # else we'll catch it later with setup.fontconfig :-) # make links: EOF # Utilities to try the compositing and transparancy extensions: cd $BLOC rm -rf transset tar zxvvf $CWD/transset.tar.gz cd transset make || failmake cat transset > $PKG/usr/X11R6/bin/transset chmod 755 $PKG/usr/X11R6/bin/transset chown root:bin $PKG/usr/X11R6/bin/transset cd $BLOC rm -rf xcompmgr tar xzf $CWD/xcompmgr.tar.gz cd xcompmgr sh autogen.sh ./configure --prefix=/usr/X11R6 make || failmake cat xcompmgr > $PKG/usr/X11R6/bin/xcompmgr chmod 755 $PKG/usr/X11R6/bin/xcompmgr chown root:bin $PKG/usr/X11R6/bin/xcompmgr cat xcompmgr.1 | gzip -9c > $PKG/usr/X11R6/man/man1/xcompmgr.1.gz # Replace freetype2: cd $CWD ./freetype2.build ldconfig DESTDIR=$PKG ./freetype2.build # Replace fontconfig: cd $CWD ./fontconfig.build ldconfig DESTDIR=$PKG ./fontconfig.build # crud removal: rm -rf $PKG/usr/X11R6/share/doc # We don't ship fonts.cache-1 files, we create them later. find $PKG/usr -type f -name fonts.cache-1 -exec rm {} \; # Strip binaries: ( cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip -g 2> /dev/null ) # Compress all manpages: find $PKG/usr/X11R6/man -name "*.?" | xargs gzip -9 find $PKG/usr/X11R6/man -name "*.?x" | xargs gzip -9 # Some of these links are now made, but some are missing. # It's not known if they are really needed, but they don't hurt anything. ( cd $PKG ( cd etc/X11/xkb/rules ; rm -rf xfree86.lst ) ( cd etc/X11/xkb/rules ; ln -sf xorg.lst xfree86.lst ) ( cd etc/X11/xkb/rules ; rm -rf xfree86.xml ) ( cd etc/X11/xkb/rules ; ln -sf xorg.xml xfree86.xml ) ( cd etc/X11/xkb/rules ; rm -rf xfree86-it.lst ) ( cd etc/X11/xkb/rules ; ln -sf xorg-it.lst xfree86-it.lst ) ( cd etc/X11/xkb/rules ; rm -rf xfree86 ) ( cd etc/X11/xkb/rules ; ln -sf xorg xfree86 ) ) # For the Acorn RiscPC packages, we want the RiscPC xorg config file: ( cd $PKG/etc/X11 # For other architectures we'll need specific xorg config files # so I'll move the default one out of the way but save it for future reference. # The selection of config files is done at install time by the install/doinst.sh mv xorg.conf xorg.conf.distributed.orig install -m644 -o0 -g0 $PORTCWD/arm/xorg.conf.{riscpc,iyonix} . # Create a symlink so that /etc/X11/xorg.conf is always removed when # x11 is removepkg'd. Let's assume we're on a RiscPC: ln -fs xorg.conf.riscpc xorg.conf ) # Install the xorg.conf switcher script: cat $PORTCWD/arm/doinst.sh.xorgconf >> $PKG/install/doinst.sh # Prep the output package: chown -R root:bin $PKG/usr/bin $PKG/usr/X11R6/bin # x11-fonts-misc package: PKG2=$BLOC/package-x11-fonts-misc mkdir -p $PKG2/usr/X11R6/lib/X11/fonts $PKG2/install mv $PKG/usr/X11R6/lib/X11/fonts/75dpi $PKG2/usr/X11R6/lib/X11/fonts mv $PKG/usr/X11R6/lib/X11/fonts/CID $PKG2/usr/X11R6/lib/X11/fonts mv $PKG/usr/X11R6/lib/X11/fonts/encodings $PKG2/usr/X11R6/lib/X11/fonts mv $PKG/usr/X11R6/lib/X11/fonts/misc $PKG2/usr/X11R6/lib/X11/fonts mv $PKG/usr/X11R6/lib/X11/fonts/util $PKG2/usr/X11R6/lib/X11/fonts # Make other directories to avoid fontpath warnings: mkdir -p $PKG2/usr/X11R6/lib/X11/fonts/{TTF,Type1,local,Speedo,100dpi,cyrillic} cp $PKG/install/doinst.sh.fonts $PKG2/install/doinst.sh mv $PKG/install/slack-desc.x11-fonts-misc $PKG2/install/slack-desc # x11-fonts-100dpi package: PKG3=$BLOC/package-x11-fonts-100dpi mkdir -p $PKG3/usr/X11R6/lib/X11/fonts $PKG3/install mv $PKG/usr/X11R6/lib/X11/fonts/100dpi $PKG3/usr/X11R6/lib/X11/fonts cp $PKG/install/doinst.sh.fonts $PKG3/install/doinst.sh mv $PKG/install/slack-desc.x11-fonts-100dpi $PKG3/install/slack-desc # x11-fonts-cyrillic package: PKG4=$BLOC/package-x11-fonts-cyrillic mkdir -p $PKG4/usr/X11R6/lib/X11/fonts $PKG4/install mv $PKG/usr/X11R6/lib/X11/fonts/cyrillic $PKG4/usr/X11R6/lib/X11/fonts cp $PKG/install/doinst.sh.fonts $PKG4/install/doinst.sh mv $PKG/install/slack-desc.x11-fonts-cyrillic $PKG4/install/slack-desc # x11-fonts-scale package: PKG5=$BLOC/package-x11-fonts-scale mkdir -p $PKG5/usr/X11R6/lib/X11/fonts $PKG5/install mv $PKG/usr/X11R6/lib/X11/fonts/TTF $PKG5/usr/X11R6/lib/X11/fonts mv $PKG/usr/X11R6/lib/X11/fonts/Type1 $PKG5/usr/X11R6/lib/X11/fonts mv $PKG/usr/X11R6/lib/X11/fonts/Speedo $PKG5/usr/X11R6/lib/X11/fonts cp $PKG/install/doinst.sh.fonts $PKG5/install/doinst.sh mv $PKG/install/slack-desc.x11-fonts-scale $PKG5/install/slack-desc # x11-docs-html package: PKG6=$BLOC/package-x11-docs-html mkdir -p $PKG6/usr/X11R6/lib/X11/doc $PKG6/install mv $PKG/usr/X11R6/lib/X11/doc/html $PKG6/usr/X11R6/lib/X11/doc mv $PKG/install/slack-desc.x11-docs-html $PKG6/install/slack-desc # x11-docs package: PKG7=$BLOC/package-x11-docs mkdir -p $PKG7/usr/X11R6/lib/X11 $PKG7/install mv $PKG/usr/X11R6/lib/X11/doc $PKG7/usr/X11R6/lib/X11 mv $PKG/install/slack-desc.x11-docs $PKG7/install/slack-desc # x11-xnest package: PKG8=$BLOC/package-x11-xnest mkdir -p $PKG8/usr/X11R6/bin $PKG8/install chown root:bin $PKG8/usr/X11R6/bin mv $PKG/usr/X11R6/bin/Xnest $PKG8/usr/X11R6/bin mv $PKG/install/slack-desc.x11-xnest $PKG8/install/slack-desc # x11-xvfb package: PKG10=$BLOC/package-x11-xvfb mkdir -p $PKG10/usr/X11R6/bin $PKG10/install chown root:bin $PKG10/usr/X11R6/bin mv $PKG/usr/X11R6/bin/Xvfb $PKG10/usr/X11R6/bin mv $PKG/install/slack-desc.x11-xvfb $PKG10/install/slack-desc # x11-xdmx package: PKG12=$BLOC/package-x11-xdmx mkdir -p $PKG12/usr/X11R6/bin $PKG12/usr/X11R6/man/man1 $PKG12/install chown root:bin $PKG12/usr/X11R6/bin mv $PKG/usr/X11R6/bin/Xdmx $PKG12/usr/X11R6/bin mv $PKG/usr/X11R6/man/man1/Xdmx.1x.gz $PKG12/usr/X11R6/man/man1 mv $PKG/usr/X11R6/man/man1/dmxtodmx.1x.gz $PKG12/usr/X11R6/man/man1 mv $PKG/usr/X11R6/man/man1/vdltodmx.1x.gz $PKG12/usr/X11R6/man/man1 mv $PKG/usr/X11R6/man/man1/xdmxconfig.1x.gz $PKG12/usr/X11R6/man/man1 mv $PKG/install/slack-desc.x11-xdmx $PKG12/install/slack-desc # x11-devel package: PKG11=$BLOC/package-x11-devel mkdir -p $PKG11/usr/X11R6/lib/X11 $PKG11/usr/lib $PKG11/usr/X11R6/man $PKG11/install mv $PKG/usr/lib/pkgconfig $PKG11/usr/lib chmod 644 $PKG11/usr/lib/pkgconfig/* mv $PKG/usr/X11R6/lib/pkgconfig $PKG11/usr/X11R6/lib mv $PKG/usr/X11R6/lib/X11/config $PKG11/usr/X11R6/lib/X11 mv $PKG/usr/X11R6/lib/*.a $PKG11/usr/X11R6/lib mv $PKG/usr/lib/*.a $PKG11/usr/lib mv $PKG/usr/X11R6/man/man3 $PKG11/usr/X11R6/man mv $PKG/usr/share $PKG11/usr mv $PKG/usr/include $PKG11/usr mv $PKG/usr/X11R6/src $PKG11/usr/X11R6 mv $PKG/usr/X11R6/include $PKG11/usr/X11R6 # We don't want it all, we just want a little bit. mkdir -p $PKG/usr/X11R6/include/X11 mv $PKG11/usr/X11R6/include/X11/bitmaps $PKG/usr/X11R6/include/X11 mv $PKG11/usr/X11R6/include/X11/pixmaps $PKG/usr/X11R6/include/X11 # Don't ship this: mv $PKG/install/slack-desc.x11-devel $PKG11/install/slack-desc mv $PKG/install/doinst.sh.devel $PKG11/install/doinst.sh # Clean up leftover stuff: rm -f $PKG/install/doinst.sh.fonts \ $PKG/install/slack-desc.x11-drm # Don't ship anything in here: rm -f $PKG/usr/X11R6/lib/X11/fonts/local/* # Build the packages: cd $PKG mv install/slack-desc.x11 install/slack-desc makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-$VERSION-$ARCH-$BUILD.tgz cd $PKG2 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-fonts-misc-$VERSION-noarch-$BUILD.tgz cd $PKG3 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-fonts-100dpi-$VERSION-noarch-$BUILD.tgz cd $PKG4 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-fonts-cyrillic-$VERSION-noarch-$BUILD.tgz cd $PKG5 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-fonts-scale-$VERSION-noarch-$BUILD.tgz cd $PKG6 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-docs-html-$VERSION-noarch-$BUILD.tgz cd $PKG7 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-docs-$VERSION-noarch-$BUILD.tgz cd $PKG8 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-xnest-$VERSION-$ARCH-$BUILD.tgz #cd $PKG9 #makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-xprt-$VERSION-$ARCH-$BUILD.tgz cd $PKG10 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-xvfb-$VERSION-$ARCH-$BUILD.tgz cd $PKG11 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-devel-$VERSION-$ARCH-$BUILD.tgz cd $PKG12 makepkg -l y -c n $PKGSTORE/$PKGSERIES/x11-xdmx-$VERSION-$ARCH-$BUILD.tgz