##
##  Makefile -- Build procedure for mod_ucam_webauth
##  Loosely based on the Makefile Autogenerated via ``apxs -n bar -g''.
##

#   the used tools

APXS=/usr/sbin/apxs    # Use 'make .... APXS=/path/to/apxs' if elsewhere 
SUFFIX=so              # Use 'make .... SUFFIX=la for Apache 2

#   additional user defines, includes, libraries and options
#DEF=-Dmy_define=my_value
#INC=-Imy/include/dir
#LIB=-Lmy/lib/dir -lmylib
#OPT=-SLIBEXECDIR=$RPM_BUILD_ROOT%{_libdir}/apache/ -Wc,-Wall

#   the default target

all: mod_ucam_webauth.$(SUFFIX)

#   compile the DSO file

mod_ucam_webauth.$(SUFFIX): mod_ucam_webauth.c
	$(APXS) -c -lcrypto $(DEF) $(INC) $(LIB) $(OPT) \
	mod_ucam_webauth.c

#   install the DSO file into the Apache installation

install: all
	$(APXS) -i $(OPT) mod_ucam_webauth.$(SUFFIX)

# Build a distribution

dist:
	(ver=`grep '#define VERSION' mod_ucam_webauth.c |      \
	 sed -e s/\"//g | cut -d' ' -f3`; \
	 mkdir -p mod_ucam_webauth-$$ver; \
	 rm -rf mod_ucam_webauth-$$ver/*; \
	 cp `cat MANIFEST` mod_ucam_webauth-$$ver; \
	 mkdir -p mod_ucam_webauth-$$ver/rpm-build; \
	 (cd rpm-build; \
          cp `cat MANIFEST` ../mod_ucam_webauth-$$ver/rpm-build); \
	 tar zcf mod_ucam_webauth-$$ver.tar.gz mod_ucam_webauth-$$ver;\
         rm -rf mod_ucam_webauth-$$ver )

rpmdirs:
	mkdir -p /home/jw35/rpmdevel/BUILD  
	mkdir -p /home/jw35/rpmdevel/RPMS 
	mkdir -p /home/jw35/rpmdevel/SOURCES
	mkdir -p /home/jw35/rpmdevel/SPECS 
	mkdir -p /home/jw35/rpmdevel/SRPMS	

rpm13: dist rpmdirs
	(ver=`grep '#define VERSION' mod_ucam_webauth.c |      \
	 sed -e s/\"//g | cut -d' ' -f3`; \
	 cp mod_ucam_webauth-$$ver.tar.gz /home/jw35/rpmdevel/SOURCES)
	cp rpm-build/README.KEYS /home/jw35/rpmdevel/SOURCES
	cp rpm-build/mod_ucam_webauth13.spec /home/jw35/rpmdevel/SPECS
	rpmbuild -ba /home/jw35/rpmdevel/SPECS/mod_ucam_webauth13.spec

rpm2: dist rpmdirs
	(ver=`grep '#define VERSION' mod_ucam_webauth.c |      \
	 sed -e s/\"//g | cut -d' ' -f3`; \
	 cp mod_ucam_webauth-$$ver.tar.gz /home/jw35/rpmdevel/SOURCES)
	cp rpm-build/README.KEYS /home/jw35/rpmdevel/SOURCES
	cp rpm-build/mod_ucam_webauth2.spec /home/jw35/rpmdevel/SPECS
	rpmbuild -ba /home/jw35/rpmdevel/SPECS/mod_ucam_webauth2.spec

zip13: 
	mkdir -p zip_build
	cp Windows/mod_ucam_webauth`cat Windows/VERSION13`.so \
	        zip_build/mod_ucam_webauth.so
	cp Windows/msvcr70.dll zip_build/msvcr70.dll
	cp README              zip_build/README.txt 
	cp README.WIN32        zip_build/README_WIN32.txt
	cp README.Platforms    zip_build/README_Platforms.txt
	cp COPYING             zip_build/COPYING.txt
	rm -f mod_ucam_webauth`cat Windows/VERSION13`.zip
	zip -j  mod_ucam_webauth`cat Windows/VERSION13`.zip \
	       zip_build/*.so zip_build/*.dll
	zip -jl mod_ucam_webauth`cat Windows/VERSION13`.zip \
	        zip_build/*.txt
	rm -r zip_build/

zip2: 
	mkdir -p zip_build
	cp Windows/mod_ucam_webauth`cat Windows/VERSION2`.so \
	        zip_build/mod_ucam_webauth.so
	cp Windows/msvcr70.dll zip_build/msvcr70.dll
	cp README              zip_build/README.txt 
	cp README.WIN32        zip_build/README_WIN32.txt
	cp README.Platforms    zip_build/README_Platforms.txt
	cp COPYING             zip_build/COPYING.txt
	rm -f mod_ucam_webauth`cat Windows/VERSION2`.zip
	zip -j  mod_ucam_webauth`cat Windows/VERSION2`.zip \
	       zip_build/*.so zip_build/*.dll
	zip -jl mod_ucam_webauth`cat Windows/VERSION2`.zip \
	        zip_build/*.txt
	rm -r zip_build/

clean:
	rm -f *~ *.o *.so *.la *.lo *.slo *.tar.gz *.zip


