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


CD = cd
NTMAKE = nmake /nologo /f ntmakefile install9x
NTMAKELANG = nmake /nologo /f ntmakefile en_install
NTMAKE_HEADERS = nmake /nologo /f ntmakefile install_headers
NTMAKE_LIBUTILS = nmake /nologo /f ntmakefile install_libutils
NTMAKE_OBJS = nmake /nologo /f ntmakefile install_objs
MKDIR = mkdir
OBJ = src

# Standard install directory.
!IFDEF AFSDEV_DESTDIR
DESTDIR = $(AFSDEV_DESTDIR)
!ELSE
DESTDIR = $(AFSROOT)\DEST
!ENDIF


start:
!	IF (!EXIST(src))
!	ERROR Execute nmake from directory above src, e.g., afs\3.5.
!	ENDIF
!	IF (!EXIST($(DESTDIR)))
    $(MKDIR) $(DESTDIR)
!	ENDIF

config: start
     echo ***** $@
	$(CD) $(OBJ)\$@
	$(NTMAKE)
	$(CD) ..\..

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

afsreg_headers: config
     echo ***** $@
	$(CD) $(OBJ)\WINNT\afsreg
	$(NTMAKE_HEADERS)
	$(CD) ..\..\..

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

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

cmd: comerr
     echo ***** $@
	$(CD) $(OBJ)\$@
	$(NTMAKE)
	$(CD) ..\..

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

sys: cm_headers
     echo ***** $@
	$(CD) $(OBJ)\$@
	$(NTMAKE)
	$(CD) ..\..

afsdobjs: sys
     echo ***** $@
     $(CD) $(OBJ)\WINNT\afsd
     $(NTMAKE_OBJS)
     $(CD) ..\..\..

auth: afsdobjs
     echo ***** $@
	$(CD) $(OBJ)\$@
	$(NTMAKE)
	$(CD) ..\..

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

ptserver: ubik
     echo ***** $@
	$(CD) $(OBJ)\$@
	$(NTMAKE_LIBUTILS)
	$(CD) ..\..	

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

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

vlserver: kauth
     echo ***** $@
	$(CD) $(OBJ)\$@
	$(NTMAKE_LIBUTILS)
	$(CD) ..\..

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

libafsrpc: usd
     echo ***** $@
	$(CD) $(OBJ)\$@
	$(NTMAKE)
	$(CD) ..\..

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

libadmin: libafsauthent
     echo ***** $@
	$(CD) $(OBJ)\$@
	$(NTMAKE)
	$(CD) ..\..

client_talocale: libadmin
     echo ***** $@
	$(CD) $(OBJ)\WINNT\talocale
	$(NTMAKE)
	$(CD) ..\..\..

client_osi: client_talocale
     echo ***** $@
	$(CD) $(OBJ)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

afsd: client_osi
     echo ***** $@
	$(CD) $(OBJ)\WINNT\$@
	$(NTMAKE_LIBUTILS)
	$(CD) ..\..\..

client_cpa: afsd
     echo ***** $@
	$(CD) $(OBJ)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..

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

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


#Leave last echo in - it helps the build reconize the last $(CD)
win9xpanel :
	echo ***** $@
	$(CD) $(OBJ)\WINNT\$@
	$(NTMAKE)
	$(CD) ..\..\..
	echo ***** End of Build 

install: start client_exp win9xpanel

install9x: install

# InstallShield dependencies

#Leave last echo in - it helps the build reconize the last $(CD)
Win9x::
	echo ***** afs_setup_utils
	$(CD) $(OBJ)\WINNT\afs_setup_utils 
	nmake -f ntmakefile      install
	$(CD) ..\..\..
	echo ***** Win9x
	$(CD) $(OBJ)\WINNT\install\Win9x
	nmake /nologo /f NTMakefile  isinstall
	$(CD) ..\..\..\..
	echo **** End of Install Scripts

media: Win9x

# Clean target for obj tree
# Fake the version copy so clean will go through the complete cycle with undefines
clean: start
	if not exist .\src\config\NTMakefile.version copy .\src\config\NTMakefile.version-NOCML .\src\config\NTMakefile.version
	nmake /nologo /f ntmake9x "NTMAKE = nmake /nologo /f ntmakefile clean" "NTMAKE_HEADERS = nmake /nologo /f ntmakefile clean" "NTMAKE_LIBUTILS = nmake /nologo /f ntmakefile clean" "NTMAKE_OBJS = nmake /nologo /f ntmakefile clean" install
	$(CD) $(OBJ)\WINNT\install\Win9x
	nmake /nologo /f NTMakefile clean
	$(CD) ..\..\..\..
	$(DESTDIR)\BIN\rmbat $(DESTDIR)\include\*.* $(DESTDIR)\include\afs\*.* $(DESTDIR)\include\WINNT\*.* $(DESTDIR)\include\rx\*.*
	$(DESTDIR)\BIN\rmbat $(DESTDIR)\LIB\*.LIB $(DESTDIR)\LIB\*.DLL $(DESTDIR)\LIB\AFS\*.LIB
	$(DESTDIR)\BIN\rmbat $(DESTDIR)\root.client\usr\vice\etc\*.*
	$(CD) $(OBJ)\config
	nmake /nologo /f ntmakefile clean_version
	$(CD) ..\..
	echo **** End of Clean

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