# (c) Zeus Technology Limited 2000-2001.  All rights reserved.
# 
# Copyright in the source code ("the Source Code") listed below in whatever
# form, whether printed electronic compiled or otherwise, belongs to Zeus
# Technology Limited ("we"/"us").
# 
# If you have entered into a written agreement with us under which the Source
# Code is licensed to you ("Licence"),  you may not use, sell, license,
# transfer, copy or reproduce the Source Code in whole or in part or in any
# manner or form other than in accordance with your Licence.  To do so is
# strictly prohibited and may be unlawful and a serious criminal offence.
# 
# If you have not entered into a Licence, disclosure of the Source Code is
# made "as is".   You may use the Source Code for non-commercial purposes
# only.  You may distribute the Source Code to individual third parties for
# their non-commercial purposes only, but only if (1) you acknowledge our web
# site as the source of the Source Code and include such acknowledgement and
# our web address (www.zeus.com) in any copy of the Source Code; (2) the
# Source Code you distribute is complete and not modified in any way and
# includes this notice; and (3) you inform such third parties that these
# conditions apply to them and that they must comply with them.
# 
# If you have not entered into a Licence, all express and implied warranties,
# conditions, terms, undertakings and representations, including without
# limitation as to quality, performance, fitness for purpose, or
# non-infringement, are excluded to the fullest extent permitted by law.
# Neither we nor any other person involved in disclosing the Source Code shall
# have any liabilities whatsoever to you, howsoever arising, in connection
# with the Source Code, or its use by you.
# 
# If you have not entered into a Licence but would like to do so,  please
# contact us at pepp@zeus.com.

##############################################################################
# These bits are automatically set from ./Configure

VERSION = 0.6
CC      = cc
LD      = ld
CFLAGS  = -I /spec/zeus/zeus_34_64/web/include +z +O2 -Ae +DA1.1 +DS2.0 -DUSE_SENDFILE_HP -DCHECK_CONFIG  
LDFLAGS = +e GetExtensionVersion +e HttpExtensionProc -b

##############################################################################

ISAPI_TARGETS = zeus-get.api zeus-cad.api zeus-post.api
CGI_TARGETS = zeus-house.cgi nph-zeus.cgi
OBJS = zeus-get.o zeus-cad.o zeus-post.o zeus-house.o \
	zeus-common.o zeus-cgi.o debug.o

all: $(ISAPI_TARGETS) $(CGI_TARGETS)

zeus-get.api: zeus-get.o zeus-common.o debug.o
	@$(LD) -o $@ zeus-get.o zeus-common.o debug.o $(LDFLAGS)
	@echo made zeus-get.api

zeus-cad.api: zeus-cad.o zeus-common.o debug.o
	@$(LD) -o $@ zeus-cad.o zeus-common.o debug.o $(LDFLAGS)
	@echo made zeus-cad.api

zeus-post.api: zeus-post.o zeus-common.o debug.o
	@$(LD) -o $@ zeus-post.o zeus-common.o debug.o $(LDFLAGS)
	@echo made zeus-post.api

zeus-house.cgi: zeus-house.o debug.o
	@$(CC) -o $@ $(CFLAGS) zeus-house.o debug.o
	@echo made zeus-house.cgi

nph-zeus.cgi: zeus-cgi.o
	@$(CC) -o $@ $(CFLAGS) zeus-cgi.o
	@echo made nph-zeus.cgi


zeus-get.o: zeus-get.c debug.h zeus-common.h
	@echo '   zeus-get.o'
	@$(CC) $(CFLAGS) -o $@ -c zeus-get.c

zeus-cad.o: zeus-cad.c debug.h zeus-common.h
	@echo '   zeus-cad.o'
	@$(CC) $(CFLAGS) -o $@ -c zeus-cad.c

zeus-post.o: zeus-post.c debug.h zeus-common.h
	@echo '   zeus-post.o'
	@$(CC) $(CFLAGS) -o $@ -c zeus-post.c

zeus-house.o: zeus-house.c debug.h
	@echo '   zeus-house.o'
	@$(CC) $(CFLAGS) -o $@ -c zeus-house.c

zeus-common.o: zeus-common.c debug.h zeus-common.h
	@echo '   zeus-common.o'
	@$(CC) $(CFLAGS) -o $@ -c zeus-common.c

zeus-cgi.o: zeus-cgi.c
	@echo '   zeus-cgi.o'
	@$(CC) $(CFLAGS) -o $@ -c zeus-cgi.c

debug.o: debug.c
	@echo '   debug.o'
	@$(CC) $(CFLAGS) -o $@ -c debug.c

$(OBJS): Makefile

.PHONY: clean
clean:
	echo cleaning...
	rm -f $(ISAPI_TARGETS)
	rm -f $(CGI_TARGETS)
	rm -f *.o

.PHONY: realclean
realclean: clean
	rm -f Makefile
	rm -f so_locations

.PHONY: dist
dist:
	tar cf - \
		$(ISAPI_TARGETS:.api=.c) zeus-house.c zeus-cgi.c \
		zeus-common.c zeus-common.h debug.c debug.h \
		Makefile.in Configure README spec_install \
	| gzip -c - > spec-$(VERSION).src.tgz

.PHONY: binary
binary: $(ISAPI_TARGETS) $(CGI_TARGETS)
	tar cf - \
		$(ISAPI_TARGETS) $(CGI_TARGETS) \
		README.binary spec_install \
	| gzip -c - > spec-$(VERSION).tgz
