# 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
DOC=$(AFSROOT)\doc

#If AFS_OBJDIR is not defined then use obj as relative obj folder
!IFNDEF AFS_OBJDIR
AFS_OBJDIR=$(AFSROOT)\obj\$(SYS_NAME)
!ENDIF

!IFNDEF DESTDIR
DESTDIR=$(AFSROOT)\dest\$(SYS_NAME)
!ENDIF

!IFNDEF NOCYGWIN
WIXCYGOPT=-dCygwinArchives
!ELSE
WIXCYGOPT=
!ENDIF

CD = cd
MKDIR = mkdir

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

#debug statement support jumping to last known 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) ..\..\..

lwp_headers:
     @echo ***** $@
	$(DOCD) $(SRC)\lwp
	$(CD) $(SRC)\lwp
	$(NTMAKE_HEADERS)
	$(CD) ..\..

util: procmgmt_headers afsreg_headers lwp_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) ..\..

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

ubik_headers: rxdebug
     @echo ***** $@
	$(DOCD) $(SRC)\ubik
	$(CD) $(SRC)\ubik
	$(NTMAKE_HEADERS)
	$(CD) ..\..

rxstat: ubik_headers
     @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) ..\..

talocale: tbutc
     @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) ..\..\..

libadmin: afsd
     @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) ..\..\..

afsadmsvr: admintest
     @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) ..\..\..

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

netidmgr_plugin: xstat
     @echo ***** $@
	$(DOCD) $(SRC)\WINNT\$@
	$(CD) $(SRC)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

extra: netidmgr_plugin
!	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) ..\..

install: finale
	@echo Build Finished Successfully
        

# 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) ..\..\..\..

man-pages: 
   @echo ***** $@
   $(DOCD) $(DOC)\man-pages
   $(CD) $(DOC)\man-pages
   $(NTMAKE)
   $(CD) ..\..

documentation:
   @echo ***** $@
   $(DOCD) $(DOC)\xml\ReleaseNotesWindows
   $(CD) $(DOC)\xml\ReleaseNotesWindows
   $(NTMAKE)
   $(DOCD) ..\UserGuide
   $(CD) ..\UserGuide
   $(NTMAKE)
   $(DOCD) ..\AdminGuide
   $(CD) ..\AdminGuide
   $(NTMAKE)
   $(DOCD) ..\..\..
   $(CD) ..\..\..

NSIS.i386: loopback man-pages documentation
   @echo ***** Making NSIS Installer
   $(DOCD) $(SRC)\WINNT\install\$@
   $(CD) $(SRC)\WINNT\install\$@
   $(NTMAKE)
   $(CD) ..\..\..\..

NSIS.AMD64:
   @echo Skipping NSIS Installer on non-x86 platforms; not implemented

NSIS: NSIS.$(CPU)

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

media: install NSIS wix

install-nsis: install NSIS

install-wix: install wix


