#******************************************************************************
#
#   Copyright (C) 1998-2000, International Business Machines
#   Corporation and others.  All Rights Reserved.
#
#******************************************************************************
## ICU data directory. This is the directory where the final packaging
## of data goes, + some test data.
##
## Point ICU_DATA to this directory.
##
## Stephen F. Booth
## Steven R. Loomis

## Install directory information
srcdir = @srcdir@
top_srcdir = @top_srcdir@

top_builddir = ..

include $(top_builddir)/icudefs.mk

## Build directory information
subdir = data

## Platform-specific setup
include @platform_make_fragment@

## Files to remove for 'make clean'
CLEANFILES = *~ $(SPECIALTESTDATA)

DOCDIRS = 
SUBDIRS = build

## Extra files to install [nothing at present]
SPECIALTESTDATA=test1.cnv test3.cnv test4.cnv
TESTDATAOBJDIR=../test/testdata
top_builddir_from_tmp = $(patsubst ..%,../..%,$(top_builddir))
INVOKE = $(LDLIBRARYPATH_ENVVAR)=$(top_builddir_from_tmp)/common:$(top_builddir_from_tmp)/tools/toolutil:$$$(LDLIBRARYPATH_ENVVAR)
CURDIR=$(shell /bin/pwd)
PKGDATA = $(top_builddir_from_tmp)/tools/pkgdata/pkgdata -O $(top_builddir_from_tmp)/tools/pkgdata/icupkg.inc -d $(CURDIR) -m $(PKGDATA_MODE) 


## List of phony targets
.PHONY : all all-local all-recursive install install-local install-udata install-udata-files install-udata-dlls install-convrtrstxt	\
install-recursive clean clean-local clean-recursive distclean		\
distclean-local distclean-recursive doc dist dist-local dist-recursive	\
check check-local check-recursive builddata

## Clear suffix list
.SUFFIXES :

## List of standard targets
all: all-recursive 
install: install-recursive 
clean: clean-recursive
distclean : distclean-recursive distclean-local
dist: dist-recursive dist-local
check: all check-recursive check-local

## Recursive targets
all-recursive install-recursive clean-recursive distclean-recursive dist-recursive check-recursive:
	@dot_seen=no; \
	target=`echo $@ | sed s/-recursive//`; \
	list='$(SUBDIRS)'; for subdir in $$list; do \
	  echo "Making $$target in $$subdir"; \
	  if test "$$subdir" = "."; then \
	    dot_seen=yes; \
	    local_target="$$target-local"; \
	  else \
	    local_target="$$target"; \
	  fi; \
	  (cd $$subdir && $(MAKE) $$local_target) || exit; \
	done; \
	if test "$$dot_seen" = "no"; then \
	  $(MAKE) "$$target-local" || exit; \
	fi

ifeq ($(OS390BATCH),1)
OS390PKG= package390
endif

all-local: packagedata testdata packagetest $(OS390PKG)



dist-local:

cleanfiles:
	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)

clean-local: cleanpackage cleanfiles


distclean-local: clean-local
	$(RMV) Makefile

check-local:

Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
	cd $(top_builddir) \
		&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status

packagedata: build/icudata.lst $(top_builddir)/tools/pkgdata/icupkg.inc
	( cd build ; $(INVOKE) $(PKGDATA) -e icudata -s . -T . -p $(ICUDATA_NAME) icudata.lst )

packagetest: $(TESTDATAOBJDIR)/testdata.lst $(top_builddir)/tools/pkgdata/icupkg.inc
	( cd $(TESTDATAOBJDIR) ; $(INVOKE) $(PKGDATA) -T . -s . -p testdata testdata.lst )

cleanpackage:
	@echo Cleaning up packaged data..
	@-( cd build ; $(INVOKE) $(PKGDATA) -s . -T . -p $(ICUDATA_NAME) icudata.lst --clean 2> /dev/null)
	@-( cd $(TESTDATAOBJDIR) ; $(INVOKE) $(PKGDATA) -T . -s . -p testdata testdata.lst  --clean 2> /dev/null )
	$(RMV) $(ICUDATA_NAME).* build/icudata.lst build/*.mak

## Install ICU data. Make a convenience link 'icudata' library if it's a library mode.
install-local:  build/icudata.lst $(top_builddir)/tools/pkgdata/icupkg.inc install-convrtrstxt
	$(MKINSTALLDIRS) $(TMPDATADIR) $(DESTDIR)$(ICUDATA_DIR)/$(VERSION)
	( cd build ; $(INVOKE) $(PKGDATA) -e icudata -T . -s . -p $(ICUDATA_NAME) icudata.lst -I $(DESTDIR)$(ICUDATA_DIR)/$(VERSION) )
ifeq ($(strip $(PKGDATA_MODE)),dll)
	(cd $(DESTDIR)$(ICUDATA_DIR)/$(VERSION); $(RM) icudata.$(SO) && ln -s $(ICUDATA_NAME).$(SO) icudata.$(SO))
endif

install-convrtrstxt: $(top_srcdir)/../data/convrtrs.txt
	$(MKINSTALLDIRS) $(DESTDIR)$(pkgsysconfdir)
	$(INSTALL_DATA) $< $(DESTDIR)$(pkgsysconfdir)

# specials
testdata: $(SPECIALTESTDATA)

%.cnv: build/%.cnv
	ln -sf $< .

###################
###################
################### 390 support
package390: build/icudata390.lst build/icudata.lst $(top_builddir)/tools/pkgdata/icupkg.inc
	@$(MKINSTALLDIRS) tmp390A
	@$(MKINSTALLDIRS) tmp3901
	( cd build ; $(INVOKE) $(PKGDATA) -s . -T ../tmp390A -p IXMICUDA icudata.lst )
	( cd build ; $(INVOKE) $(PKGDATA) -s . -T ../tmp3901 -p IXMICUD1 icudata390.lst )