From 6152f9386fff0cc6963106f64c11435c20748b2f Mon Sep 17 00:00:00 2001 From: lfittl Date: Thu, 2 Mar 2006 21:19:41 +0000 Subject: [PATCH] - Added some missing newlines at end of files - Modified Makefiles to produce a shared library - Added SingletonDll Makefile git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@581 7ec92016-0320-0410-acc4-a06ded1c099a --- Makefile | 16 ++++++--- src/Makefile | 46 +++++++++++++++++-------- test/SingletonDll/Makefile | 22 ++++++++++++ test/SingletonDll/client.cpp | 2 +- test/SingletonDll/foo.cpp | 2 +- test/SingletonDll/foo.h | 2 +- test/SingletonDll/foo_export.h | 2 +- test/SingletonDll/singletondll.h | 2 +- test/SingletonDll/singletondll_export.h | 2 +- 9 files changed, 70 insertions(+), 26 deletions(-) create mode 100755 test/SingletonDll/Makefile diff --git a/Makefile b/Makefile index afcb5bc..2733305 100755 --- a/Makefile +++ b/Makefile @@ -1,14 +1,20 @@ -.PHONY: build check install clean-tmp clean -build: - $(MAKE) -C src +.PHONY: build-static build-shared check install clean-tmp clean +build-static: + $(MAKE) -C src build-static -check: build +build-shared: + $(MAKE) -C src build-shared + +check: build-static $(MAKE) -C test install: - $(MAKE) -C src install + $(MAKE) -C src install-static $(MAKE) -C include install +install-shared: + $(MAKE) -C src install-shared + clean-tmp: $(MAKE) -C src clean-tmp diff --git a/src/Makefile b/src/Makefile index b0ded6a..4f7aa61 100755 --- a/src/Makefile +++ b/src/Makefile @@ -1,24 +1,40 @@ -OBJ = \ - OrderedStatic.o \ - SafeFormat.o \ - Singleton.o \ - SmallObj.o \ - SmartPtr.o - -BIN = ../lib/libloki.a +SRC = $(wildcard *.cpp) +STATIC_OBJ = $(SRC:.cpp=.o) +SHARED_OBJ = $(SRC:.cpp=.lo) + +LOKI_VERSION = 0.1.4 + +STATIC_LIB = ../lib/libloki.a +SHARED_LIB = ../lib/libloki.so.$(LOKI_VERSION) CXXFLAGS = -Wall -Wold-style-cast -Wundef -Wsign-compare -Wconversion -Wpointer-arith -pedantic -O2 CPPFLAGS = -I../include -DNDEBUG -$(BIN): $(OBJ) - ar rs $(BIN) $(OBJ) +$(STATIC_LIB): $(STATIC_OBJ) + ar rs $(STATIC_LIB) $(STATIC_OBJ) -.PHONY: install clean-tmp clean -install: $(BIN) +$(SHARED_LIB): $(SHARED_OBJ) + g++ --shared -Wl,-soname=libloki.so.$(LOKI_VERSION) -o $(SHARED_LIB) $(SHARED_OBJ) + +%.lo : %.cpp + $(CXX) -c $(CXXFLAGS) -fPIC $(CPPFLAGS) -o $@ $< + +.PHONY: build-static build-shared install-static install-shared clean-tmp clean +build-static: $(STATIC_LIB) +build-shared: $(SHARED_LIB) + +install-static: $(STATIC_LIB) mkdir -p $(DESTDIR)/usr/lib - install $(BIN) $(DESTDIR)/usr/lib + install -m 644 $(STATIC_LIB) $(DESTDIR)/usr/lib + +install-shared: $(SHARED_LIB) + mkdir -p $(DESTDIR)/usr/lib + install -m 644 -s $(SHARED_LIB) $(DESTDIR)/usr/lib + cd $(DESTDIR)/usr/lib/; ln -s libloki.so.$(LOKI_VERSION) libloki.so clean-tmp: - rm -f $(OBJ) + rm -f $(STATIC_OBJ) + rm -f $(SHARED_OBJ) clean: clean-tmp - rm -f $(BIN) + rm -f $(STATIC_LIB) + rm -f $(SHARED_LIB) diff --git a/test/SingletonDll/Makefile b/test/SingletonDll/Makefile new file mode 100755 index 0000000..ee7d772 --- /dev/null +++ b/test/SingletonDll/Makefile @@ -0,0 +1,22 @@ +BIN = client +LIB1 = libfoo.so +LIB2 = libsingletondll.so +CXXFLAGS = -Wall -Wold-style-cast -Wundef -Wsign-compare -Wconversion -Wpointer-arith -pedantic -O2 +CPPFLAGS = -I../../include -DNDEBUG +LDFLAGS = -L../../lib +LDLIBS = -lloki + +.PHONY: build clean +build: $(BIN) + +$(BIN): $(LIB1) $(LIB2) + $(CXX) $(CXXFLAGS) -L. $(LDFLAGS) $(CPPFLAGS) -o $(BIN) client.cpp $(LDLIBS) -lfoo -lsingletondll + +$(LIB1): foo.cpp + $(CXX) --shared $(CXXFLAGS) $(CPPFLAGS) -o $(LIB1) foo.cpp + +$(LIB2): singletondll.cpp + $(CXX) --shared $(CXXFLAGS) $(CPPFLAGS) -o $(LIB2) foo.cpp + +clean: + rm -f $(BIN) $(LIB1) $(LIB2) diff --git a/test/SingletonDll/client.cpp b/test/SingletonDll/client.cpp index 34c5056..70612f4 100755 --- a/test/SingletonDll/client.cpp +++ b/test/SingletonDll/client.cpp @@ -43,4 +43,4 @@ int main() #endif return 0; -} \ No newline at end of file +} diff --git a/test/SingletonDll/foo.cpp b/test/SingletonDll/foo.cpp index 1e1d343..ccd63fb 100755 --- a/test/SingletonDll/foo.cpp +++ b/test/SingletonDll/foo.cpp @@ -22,4 +22,4 @@ Foo::Foo() void Foo::foo() { std::cout << "\nFoo:foo() called, this: " << this << "\n"; -} \ No newline at end of file +} diff --git a/test/SingletonDll/foo.h b/test/SingletonDll/foo.h index f58d2d2..4f925e8 100755 --- a/test/SingletonDll/foo.h +++ b/test/SingletonDll/foo.h @@ -27,4 +27,4 @@ public: }; -#endif \ No newline at end of file +#endif diff --git a/test/SingletonDll/foo_export.h b/test/SingletonDll/foo_export.h index ef0ef24..0f610cc 100755 --- a/test/SingletonDll/foo_export.h +++ b/test/SingletonDll/foo_export.h @@ -41,4 +41,4 @@ #endif -#endif \ No newline at end of file +#endif diff --git a/test/SingletonDll/singletondll.h b/test/SingletonDll/singletondll.h index a55c86c..84f8760 100755 --- a/test/SingletonDll/singletondll.h +++ b/test/SingletonDll/singletondll.h @@ -39,4 +39,4 @@ template class SINGLETONDLL_EXPORT Singleton; -#endif \ No newline at end of file +#endif diff --git a/test/SingletonDll/singletondll_export.h b/test/SingletonDll/singletondll_export.h index 851c2f2..f0c8ef8 100755 --- a/test/SingletonDll/singletondll_export.h +++ b/test/SingletonDll/singletondll_export.h @@ -41,4 +41,4 @@ #endif -#endif \ No newline at end of file +#endif