# Makefile for Kyoto Cabinet for Win32



#================================================================
# Setting Variables
#================================================================


# VC++ directory
VCPATH = C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
SDKPATH = C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A


# Targets
LIBRARYFILES = kyotocabinet.lib
LIBOBJFILES = kcutil.obj kcdb.obj kcthread.obj kcfile.obj \
  kccompress.obj kccompare.obj kcmap.obj kcregex.obj \
  kchashdb.obj
COMMANDFILES = kctreemgr.exe

# Building configuration
CL = cl
LIB = lib
LINK = link
CLFLAGS = /nologo \
  /I "$(VCPATH)\Include" /I "$(VCPATH)\PlatformSDK\Include" /I "$(SDKPATH)\Include" \
  /I "." \
  /D_MYZLIB \
  /DNDEBUG /D_CRT_SECURE_NO_WARNINGS \
  /O2 /EHsc /W3 /wd4244 /wd4351 /wd4800 /MT
LIBFLAGS = /nologo \
  /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"$(SDKPATH)\Lib" \
  /libpath:"."
LINKFLAGS = /nologo \
  /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"$(SDKPATH)\Lib" \
  /libpath:"."



#================================================================
# Suffix rules
#================================================================


.SUFFIXES :
.SUFFIXES : .cc .c .obj .exe

.c.obj :
	$(CL) /c $(CLFLAGS) $<

.cc.obj :
	$(CL) /c $(CLFLAGS) $<



#================================================================
# Actions
#================================================================


all : $(LIBRARYFILES) $(COMMANDFILES)
	@echo #
	@echo #================================================================
	@echo # Ready to install.
	@echo #================================================================


clean :
	-del *.obj kyotocabinet.lib kyotocabinet.dll *.exp *.exe /F /Q > NUL: 2>&1
	-del casket* /F /Q > NUL: 2>&1
	-rd casket casket.wal casket.tmp casket-para casket.kcd casket.kcf /S /Q > NUL: 2>&1


binpkg :
	-rd output /S /Q > NUL: 2>&1
	md output
	md output\include
	copy *.h output\include
	del output\include\myconf.h
	del output\include\cmdcommon.h
	md output\lib
	copy *.lib output\lib
	md output\bin
	copy *.dll output\bin
	copy *.exe output\bin



#================================================================
# Building binaries
#================================================================


kyotocabinet.lib : $(LIBOBJFILES)
	$(LIB) $(LIBFLAGS) /OUT:$@ $(LIBOBJFILES) zlib.lib


kcutilmgr.exe : kcutilmgr.obj kyotocabinet.lib
	$(LINK) $(LINKFLAGS) /OUT:$@ kcutilmgr.obj kyotocabinet.lib


kctreemgr.exe : kctreemgr.obj kyotocabinet.lib
	$(LINK) $(LINKFLAGS) /OUT:$@ kctreemgr.obj kyotocabinet.lib


kcutil.obj : kccommon.h kcutil.h myconf.h

kcdb.obj : kccommon.h kcutil.h kcdb.h myconf.h

kcthread.obj : kccommon.h kcutil.h kcthread.h myconf.h

kcfile.obj : kccommon.h kcutil.h kcthread.h kcfile.h myconf.h

kccompress.obj : kccommon.h kcutil.h kccompress.h myconf.h

kccompare.obj : kccommon.h kcutil.h kccompare.h myconf.h

kcmap.obj : kccommon.h kcutil.h kcmap.h myconf.h

kcregex.obj : kccommon.h kcutil.h kcregex.h myconf.h

kchashdb.obj : kccommon.h kcutil.h kcdb.h kcthread.h kcfile.h kccompress.h kccompare.h \
  kcmap.h kcregex.h \
  kcplantdb.h kchashdb.h

kcutilmgr.obj : \
  kccommon.h kcdb.h kcutil.h kcthread.h kcfile.h kccompress.h kccompare.h \
  kcmap.h kcregex.h \
  cmdcommon.h

kctreemgr.obj : \
  kccommon.h kcdb.h kcutil.h kcthread.h kcfile.h kccompress.h kccompare.h \
  kcmap.h kcregex.h \
  kcplantdb.h kchashdb.h cmdcommon.h


# END OF FILE
