## ******************************************************************************
## *
## *   Copyright (C) 1999-2004, International Business Machines
## *   Corporation and others.  All Rights Reserved.
## *
## *******************************************************************************
## Makefile.in for ICU - uconv
## Steven  R. Loomis

## Set the following to dll or static or common..
UCONVMSG_MODE=static
##############################################################

srcdir=@srcdir@
top_srcdir=@top_srcdir@

top_builddir = ../..
subdir = extra/uconv

include $(top_builddir)/icudefs.mk

MSGNAME=uconvmsg

# RESSRC comes from resfiles.mk
FILESEPCHAR=/
include $(srcdir)/resfiles.mk

RESDIR=$(MSGNAME)
RESFILES=$(RESSRC:$(RESOURCESDIR)$(FILESEPCHAR)%.txt=$(RESDIR)/$(RESOURCESDIR)$(FILESEPCHAR)$(MSGNAME)_%.res)

##

TARGET_STUB_NAME = uconv

SECTION = 1

ALL_MAN_FILES = $(TARGET_STUB_NAME).$(SECTION)

## Extra files to remove for 'make clean'
CLEANFILES = *~ $(DEPS) $(ALL_MAN_FILES)

## Target information
TARGET = $(BINDIR)/$(TARGET_STUB_NAME)$(EXEEXT)

CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(srcdir)/../toolutil
LIBS = $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)

ifeq ($(PKGDATA_OPTS),)
PKGDATA_OPTS = -O pkgdata.inc
endif

## generic settings for data - common.
PKGMODE=common
INSTALLTO=$(DESTDIR)$(ICUDATA_DIR)
UCONVMSG_LIB=dummy

## Static mode
ifeq ($(UCONVMSG_MODE),static)
DEFS += -DUCONVMSG_LINK=$(MSGNAME)
UCONVMSG_LIB = $(RESDIR)/$(LIBPREFIX)$(MSGNAME).$(A)
LIBS += $(UCONVMSG_LIB)
PKGMODE=static
INSTALLTO=$(libdir)
endif

## DLL mode
ifeq ($(UCONVMSG_MODE),dll)
DEFS += -DUCONVMSG_LINK=$(MSGNAME)
LIBS += -L$(RESDIR) -l$(MSGNAME)
PKGMODE=dll
INSTALLTO=$(libdir)
endif

OBJECTS = uconv.o uwmsg.o

DEPS = $(OBJECTS:.o=.d)

## List of phony targets
.PHONY : all all-local install install-local clean clean-local \
distclean resclean distclean-local dist dist-local check check-local resfiles package-resfiles install-resfiles install-man

## Clear suffix list
.SUFFIXES :

## List of standard targets
all: all-local

install: install-local
clean: clean-local
distclean : distclean-local
dist: dist-local
check: check-local

all-local: $(TARGET) resfiles $(ALL_MAN_FILES)

install-local: all-local install-target install-resfiles install-man

install-target: all-local
	$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
	$(INSTALL) $(TARGET) $(DESTDIR)$(bindir)

dist-local:

clean-local: resclean
	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) $(RESFILES)
	$(RMV) $(OBJECTS) $(TARGET)

resclean:
	#-$(INVOKE) $(BINDIR)/pkgdata --clean -p $(RESDIR) -O pkgdata.inc -m $(PKGMODE) -d $(RESDIR) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst
	$(RMV) pkgdata.inc $(RESDIR)

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

check-local:

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

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

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

$(TARGET) : $(OBJECTS)  $(UCONVMSG_LIB)
	$(LINK.cc) $(OUTOPT)$@ $(OBJECTS) $(LIBS)

resfiles: $(RESFILES) package-resfiles

ifeq ($(UCONVMSG_STATIC),YES)
$(UCONVMSG_LIB): resfiles
endif


package-resfiles: $(RESDIR)/$(RESDIR).lst pkgdata.inc
	$(INVOKE) $(PKGDATA_INVOKE_OPTS) $(BINDIR)/pkgdata -p $(RESDIR) $(PKGDATA_OPTS) -m $(PKGMODE) -d $(RESDIR) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst

$(RESDIR)/$(RESDIR).lst: Makefile pkgdata.inc $(srcdir)/resfiles.mk
	@$(MKINSTALLDIRS) $(RESDIR)
	@-$(RMV) $@
	@for file in $(RESFILES); do \
	  echo $(CURR_FULL_DIR)/$$file >> $@; \
	done;

# no install for static mode
ifneq ($(UCONVMSG_MODE),static)
install-resfiles: $(RESFILES)
	$(MKINSTALLDIRS) $(DESTDIR)$(ICUDATA_DIR)
	$(INVOKE) $(BINDIR)/pkgdata -p $(RESDIR) -O pkgdata.inc -m $(PKGMODE) -d $(RESDIR) -I $(INSTALLTO) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst
endif

##
$(UCONVMSG_LIB): resfiles

$(RESDIR)/$(RESOURCESDIR)/$(MSGNAME)_%.res: $(srcdir)/$(RESOURCESDIR)/%.txt
	$(MKINSTALLDIRS) $(@D)
	$(INVOKE) $(BINDIR)/genrb -p $(MSGNAME) -e UTF-8 -s $(^D) -d $(@D) $(^F)

install-man: $(ALL_MAN_FILES)
	$(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(SECTION)
	$(INSTALL_DATA) $? $(DESTDIR)$(mandir)/man$(SECTION)



