-#!/bin/sh
-set -o errexit
-
-# First argument of this script is the package name
-
-# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-source ../packages-list
-
-# Applying patches (if any)
-apply_patches ${1}
-
-cd ${LFS_TMP}/${1}
-
-# Xfree86 may have a problem with sys/kd.h installed with some recent versions of
-# Glibc. This has recently been fixed in LFS SVN. Execute the following commands
-# to work around a broken kd.h file. The grep command is to ensure the modification
-# is only made if it is needed:
-grep "__undef_LINUX" \
- /usr/include/sys/kd.h 2>&1 > /dev/null || \
- sed -i.bak '/X.h/i #include <linux/types.h>' \
- programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c
-
-# When building XFree86, you should create a shadow directory of symbolic links for the compiled code:
-make -C config/util -f Makefile.ini lndir
-
-# Now create the shadow tree:
-cd ../${1}-build
-../${1}/config/util/lndir ../${1}
-
-# Creating host.def
-# Although XFree86 will compile without a host.def file, the following file is
-# recommended for customizing the installation.
-cat > config/cf/host.def << "EOF"
-/* host.def */
-/* System Related Information. */
-#define DefaultGcc2i386Opt -O2 -fomit-frame-pointer -march=_MACHINE_ARCHITECTURE_
-
-/* The following definitions are normally set properly by XFree86's scripts.
- * You can uncomment them if you want to make sure. */
-#define HasMTRRSupport YES /* Enabled in kernel see kernel docs */
-#define HasMMXSupport YES /* Any i586 or above */
-#define HasKatmaiSupport YES /* PIII SSE instuctions */
-#define Has3DNowSupport NO /* AMD instructions */
-
-/* This setting reduces compile time a little by omitting rarely used input
- * devices. You can find the complete list in config/cf/xfree86.cf */
-#define XInputDrivers mouse void
-
-/* VIDEO DRIVERS */
-#define XF86CardDrivers vesa vga _XF86_CARD_DRIVER_
-
-/* FONT SERVER AND LIBRARY SETTINGS */
-/* These setting should be set by default, but we are making sure. */
-#define BuildFontServer YES /* Need for GhostScript Print Server */
-#define SharedLibFont YES
-#define CompressAllFonts YES
-#define GzipFontCompression YES
-
-/* These setting ensure we use our libraries */
-#define HasFreetype2 YES
-#define HasFontconfig YES
-#define HasExpat YES
-#define HasLibpng YES
-#define HasZlib YES
-#define HasNCurses YES
-
-/* The font path can be redefined in the XF86Config file */
-#define DefaultFontPath $(FONTDIR)/misc/,$(FONTDIR)/75dpi/,\
-$(FONTDIR)/100dpi/,$(FONTDIR)/Type1,$(FONTDIR)/local,\
-$(FONTDIR)/TrueType,$(FONTDIR)/CID,$(FONTDIR)/Speedo
-
-/* INTERNATIONAL FONTS. Change to YES if you need any of them. These are
- * the defaults. */
-#define BuildCyrillicFonts NO
-#define BuildArabicFonts NO
-#define BuildISO8859_6Fonts NO
-#define BuildGreekFonts NO
-#define BuildISO8859_7Fonts NO
-#define BuildHebrewFonts NO
-#define BuildISO8859_8Fonts NO
-#define BuildKOI8_RFonts NO
-#define BuildJapaneseFonts NO
-#define BuildJISX0201Fonts NO
-#define BuildKoreanFonts NO
-#define BuildChineseFonts NO
-
-/* DOCUMENTATION SETTINGS */
-/* These setting are the defaults. */
-#define BuildLinuxDocHtml NO /* X Docs in Html format */
-#define BuildLinuxDocPS NO /* X Docs in PostScript format */
-#define BuildAllSpecsDocs NO /* Various docs */
-#define BuildHtmlManPages NO
-/* Linux Distribution Information - Not essential that it is totally right.*/
-#define LinuxDistribution hvlinux
-
-/* Disabling IPv6 support, as it causes a problem with xdm. */
-#define BuildIPv6 NO
-
-/* GENERAL SETTINGS: You generally want to leave these alone when
- * building X on an LFS system */
-#define GccWarningOptions -pipe
-#define TermcapLibrary -lncurses
-#define XprtServer YES /* Needed by realplayer */
-#define XnestServer YES
-#define XAppLoadDir EtcX11Directory/app-defaults
-#define VarLibDir /var/lib
-#define XFree86Devel NO
-#define FSUseSyslog YES
-#define ThreadedX YES
-#define HasPam NO
-#define SystemManDirectory /usr/share/man
-#define HasLibCrypt YES
-#define InstallXinitConfig YES
-#define InstallXdmConfig YES
-#define ForceNormalLib YES
-#define BuildSpecsDocs NO
-EOF
-
-sed -i -e "s!_MACHINE_ARCHITECTURE_!${MACHINE_ARCHITECTURE}!g" config/cf/host.def
-sed -i -e "s!_XF86_CARD_DRIVER_!${XF86_CARD_DRIVER}!g" config/cf/host.def
-
-sed -i 's:^.*asm.*$:# define PAGE_MASK (~(getpagesize() - 1)):' \
- ../${1}/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c
-
-sed -i -e "s@^#include <linux/config.h>@/* & */@" \
- `grep -lr linux/config.h ../${1}`
-echo "make World"
-make World
-
-echo "make install"
-make install
-echo "make install.man"
-make install.man
-ldconfig
-
-ln -svfT /usr/X11R6/bin /usr/bin/X11
-ln -svfT /usr/X11R6/lib/X11 /usr/lib/X11
-ln -svfT /usr/X11R6/include/X11 /usr/include/X11
-
-cat > /etc/X11/XF86Config << "EOF"
-# XF86Config
-#
-# **********************************************************************
-# Files section.
-# **********************************************************************
-Section "Files"
- RgbPath "/usr/X11R6/lib/X11/rgb"
- ModulePath "/usr/X11R6/lib/modules" # Module search path
- FontPath "_HV_FONTS_PATH_/TrueType"
-
- # Standard XFree86 Fonts
- FontPath "/usr/X11R6/lib/X11/fonts/TTF"
- FontPath "/usr/X11R6/lib/X11/fonts/Type1"
- FontPath "/usr/X11R6/lib/X11/fonts/misc/:unscaled"
- FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
- FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
- FontPath "/usr/X11R6/lib/X11/fonts/local"
- FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
- FontPath "/usr/X11R6/lib/X11/fonts/misc/"
- FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
- FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
-EndSection
-
-# **********************************************************************
-# Dynamically loadable modules section.
-# **********************************************************************
-Section "Module"
- Load "dbe" # Double buffer extension
-
- # This loads the miscellaneous extensions module, and disables
- # initialisation of the XFree86-DGA extension within that module.
- SubSection "extmod"
- Option "omit xfree86-dga" # don't initialise the DGA extension
- EndSubSection
-
- # This loads the Type1 and FreeType font modules
- Load "type1"
- Load "speedo"
- Load "freetype"
-
- Load "glx"
- Load "dri"
-EndSection
-
-# **********************************************************************
-# Input devices.
-# **********************************************************************
-Section "InputDevice"
- Identifier "Keyboard1"
- Driver "keyboard"
- Option "XkbRules" "xfree86"
- Option "XkbModel" "pc105"
- Option "XkbLayout" "_XF86_KEYBOARD_LAYOUT_"
- Option "XkbVariant" "_XF86_KEYBOARD_VARIANT_"
- Option "XkbOptions" "_XF86_KEYBOARD_OPTIONS_"
- Option "AutoRepeat" "500 30"
-EndSection
-
-Section "InputDevice"
- Identifier "Mouse1"
- Driver "mouse"
- Option "Emulate3Buttons"
- Option "Protocol" "auto"
- Option "Device" "/dev/input/mice"
- Option "ZAxisMapping" "4 5"
- Option "Buttons" "5"
-EndSection
-
-# **********************************************************************
-# Monitor section
-# No need to specify VertRefresh and HorizSync, as DDC2 data will
-# be used (if monitor is recent and supports it).
-# **********************************************************************
-Section "Monitor"
- Identifier "Monitor1"
- VendorName "Unknown"
- ModelName "Unknown"
-EndSection
-
-# **********************************************************************
-# Device (video card) section
-# **********************************************************************
-Section "Device"
- Identifier "VideoCard1"
- Driver "_VIDEO_CARD_DRIVER_"
-EndSection
-
-# **********************************************************************
-# Screen section
-# **********************************************************************
-Section "Screen"
- Identifier "Screen1"
- Device "VideoCard1"
- Monitor "Monitor1"
- DefaultColorDepth 24
- Subsection "Display"
- Depth 24
- Modes "1024x768" "800x600"
- ViewPort 0 0
- EndSubsection
-EndSection
-
-# **********************************************************************
-# Layout(s) section
-# **********************************************************************
-Section "ServerLayout"
- Identifier "Default"
- Screen "Screen1"
- InputDevice "Mouse1" "CorePointer"
- InputDevice "Keyboard1" "CoreKeyboard"
-EndSection
-
-EOF
-
-# The ! character is the SED delimiter
-sed -i -e "s!_HV_FONTS_PATH_!${HV_FONTS_PATH}!g" /etc/X11/XF86Config
-sed -i -e "s!_VIDEO_CARD_DRIVER_!${XF86_CARD_DRIVER}!g" /etc/X11/XF86Config
-sed -i -e "s!_XF86_KEYBOARD_LAYOUT_!${HV_XF86_KEYBOARD_LAYOUT}!g" /etc/X11/XF86Config
-sed -i -e "s!_XF86_KEYBOARD_VARIANT_!${HV_XF86_KEYBOARD_VARIANT}!g" /etc/X11/XF86Config
-sed -i -e "s!_XF86_KEYBOARD_OPTIONS_!${HV_XF86_KEYBOARD_OPTIONS}!g" /etc/X11/XF86Config
-
-cat > /etc/skel/.xinitrc << "EOF"
-# ~/.xinitrc
-
-exec wmaker
-EOF
-
-cat > /etc/skel/.Xdefaults << "EOF"
-xterm*scrollBar: false
-xterm*rightScrollBar: false
-xterm*saveLines: 1000
-xterm*geometry: 120x45+70+50
-xterm*background: #000000
-xterm*foreground: #A8A8A8
-xterm*color0: #000000
-xterm*color1: #A80000
-xterm*color2: #00A800
-xterm*color3: #A85400
-xterm*color4: #0000A8
-xterm*color5: #A800A8
-xterm*color6: #00A8A8
-xterm*color7: #A8A8A8
-xterm*color8: #545054
-xterm*color9: #F85450
-xterm*color10: #50FC50
-xterm*color11: #F2FC50
-xterm*color12: #5054F8
-xterm*color13: #F854F8
-xterm*color14: #50FCF8
-xterm*color15: #F8FCF8
-EOF
-
-cat > /etc/skel/.xsession << "EOF"
-#!/bin/sh
-# ~/.xsession
-
-userresources=$HOME/.Xresources
-usermodmap=$HOME/.Xmodmap
-sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
-sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap
-
-# merge in defaults and keymaps
-
-if [ -f $sysresources ]; then
- xrdb -merge $sysresources
-fi
-
-if [ -f $sysmodmap ]; then
- xmodmap $sysmodmap
-fi
-
-if [ -f $userresources ]; then
- xrdb -merge $userresources
-fi
-
-if [ -f $usermodmap ]; then
- xmodmap $usermodmap
-fi
-
-# now, we see if xdm/gdm/kdm has asked for a specific environment
-
-case $# in
- 1)
- case $1 in
- kde)
- exec dbus-launch --exit-with-session startkde
- ;;
- twm)
- xsetroot -solid rgb:33/33/55 &
- xclock -digital -update 1 -geometry 180x23-5+5 &
- opera -geometry 1100x950+150+10 -iconic -title "Opera 6.0 TP3" &
- emacs -geometry 140x60-5+100 -iconic -title "Emacs" &
- xterm -ls -geometry 160x60+25-25 -title "xterm" &
- exec dbus-launch --exit-with-session twm
- ;;
- wmaker)
- exec dbus-launch --exit-with-session wmaker
- ;;
- failsafe)
- exec xterm -geometry 80x24-0-0
- ;;
- default)
- exec dbus-launch --exit-with-session wmaker
- ;;
- *)
- exec dbus-launch --exit-with-session wmaker
- ;;
- esac
- ;;
- *)
- exec dbus-launch --exit-with-session wmaker
- ;;
-esac
-
-exit 0
-EOF
-
-chmod 755 /etc/skel/.xsession
-
-cp /etc/skel/.{xinitrc,Xdefaults,xsession} /root
-cp /etc/skel/.{xinitrc,Xdefaults,xsession} /home/${REGUSER}
-
-var_add_path "PATH" /etc/profile "/usr/X11R6/bin"
-
-var_add_path "PKG_CONFIG_PATH" /etc/profile "/usr/X11R6/lib/pkgconfig"
-var_export "PKG_CONFIG_PATH" /etc/profile
-
-var_add_path "MANPATH" /etc/profile "/usr/X11R6/man"
-var_export "MANPATH" /etc/profile
-
-var_add_shadow "ENV_SUPATH" /etc/login.defs "/usr/X11R6/bin"
-
-string_add "/usr/X11R6/lib" /etc/ld.so.conf
-
-if [ "x${INST_TYPE}" = "xltsp-server" ]; then
- # Enable remote xdm login for LTSP clients
- sed -i -e "s@^\(DisplayManager.requestPort.*\)@!\1@g" /etc/X11/xdm/xdm-config
- chmod 644 /etc/X11/xdm/Xaccess
- sed -i -e "s@^#\(\*[\t ]*#any host can get a login window\)@\1@g" /etc/X11/xdm/Xaccess
- chmod 444 /etc/X11/xdm/Xaccess
-fi
-
-# When needed, XFree86 creates the directory /tmp/.ICE-unix if it does not
-# exist. If this directory is not owned by root, XFree86 delays startup by a
-# few seconds and also appends a warning to the logfile. This also affects
-# startup of other applications. To improve performance, it is advisable to
-# manually create the directory before XFree86 uses it.
-# startup script.
-#cat >> /etc/sysconfig/createfiles <<EOF
-# "EOF"
-#/tmp/.ICE-unix dir 1777 root root
-#EOF
-
-exit $?
-