
all: libshared_object.so executable.exe

clean:
	rm *.o *.so *.exe

libshared_object.so : shared_object.o
	g++ -fPIC --shared -O2 $< -o $@
	strip $@

shared_object.o : shared_object.cpp interface.h
	g++ -fPIC -O2 $< -c -o $@
	objcopy --redefine-sym _ZN17MyVerySecretClass14secret_method1Ev=m1 \
			--redefine-sym _ZN17MyVerySecretClass14secret_method2Ev=m2 \
			--redefine-sym _ZN17MyVerySecretClass14secret_method3Ev=m3 $@
	

executable.exe : executable.o libshared_object.so
	g++ -O2 -lshared_object -L. $< -o $@
	strip $@
	
executable.o : executable.cpp interface.h
	g++ -O2 -lshared_object -L. $< -c -o $@
	objcopy --redefine-sym _ZN17MyVerySecretClass14secret_method1Ev=m1 \
			--redefine-sym _ZN17MyVerySecretClass14secret_method2Ev=m2 \
			--redefine-sym _ZN17MyVerySecretClass14secret_method3Ev=m3 $@

run: all
	LD_LIBRARY_PATH=. ./executable.exe

