# Copyright 2004, OpenAFS.ORG and others.
# All Rights Reserved.
#
# This software has been released under the terms of the IBM Public
# License.  For details, see the LICENSE file in the top-level source
# directory or online at http://www.openafs.org/dl/license10.html

RELDIR=WINNT\install\wix
!INCLUDE ..\..\..\config\NTMakefile.$(SYS_NAME)
!INCLUDE ..\..\..\config\NTMakefile.version

MEDIADIR = $(DESTDIR)\WinInstall
MEDIABINDIR = $(MEDIADIR)\Dll

MSIFILE = $(MEDIADIR)\openafs-$(LANG).msi

WIXINCLUDES = \
	config.wxi \
	feature.wxi \
	files.wxi \
	language_config.wxi \
	property.wxi \
	registry.wxi \
	lang\$(LANG)\ui.wxi

WIXOBJ = $(OUT)\openafs-$(LANG).wixobj

LANGUAGES=en_US de_DE es_ES ja_JP ko_KR pt_BR zh_CN zh_TW

languages:
# Don't bother with non en_US for now.  The other builds comprise of either
# verbatim copies of en_US files, partial translations or doesn't build 
# (no languages resources). Someday when OpenAFS 8.1029828419 comes out we'll 
# get someone to translate.
#	for %l in ( $(LANGUAGES ) do (
#	$(MAKE) /f NTMakefile /nologo LANG=%l lang
#	)
	$(MAKE) /f NTMakefile /nologo LANG=en_US lang

lang:: lang_clean $(MSIFILE)

uninst: 
        $(CD) uninstall
        $(MAKE) /f NTMakefile /nologo install
        $(CD) ..

customactions:
	$(CD) custom
	$(MAKE) /f NTMakefile /nologo install
	$(CD) ..

install: uninst customactions languages 

$(MSIFILE): $(WIXOBJ)
	light -nologo -out $(MSIFILE) \
		-loc lang\$(LANG)\strings.wxl \
		$(WIXOBJ)
	dir $(MSIFILE)

$(WIXOBJ): openafs.wxs $(WIXINCLUDES)
	candle -nologo -out $@	\
		"-dCellName=$(CELLNAME_DEFAULT)" \
		-dLanguage=$(LANG) \
		-dNumericVersion=$(AFSPRODUCT_VERSION)	\
		-dVersionMajor=$(AFSPRODUCT_VER_MAJOR)	\
		-dVersionMinor=$(AFSPRODUCT_VER_MINOR)	\
		-dVersionPatch=$(AFSPRODUCT_VER_PATCH)	\
		"-dDestDir=$(DESTDIR)\\" \
		-dCellDbFile=CellServDB \
		-v0 \
		-w0 \
        $(AFSDEV_AUXWIXDEFINES)	openafs.wxs

# Cleanup
clean::
	for %l in ( $(LANGUAGES) ) do \
		$(MAKE) /f NTMakefile /nologo LANG=%l lang_clean
	$(CD) custom
	$(MAKE) /f NTMakefile /nologo clean
	$(CD) ..
	$(CD) uninstall
	$(MAKE) /f NTMakefile /nologo clean
	$(CD) ..
	
lang_clean:
	-$(DEL) $(WIXOBJ)
	-$(DEL) $(MSIFILE)
