!INCLUDE ..\win32\common.mak

compat_sources = getaddrinfo.c
compat_objs = getaddrinfo.obj

libsasl_sources = auxprop.c canonusr.c checkpw.c client.c common.c config.c external.c md5.c saslutil.c server.c seterror.c windlopen.c getsubopt.c plugin_common.c plugin_common.h $(compat_sources)
libsasl_objs = auxprop.obj canonusr.obj checkpw.obj client.obj common.obj config.obj external.obj md5.obj saslutil.obj server.obj seterror.obj windlopen.obj getsubopt.obj plugin_common.obj $(compat_objs)
libsasl_out = libsasl.dll libsasl.exp libsasl.lib

CPPFLAGS = /I "..\win32\include" /I "." /I "..\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBSASL_EXPORTS"

all_objs = $(libsasl_objs)
all_out = $(libsasl_out)

libdir = $(prefix)\lib
bindir = $(prefix)\bin
exclude_list = binexclude.lst

all: all-recursive

#
# /I flag to xcopy tells to treat the last parameter as directory and create all missing levels
#
# In order to force xcopy not to confirm if the second parameter is file or directory,
# the first parameter has to contain a wildcard character. For example, we use libsasl.l*,
# instead of libsasl.lib. Ugly, but works!
#
install: libsasl.dll
	@echo libsasl.exp > $(exclude_list)
	@echo libsasl.lib >> $(exclude_list)
	@xcopy libsasl.* $(bindir) /I /F /Y /EXCLUDE:$(exclude_list)
	@xcopy libsasl.l* $(libdir) /I /F /Y

all-recursive: libsasl.dll

libsasl.dll: $(libsasl_objs)
	$(LINK32DLL) @<< $(LINK32DLL_FLAGS) /out:"libsasl.dll" /implib:"libsasl.lib" /pdb:"libsasl.pdb" $(libsasl_objs)
<<

plugin_common.c: ..\plugins\plugin_common.c plugin_common.h
	copy ..\plugins\plugin_common.c .

plugin_common.h: ..\plugins\plugin_common.h
	copy ..\plugins\plugin_common.h .

CLEAN :
	-@erase $(all_objs)
	-@erase "*.idb"
	-@erase "*.pdb"
	-@erase $(all_out)
	-@erase $(exclude_list)

.c.obj::
   $(CPP) @<<
   $(CPP_PROJ) $< 
<<

.cpp.obj::
   $(CPP) @<<
   $(CPP_PROJ) $< 
<<

.cxx.obj::
   $(CPP) @<<
   $(CPP_PROJ) $< 
<<
