# Makefile for portnls library routines and auxiliary
# message catalog files (/usr/lib/nls/$LANG/custdat.cat)
#

GENCAT=/usr/bin/gencat

NLSDIR=nls
LIB=libportnls.a
LIB_M=libportnls.M
INC=include
PFLAGS	= -I$(INC)
VERSION=Uni_rel.o

HFILES=$(INC)/nlinfo.h

OBJECTS=hpux_rel.o	\
	almanac.o	\
	getnltable.o	\
	nlappend.o	\
	nlcollate.o	\
	nlcollsys.o	\
	nlconvclock.o	\
	nlconvcustda.o	\
	nlconvnum.o	\
	extract_nldt.o	\
	format_nldt.o	\
	nlcrtm.o	\
	nldate.o	\
	nlfindstr.o	\
	nlfmtcal.o	\
	nlfmtclock.o	\
	nlfmtcustdat.o	\
	nlfmtdate.o	\
	nlfmtlongcal.o	\
	nlfmtnum.o	\
	nlgetlang.o	\
	nlinfo.o	\
	nljudge.o	\
	nlkeycompare.o	\
	nlnumspec.o	\
	nlrepchar.o	\
	nlscanmove.o	\
	nlsubstr.o	\
	nlswitchbuf.o	\
	nltranslate.o	\
	nlutils.o	\
	utils.o

SOURCES=hpux_rel.c	\
	almanac.c	\
	getnltable.c	\
	nlappend.c	\
	nlcollate.c	\
	nlcollsys.c	\
	nlconvclock.c	\
	nlconvcustda.c	\
	nlconvnum.c	\
	extract_nldt.c	\
	format_nldt.c	\
	nlcrtm.c	\
	nldate.c	\
	nlfindstr.c	\
	nlfmtcal.c	\
	nlfmtclock.c	\
	nlfmtcustdat.c	\
	nlfmtdate.c	\
	nlfmtlongcal.c	\
	nlfmtnum.c	\
	nlgetlang.c	\
	nlinfo.c	\
	nljudge.c	\
	nlkeycompare.c	\
	nlnumspec.c	\
	nlrepchar.c	\
	nlscanmove.c	\
	nlsubstr.c	\
	nlswitchbuf.c	\
	nltranslate.c	\
	nlutils.c	\
	utils.c

LANGS = american 	\
	arabic 		\
	arabic-w 	\
	c-french 	\
	chinese-s 	\
	chinese-t  	\
        danish 		\
	dutch 		\
	english 	\
	finnish 	\
	french 		\
	german 		\
	greek     	\
        hebrew 		\
	icelandic 	\
	italian 	\
	japanese 	\
	katakana 	\
	korean      	\
        n-computer 	\
	norwegian 	\
	portuguese 	\
	spanish 	\
	swedish 	\
	turkish

default: all

metrics: $(LIB_M)

all:	expand catalogs $(LIB)

$(LIB): $(OBJECTS) 
	rm -f $(LIB)
	ar q $(LIB) $(OBJECTS)

$(LIB_M): expand $(SOURCES)
	$(METRICS) $(CFLAGS) $(PFLAGS) $(SOURCES) -o $(LIB_M)

#
# The following target has been added to expand certain file names,
# that get truncated to 12 characters by rcs, to their original
# 14 character file names.
#
expand:
	-cp extract_nldt extract_nldt.c
	-cp format_nldt. format_nldt.c
	-cp nlconvclock. nlconvclock.c
	-cp nlconvcustda nlconvcustda.c
	-cp nlfmtcustdat nlfmtcustdat.c
	-cp nlfmtlongcal nlfmtlongcal.c
	-cp nlkeycompare nlkeycompare.c
	-cp nlswitchbuf. nlswitchbuf.c
	-cp nltranslate. nltranslate.c


#
# For completeness sake, go ahead and nuke all the "expanded" source
# files.
#
clean:
	rm -f $(OBJECTS) $(VERSION) extract_nldt.c format_nldt.c \
		nlconvclock.c nlconvcustda.c nlfmtcustdat.c nlfmtlongcal.c \
		nlkeycompare.c nlswitchbuf.c nltranslate.c

#
# For the clobber target a rm -rf was added to delete the nls directory and
# everything that it contained.  Previously just the .cat files were removed
# in the clean target.
#
clobber: clean
	rm -rf $(LIB) $(NLSDIR)

catalogs: 
	test ! -d $(NLSDIR) && mkdir $(NLSDIR);			\
	for i in $(LANGS);					\
		do 						\
			test ! -d $(NLSDIR)/$$i && mkdir $(NLSDIR)/$$i; \
			$(GENCAT) $(NLSDIR)/$$i/custdat.cat c.$$i; \
		done

.c.o:
	$(CC) $(CFLAGS) $(PFLAGS) -c $<
