thisconfigdir=./..
myfulldir=lib
mydir=lib
MY_SUBDIRS=crypto krb5 des425 @KRB4@ kdb gssapi rpc kadm5
BUILDTOP=$(REL)..

MAC_SUBDIRS = crypto krb5 gssapi

all-unix::

all-mac::

CLEANLIBS = libkrb5.a libkdb5.a libcrypto.a libgssapi_krb5.a libdes425.a \
	libkrb425.a libkadm.a libkrb4.a libcom_err.a libpty.a \
	libss.a libgssapi.a \
	libkrb5.so libcrypto.so libkrb4.so libdes425.so

clean-mac:: clean-unix
	$(RM) $(CLEANLIBS)
clean-unix::

clean-windows::

# Windows stuff to make krb5 and gssapi DLLs.

##MIT##!if !defined(VS_INC)
##MIT##!message Must define VS_INC to point to version server include dir!
##MIT##!error
##MIT##!endif
##MIT##!if !defined(VS_LIB)
##MIT##!message Must define VS_LIB to point to version server library!
##MIT##!error
##MIT##!endif
##MIT##MITLIBS=$(VS_LIB)
##MIT##MITFLAGS=-I$(VS_INC) /DVERSERV=1

CLIBS = $(BUILDTOP)\util\et\$(OUTPRE)comerr.lib
PLIBS = $(BUILDTOP)\util\profile\$(OUTPRE)profile.lib
KLIBS = krb5\$(OUTPRE)krb5.lib crypto\$(OUTPRE)crypto.lib \
	$(BUILDTOP)\util\profile\$(OUTPRE)profile.lib \
	des425\$(OUTPRE)des425.lib
GLIBS = gssapi\$(OUTPRE)gssapi.lib
K4LIBS = krb4\$(OUTPRE)krb4.lib

CDEF = comerr32.def
PDEF = xpprof32.def
KDEF = krb5_32.def
GDEF = gssapi32.def
K4DEF = krb4_32.def

KRB5RC = krb5.rc
VERSIONRC = $(BUILDTOP)\windows\version.rc

WINLIBS = kernel32.lib ws2_32.lib user32.lib shell32.lib oldnames.lib \
	version.lib advapi32.lib gdi32.lib
WINDLLFLAGS = $(DLL_LINKOPTS) -base:0x1c000000

NO_GLUE=$(OUTPRE)no_glue.obj
K5_GLUE=$(OUTPRE)k5_glue.obj
K4_GLUE=$(OUTPRE)k4_glue.obj
GSS_GLUE=$(OUTPRE)gss_glue.obj

CGLUE=$(NO_GLUE)
PGLUE=$(NO_GLUE)
KGLUE=$(K5_GLUE)
GGLUE=$(GSS_GLUE)
K4GLUE=$(K4_GLUE)

RCFLAGS=$(CPPFLAGS) -D_WIN32 -DRES_ONLY

##WIN32##CRES=$(CLIB:.lib=.res)
##WIN32##PRES=$(PLIB:.lib=.res)
##WIN32##KRES=$(KLIB:.lib=.res)
##WIN32##GRES=$(GLIB:.lib=.res)
##WIN32##K4RES=$(K4LIB:.lib=.res)

##WIN32##$(CRES): $(VERSIONRC)
##WIN32##	$(RC) $(RCFLAGS) -DCE_LIB -fo $@ -r $**
##WIN32##$(PRES): $(VERSIONRC)
##WIN32##	$(RC) $(RCFLAGS) -DPROF_LIB -fo $@ -r $**
##WIN32##$(KRES): $(KRB5RC)
##WIN32##	$(RC) $(RCFLAGS) -DKRB5_LIB -fo $@ -r $**
##WIN32##$(K4RES): $(VERSIONRC)
##WIN32##	$(RC) $(RCFLAGS) -DKRB4_LIB -fo $@ -r $**
##WIN32##$(GRES): $(VERSIONRC)
##WIN32##	$(RC) $(RCFLAGS) -DGSSAPI_LIB -fo $@ -r $**
##WIN32##$(KRB5RC): $(VERSIONRC)

##WIN32##$(CLIB): $(CDEF) $(CLIBS) $(CGLUE) $(CRES)
##WIN32##	link $(WINDLLFLAGS) -def:$(CDEF) -out:$*.dll \
##WIN32##	  $(CLIBS) $(CGLUE) $(CRES) $(WINLIBS)

##WIN32##$(PLIB): $(PDEF) $(PLIBS) $(PGLUE) $(PRES) $(CLIB)
##WIN32##	link $(WINDLLFLAGS) -def:$(PDEF) -out:$*.dll \
##WIN32##	  $(PLIBS) $(PGLUE) $(PRES) $(CLIB) $(WINLIBS)

##WIN32##$(KLIB): $(KDEF) $(KLIBS) $(KGLUE) $(KRES) $(CLIB) $(MITLIBS) $(DNSLIBS)
##WIN32##	link $(WINDLLFLAGS) -def:$(KDEF) -out:$*.dll \
##WIN32##	  $(KLIBS) $(KGLUE) $(KRES) $(CLIB) $(MITLIBS) $(DNSLIBS) $(WINLIBS)

##WIN32##$(GLIB): $(GDEF) $(GLIBS) $(GGLUE) $(GRES) $(KLIB) $(CLIB)
##WIN32##	link $(WINDLLFLAGS) -def:$(GDEF) -out:$*.dll \
##WIN32##	  $(GLIBS) $(GGLUE) $(GRES) $(KLIB) $(CLIB) $(WINLIBS)

##WIN32##$(K4LIB): $(K4DEF) $(K4LIBS) $(K4GLUE) $(K4RES) $(KLIB) $(CLIB) $(PLIB)
##WIN32##	link $(WINDLLFLAGS) -def:$(K4DEF) -out:$*.dll \
##WIN32##	  $(K4LIBS) $(K4GLUE) $(K4RES) $(KLIB) $(CLIB) $(PLIB) $(WINLIBS)

$(K5_GLUE): win_glue.c
	$(CC) $(ALL_CFLAGS) $(MITFLAGS) /c /DKRB5=1 /Fo$@ $**
$(K4_GLUE): win_glue.c
	$(CC) $(ALL_CFLAGS) /c /DKRB4=1 /Fo$@ $**
$(GSS_GLUE): win_glue.c
	$(CC) $(ALL_CFLAGS) /c /DGSSAPI=1 /Fo$@ $**
$(NO_GLUE): win_glue.c
	$(CC) $(ALL_CFLAGS) /c /Fo$@ $**

# Build Convenience
comerr.lib: $(CLIB)
krb4.lib:   $(K4LIB)
krb5.lib:   $(KLIB)
gssapi.lib: $(GLIB)
profile.lib: $(PLIB)

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

all-windows:: lib-windows
lib-windows:: krb5.lib gssapi.lib krb4.lib 

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