# This makefile should work with the rpms distributed from the www.tcx.se FTP
# site for linux.  Other instalations may have to change some of the following
# variables.  Then just type 'make ; make install'

MYSQL_INC=/usr/include/mysql
MYSQL_LIB=/usr/lib/mysql
INSTALLDIR=/usr/lib/python1.4

CC = gcc
LD = ld
INDENT = indent  # only required if you use make indent

CFLAGS = -O2 -fPIC
LDFLAGS = -shared

# No modifications below this line should be required.

VERSION = 1.4
DISTFILES = Changelog Makefile New README.mSQLmodule mySQLmodule.c \
  mysqldb.py mysqlshelve.py

CPPFLAGS = -I/usr/include/python1.4 -I$(MYSQL_INC)
INDENTFLAGS = -gnu -br -ce -npcs -ts0 -i4 -cli4 -cd40

LIBS-mySQL = -L$(MYSQL_LIB) -lmysqlclient -lm
ifeq ($(CC), gcc)
LIBS-mySQL += `gcc -print-libgcc-file-name`
endif


all: mySQLmodule.so

install: all
	install -m644 mysqldb.py $(INSTALLDIR)
	install -m644 mysqlchelve.py $(INSTALLDIR)
	install -m644 mySQLmodule.so $(INSTALLDIR)/sharedmodules

%module.so: %module.o
	$(LD) $(LDFLAGS) $< $(LIBS-$*) -o $@
%module.so: %.o
	$(LD) $(LDFLAGS) $< $(LIBS-$*) -o $@

dist: mysql-python-$(VERSION).tar.gz
mysql-python-$(VERSION).tar.gz: $(DISTFILES)
	[ ! -d mysql-python-$(VERSION) ] || rm -rf mysql-python-$(VERSION)
	mkdir mysql-python-$(VERSION)
	cp $(DISTFILES) mysql-python-$(VERSION)
	tar czvf mysql-python-$(VERSION).tar.gz mysql-python-$(VERSION)
	rm -rf mysql-python-$(VERSION)

indent:
	$(INDENT) $(INDENTFLAGS) mySQLmodule.c

clean:
	rm -f *.o core

distclean: clean
	rm -f *.pyc *.so

.PHONY: indent all dist clean distclean install
