#!/bin/sh # # Why any "configure" fuss for this? # Well, getting the proper directory and encoding for the # japanese manpage is A Hard Task. # # This "configure" will create "Makefile". # OLANG="$LANG" LANG=C; export LANG while [ $# -gt 0 ]; do case "$1" in --prefix=*) prefix="${1##--prefix=}"; shift;; --prefix) shift; prefix="$1"; shift;; --mandirja=*) mandirja="${1##--mandirja=}"; shift;; --mandirja) shift; mandirja="$1"; shift;; --mancodeja=*) mancodeja="${1##--mancodeja=}"; shift;; --mancodeja) shift; mancodeja="$1"; shift;; --libexecdir=*) libexecdir="${1##--libexecdir=}"; shift;; --libexecdir) shift; libexecdir="$1"; shift;; --bindir=*) bindir="${1##--bindir=}"; shift;; --bindir) shift; bindir="$1"; shift;; --etcdir=*) etcdir="${1##--etcdir=}"; shift;; --etcdir) shift; etcdir="$1"; shift;; *) echo "Unknown option: $1"; exit 1;; esac done : ${prefix:=/usr/local} : ${bindir:=${prefix}/bin} : ${libexecdir=${prefix}/libexec} if [ -z "$etcdir" ]; then if [ "$prefix" = /usr ]; then # /usr/etc is not particulary useful etcdir=/etc else etcdir=${prefix}/etc fi fi test -d ${prefix}/share/man && : ${mandir:=${prefix}/share/man} test -d ${prefix}/man && : ${mandir:=${prefix}/man} test -r /usr/include/crypt.h && cppflags="${cppflags} -DHAVE_CRYPT_H=1" cat < ./Makefile # # Autogenerated from $0; DO NOT EDIT # prefix=${prefix} BINDIR=${bindir} MANDIR=${mandir} ETCDIR=${etcdir} LIBEXECDIR=${libexecdir} CPPFLAGS=${cppflags} LDLIBS=-lcrypt all: passwdbattler battlerV2 passwdbattler.ja.6 battlerV2: battler.c \$(CC) -o \$@ \$(CPPFLAGS) \$(LDFLAGS) battler.c \$(LDLIBS) clean:: rm -f ./battlerV2 *.o rm -f ./.#* rm -f ./passwdbattler ./pwbrc distclean:: clean rm -f ./Makefile passwdbattler: ./passwdbattler.in sed -e 's:@LIBEXECDIR@:\$(LIBEXECDIR):g; s:@ETCDIR@:\$(ETCDIR):g' ./passwdbattler.in > \$@ chmod 755 \$@ test: all ./passwdbattler -HISTO install: passwdbattler passwdbattler-genrc ./battlerV2 install-man install-man-ja install-pwbrc test -d \$(DESTDIR)\$(LIBEXECDIR) || mkdir -p \$(DESTDIR)\$(LIBEXECDIR) cp ./battlerV2 \$(DESTDIR)\$(LIBEXECDIR)/battlerV2 touch -r ./battlerV2 \$(DESTDIR)\$(LIBEXECDIR)/battlerV2 test -d \$(DESTDIR)\$(BINDIR) || mkdir -p \$(DESTDIR)\$(BINDIR) cp ./passwdbattler \$(DESTDIR)\$(BINDIR)/passwdbattler touch -r ./passwdbattler \$(DESTDIR)\$(BINDIR)/passwdbattler cp ./passwdbattler-genrc \$(DESTDIR)\$(BINDIR)/passwdbattler-genrc touch -r ./passwdbattler-genrc \$(DESTDIR)\$(BINDIR)/passwdbattler-genrc install-man: ./passwdbattler.en.6 test -d \$(DESTDIR)\$(MANDIR)/man6 || mkdir -p \$(DESTDIR)\$(MANDIR)/man6 cp ./passwdbattler.en.6 \$(DESTDIR)\$(MANDIR)/man6/passwdbattler.6 touch -r ./passwdbattler.en.6 \$(DESTDIR)\$(MANDIR)/man6/passwdbattler.6 install-pwbrc: #./pwbrc if [ -e ./pwbrc ]; then \ test -d \$(DESTDIR)\$(ETCDIR) || mkdir \$(DESTDIR)\$(ETCDIR); \ cp ./pwbrc \$(DESTDIR)\$(ETCDIR)/pwbrc; \ fi EOF ## Determine mandirja=/usr/local/share/man/ja_JP.eucJP # Easiest: we have man/ja_JP.{encoding}/ directory if test -z "$mandirja" && d=`ls -d ${mandir}/ja_JP.[uU][tT][fF]8 2>/dev/null`; then mandirja="$d" fi if test -z "$mandirja" && d=`ls -d ${mandir}/ja_JP.[uU][tT][fF]-8 2>/dev/null`; then mandirja="$d" fi if test -z "$mandirja" && d=`ls -d ${mandir}/ja_JP.[eE][uU][cC]JP 2>/dev/null`; then mandirja="$d" fi if test -z "$mandirja" && d=`ls -d ${mandir}/ja_JP.[eE][uU][cC] 2>/dev/null`; then mandirja="$d" fi # set $mancodeja for given mandirja=/usr/local/man/ja_JP.eucJP case "$mandirja" in *.[uU][tT][fF]8) mancodeja="utf-8";; *.[uU][tT][fF]-8) mancodeja="utf-8";; *.[eE][uU][cC]JP) mancodeja="euc-jp";; *.[eE][uU][cC]) mancodeja="euc-jp";; esac # We only have man/ja_JP or man/ja . # What encoding it is depends on OS and version, # so determine it later. if test -z "$mandirja" && d=`ls -d ${mandir}/ja_JP 2>/dev/null`; then mandirja="$d" fi if test -z "$mandirja" && d=`ls -d ${mandir}/ja 2>/dev/null`; then mandirja="$d" fi ## If we still cannot find man/ja, give up. : ## If $mancodeja is still unavailable, and # this was invoked with .utf-8 locale, assume that. if [ -z "$mancodeja" ]; then case "$OLANG" in *.[uU][tT][fF]-8) mancodeja="utf-8";; *.[uU][tT][fF]8) mancodeja="utf-8";; *.[eE][uU][cC]JP) mancodeja="euc-jp";; *.[eE][uU][cC]) mancodeja="euc-jp";; japanese) # likely old SunOS mancodeja="euc-jp";; esac fi ## Now comes the hard part. We only have man/ja_JP or man/ja . ## What encoding it is depends on OS and version. if [ -z "$mancodeja" ]; then e3e3=`awk 'BEGIN{printf "\343..\343"}' /dev/null` ## Try locating "something.1", and peek in it ## We're not using $mandirja, as it could be an empty directory. set ${prefix}/share/man/ja*/man1*/*.1* \ ${prefix}/man/ja*/man1*/*.1* \ /usr/share/man/ja*/man1*/*.1* \ /usr/man/ja*/man1*/*.1* while [ $# -gt 0 ]; do test -r "$1" || continue case "$1" in *'*') shift;; #failed glob *.gz) if zcat "$1" | grep -q "$e3e3" 2>/dev/null >/dev/null; then mancodeja="utf-8" else # default mancodeja="euc-jp" fi break;; *) if grep -q "$e3e3" "$1" 2>/dev/null >/dev/null; then mancodeja="utf-8" else # default mancodeja="euc-jp" fi break;; esac done if [ -z "$mancodeja" ]; then echo "Cannot determine default man/ja charset. Stop." >&2 exit 2 fi fi ## Now, determine a program to convert ISO-2022-JP to $mancodeja. if nkf2 -w /dev/null 2>/dev/null; then ## nkf2 is most robust CONVJ="nkf2 -j" case "$mancodeja" in euc-jp) CONV="nkf2 -e";; utf-8) CONV="nkf2 -w";; esac elif piconv -f iso-2022-jp -t $mancodeja /dev/null 2>/dev/null; then ## piconv (Perl iconv) is portable, given perl >= 5.8.0 CONV="piconv -f iso-2022-jp -t $mancodeja" CONVJ="piconv -t iso-2022-jp -f $mancodeja" elif iconv -f iso-2022-jp -t $mancodeja /dev/null 2>/dev/null; then ## iconv is less reliable, but better than nothing CONV="iconv -f iso-2022-jp -t $mancodeja" CONVJ="iconv -t iso-2022-jp -f $mancodeja" elif "$mancodeja" = "euc-jp" && jistoeuc /dev/null; then ## Older SunOS may have this CONV="jistoeuc" CONVJ="euctojis" fi if [ -z "$CONV" ]; then echo "Cannot determine converter to charcode ${mancodeja}. Stop." >&2 exit 3 fi if [ -z "$mandirja" ]; then echo "Warning: cannot determine japanese man directory. Emitting null install-man-ja." >&2 cat <>./Makefile install-man-ja: : EOF else cat <>./Makefile MANDIRJA=$mandirja install-man-ja: passwdbattler.ja.6 test -d \$(DESTDIR)\$(MANDIRJA)/man6 || mkdir -p \$(DESTDIR)\$(MANDIRJA)/man6 $CONV < ./passwdbattler.ja.6 > \$(DESTDIR)\$(MANDIRJA)/man6/passwdbattler.6 chmod 644 \${DESTDIR}\$(MANDIRJA)/man6/passwdbattler.6 touch -r ./passwdbattler.ja.6 \$(DESTDIR)\$(MANDIRJA)/man6/passwdbattler.6 passwdbattler.ja.6: passwdbattler.ja.html $CONV < ./passwdbattler.ja.html | sed -f html2roff | $CONVJ > \$@ EOF if [ "$mancodeja" = utf-8 ]; then # Easiest; we may have UTF-8 capable groff. JGROFF="groff -K utf8 -Tutf8 -man" else # Harder to detect. # jgroff -Tnippon || groff -Tnippon : groff with japanese patch # Fallback to nroff -man, which may not work if jgroff -Tnippon -man >./Makefile man-test: ./passwdbattler.ja.6 $CONV < ./passwdbattler.ja.6 | $JGROFF EOF fi echo "./Makefile generated." >&2