# WIN32 Makefile tested using VC-9.0
# Don't forget to set your PATH using the following command :
# c:\Progam Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat
# set PATH=%PATH%;$(TOOLS)
# using value for TOOLS relative to your local installation
#

!INCLUDE nmake.opt

all:  $(PROGRAMNAME) zcfg2yaml

version.h:
	set VERS=`svnversion .`
	echo #define ZOO_VERSION "$(VERS)" > version.h

main_conf_read.tab.c: main_conf_read.y service.h
	bison -p cr -d main_conf_read.y

main_conf_read.tab.obj: main_conf_read.tab.c service.h
	$(CPP) /EHsc $(CFLAGS) main_conf_read.tab.c /c

lex.cr.c: main_conf_read.y main_conf_read.l main_conf_read.tab.c service.h
	flex -Pcr main_conf_read.l

lex.cr.obj: lex.cr.c service.h
	$(CPP) $(CFLAGS) /c lex.cr.c

service_conf.tab.c: service_conf.y service.h
	bison -p sr -d service_conf.y

service_conf.tab.obj: service_conf.tab.c service.h
	$(CPP) $(CFLAGS) service_conf.tab.c /c

lex.sr.c: service_conf.y service_conf.l service_conf.tab.c service.h
	flex -Psr service_conf.l

lex.sr.obj: lex.sr.c service.h
	$(CPP) $(CFLAGS) /c lex.sr.c

zcfg2yaml.obj: zcfg2yaml.c
	$(CPP) $(CFLAGS) /c zcfg2yaml.c

service_internal.obj: service_internal.c mimetypes.h
	$(CPP) $(CFLAGS) /c service_internal.c

service_internal_js.obj: service_internal_js.c service.h
	$(CPP) /c $(CFLAGS) service_internal_js.c

service_internal_java.obj: service_internal_java.c service.h
	$(CPP) /c $(CFLAGS) service_internal_java.c

service_internal_ruby.obj: service_internal_ruby.c service_internal_ruby.h service.h
	$(CPP) /c $(CFLAGS) service_internal_ruby.c

service_internal_python.obj: service_internal_python.c service.h
	$(CPP) /c $(CFLAGS) service_internal_python.c

service_internal_ms.obj: service_internal_ms.c service.h
	$(CPP) /c $(CFLAGS) service_internal_ms.c

service_loader.obj: service_loader.c service.h
	$(CPP) /c $(CFLAGS)  service_loader.c

zoo_service_loader.obj: zoo_service_loader.c service.h
	$(CPP) /c $(CFLAGS)  zoo_service_loader.c

zoo_loader.obj: zoo_loader.c service.h
	$(CPP) /EHsc /c $(CFLAGS) zoo_loader.c

$(PROGRAMNAME): version.h zoo_loader.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj
	link zoo_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj  zoo_service_loader.obj /out:$(PROGRAMNAME) $(LDFLAGS) $(LDFLAGSCGI)

zcfg2yaml: version.h zcfg2yaml.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj
	link zcfg2yaml.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj /out:zcfg2yaml.exe $(LDFLAGS) $(LDFLAGSCGI)

clean:
	erase -f *.cgi *.obj *.tab.c* *.tab.h *.sr.c* lex.* *.lreg *.sibling
