#!/bin/sh
# Simple installer for dcraw executable, manpages, and message catalogs.
# Dave Coffin, dcoffin a cybercom o net
#
# Following changes have been added for djgpp support:
# 1) Allow for an installation prefix that can be set
#    with a value at the command line.
# 2) Allow for a binary extension that can be set
#    with a value at the command line.
# 3) No LOCALE support still, so undefine LOCALEDIR.
#    Do not install translation of man pages.
#


prefix=$1
if [ -z "$prefix" ]; then
  prefix=/dev/env/DJDIR
fi

EXEEXT=$2
if [ -z "$EXEEXT" ]; then
  EXEEXT=.exe
fi


# Add a CPU-specific "-march=" for greater speed
gcc -O4 -Wall -o dcraw$EXEEXT dcraw.c -lm -ljpeg -llcms -s -march=i386
mkdir -pv $prefix/bin
cp -vf dcraw$EXEEXT $prefix/bin/dcraw$EXEEXT

groff -mman -Tascii dcraw.1 > dcraw.1-t
mkdir -pv $prefix/share/man/cat1
cp -vf dcraw.1-t $prefix/share/man/cat1/dcraw.1

# # Please help me add more languages
# for lang in eo ru fr it de pt es zh_TW zh_CN
# do
#   cp dcraw_$lang.1 $prefix/share/man/$lang/man1/dcraw.1
#   msgfmt -o $prefix/share/locale/$lang/LC_MESSAGES/dcraw.mo dcraw_$lang.po
# done
