#
# Test case for dlopen'ing dependent libraries.
#  The executable "test" is created to dlopen the
# library "mylib" which depends on library "dep".
# Some systems need "test" to be linked with -ldl
# like Linux, others do not.  Under AIX the symbols
# that are dlopen'ed are exported explicitly.
# Setting LD_LIBRARY_PATH or equivalent is required.

CXXFLAGS=-g

test: test.o libmylib.so
	$(CXX) -o test test.o

libmylib.so: libdep.so mylib.o
	$(CXX) -shared -L. -ldep -o libmylib.so mylib.o

libdep.so: mydep.o
	$(CXX) -shared -o libdep.so mydep.o

# rules used for AIX
#libmylib.a: mylib.o libmylib.exp
#	$(CXX) -shared -Wl,-bE:libmylib.exp -o libmylib.a mylib.o

#libmylib.exp:
#	nm -BCpg mylib.o | awk -f expme.awk > libmylib.exp

#libdep.exp:
#	nm -BCpg mydep.o | awk -f expme.awk > libdep.exp

test.o: test.cpp
mylib.o: mylib.cpp
mydep.o: mydep.cpp

clean:
	-rm -f *.o *.so *.a *.exp test *~

.cpp.o:
	$(CXX) $(CXXFLAGS) -c -o $@ $<

