# 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

# Top level nmake NTMakefile driver for building AFS.
#
# This file simply imposes a reasonable total ordering on the set of
# directories to build; this ordering is of course more strict than the
# partial ordering established by the actual directory dependencies.
#
# When porting a new directory, simply add the directory into the
# dependence chain at the earliest point possible, updating its successor
# appropriately; if the new directory is the last in the chain, then
# update the 'finale' dependency to be the new directory.

# These three macros define the source, object, and destination folders
SRC=$(AFSROOT)\src
#If AFS_OBJDIR is not defined then use obj as relative obj folder
!IFNDEF AFS_OBJDIR
AFS_OBJDIR=$(AFSROOT)\obj
!ENDIF
!IFNDEF DESTDIR
DESTDIR=$(AFSROOT)\dest
!ENDIF

CD = cd
NTMAKE = nmake /nologo /f ntmakefile install
NTMAKELANG = nmake /nologo  /f ntmakefile en_US
NTMAKE_HEADERS = nmake /nologo  /f ntmakefile install_headers
NTMAKE_OBJS = nmake /nologo /f ntmakefile install_objs
MKDIR = mkdir

#debug statement support jumping to last know error
DOCD=$(SRC)\DOLASTCMP.BAT

config:
     echo ***** $@
	$(DOCD) $(SRC)\config
	$(CD) $(SRC)\config
	$(NTMAKE)
	$(CD) ..\..

procmgmt_headers:config
     echo ***** $@
	$(DOCD) $(SRC)\procmgmt
	$(CD) $(SRC)\procmgmt
	$(NTMAKE_HEADERS)
	$(CD) ..\..

afsreg_headers:
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\afsreg
	$(CD) $(SRC)\WINNT\afsreg
	$(NTMAKE_HEADERS)
	$(CD) ..\..\..

util: procmgmt_headers afsreg_headers
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

comerr: util
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

afs: comerr
      echo ***** $@
      $(DOCD) $(SRC)\afs
      $(CD) $(SRC)\afs
      $(NTMAKE)
      $(CD) ..\..

cmd: afs
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

afsreg: cmd
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

eventlog: afsreg
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

lwp: eventlog
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

rxgen: lwp
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

des: rxgen
     echo ***** $@
!	IF (EXIST($(SRC)\des\NTMakefile))
		$(DOCD) $(SRC)\des
		$(CD) $(SRC)\des
		$(NTMAKE)
		$(CD) ..\..
!	ELSE
		$(DOCD) $(SRC)\des_stub
		$(CD) $(SRC)\des_stub
		$(NTMAKE)
		$(CD) ..\..
!	ENDIF

rx: des
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

rxstat: rx
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

rxkad: rxstat
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

pthread: rxkad
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

procmgmt: pthread
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

fsint: procmgmt
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

audit: fsint
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

osi_headers: audit
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\client_osi
	$(CD) $(SRC)\WINNT\client_osi
	$(NTMAKE_HEADERS)
	$(CD) ..\..\..

libacl_headers: osi_headers
     echo ***** $@
	$(DOCD) $(SRC)\libacl
	$(CD) $(SRC)\libacl
	$(NTMAKE_HEADERS)
	$(CD) ..\..

cm_headers: libacl_headers
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\afsd
	$(CD) $(SRC)\WINNT\afsd
	$(NTMAKE_HEADERS)
	$(CD) ..\..\..

auth_headers: cm_headers
     echo ***** $@
	$(DOCD) $(SRC)\auth
	$(CD) $(SRC)\auth
	$(NTMAKE_HEADERS)
	$(CD) ..\..

vlserver_headers: auth_headers
     echo ***** $@
	$(DOCD) $(SRC)\vlserver
	$(CD) $(SRC)\vlserver
	$(NTMAKE_HEADERS)
	$(CD) ..\..

afsdobjs: vlserver_headers
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\afsd
	$(CD) $(SRC)\WINNT\afsd
	$(NTMAKE_OBJS)
	$(CD) ..\..\..

sys: afsdobjs
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

auth: sys
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..	

ubik: auth
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..	

ptserver: ubik
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..	

libacl: ptserver
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

kauth: libacl
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

vlserver: kauth
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

usd: vlserver
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

bubasics: usd
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

budb:	bubasics
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..
butm:  budb
     echo ***** $@
     $(DOCD) $(SRC)\$@
     $(CD) $(SRC)\$@
     $(NTMAKE)
     $(CD) ..\..

dir: butm
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

vol: dir
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

volser: vol
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

viced: volser
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

update: viced
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

bucoord: update
     echo ***** $@
     $(DOCD) $(SRC)\$@
     $(CD) $(SRC)\$@
     $(NTMAKE)
     $(CD) ..\..

butc:   bucoord
     echo ***** $@
     $(DOCD) $(SRC)\$@
     $(CD) $(SRC)\$@
     $(NTMAKE)
     $(CD) ..\..

bozo: butc
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

bosctlsvc: bozo
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

bu_utils: bosctlsvc
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

libafsrpc: bu_utils
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

libafsauthent: libafsrpc
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

tviced: libafsauthent
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

tbutc:  tviced
     echo ***** $@
     $(DOCD) $(SRC)\$@
     $(CD) $(SRC)\$@
     $(NTMAKE)
     $(CD) ..\..

libadmin: tbutc
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..

adminutil: libadmin
     echo ***** $@
	$(DOCD) $(SRC)\libadmin\$@
	$(CD) $(SRC)\libadmin\$@
	$(NTMAKE)
	$(CD) ..\..\..

vos: adminutil
     echo ***** $@
	$(DOCD) $(SRC)\libadmin\$@
	$(CD) $(SRC)\libadmin\$@
	$(NTMAKE)
	$(CD) ..\..\..

client: vos
     echo ***** $@
	$(DOCD) $(SRC)\libadmin\$@
	$(CD) $(SRC)\libadmin\$@
	$(NTMAKE)
	$(CD) ..\..\..

kas: client
     echo ***** $@
	$(DOCD) $(SRC)\libadmin\$@
	$(CD) $(SRC)\libadmin\$@
	$(NTMAKE)
	$(CD) ..\..\..

pts: kas
     echo ***** $@
	$(DOCD) $(SRC)\libadmin\$@
	$(CD) $(SRC)\libadmin\$@
	$(NTMAKE)
	$(CD) ..\..\..

bos: pts
     echo ***** $@
	$(DOCD) $(SRC)\libadmin\$@
	$(CD) $(SRC)\libadmin\$@
	$(NTMAKE)
	$(CD) ..\..\..

cfg: bos
     echo ***** $@
	$(DOCD) $(SRC)\libadmin\$@
	$(CD) $(SRC)\libadmin\$@
	$(NTMAKE)
	$(CD) ..\..\..

admintest: cfg
     echo ***** $@
	$(DOCD) $(SRC)\libadmin\test
	$(CD) $(SRC)\libadmin\test
	$(NTMAKE)
	$(CD) ..\..\..

talocale: admintest
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

license: talocale
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

client_osi: license
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

afsd: client_osi
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

afsadmsvr: afsd
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

afsusrmgr: afsadmsvr
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

afssvrmgr: afsusrmgr
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

afssvrcfg: afssvrmgr
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

afssvrcpa: afssvrcfg
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

client_talocale: afssvrcpa
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\talocale
	$(CD) $(SRC)\WINNT\talocale
	$(NTMAKE)
	$(CD) ..\..\..

client_cpa: client_talocale
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

client_config: client_cpa
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

client_exp: client_config
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

client_creds: client_exp
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

aklog: client_creds
     echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

extra: aklog
!	IF EXIST($(SRC)\WINNT\extra) && EXIST($(SRC)\WINNT\extra\NTMakefile)
     echo ***** $@
    $(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..
!	ELSE
     echo ***** Skipping $@ ***** Not found.
!	ENDIF
                
finale: extra
     echo ***** $@
	$(DOCD) $(SRC)\$@
	$(CD) $(SRC)\$@
	$(NTMAKE)
	$(CD) ..\..	
	echo Build Finished Successfully

install: finale

# InstallShield dependencies

# Clean target for obj tree
clean:
	nmake /nologo /f ntmakefile "NTMAKE = nmake /nologo /f ntmakefile clean" "NTMAKE_HEADERS = nmake /nologo /f ntmakefile clean" "NTMAKE_OBJS = nmake /nologo /f ntmakefile clean" install
	nmake /nologo /f ntmakefile "NTMAKE = nmake /nologo /f ntmakefile clean" "NTMAKE_HEADERS = nmake /nologo /f ntmakefile clean" "NTMAKE_OBJS = nmake /nologo /f ntmakefile clean" media
	$(CD) $(SRC)\config
	nmake /nologo /f ntmakefile clean_version
	$(CD) ..\..

# Language-only build target
lang:
    nmake /nologo /f ntmakefile "NTMAKE = nmake /nologo /f ntmakefile lang" "NTMAKE_HEADERS = nmake /nologo /f ntmakefile lang" install

mkdir:
    -mkdir $(AFS_OBJDIR)
    -mkdir $(DESTDIR)
    -mkdir $(AFS_OBJDIR)\checked
    -mkdir $(AFS_OBJDIR)\free
	-xcopy /q /t /e $(SRC)\*.* $(AFS_OBJDIR)\checked\ 
	-xcopy /q /t /e $(SRC)\*.* $(AFS_OBJDIR)\free\ 
    -mkdir $(DESTDIR)\checked
	-mkdir $(DESTDIR)\free
    -mkdir $(DESTDIR)\checked\bin
	-mkdir $(DESTDIR)\free\bin
	-@copy $(SRC)\config\NTLANG.BAT .

loopback:
   echo ***** Making Loopback Adapter Utility DLL
   $(DOCD) $(SRC)\WINNT\install\$@
   $(CD) $(SRC)\WINNT\install\$@
   $(NTMAKE)
   $(CD) ..\..\..\..

NSIS: loopback
   echo ***** Making NSIS Installer
   $(DOCD) $(SRC)\WINNT\install\$@
   $(CD) $(SRC)\WINNT\install\$@
   $(NTMAKE)
   $(CD) ..\..\..\..

wix: loopback
   echo ***** Making Wix MSI Installer
   $(DOCD) $(SRC)\WINNT\install\$@
   $(CD) $(SRC)\WINNT\install\$@
   $(NTMAKE)
   $(CD) ..\..\..\..

InstallShield5:
	echo ***** afs_setup_utils
	$(DOCD) $(SRC)\WINNT\afs_setup_utils
	$(CD) $(SRC)\WINNT\afs_setup_utils
	$(NTMAKE)
	$(CD) ..\..\..

	$(DOCD) $(SRC)\WINNT\install\$@
	$(CD) $(SRC)\WINNT\install\$@
	$(NTMAKE)
	$(CD) ..\..\..\..

media: install InstallShield5 NSIS wix

install-nsis: install NSIS

install-wix: install wix

install-is5: install InstallShield5

