#!/usr/bin/make -f
CFLAGS = -O2 -Wall
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
CFLAGS += -g
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
INSTALL_PROGRAM += -s
endif

binary: binary-indep binary-arch

binary-indep:

binary-arch: build install
	dh_testdir
	dh_testroot
	#dh_installchangelogs CHANGES
	dh_installdocs docs/mod_fastcgi.html CHANGES
	dh_installdeb
	dh_fixperms
	dh_shlibdeps
	dh_compress
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	dh_strip
endif
	dh_md5sums
	dh_gencontrol
	dh_builddeb

build: build-stamp
build-stamp:
	dh_testdir
	CFLAGS="$(CFLAGS)" /usr/bin/apxs -o mod_fastcgi.so -c *.c
	touch build-stamp
	
clean:
	dh_testdir
	rm -f build-stamp
	-rm -f *.o mod_fastcgi.so			
	dh_clean build-stamp

install:
	dh_testdir
	dh_installdirs
	mkdir -p debian/tmp/usr/lib/apache/1.3
	cp mod_fastcgi.so debian/tmp/usr/lib/apache/1.3/
	chmod 644 debian/tmp/usr/lib/apache/1.3/mod_fastcgi.so
	cp debian/500mod_fastcgi.info debian/tmp/usr/lib/apache/1.3/		
	
.PHONY: binary binary-arch binary-indep clean build install 
