# polipo.sh

spf_url home "http://www.pps.jussieu.fr/~jch/software/polipo/" &&
spf_url watch "http://www.pps.jussieu.fr/~jch/software/files/polipo/" &&
spf_url src "http://www.pps.jussieu.fr/~jch/software/files/polipo/polipo-${spf_version?}.tar.gz" &&
spf_tested_version 1.0.4 &&

spf_cc_ cpp_args &&
spf_cc_ cc_args -O2 &&
spf_cc_ ld_args &&
spf_cc_ make_args &&

# Apply some CSS patches in addition to normal compilation and installation.
spf_do_install() {
  # Patch C sources to include references to style.css in generated HTML.
  for file in diskcache.c http.c local.c server.c; do
    prj_sedfile "$file" 's:</title>\\n"$:</title>\\n<link rel=\\"stylesheet\\" href=\\"/style.css\\" />\\n":' || return "$?"
  done &&

  # Compile and install.
  set PREFIX="${spf_path_prefix?}" \
    LOCAL_ROOT="${spf_path_prefix?}"/localroot \
    PLATFORM_DEFINES="${spf_args_cpp?} ${spf_args_cc?}" \
    LDFLAGS="${spf_args_ld?}" &&
  eval 'make "$@" '"${spf_args_make?} all install" &&

  # Patch installed HTML documentation to reference style.css.
  for file in "${spf_path_prefix?}"/localroot/{,doc/}*.html; do
    prj_sedfile "$file" 's:</title>$:&<link rel="stylesheet" href="/style.css" />:' || return "$?"
  done &&

  # Create style.css.
  cat > "${spf_path_prefix?}/localroot/style.css" <<EOT
table  {border-collapse: collapse; border: 2px solid;           }
th     {background: silver;                                     }
td, th {border: thin solid; vertical-align: top; padding: 0.5ex;}
EOT
} &&

spf_no_check

# vim: set ts=2 sts=2 sw=2 tw=80 et ft=sh:
