From f71053f174d0087318e97eeb6b2f22d22359307e Mon Sep 17 00:00:00 2001
From: Justin Waters <justin.waters@timesys.com>
Date: Fri, 6 Dec 2013 14:00:56 -0500
Subject: [PATCH] Add shared library

---
 Makefile |   24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 4177449..6c1daff 100644
--- a/Makefile
+++ b/Makefile
@@ -25,8 +25,8 @@ LD     ?= g++
 AR     ?= ar rc
 RANLIB ?= ranlib
 
-DEBUG_CFLAGS     := -Wall -Wno-format -g -DDEBUG
-RELEASE_CFLAGS   := -Wall -Wno-unknown-pragmas -Wno-format -O3
+DEBUG_CFLAGS     := -Wall -Wno-format -g -DDEBUG -fPIC
+RELEASE_CFLAGS   := -Wall -Wno-unknown-pragmas -Wno-format -O3 -fPIC
 
 LIBS		 :=
 
@@ -36,6 +36,8 @@ RELEASE_CXXFLAGS := ${RELEASE_CFLAGS}
 DEBUG_LDFLAGS    := -g -lstdc++
 RELEASE_LDFLAGS  := -lstdc++
 
+LIBFLAGS	 := -shared -lstdc++
+
 ifeq (YES, ${DEBUG})
    CFLAGS       := ${DEBUG_CFLAGS}
    CXXFLAGS     := ${DEBUG_CXXFLAGS}
@@ -82,8 +84,9 @@ CXXFLAGS := ${CXXFLAGS} ${DEFS}
 #****************************************************************************
 
 OUTPUT := xmltest
+LIBRARY := libtinyxml.so
 
-all: ${OUTPUT}
+all: ${OUTPUT} ${LIBRARY}
 
 
 #****************************************************************************
@@ -104,6 +107,9 @@ OBJS := $(addsuffix .o,$(basename ${SRCS}))
 ${OUTPUT}: ${OBJS}
 	${CC} -o $@ ${LDFLAGS} ${OBJS} ${LIBS} ${EXTRA_LIBS}
 
+${LIBRARY}: tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o
+	${CC} -o $@ ${LIBFLAGS} $^
+
 #****************************************************************************
 # common rules
 #****************************************************************************
@@ -119,15 +125,23 @@ dist:
 	bash makedistlinux
 
 clean:
-	-rm -f core ${OBJS} ${OUTPUT}
+	-rm -f core ${OBJS} ${OUTPUT} ${LIBRARY}
 
 depend:
 	#makedepend ${INCS} ${SRCS}
 
-install: ${OUTPUT}
+install-bin: ${OUTPUT}
 	mkdir -p ${DESTDIR}/usr/bin
 	install -m 755 ${OUTPUT} ${DESTDIR}/usr/bin
 
+install-lib: ${LIBRARY} tinyxml.h tinystr.h
+	mkdir -p ${DESTDIR}/usr/lib
+	mkdir -p ${DESTDIR}/usr/include
+	install -m 755 ${LIBRARY} ${DESTDIR}/usr/lib
+	install -m 644 tinyxml.h tinystr.h ${DESTDIR}/usr/include
+
+install: install-bin install-lib
+
 tinyxml.o: tinyxml.h tinystr.h
 tinyxmlparser.o: tinyxml.h tinystr.h
 xmltest.o: tinyxml.h tinystr.h
-- 
1.7.9.6

