#!/usr/bin/make -f

all: compile package

compile:
	make distclean
	./configure --enable-static-binaries
	cd ../pdns-pipebackend ; ./configure ; make clean;	make 
	cd ../ahudns-mysqlbackend ; ./configure ; make clean ;	make && cd -
	cd  ../ahudns-pdnsbackend ; ./configure ; make clean ;	make && cd -
	cd ../pdns-gpgsqlbackend; ./configure ; make clean  ; 	make && cd -
	cd ../pdns-gmysqlbackend; ./configure ; make clean  ; 	make && cd -
	rm -f extra/*.o 
	cd extra; ln -s ../backends/bind/{bindbackend.o,zoneparser2.o,bindparser.o,bindlexer.o} . ; cd -
	cd extra ; ln -s ../backends/bind/huffman.o . ; cd -
	cd extra ; ln -s ../../pdns-pipebackend/*.o . ; cd -
	cd extra; ln -s ../../ahudns-mysqlbackend/*.o . ; cd -
	cd extra; ln -s ../../ahudns-pdnsbackend/*.o . ; cd -
	cd extra; ln -s ../../pdns-gpgsqlbackend/*.o . ; cd -
	cd extra; ln -s ../../pdns-gmysqlbackend/*.o . ; cd -
	echo "-lmysqlclient  -L/opt/postgresql/lib -lpq++ -lpq -lssl -lcrypt -lcrypto" > extra/ld
	rm -f libs/*
	make 
	make mkbindist


package:
	mkdir -p release-files/deb/stable
	mkdir -p release-files/linux-static
	mkdir -p release-files/rpm

	rm -rf ../pdns_*deb
	rm -rf ../pdns-*rpm

	cp backends/bind/zone2sql .
	
	sudo debian/rules.stable clean
	sudo debian/rules.stable binary

	mv ../pdns_*deb release-files/deb/stable

	cp pathconfig.redhat pathconfig
	DESTDIR=/tmp/pdns sudo ./installer
	sudo rpm -bb ./pdns.spec
	mv ../pdns-*rpm release-files/rpm

	rm -f pdns*tar.gz

	. ./mkbindist
	mv pdns*tar.gz release-files/linux-static
			

