#
# $Id: makefile,v 1.46 2004/08/07 15:46:30 ggw Exp $
# (tAuthorize.cPasswd template set member)
#
# (C) 2001-2004 Gary Wallis under GPL License see www.fsf.org for details
# 	LICENSE included in this distribution.
#
# Notes:
# 	Before running make export SSL=1 if your local mySQL libraries were built 
# 	with SSL support.
#
#	Must use gmake (usually same as make in linux)
#
#	Must set env variable CGIDIR with trailing / for placing cgi in
#	target directory. Ex Bash shell: CGIDIR=/cgi-bin/ ; export CGIDIR
#
#       Use mySQL version 3.23.39 or later:
#       Requires /usr/lib/mysql/libmysqlclient.a
#       Requires /usr/include/mysql/mysql.h
#
#	These mysqlRAD generated files have only been tested extensively
#	on Linux x86. Please share your ports.
#
#	Please remove the mail line below after first compile.
#
#	For help contact support @ openisp . net
#
#

#Change these for your system: Ex. -DFreeBSD or -DSolaris instead of -DLinux
#CFLAGS=-O DFreeBSD -DLinux -Wall
CFLAGS= -DLinux -Wall
RELEASE = 1.94

#FreeBSD make support un comment the next two lines. Yes you need both -D and the gmake
#define. Also check mysqlrad.h for FreeBSD parts and adjust for your system.
#In general "grep -l FreeBSD *" and then check the files to see if you need to change
#anything else.
#CFLAGS= -DLinux -DFreeBSD -Wall 
#FreeBSD=1

ifdef FreeBSD
	LIBS= /usr/local/lib/mysql/libmysqlclient.a -lz -lm /usr/lib/libcrypt.a
else
	ifdef SSL
		LIBS= /usr/lib/mysql/libmysqlclient.a -lz -lcrypt -lm -lssl
	else
		LIBS= /usr/lib/mysql/libmysqlclient.a -lz -lcrypt -lm
	endif
endif


all: mysqlBind.cgi

mysqlBind.cgi: tzone.o tresource.o trrtype.o tjob.o tnameserver.o tmailserver.o tconfiguration.o tclient.o tauthorize.o bind.o main.o cgi.o 
	cc tzone.o tresource.o trrtype.o tjob.o tnameserver.o tmailserver.o tconfiguration.o tclient.o tauthorize.o bind.o main.o cgi.o -o mysqlBind.cgi $(LIBS)
#	mail -s "mysqlBind$(RELEASE) `uname -n -s`" support@openisp.net < /dev/null > /dev/null 2>&1

#Note use -lmsql if so defined in local.h
#-lmsql

tzone.o: tzone.c mysqlrad.h language.h tzonefunc.h
	cc -c tzone.c -o tzone.o $(CFLAGS)

tresource.o: tresource.c mysqlrad.h language.h tresourcefunc.h
	cc -c tresource.c -o tresource.o $(CFLAGS)

trrtype.o: trrtype.c mysqlrad.h language.h trrtypefunc.h
	cc -c trrtype.c -o trrtype.o $(CFLAGS)

tjob.o: tjob.c mysqlrad.h language.h tjobfunc.h
	cc -c tjob.c -o tjob.o $(CFLAGS)

tnameserver.o: tnameserver.c mysqlrad.h language.h tnameserverfunc.h
	cc -c tnameserver.c -o tnameserver.o $(CFLAGS)

tmailserver.o: tmailserver.c mysqlrad.h language.h tmailserverfunc.h
	cc -c tmailserver.c -o tmailserver.o $(CFLAGS)

tconfiguration.o: tconfiguration.c mysqlrad.h language.h tconfigurationfunc.h
	cc -c tconfiguration.c -o tconfiguration.o $(CFLAGS)

tclient.o: tclient.c mysqlrad.h language.h tclientfunc.h
	cc -c tclient.c -o tclient.o $(CFLAGS)

tauthorize.o: tauthorize.c mysqlrad.h language.h tauthorizefunc.h
	cc -c tauthorize.c -o tauthorize.o $(CFLAGS)


main.o: main.c mysqlrad.h mainfunc.h language.h local.h
	cc -c main.c -o main.o $(CFLAGS)

cgi.o: cgi.h cgi.c
	cc -c cgi.c -o cgi.o $(CFLAGS)

#List: bind.o
#Extra Link Command: -lmsql
bind.o: bind.c mysqlrad.h
	cc -c bind.c -o bind.o $(CFLAGS)

clean:
	rm -f *.o

cleandist:
	rm -f *.o *.gz

install: mysqlBind.cgi
	install -s mysqlBind.cgi $(CGIDIR)mysqlBind.cgi
	rm mysqlBind.cgi

distribution:
	cd ..;  tar czvf mysqlBind$(RELEASE)/mysqlBind$(RELEASE).tar.gz\
		mysqlBind$(RELEASE)/*.h\
		mysqlBind$(RELEASE)/*.c\
		mysqlBind$(RELEASE)/data/*.txt\
		mysqlBind$(RELEASE)/docs/*.html\
		mysqlBind$(RELEASE)/docs/*.cgi\
		mysqlBind$(RELEASE)/setup/127.0.0\
		mysqlBind$(RELEASE)/setup/localhost\
		mysqlBind$(RELEASE)/setup/named.conf\
		mysqlBind$(RELEASE)/setup/root.cache\
		mysqlBind$(RELEASE)/setup9/127.0.0\
		mysqlBind$(RELEASE)/setup9/localhost\
		mysqlBind$(RELEASE)/setup9/named.conf\
		mysqlBind$(RELEASE)/setup9/named.conf.norecursion\
		mysqlBind$(RELEASE)/setup9/root.cache\
		mysqlBind$(RELEASE)/makefile\
		mysqlBind$(RELEASE)/CHANGES\
		mysqlBind$(RELEASE)/INSTALL\
		mysqlBind$(RELEASE)/LICENSE
