#!/bin/sh
# Simple installer for dcraw executable, manpages, and message catalogs.
# Dave Coffin, dcoffin a cybercom o net

# You will need these:
# apt-get install libjasper-dev libjpeg-dev liblcms-dev gettext

prefix=/usr/local

gcc -O4 -march=native -o $prefix/bin/dcraw dcraw.c \
	-Wall -Wno-unused-result -Wno-array-bounds \
	-lm -ljasper -ljpeg -llcms -s -DLOCALEDIR=\"$prefix/share/locale/\"

mkdir -p -m 755 $prefix/share/man/man1
cp dcraw.1 $prefix/share/man/man1

# Please help me add more languages
for langchar in \
  fr.latin1 it.latin1 de.latin1 pt.latin1 es.latin1 nl.latin1 sv.latin1 \
  ca.latin1 da.latin1 cs.latin2 hu.latin2 pl.latin2 eo.latin3 ru.koi8-r \
  zh_TW.big5 zh_CN.gb2312
do
  lang=`echo $langchar | cut -d. -f1`
  char=`echo $langchar | cut -d. -f2-`
  mkdir -p -m 755 $prefix/share/man/$lang/man1
  iconv -f utf-8 -t $char dcraw_$lang.1 > $prefix/share/man/$lang/man1/dcraw.1
  mkdir -p -m 755 $prefix/share/man/$lang.UTF-8/man1
  cp dcraw_$lang.1 $prefix/share/man/$lang.UTF-8/man1/dcraw.1
  mkdir -p -m 755 $prefix/share/locale/$lang/LC_MESSAGES
  msgfmt -o $prefix/share/locale/$lang/LC_MESSAGES/dcraw.mo dcraw_$lang.po
done
