SHELL=/bin/sh
CFG=`which mysql_config`
CFLAGS=-g -O0 -pipe -fpic -Wall -pedantic -std=c99
MYSQL_LIBS:=$(shell $(CFG) --libs)
MYSQL_FLAGS:=$(shell $(CFG) --cflags)
LIBS=-lpslib

test_objects=test.o psleak.o
objects=psDB.o

all: libpsdb.so

test: test-bin
	LD_LIBRARY_PATH=. ./test
     
test-bin: $(test_objects) libpsdb.so
	$(CC) $(CFLAGS) -o test $(test_objects) -L./ -lpsdb

$(test-objects): %.o : %.c
	$(CC) $(CFLAGS) -o $@ -c $<

libpsdb.so: $(objects)
	$(CC) $(CFLAGS) -shared -o libpsdb.so $(objects) $(LIBS) $(MYSQL_FLAGS) $(MYSQL_LIBS)

$(objects): %.o : %.c
	$(CC) $(CFLAGS) -o $@ -c $<

clean:
	$(RM) *.so *.o core test
