# Copyright 2000, International Business Machines Corporation 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

# make compiler warnings fatal

AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -WX

# include the primary makefile
RELDIR=WINNT\afs_setup_utils
!INCLUDE ..\..\config\NTMakefile.$(SYS_NAME)
!INCLUDE ..\..\config\NTMakefile.version

############################################################################

ILIBDIR = $(DESTDIR)\lib\afs


############################################################################
# Build targets - one for each dll we need to make

INSTALL_UTILS_DLLFILE       = $(DESTDIR)\root.server\usr\afs\bin\InstallUtils.dll
SERVER_UNINST_DLLFILE       = $(DESTDIR)\root.server\usr\afs\bin\ServerUninst.dll
CLIENT_UNINST_DLLFILE       = $(DESTDIR)\root.server\usr\afs\bin\ClientUninst.dll
CC_UNINST_DLLFILE           = $(DESTDIR)\root.server\usr\afs\bin\CCUninst.dll
LIGHT_CLIENT_UNINST_DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\LightClientUninst.dll
DOCS_UNINST_DLLFILE         = $(DESTDIR)\root.server\usr\afs\bin\DocsUninst.dll


############################################################################
# Source files and libraries that are shared by all of the targets.

AFSAPPLIBOBJS = \
    $(OUT)\subclass.obj

DLLOBJS = \
    $(AFSAPPLIBOBJS)    \
    $(OUT)\progress_dlg.obj    \
    $(OUT)\animate_icon.obj    \
    $(OUT)\sutil.obj           \
    $(OUT)\forceremove.obj     \
    $(OUT)\afs_setup_utils_stub.res

VCLIBS = \
	comctl32.lib \
	shell32.lib

DLLLIBS = \
	$(DESTDIR)\lib\afs\TaLocale.lib \
    $(DESTDIR)\lib\afs\afsreg.lib \
    $(DESTDIR)\lib\afs\afsutil.lib


############################################################################
# Definitions for building afsapplib objects

AFSAPPLIBDIR = ..\..\WINNT\afsapplib

$(OUT)\subclass.obj: $(AFSAPPLIBDIR)\subclass.cpp
    $(C2OBJ) -I$(AFSAPPLIBDIR) $(AFSAPPLIBDIR)\subclass.cpp


############################################################################
# Definitions for building afsrm.exe

AFSRM_EXEFILE = $(DESTDIR)\bin\afsrm.exe

AFSRM_EXEOBJS =\
    $(OUT)\afsrm.obj \
    $(OUT)\forceremove.obj \
    $(OUT)\sutil.obj \
    $(OUT)\AFS_component_version_number.obj

AFSRM_EXELIBS =\
    $(DESTDIR)\lib\afs\afsreg.lib \
    $(DESTDIR)\lib\afs\afscmd.lib \
    $(DESTDIR)\lib\afs\afscom_err.lib \
    $(DESTDIR)\lib\afs\afsutil.lib

$(AFSRM_EXEFILE): $(AFSRM_EXEOBJS) $(AFSRM_EXELIBS)
        $(EXECONLINK)
        $(_VC_MANIFEST_EMBED_EXE)
        $(CODESIGN_USERLAND)

############################################################################

DIRLANG= ZH_TW ZH_CN PT_BR KO_KR JA_JP ES_ES EN_US DE_DE

install : $(INSTALL_UTILS_DLLFILE) $(SERVER_UNINST_DLLFILE) $(CLIENT_UNINST_DLLFILE) \
          $(CC_UNINST_DLLFILE) $(LIGHT_CLIENT_UNINST_DLLFILE) $(DOCS_UNINST_DLLFILE) \
          $(AFSRM_EXEFILE) $(DIRLANG)
		  cd _isuser
		  nmake -fntmakefile install
          $(CD) ..
		  cd getwebdll
		  nmake -fntmakefile install
          $(CD) ..
		  echo 

$(DIRLANG) ::
	$(CD) lang
	@$(NTLANG) $@ $(MAKECMD) /nologo /f NTMakefile install
	$(CD) ..
   echo done lang

############################################################################
# How to build the shared source file for each uninstall dll

C2OBJ = $(C2OBJ) -DSERVER_UNINST

$(OUT)\s_afs_setup_utils.obj: afs_setup_utils.cpp
	$(C2OBJ) $**

$(OUT)\c_afs_setup_utils.obj: afs_setup_utils.cpp
	$(C2OBJ) $**

$(OUT)\cc_afs_setup_utils.obj: afs_setup_utils.cpp
	$(C2OBJ) $**

$(OUT)\lc_afs_setup_utils.obj: afs_setup_utils.cpp
	$(C2OBJ) $**

$(OUT)\d_afs_setup_utils.obj: afs_setup_utils.cpp
	$(C2OBJ) $**


############################################################################

$(INSTALL_UTILS_DLLFILE) : $(OUT)\afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
    $(DLLGUILINK) -entry:DllEntryPoint /DEF:install_utils.def $(VCLIBS)
        $(_VC_MANIFEST_EMBED_DLL)
    $(DLLPREP)
        $(CODESIGN_USERLAND)
    $(COPY) $*.lib $(ILIBDIR)
    $(DEL) $*.lib $*.exp

$(SERVER_UNINST_DLLFILE) : $(OUT)\s_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
    $(DLLGUILINK) -entry:DllEntryPoint /DEF:server_uninst.def $(VCLIBS)
        $(_VC_MANIFEST_EMBED_DLL)
    $(DLLPREP)
        $(CODESIGN_USERLAND)
    $(COPY) $*.lib $(ILIBDIR)
    $(DEL) $*.lib $*.exp

$(CLIENT_UNINST_DLLFILE) : $(OUT)\c_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
    $(DLLGUILINK) -entry:DllEntryPoint /DEF:client_uninst.def $(VCLIBS)
        $(_VC_MANIFEST_EMBED_DLL)
    $(DLLPREP)
        $(CODESIGN_USERLAND)
    $(COPY) $*.lib $(ILIBDIR)
    $(DEL) $*.lib $*.exp

$(CC_UNINST_DLLFILE) : $(OUT)\cc_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
    $(DLLGUILINK) -entry:DllEntryPoint /DEF:cc_uninst.def $(VCLIBS)
        $(_VC_MANIFEST_EMBED_DLL)
    $(DLLPREP)
        $(CODESIGN_USERLAND)
    $(COPY) $*.lib $(ILIBDIR)
    $(DEL) $*.lib $*.exp

$(LIGHT_CLIENT_UNINST_DLLFILE) : $(OUT)\lc_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
    $(DLLGUILINK) -entry:DllEntryPoint /DEF:light_client_uninst.def $(VCLIBS)
        $(_VC_MANIFEST_EMBED_DLL)
    $(DLLPREP)
        $(CODESIGN_USERLAND)
    $(COPY) $*.lib $(ILIBDIR)
    $(DEL) $*.lib $*.exp

$(DOCS_UNINST_DLLFILE) : $(OUT)\d_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
    $(DLLGUILINK) -entry:DllEntryPoint /DEF:docs_uninst.def $(VCLIBS)
        $(_VC_MANIFEST_EMBED_DLL)
    $(DLLPREP)
        $(CODESIGN_USERLAND)
    $(COPY) $*.lib $(ILIBDIR)
    $(DEL) $*.lib $*.exp


############################################################################

clean::
   $(CD) _isuser
   nmake -fntmakefile clean
   $(CD) ..
   $(CD) getwebdll
   nmake -fntmakefile clean
   $(CD) ..
   echo done clean
   cd _isuser
   nmake -fntmakefile clean
   $(CD) ..
   cd getwebdll
   nmake -fntmakefile clean
   $(CD) ..
   echo

############################################################################
#
# Dependencies
#

$(OUT)\afs_setup_utils_stub.res : afs_setup_utils_stub.rc AFS_component_version_number.h

mkdir:
	-mkdir $(OUT)\lang
	cd lang
	nmake /nologo /f ntmakefile SRC=$(SRC) OBJ=$(OBJ) mkdir
	cd ..
