CFLAGS = $(CCOPTS) $(DEFS)

##DOSBUILDTOP = ..
##DOS!include $(BUILDTOP)\config\windows.in

all:: all-$(WHAT)

all-unix::

all-mac::

clean:: clean-$(WHAT)

clean-mac:: clean-unix
clean-unix::
	$(RM) libkrb5.a libkdb5.a libcrypto.a 
	$(RM) libgssapi_krb5.a libdes425.a libkrb425.a
	$(RM) libkadm.a libkrb4.a libkdb4.a
	$(RM) libkrb5.so libcrypto.so libkrb4.so libdes425.so

clean-mac::
	$(RM) libkrb5.a libkdb5.a libcrypto.a 
	$(RM) libgssapi_krb5.a libdes425.a libkrb425.a
	$(RM) libkadm.a

clean-windows::
	$(RM) libkrb5.dll libkrb5.lib libkrb5.bak libkrb5.map winsock.lib
	$(RM) gssapi.dll gssapi.lib gssapi.bak gssapi.map
#
# Windows stuff to make libkrb5.dll and libkrb5.lib. Currently it
# combines crypto, krb5, kadm and the util/et directories.
#
ALIB  = kadm\kadm.lib
CLIB  = crypto\crypto.lib
KLIB  = krb5\krb5.lib
GLIB  = gssapi\gssapi.lib
ETLIB = $(BUILDTOP)\util\et\comerr.lib
PLIB  = $(BUILDTOP)\util\profile\profile.lib
WLIB  = .\winsock.lib
LIBS  = $(ALIB) $(CLIB) $(KLIB) $(GLIB) $(ETLIB) $(PLIB) $(WLIB)

lib-windows: winsock.lib libkrb5.lib gssapi.lib 

gssapi.lib:: gssapi.dll
	implib /nologo gssapi.lib gssapi.dll

gssapi.dll:: $(GLIB) $(LIBS) gssapi.def
	link /co /seg:400 /noe /nol win_glue, gssapi.dll, gssapi.map, \
	   $(LIBS) ldllcew libw, gssapi.def
	rc /nologo /p /k gssapi.dll

libkrb5.lib:: libkrb5.dll
	implib /nologo libkrb5.lib libkrb5.dll

libkrb5.dll:: $(LIBS) libkrb5.def win_glue.obj
	link /co /seg:400 /noe /nol win_glue, libkrb5.dll, libkrb5.map, \
	   $(LIBS) ldllcew libw, libkrb5.def
	rc /nologo /p /k libkrb5.dll

winsock.lib:  winsock.def
	implib /nologo winsock.lib winsock.def

all-windows:: 
	@echo Making in lib\crypto
	cd crypto
	-$(MAKE) -$(MFLAGS) LIBCMD=$(LIBCMD)
	@echo Making in lib\kadm
	cd ..\kadm
	-$(MAKE) -$(MFLAGS) LIBCMD=$(LIBCMD)
	@echo Making in lib\krb5
	cd ..\krb5
	-$(MAKE) -$(MFLAGS) LIBCMD=$(LIBCMD)
	@echo Making in lib\gssapi
	cd ..\gssapi
	-$(MAKE) -$(MFLAGS) LIBCMD=$(LIBCMD)
	@echo Making in lib
	cd ..

all-windows:: libkrb5.lib gssapi.lib

clean-windows::
	@echo Making clean in lib\crypto
	cd crypto
	-$(MAKE) -$(MFLAGS) clean
	@echo Making clean in lib\kadm
	cd ..\kadm
	-$(MAKE) -$(MFLAGS) clean
	@echo Making clean in lib\krb5
	cd ..\krb5
	-$(MAKE) -$(MFLAGS) clean
	@echo Making clean in lib\gssapi
	cd ..\gssapi
	-$(MAKE) -$(MFLAGS) clean
	@echo Making clean in lib
	cd ..

