# This makefile is not required for building pysync, as everything can be
# built from the source distributions using Python's distutils. This is still 
# useful though for cleaning out and preparing for distribution.
#
# Usage:
#  'make'               make distutils source and binary distributions.
#  'make clean'         remove generated files
#  'make distclean'     remove everything that can be autogenerated.
#  'make configure'     reconfigure librsync for your target platform.
#  'make distready'     prepare swig wrappers for distutils.
#  'make sdist'         make a distutils source distribution.
#  'make bdist'         make a distutils binary distribution.
#  'make bdist_wininst' make a distutils windows installer.
#  'make bdist_rpm'     make a distutils binary rpm.
#
# The Python distributions are built using distutils. Since distutils
# does not support swig well, and swig is not guarenteed on typical Python
# development platforms, the windows source distribution includes pre-swiged
# and configured sources.

CC = gcc

PYINCLUDE = /usr/include/python2.1/
RSINCLUDE = ./librsync/

DEFS = -DHAVE_CONFIG_H
CFLAGS=-O2 -fPIC -I$(PYINCLUDE) -I$(RSINCLUDE) $(DEFS)
LDFLAGS = -shared

all: bdist sdist

bdist: distready
	python setup.py bdist

sdist: distready
	python setup.py sdist

bdist_wininst: distready
	python setup.py bdist_wininst

bdist_rpm: distready
	python setup.py bdist_rpm

configure:
	cd librsync && ./configure

distready: librsync_wrap.c librsync/config.h librsync/prototab.h

librsync/config.h:
	make configure
        
librsync/prototab.h:
	cd librsync && make prototab.h

librsync_wrap.c: librsync.i librsync.py.inc
	swig -python -shadow $<

clean:
	rm -fv *.pyc *.o *~ test/*~ test/*.pyc
	python setup.py clean
	cd librsync && make clean

distclean:
	rm -Rfv build dist
	rm -fv *~ *.o *.so *.pyc */*~ */*.o */*.so */*.pyc
	rm -fv MANIFEST *_wrap.doc *_wrap.c librsync.py
	cd librsync && make distclean


#These are for unix builds without using distutils.
librsync: librsyncc.so

librsyncc.so: librsync_wrap.o librsync/.libs/librsync.a
	gcc $(LDFLAGS) $^ -o $@

