# Build simple library and test program

CC=CC

all:
	@echo "This is test program that does the following:"
	@echo "- Create a trivial C++ library (that uses no STL) in several different ways:"
	@echo "  <no additional flags>"
	@echo "  --library=Crun"
	@echo "  --library=Cstd"
	@echo "  --library=stlport4"
	@echo ""
	@echo "target: build_clean"
	@echo "- Compiles a trivial C++ application (that uses no STL) against the above libraries."
	@echo ""
	@echo "target: run_clean"
	@echo "- Runs the trivial C++ applications (that uses no STL) and shows that an application compiled including stlport against a library that has Cstd will dump at runtime"
	@echo ""
	@echo "target: build_std"
	@echo "- Compiles a trivial C++ application (that usesd STL) against the above libraries.  Shows that when attempting to compile the trivial program against the stlport4 library will result in an error"
	@echo ""
 
libverify.so: verify.cc verify.h
	$(CC) -c verify.cc
	$(CC) -G -h libverify.so -o libverify.so verify.o
	$(CC) -G -h libverify_crun.so -library=Crun -o libverify_crun.so verify.o
	$(CC) -G -h libverify_cstd.so -library=Cstd -o libverify_cstd.so verify.o
	$(CC) -G -h libverify_stl.so -library=stlport4 -o libverify_stl.so verify.o

build_clean: libverify.so libverify_crun.so libverify_cstd.so libverify_stl.so \
          testprog_clean.cc verify.h
	$(CC) testprog_clean.cc -c
	$(CC) testprog_clean.o -L. -R. -lverify -o testprog_clean
	$(CC) testprog_clean.o -library=Crun -L. -R. -lverify_crun -o testprog_clean_crun
	$(CC) testprog_clean.o -library=Cstd -L. -R. -lverify_cstd -o testprog_clean_cstd
	$(CC) testprog_clean.o -library=stlport4 -L. -R. -lverify_stl -o testprog_clean_stl
	$(CC) testprog_clean.o -library=stlport4 -L. -R. -lverify_crun -o testprog_clean_crun_stl
	$(CC) testprog_clean.o -library=stlport4 -L. -R. -lverify_cstd -o testprog_clean_cstd_stl

build_std: libverify.so libverify_crun.so libverify_cstd.so libverify_stl.so \
          testprog_std.cc verify.h
	$(CC) testprog_std.cc -c
	$(CC) testprog_std.o -L. -R. -lverify -o testprog_std
	$(CC) testprog_std.o -library=Crun -L. -R. -lverify_crun -o testprog_std_crun
	$(CC) testprog_std.o -library=Cstd -L. -R. -lverify_cstd -o testprog_std_cstd
	$(CC) testprog_std.o -library=stlport4 -L. -R. -lverify_stl -o testprog_std_stl
	$(CC) testprog_std.o -library=stlport4 -L. -R. -lverify_crun -o testprog_std_crun_stl
	$(CC) testprog_std.o -library=stlport4 -L. -R. -lverify_cstd -o testprog_std_cstd_stl

run_clean: testprog_clean testprog_clean_crun testprog_clean_cstd testprog_clean_stl testprog_clean_crun_stl testprog_clean_cstd_stl
	./testprog_clean
	./testprog_clean_crun
	./testprog_clean_cstd
	./testprog_clean_stl
	./testprog_clean_crun_stl
	./testprog_clean_cstd_stl

clean:
	/bin/rm -f \
        testprog_clean \
        testprog_clean_crun \
        testprog_clean_cstd \
        testprog_clean_stl \
        testprog_clean_crun_stl \
        testprog_clean_cstd_stl \
        testprog_std \
        testprog_std_crun \
        testprog_std_cstd \
        testprog_std_stl \
        testprog_std_crun_stl \
        testprog_std_cstd_stl \
        *.so *.o core
