#!/bin/sh

# Location of gtk-sources data and lisp files
GTK_SOURCES_LIB=/usr/share/gtk-sources

if [ "$DO_NOT_COMPILE" = "true" ]; then
    rep $GTK_SOURCES_LIB/gtk-sources.jl $*
elif [ -f "$GTK_SOURCES_LIB/gtk-sources.jlc" ]; then
    rep $GTK_SOURCES_LIB/gtk-sources.jlc $*
else
    echo "Compiling gtk-sources.jl"
    cat > $GTK_SOURCES_LIB/compile-script.jl <<EOF
(require 'compiler)
(compile-file "$GTK_SOURCES_LIB/gtk-sources.jl")
EOF
    rep $GTK_SOURCES_LIB/compile-script.jl 2>&1 | gzip -v > $GTK_SOURCES_LIB/compile.log.gz
    rm -f $GTK_SOURCES_LIB/compile-script.jl

    if [ -f "$GTK_SOURCES_LIB/gtk-sources.jlc" ]; then
	rep $GTK_SOURCES_LIB/gtk-sources.jlc $*
    else
	echo "There was an error compiling, please check $GTK_SOURCES_LIB/compile.log.gz"
	echo "And report a bug if necessary, see http://www.debian.org/Bugs/Reporting"
	echo "Include compile.log.gz and your system information in the report."
	echo "Meanwhile, running the rep interpreter..."
	rep $GTK_SOURCES_LIB/gtk-sources.jl $*
    fi
fi





