#!/bin/sh
# configuration scripts for imake/XFree86

F=$WRKDIR/.config

isyes() {
    if [ X$1 = XYES -o X$1 = XYes -o X$1 = Xyes -o X$1 = XY -o X$1 = Xy ]; then
	ret=YES
    else
        ret=$1
    fi
}

rm -f $F

echo "/*" >> $F
echo "/* The following was generated by FreeBSD imake-4/XFree86-4-* ports system." >> $F
echo " */" >> $F
echo "#ifndef HasSecureRPC"			>> $F
echo "#define HasSecureRPC $HasSecureRPC"	>> $F
echo "#endif"					>> $F
echo "#ifndef BuildAoutLibraries"		>> $F
echo "#define BuildAoutLibraries $BuildAoutLibraries" >> $F
echo "#endif"					>> $F
isyes $DebuggableLibraries
if [ $ret = YES -a $OSVERSION -ge 400000 ]; then
    echo "#ifndef DebuggableLibraries"		>> $F
    echo "#define DebuggableLibraries $ret"	>> $F
    echo "#endif"				>> $F
fi
echo "#ifndef InstallXdmConfig"			>> $F
echo "#define InstallXdmConfig $InstallXdmConfig" >> $F
echo "#endif"					>> $F
echo "#ifndef InstallXinitConfig"		>> $F
echo "#define InstallXinitConfig $InstallXinitConfig" >> $F
echo "#endif"					>> $F
echo "#ifndef InstallAppDefFiles"		>> $F
echo "#define InstallAppDefFiles $InstallAppDefFiles" >> $F
echo "#endif"					>> $F
echo "#define HasXdmAuth YES"			>> $F
echo "#define BuildXF86Setup NO"		>> $F
echo "#define HasFreetype2 YES"			>> $F
echo "#define Freetype2Dir ${LOCALBASE}"	>> $F
echo "#define HasExpat YES"			>> $F
echo "#define ExpatDir ${LOCALBASE}"		>> $F
echo "#define HasFontconfig YES"		>> $F
echo "#define FontconfigDir ${PREFIX}"		>> $F
echo "#define HasLibpng YES"			>> $F
echo "#define LibpngDir ${LOCALBASE}"		>> $F
# Never install something to outside ${X11BASE}
echo "#define NothingOutsideProjectRoot YES"	>> $F

cat $F >> ${WRKDIR}/xc/config/cf/xf86site.def

echo "#define ProjectRoot ${PREFIX}" > ${WRKDIR}/xc/config/cf/host.def

cd ${WRKDIR}/xc
touch config/cf/version.def
touch config/cf/date.def
make Makefile.boot
make -f xmakefile SUBDIRS="include config" VerifyOS version.def Makefiles includes
