#
# Copyright (C) 2002 Ilya Volynets, Total Knowledge
#
# This program is free software. Free means freedom.
# You are hereby granted the right to use this program
# in any way you want as long as following conditions are met:
# 1. All source distributions with code unmodified will also retain this
#    notice intact.
# 2. All binary distributions will be accompanied by text file clearly
#    attributing authorship to Ilya Volynets and sopnsorship to
#    Total Knowledge using following wording:
#    "This binary is built from sources developed by Ilya Volynets.
#    Development was kindly sponsored by Total Knowledge"
# 3. All modified versions, if distributed, will clearly indicate
#    that they are not original works and that they were derived from
#    work developed by Ilya Volynets and sponsored by Total Knowledge
#

VERSION=0.1.1

SSL_INCLUDES=-I/usr/local/ssl/include -I/usr/local/ssl/include/openssl -I/usr/local/include
SSL_LIBS=-lssl -lcrypto

CFLAGS= $(SSL_INCLUDES) -O2 -I./include -g
CXXFLAGS= $(CFLAGS)
LIBS= -lssl++ $(SSL_LIBS)
LDFLAGS=-L./ -Wl,-rpath,./

SSL_PP_LIB=libssl++.so
EXAMPLES=server client

#ugly hack to use TEMP or TMP from ENV, if it is set at all...
TEMP=/tmp
TMP=$(TEMP)

TARNAME=ssl++.$(VERSION)

all: $(SSL_PP_LIB) $(EXAMPLES)

$(SSL_PP_LIB):
	$(MAKE) -C src $@
	cp src/$(SSL_PP_LIB) ./

%.d:%.cpp
	g++ $(CXXFLAGS) -M $< >$@

server: server.o $(SSL_PP_LIB)
	g++ server.o -o $@ $(LIBS) $(LDFLAGS)

client: client.o  $(SSL_PP_LIB)
	g++ client.o -o $@ $(LIBS) $(LDFLAGS)

clean:
	make -C src clean
	rm  -f *.o deps core *~ *.d $(SSL_PP_LIB) $(EXAMPLES)

tarball: clean
	test ! -e $(TMP)/$(TARNAME)
	mkdir $(TMP)/$(TARNAME)
	cp -R * $(TMP)/$(TARNAME)
	tar -czvf $(TARNAME).tgz --exclude CVS --exclude test.key --exclude test.crt -C $(TMP) $(TARNAME)
	rm -rf $(TMP)/$(TARNAME)

.PHONY: $(SSL_PP_LIB) clean

deps: $(EXAMPLES:=.d) 
	cat $^ >$@

include deps

