all: test_dl all-libs/stamp
	./test_dl G all-libs
	./test_dl N all-libs

libtest_dbi_lib.so:
	gcc test_dbi_lib.c -export-dynamic -shared -Wl,-soname,libtest_dbi_lib.so -o libtest_dbi_lib.so -ldbi -fPIC

test_dl: libtest_dbi_lib.so
	gcc test_dl.c -o test_dl -ldl

all-libs/stamp:
	rm -rf all-libs
	mkdir -p all-libs 
	olddir=`pwd` && cd ../.. && rootdir=`pwd` && for f in `find drivers -name 'libdbd*.so'` ; do  ln -vs $$rootdir/$$f $$olddir/all-libs ; done

clean:
	rm -f test_dl libtest_dbi_lib.so
	rm -rf all-libs
