From: Maxim Mamontov <faust.madf@gmail.com>
Date: Tue, 20 Sep 2011 09:17:37 +0000 (+0300)
Subject: Fix projects and plugins building system to support new libs
X-Git-Tag: 2.408-rc1~20
X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/9dbaa1f22054ff5492e793259d5641b876b57ac1?ds=sidebyside;hp=a9f633a23d4fdd32c3185d13f8987a8ff7a8f82d

Fix projects and plugins building system to support new libs
---

diff --git a/projects/convertor/Makefile b/projects/convertor/Makefile
index 86ab6ed3..7fd02880 100644
--- a/projects/convertor/Makefile
+++ b/projects/convertor/Makefile
@@ -9,12 +9,16 @@ PROG = convertor
 SRCS = ./main.cpp \
        ./settings_impl.cpp
 
-STGLIBS =  -lstglogger \
-           -lstgcommon \
-           -ldotconfpp \
-	   -lstgcrypto
+STGLIBS =  logger \
+           common \
+           dotconfpp \
+	   crypto \
+	   conffiles
 
-LIBS += $(LIB_THREAD)
+STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
+STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
+
+LIBS += $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
 
 ifeq ($(OS),linux)
 LIBS += -ldl
@@ -22,14 +26,13 @@ else
 LIBS += -lc
 endif
 
-SEARCH_DIRS = -I $(DIR_INCLUDE)
+SEARCH_DIRS = -I ../../include
 
 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
-CXXFLAGS += -Wall
-LDFLAGS += -Wl,-E -L$(DIR_LIB) -Wl,-rpath,$(DIR_LIB)
-
-vpath %.a $(DIR_LIB)
+CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
 
 .PHONY: all clean distclean libs plugins install uninstall
 all: libs plugins $(PROG) ../../Makefile.conf
@@ -40,7 +43,7 @@ libs:
 plugins: libs 
 	$(MAKE) -C $(DIR_PLUGINS)
 
-$(PROG): $(OBJS) $(STGLIBS) 
+$(PROG): $(OBJS)
 	$(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
 
 clean:
@@ -64,11 +67,11 @@ endif
 endif
 
 deps:	$(SRCS) ../../Makefile.conf
-	$(MAKE) -C $(DIR_LIBSRC) includes
+	$(MAKE) -C $(DIR_LIBSRC)
 	@>deps ;\
 	for file in $(SRCS); do\
-	  echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) -MM $$file` Makefile" >> deps ;\
-	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS)' >> deps ;\
+	  echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
+	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
 	done
 
 
diff --git a/projects/rlm_stg/Makefile b/projects/rlm_stg/Makefile
index 68cdb5be..0c9d8a64 100644
--- a/projects/rlm_stg/Makefile
+++ b/projects/rlm_stg/Makefile
@@ -11,10 +11,13 @@ PROG = $(LIB_NAME).so
 SRCS = ./rlm_stg.cpp \
        ./stg_client.cpp
 
-STGLIBS = -lstgcommon \
-          -lstgcrypto
+STGLIBS = common \
+          crypto
 
-LIBS += $(LIB_THREAD)
+STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
+STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
+
+LIBS += $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
 
 ifeq ($(OS),linux)
 LIBS += -ldl
@@ -23,14 +26,13 @@ LIBS += -lintl \
         -lc
 endif
 
-SEARCH_DIRS = -I $(DIR_INCLUDE)
+SEARCH_DIRS = -I ../../include
 
 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
-CXXFLAGS += -Wall -fPIC -I./ 
-LDFLAGS += -shared -L$(DIR_LIB) -Wl,-rpath,$(PREFIX)/usr/lib/stg
-
-vpath %.a $(DIR_LIB)
+CXXFLAGS += -fPIC $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+LDFLAGS += -shared -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-E $(STGLIBS_LIBS)
 
 .PHONY: all clean distclean libs install uninstall install-bin uninstall-bin
 all: libs $(PROG) ../../Makefile.conf
@@ -38,7 +40,7 @@ all: libs $(PROG) ../../Makefile.conf
 libs:
 	$(MAKE) -C $(DIR_LIBSRC)
 
-$(PROG): $(OBJS) $(STGLIBS) 
+$(PROG): $(OBJS)
 	$(CXX) $^ $(LDFLAGS) -o $(PROG) $(LIBS)
 
 clean:
@@ -70,11 +72,11 @@ endif
 endif
 
 deps:	$(SRCS) ../../Makefile.conf
-	$(MAKE) -C $(DIR_LIBSRC) includes
+	$(MAKE) -C $(DIR_LIBSRC)
 	@>deps ;\
 	for file in $(SRCS); do\
-	  echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) -MM $$file` Makefile" >> deps ;\
-	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS)' >> deps ;\
+	  echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
+	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
 	done
 
 
diff --git a/projects/rscriptd/Makefile b/projects/rscriptd/Makefile
index a009a5c1..2b7395a3 100644
--- a/projects/rscriptd/Makefile
+++ b/projects/rscriptd/Makefile
@@ -10,22 +10,25 @@ SRCS = ./main.cpp \
        ./listener.cpp \
        ./pidfile.cpp
 
-STGLIBS =  -lstglogger \
-           -lstgcommon \
-	   -lstgcrypto \
-           -lstgscriptexecuter \
-           -lstgconffiles
+STGLIBS =  logger \
+	   locker \
+           common \
+	   crypto \
+           scriptexecuter \
+           conffiles
 
-LIBS += $(LIB_THREAD)
+STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
+STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
 
-SEARCH_DIRS = -I $(DIR_INCLUDE)
+LIBS += $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
 
-OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
+SEARCH_DIRS = -I ../../include
 
-CXXFLAGS += -Wall
-LDFLAGS += -Wl,-E -L$(DIR_LIB) -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-rpath-link,$(DIR_LIB)
+OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
-vpath %.a $(DIR_LIB)
+CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
 
 .PHONY: all clean distclean libs install uninstall
 all: libs $(PROG) ../../Makefile.conf
@@ -33,7 +36,7 @@ all: libs $(PROG) ../../Makefile.conf
 libs:
 	$(MAKE) -C $(DIR_LIBSRC)
 
-$(PROG): $(OBJS) $(STGLIBS) 
+$(PROG): $(OBJS)
 	$(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
 
 clean:
@@ -77,11 +80,11 @@ endif
 endif
 
 deps:	$(SRCS) ../../Makefile.conf
-	$(MAKE) -C $(DIR_LIBSRC) includes
+	$(MAKE) -C $(DIR_LIBSRC)
 	@>deps ;\
 	for file in $(SRCS); do\
-	  echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) -MM $$file` Makefile" >> deps ;\
-	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS)' >> deps ;\
+	  echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
+	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
 	done
 
 
diff --git a/projects/sgauth/Makefile b/projects/sgauth/Makefile
index cf2e2c53..6e330c78 100644
--- a/projects/sgauth/Makefile
+++ b/projects/sgauth/Makefile
@@ -10,12 +10,15 @@ SRCS = ./main.cpp \
        ./settings_impl.cpp \
        ./web.cpp
 
-STGLIBS =  -lstgconffiles \
-           -lstgia \
-           -lstgcrypto \
-           -lstgcommon
+STGLIBS =  conffiles \
+           ia \
+           crypto \
+           common
 
-LIBS += $(LIB_THREAD)
+STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
+STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
+
+LIBS += $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
 
 ifeq ($(OS),linux)
 else
@@ -23,14 +26,13 @@ LIBS += -lintl \
         -lc
 endif
 
-SEARCH_DIRS = -I $(DIR_INCLUDE)
+SEARCH_DIRS = -I ../../include
 
 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
-CXXFLAGS += -Wall
-LDFLAGS += -Wl,-E -L$(DIR_LIB) -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-rpath-link,$(DIR_LIB)
-
-vpath %.a $(DIR_LIB)
+CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
 
 .PHONY: all clean distclean libs install uninstall install-bin install-data uninstall-bin uninstall-data
 all: libs $(PROG) ../../Makefile.conf
@@ -38,7 +40,7 @@ all: libs $(PROG) ../../Makefile.conf
 libs:
 	$(MAKE) -C $(DIR_LIBSRC)
 
-$(PROG): $(OBJS) $(STGLIBS) 
+$(PROG): $(OBJS)
 	$(CXX) $^ $(LDFLAGS) -o $(PROG) $(LIBS)
 
 clean:
@@ -83,10 +85,10 @@ endif
 endif
 
 deps:	$(SRCS) ../../Makefile.conf sgauth.css
-	$(MAKE) -C $(DIR_LIBSRC) includes
+	$(MAKE) -C $(DIR_LIBSRC)
 	@>deps ;\
 	./make_css.sh
 	for file in $(SRCS); do\
-	  echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) -MM $$file` Makefile" >> deps ;\
-	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS)' >> deps ;\
+	  echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
+	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
 	done
diff --git a/projects/sgauthstress/Makefile b/projects/sgauthstress/Makefile
index 4864da31..9d5e94cd 100644
--- a/projects/sgauthstress/Makefile
+++ b/projects/sgauthstress/Makefile
@@ -8,11 +8,15 @@ SRCS = main.cpp \
        user.cpp \
        proto.cpp
 
-STGLIBS =  -lstgcrypto \
-           -lstgcommon \
-           -ldotconfpp
+STGLIBS = crypto \
+          common \
+          dotconfpp \
+	  locker
 
-LIBS += $(LIB_THREAD)
+STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
+STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
+
+LIBS += $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
 
 ifeq ($(OS),linux)
 LIBS += -ldl
@@ -21,14 +25,13 @@ LIBS += -lintl \
         -lc
 endif
 
-SEARCH_DIRS = -I $(DIR_INCLUDE)
+SEARCH_DIRS = -I ../../include
 
 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
-CXXFLAGS += -Wall
-LDFLAGS += -Wl,-E -L$(DIR_LIB) -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-rpath-link,$(DIR_LIB)
-
-vpath %.a $(DIR_LIB)
+CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
 
 .PHONY: all clean distclean libs plugins
 all: libs plugins $(PROG) ../../Makefile.conf
@@ -39,8 +42,8 @@ libs:
 plugins: libs 
 	$(MAKE) -C $(DIR_PLUGINS)
 
-$(PROG): $(OBJS) libs
-	$(CXX) $(OBJS) $(LDFLAGS) $(LIBS) $(STGLIBS) -o $(PROG)
+$(PROG): $(OBJS)
+	$(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
 
 clean:
 	rm -f deps $(PROG) *.o *.*~
@@ -59,9 +62,9 @@ endif
 endif
 
 deps:	$(SRCS) ../../Makefile.conf
-	$(MAKE) -C $(DIR_LIBSRC) includes
+	$(MAKE) -C $(DIR_LIBSRC)
 	@>deps ;\
 	for file in $(SRCS); do\
-	  echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
-	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS)' >> deps ;\
+	  echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
+	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
 	done
diff --git a/projects/sgconf/Makefile b/projects/sgconf/Makefile
index 02f8d7b8..6dbf2117 100644
--- a/projects/sgconf/Makefile
+++ b/projects/sgconf/Makefile
@@ -9,22 +9,23 @@ PROG = sgconf
 SRCS = ./main.cpp \
        ./common_sg.cpp
 
-STGLIBS =  -lstgconffiles \
-           -lstgsrvconf \
-           -lstgcommon \
-	   -lstgcrypto
+STGLIBS = conffiles \
+          srvconf \
+          common \
+	  crypto
 
-LIBS += -lexpat \
-	$(LIB_THREAD)
+STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
+STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
+
+LIBS += -lexpat $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
 
 ifeq ($(OS),linux)
-LIBS += -ldl
 else
 LIBS += -lc \
 	-liconv
 endif
 
-SEARCH_DIRS = -I $(DIR_INCLUDE)
+SEARCH_DIRS = -I ../../include
 
 ifeq ($(OS),bsd)
 SEARCH_DIRS += -I/usr/local/include
@@ -38,10 +39,9 @@ endif
 
 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
-CXXFLAGS += -Wall
-LDFLAGS += -Wl,-E -L$(DIR_LIB) -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-rpath-link,$(DIR_LIB)
-
-vpath %.a $(DIR_LIB)
+CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
 
 .PHONY: all clean distclean libs install uninstall install-bin install-data uninstall-bin uninstall-data
 all: libs $(PROG) ../../Makefile.conf
@@ -49,7 +49,7 @@ all: libs $(PROG) ../../Makefile.conf
 libs:
 	$(MAKE) -C $(DIR_LIBSRC)
 
-$(PROG): $(OBJS) $(STGLIBS)
+$(PROG): $(OBJS)
 	$(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
 
 clean:
@@ -84,11 +84,11 @@ endif
 endif
 
 deps:	$(SRCS) ../../Makefile.conf
-	$(MAKE) -C $(DIR_LIBSRC) includes
+	$(MAKE) -C $(DIR_LIBSRC)
 	@>deps ;\
 	for file in $(SRCS); do\
-	  echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) -MM $$file` Makefile" >> deps ;\
-	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS)' >> deps ;\
+	  echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
+	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
 	done
 
 
diff --git a/projects/sgconf_xml/Makefile b/projects/sgconf_xml/Makefile
index 2453ef5c..671833ed 100644
--- a/projects/sgconf_xml/Makefile
+++ b/projects/sgconf_xml/Makefile
@@ -9,22 +9,23 @@ PROG = sgconf_xml
 SRCS = ./main.cpp \
        ./parser.cpp
 
-LIBS =  -lstgconffiles \
-        -lstgsrvconf \
-        -lstgcrypto \
-        -lstgcommon
+STGLIBS = conffiles \
+          srvconf \
+          crypto \
+          common
 
-LIBS += -lexpat \
-	$(LIB_THREAD)
+STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
+STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
+
+LIBS += -lexpat $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
 
 ifeq ($(OS),linux)
-LIBS += -ldl
 else
 LIBS += -lc \
 	-liconv
 endif
 
-SEARCH_DIRS = -I $(DIR_INCLUDE)
+SEARCH_DIRS = -I ../../include
 
 ifeq ($(OS),bsd)
 SEARCH_DIRS += -I/usr/local/include
@@ -38,10 +39,9 @@ endif
 
 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
-CXXFLAGS += -Wall
-LDFLAGS += -Wl,-E -L$(DIR_LIB) -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-rpath-link,$(DIR_LIB)
-
-vpath %.a $(DIR_LIB)
+CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
 
 .PHONY: all clean distclean libs install uninstall install-bin install-data uninstall-bin uninstall-data
 all: libs $(PROG) ../../Makefile.conf
@@ -49,7 +49,7 @@ all: libs $(PROG) ../../Makefile.conf
 libs:
 	$(MAKE) -C $(DIR_LIBSRC)
 
-$(PROG): $(OBJS) $(STGLIBS)
+$(PROG): $(OBJS)
 	$(CXX) $^ $(LIBS) $(LDFLAGS) -o $(PROG)
 
 clean:
@@ -84,11 +84,11 @@ endif
 endif
 
 deps:	$(SRCS) ../../Makefile.conf
-	$(MAKE) -C $(DIR_LIBSRC) includes
+	$(MAKE) -C $(DIR_LIBSRC)
 	@>deps ;\
 	for file in $(SRCS); do\
-	  echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) -MM $$file` Makefile" >> deps ;\
-	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS)' >> deps ;\
+	  echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
+	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
 	done
 
 
diff --git a/projects/stargazer/Makefile b/projects/stargazer/Makefile
index 56702d07..020e05b5 100644
--- a/projects/stargazer/Makefile
+++ b/projects/stargazer/Makefile
@@ -24,28 +24,30 @@ SRCS = ./admin_impl.cpp \
        ./user_property.cpp \
        ./users_impl.cpp
 
-STGLIBS =  -lstglogger \
-    	   -lstglocker \
-           -lstgcommon \
-           -lstgscriptexecuter \
-           -ldotconfpp
+STGLIBS = logger \
+    	  locker \
+          common \
+          scriptexecuter \
+          dotconfpp
 
-LIBS += -lexpat
+STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
+STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
+
+LIBS += -lexpat $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
 
 ifeq ($(OS),linux)
-LIBS += $(LIB_THREAD) \
-        -ldl
+LIBS += -ldl
 else
-LIBS += $(LIB_THREAD) \
-        -lc
+LIBS += -lc
 endif
 
-SEARCH_DIRS = -I $(DIR_INCLUDE)
+SEARCH_DIRS = -I ../../include
 
 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
-LDFLAGS += -Wl,-E -L$(DIR_LIB) -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-rpath-link,$(DIR_LIB) 
-vpath %.so $(DIR_LIB)
+CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
+LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
 
 .PHONY: all clean distclean libs plugins install uninstall install-bin install-data
 all: libs plugins $(PROG)
@@ -56,8 +58,8 @@ libs:
 plugins: libs 
 	$(MAKE) -C $(DIR_PLUGINS)
 
-$(PROG): $(OBJS) libs
-	$(CXX) $(OBJS) $(LDFLAGS) $(LIBS) $(STGLIBS) -o $(PROG)
+$(PROG): $(OBJS)
+	$(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
 
 clean:
 	rm -f deps $(PROG) *.o tags *.*~ .OS
@@ -146,9 +148,9 @@ endif
 endif
 
 deps: $(SRCS) ../../Makefile.conf
-	$(MAKE) -C $(DIR_LIBSRC) includes
+	$(MAKE) -C $(DIR_LIBSRC)
 	@>deps ;\
 	for file in $(SRCS); do\
-	  echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
-	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS)' >> deps ;\
+	  echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
+	  echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
 	done
diff --git a/projects/stargazer/plugins/Makefile.in b/projects/stargazer/plugins/Makefile.in
index 961ba3aa..1389d9ef 100644
--- a/projects/stargazer/plugins/Makefile.in
+++ b/projects/stargazer/plugins/Makefile.in
@@ -8,15 +8,18 @@ OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
 LN = ln
 
-CXXFLAGS += -fPIC
-CFLAGS += -fPIC
-LDFLAGS += -shared -L$(DIR_LIB) -Wl,-rpath,$(PREFIX)/usr/lib/stg
+STGLIBS_INCS = $(addprefix -I ../../../../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
+STGLIBS_LIBS = $(addprefix -L ../../../../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
 
-vpath %.a $(DIR_LIB)
+LIBS += $(addprefix -lstg,$(STGLIBS))
+
+CXXFLAGS += -fPIC $(STGLIBS_INCS)
+CFLAGS += -fPIC $(STGLIBS_INCS)
+LDFLAGS += -shared -Wl,-rpath,$(PREFIX)/usr/lib/stg $(STGLIBS_LIBS)
 
 all: $(PROG)
 
-$(PROG): $(OBJS) $(STGLIBS)
+$(PROG): $(OBJS)
 	$(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
 	$(LN) -fs "`pwd`/$(PROG)" $(DIR_MOD)/$(PROG)
 
diff --git a/projects/stargazer/plugins/authorization/ao/Makefile b/projects/stargazer/plugins/authorization/ao/Makefile
index a8651d64..1a7697e3 100644
--- a/projects/stargazer/plugins/authorization/ao/Makefile
+++ b/projects/stargazer/plugins/authorization/ao/Makefile
@@ -8,7 +8,10 @@ PROG = mod_auth_ao.so
 
 SRCS = ./ao.cpp
 
-STGLIBS = -lstgcommon
+STGLIBS = common \
+	  logger \
+	  locker \
+	  scriptexecuter
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/authorization/inetaccess/Makefile b/projects/stargazer/plugins/authorization/inetaccess/Makefile
index 15fd5287..6f735ad8 100644
--- a/projects/stargazer/plugins/authorization/inetaccess/Makefile
+++ b/projects/stargazer/plugins/authorization/inetaccess/Makefile
@@ -10,7 +10,11 @@ PROG = mod_auth_ia.so
 
 SRCS = ./inetaccess.cpp
 
-STGLIBS = -lstgcommon -lstgcrypto
+STGLIBS = common \
+	  crypto \
+	  logger \
+	  locker \
+	  scriptexecuter
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/authorization/stress/Makefile b/projects/stargazer/plugins/authorization/stress/Makefile
index 2bdcf1b0..411acfaf 100644
--- a/projects/stargazer/plugins/authorization/stress/Makefile
+++ b/projects/stargazer/plugins/authorization/stress/Makefile
@@ -10,5 +10,10 @@ SRCS = ./stress.cpp
 
 LIBS += $(LIB_THREAD)
 
+STGLIBS = common \
+	  logger \
+	  locker \
+	  scriptexecuter
+
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/capture/cap_debug/Makefile b/projects/stargazer/plugins/capture/cap_debug/Makefile
index 916ae175..48b0e870 100644
--- a/projects/stargazer/plugins/capture/cap_debug/Makefile
+++ b/projects/stargazer/plugins/capture/cap_debug/Makefile
@@ -16,7 +16,7 @@ SRCS = ./debug_cap.cpp \
        ./tcp.c \
        ./udp.c
 
-STGLIBS = -lstgcommon
+STGLIBS = common
 
 LIBS += $(LIB_THREAD)
 
diff --git a/projects/stargazer/plugins/capture/cap_nf/Makefile b/projects/stargazer/plugins/capture/cap_nf/Makefile
index b0f7713d..481862dd 100644
--- a/projects/stargazer/plugins/capture/cap_nf/Makefile
+++ b/projects/stargazer/plugins/capture/cap_nf/Makefile
@@ -9,7 +9,8 @@ PROG = mod_cap_nf.so
 SRCS = ./cap_nf.cpp
 
 LIBS += $(LIB_THREAD)
-STGLIBS = -lstgcommon
+
+STGLIBS = common
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/capture/divert_freebsd/Makefile b/projects/stargazer/plugins/capture/divert_freebsd/Makefile
index 2fbc97d6..48e24826 100644
--- a/projects/stargazer/plugins/capture/divert_freebsd/Makefile
+++ b/projects/stargazer/plugins/capture/divert_freebsd/Makefile
@@ -8,9 +8,9 @@ PROG = mod_cap_divert.so
 
 SRCS = ./divert_cap.cpp 
 
-STGLIBS = -lstgcommon
-
 LIBS += $(LIB_THREAD)
 
+STGLIBS = common
+
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/capture/ether_freebsd/Makefile b/projects/stargazer/plugins/capture/ether_freebsd/Makefile
index f4b86e21..d1087896 100644
--- a/projects/stargazer/plugins/capture/ether_freebsd/Makefile
+++ b/projects/stargazer/plugins/capture/ether_freebsd/Makefile
@@ -8,9 +8,9 @@ PROG = mod_cap_bpf.so
 
 SRCS = ./ether_cap.cpp 
 
-STGLIBS = -lstgcommon
-
 LIBS += $(LIB_THREAD)
 
+STGLIBS = common
+
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/capture/ether_linux/Makefile b/projects/stargazer/plugins/capture/ether_linux/Makefile
index a045167c..873ba6f0 100644
--- a/projects/stargazer/plugins/capture/ether_linux/Makefile
+++ b/projects/stargazer/plugins/capture/ether_linux/Makefile
@@ -9,7 +9,8 @@ PROG = mod_cap_ether.so
 SRCS = ./ether_cap.cpp
 
 LIBS += $(LIB_THREAD)
-STGLIBS = -lstgcommon
+
+STGLIBS = common
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/capture/ipq_linux/Makefile b/projects/stargazer/plugins/capture/ipq_linux/Makefile
index 988cd948..548f589c 100644
--- a/projects/stargazer/plugins/capture/ipq_linux/Makefile
+++ b/projects/stargazer/plugins/capture/ipq_linux/Makefile
@@ -10,7 +10,8 @@ SRCS = ./ipq_cap.cpp \
        ./libipq.c
 
 LIBS += $(LIB_THREAD)
-STGLIBS = -lstgcommon
+
+STGLIBS = common
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/configuration/rpcconfig/Makefile b/projects/stargazer/plugins/configuration/rpcconfig/Makefile
index e0e09052..b2bdabf6 100644
--- a/projects/stargazer/plugins/configuration/rpcconfig/Makefile
+++ b/projects/stargazer/plugins/configuration/rpcconfig/Makefile
@@ -24,7 +24,10 @@ ifneq ($(OS),linux)
 LIBS += -liconv
 endif
 
-STGLIBS = -lstgcommon -lstglogger
+STGLIBS = common \
+	  locker \
+	  logger \
+	  scriptexecuter
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/configuration/sgconfig-ng/Makefile b/projects/stargazer/plugins/configuration/sgconfig-ng/Makefile
index 6d1a7a7b..8f100233 100644
--- a/projects/stargazer/plugins/configuration/sgconfig-ng/Makefile
+++ b/projects/stargazer/plugins/configuration/sgconfig-ng/Makefile
@@ -18,6 +18,8 @@ SRCS = ./stgconfig.cpp \
 LIBS += -lexpat \
 	-lboost_thread-mt
 
-STGLIBS = -lstgcommon -lstglogger -lcrypto
+STGLIBS = common \
+	  logger \
+	  crypto
 
 include ../../Makefile.in
diff --git a/projects/stargazer/plugins/configuration/sgconfig/Makefile b/projects/stargazer/plugins/configuration/sgconfig/Makefile
index f49ed018..b6f4938a 100644
--- a/projects/stargazer/plugins/configuration/sgconfig/Makefile
+++ b/projects/stargazer/plugins/configuration/sgconfig/Makefile
@@ -16,7 +16,11 @@ SRCS = ./stgconfig.cpp \
 LIBS += -lexpat \
 	$(LIB_THREAD)
 
-STGLIBS = -lstgcommon -lstglogger -lstgcrypto
+STGLIBS = common \
+	  locker \
+	  logger \
+	  crypto \
+	  scriptexecuter
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/configuration/sgconfig2/Makefile b/projects/stargazer/plugins/configuration/sgconfig2/Makefile
index 290a616b..68bf7f74 100644
--- a/projects/stargazer/plugins/configuration/sgconfig2/Makefile
+++ b/projects/stargazer/plugins/configuration/sgconfig2/Makefile
@@ -16,7 +16,8 @@ SRCS = ./stgconfig.cpp \
 LIBS += -lexpat \
 	$(LIB_THREAD)
 
-STGLIBS = -lstgcommon -lstglogger
+STGLIBS = common \
+	  logger
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/other/ping/Makefile b/projects/stargazer/plugins/other/ping/Makefile
index 212bd288..931c3f4a 100644
--- a/projects/stargazer/plugins/other/ping/Makefile
+++ b/projects/stargazer/plugins/other/ping/Makefile
@@ -10,7 +10,11 @@ PROG = mod_ping.so
 
 SRCS = ./ping.cpp
 
-STGLIBS = -lstgpinger -lstgcommon
+STGLIBS = pinger \
+	  common \
+	  locker \
+	  logger \
+	  scriptexecuter
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/other/radius/Makefile b/projects/stargazer/plugins/other/radius/Makefile
index 9735fb67..06f467ba 100644
--- a/projects/stargazer/plugins/other/radius/Makefile
+++ b/projects/stargazer/plugins/other/radius/Makefile
@@ -10,7 +10,11 @@ PROG = mod_radius.so
 
 SRCS = ./radius.cpp
 
-STGLIBS = -lstgcommon -lstgcrypto
+STGLIBS = common \
+	  crypto \
+	  logger \
+	  locker \
+	  scriptexecuter
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/other/rscript/Makefile b/projects/stargazer/plugins/other/rscript/Makefile
index 343d1150..f9ba3ba1 100644
--- a/projects/stargazer/plugins/other/rscript/Makefile
+++ b/projects/stargazer/plugins/other/rscript/Makefile
@@ -11,7 +11,11 @@ PROG = mod_remote_script.so
 SRCS = ./rscript.cpp \
        ./nrmap_parser.cpp
 
-STGLIBS = -lstgcommon -lstgcrypto
+STGLIBS = common \
+	  crypto \
+	  locker \
+	  logger \
+	  scriptexecuter
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/other/smux/Makefile b/projects/stargazer/plugins/other/smux/Makefile
index feaef9ee..1c875dcd 100644
--- a/projects/stargazer/plugins/other/smux/Makefile
+++ b/projects/stargazer/plugins/other/smux/Makefile
@@ -11,13 +11,13 @@ SRCS =  smux.cpp \
 	utils.cpp \
 	types.cpp
 
-STGLIBS = -lstgcommon -lstgsmux
+STGLIBS = common \
+	  smux \
+	  logger \
+	  locker \
+	  scriptexecuter
 
-CXXFLAGS += -I$(DIR_INCLUDE)/stg
+CFLAGS += -I ../../../../../stglibs/smux.lib/include/stg
+CXXFLAGS += -I ../../../../../stglibs/smux.lib/include/stg
 
 include ../../Makefile.in
-
-.PHONY: asn1
-
-asn1:
-	$(MAKE) -C asn1 asn1
diff --git a/projects/stargazer/plugins/store/files/Makefile b/projects/stargazer/plugins/store/files/Makefile
index 8bf5777a..372a3cd4 100644
--- a/projects/stargazer/plugins/store/files/Makefile
+++ b/projects/stargazer/plugins/store/files/Makefile
@@ -8,7 +8,11 @@ PROG = mod_store_files.so
 
 SRCS = ./file_store.cpp
 
-STGLIBS = -lstgconffiles -lstgcommon -lstglocker -lstgcrypto
+STGLIBS = conffiles \
+	  common \
+	  locker \
+	  logger \
+	  crypto
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/store/firebird/Makefile b/projects/stargazer/plugins/store/firebird/Makefile
index 8b175fd9..b4cce929 100644
--- a/projects/stargazer/plugins/store/firebird/Makefile
+++ b/projects/stargazer/plugins/store/firebird/Makefile
@@ -17,7 +17,10 @@ SRCS =	./firebird_store.cpp \
 	./firebird_store_users.cpp \
 	./firebird_store_utils.cpp
 
-STGLIBS = -libpp -lstgcommon -lstglocker -lstgcrypto
+STGLIBS = ibpp \
+	  common \
+	  locker \
+	  crypto
 
 include ../../Makefile.in
 
diff --git a/projects/stargazer/plugins/store/mysql/Makefile b/projects/stargazer/plugins/store/mysql/Makefile
index 81196222..57c52a6b 100644
--- a/projects/stargazer/plugins/store/mysql/Makefile
+++ b/projects/stargazer/plugins/store/mysql/Makefile
@@ -8,7 +8,8 @@ PROG = mod_store_mysql.so
 
 SRCS = ./mysql_store.cpp
 
-STGLIBS = -lstgcommon -lstgcrypto
+STGLIBS = common \
+	  crypto
 
 MYSQL_CFLAGS = $(shell mysql_config --cflags)
 MYSQL_LDFLAGS = $(shell mysql_config --libs_r)
diff --git a/projects/stargazer/plugins/store/postgresql/Makefile b/projects/stargazer/plugins/store/postgresql/Makefile
index fa6ebf0d..b59e45cd 100644
--- a/projects/stargazer/plugins/store/postgresql/Makefile
+++ b/projects/stargazer/plugins/store/postgresql/Makefile
@@ -15,7 +15,9 @@ SRCS =	./postgresql_store.cpp \
 	./postgresql_store_users.cpp \
 	./postgresql_store_utils.cpp
 
-STGLIBS = -lstgcommon -lstgcrypto
+STGLIBS = common \
+	  crypto \
+	  locker
 
 PG_CFLAGS = $(shell pg_config --includedir)
 PG_LDFLAGS = $(shell pg_config --libdir)
diff --git a/stglibs/Makefile b/stglibs/Makefile
index f7d5e45e..912be63d 100644
--- a/stglibs/Makefile
+++ b/stglibs/Makefile
@@ -14,9 +14,7 @@ $(STG_LIBS):
 includes: all
 
 clean: all
-	rm -f $(DIR_LIB)/*
 
 install: all
 
 uninstall: all
-
diff --git a/stglibs/Makefile.in b/stglibs/Makefile.in
index c0b4f2b9..5bbc24e5 100644
--- a/stglibs/Makefile.in
+++ b/stglibs/Makefile.in
@@ -6,7 +6,7 @@ include ../../Makefile.conf
 
 PROG = lib$(LIB_NAME).a
 
-SEARCH_DIRS = -I $(DIR_INCLUDE) -I . -I ./include
+SEARCH_DIRS = -I ../../include -I . -I ./include
 
 ifeq ($(STG_TIME), yes)
 DEFS += -DSTG_TIME
@@ -22,29 +22,17 @@ endif
 
 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
 
-#INST_INCS = $(addprefix $(DIR_INCLUDE)/, $(notdir $(INCS)))
-#INST_LIBS = $(DIR_LIB)/lib$(LIB_NAME)
-
-CXXFLAGS += -fPIC
-CFLAGS += -fPIC
-
-vpath %.a $(DIR_LIB)
+CXXFLAGS += -fPIC $(SEARCH_DIRS) $(DEFS)
+CFLAGS += -fPIC $(SEARCH_DIRS) $(DEFS)
 
 all: $(PROG)
 
-$(PROG): $(OBJS) $(STGLIBS)
+$(PROG): $(OBJS)
 	ar rc lib$(LIB_NAME).a $(OBJS)
 	ranlib lib$(LIB_NAME).a
-	#cp *.a $(DIR_LIB)
-
-#includes: $(INCS)
-#	cp -p $(INCS) $(DIR_INCLUDE)/stg
 
 clean:
 	rm -f deps $(PROG) *.o *.a *.so tags *.*~ 
-	#for file in $(INCS); do \
-	#    rm -f $(DIR_INCLUDE)/stg/$$file; \
-	#done
 
 install: $(PROG)
 	mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/lib/stg
@@ -72,11 +60,10 @@ deps:	$(SRCS) ../../Makefile.conf
 	  echo "$$file" | grep ".c$$" > /dev/null;\
 	  if [ $$? == 0 ];\
 	  then\
-	    echo "`$(CC) $(CFLAGS) $(SEARCH_DIRS) $(DEFS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
-	    echo -e '\t$$(CC) $(CFLAGS) $(SEARCH_DIRS) $(DEFS) -c $$<' >> deps ;\
+	    echo "`$(CC) $(CFLAGS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
+	    echo -e '\t$$(CC) $(CFLAGS) -c $$<' >> deps ;\
 	  else\
-	    echo "`$(CXX) $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
-	    echo -e '\t$$(CXX) $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS) -c $$<' >> deps ;\
+	    echo "`$(CXX) $(CXXFLAGS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
+	    echo -e '\t$$(CXX) $(CXXFLAGS) -c $$<' >> deps ;\
 	  fi;\
 	done
-
diff --git a/stglibs/dotconfpp.lib/Makefile b/stglibs/dotconfpp.lib/Makefile
index 3acce922..52c44833 100644
--- a/stglibs/dotconfpp.lib/Makefile
+++ b/stglibs/dotconfpp.lib/Makefile
@@ -2,7 +2,7 @@
 # $Id: Makefile,v 1.3 2007/05/08 14:29:19 faust Exp $
 ###############################################################################
 
-LIB_NAME = dotconfpp
+LIB_NAME = stgdotconfpp
 
 SRCS = dotconfpp.cpp \
        mempool.cpp
diff --git a/stglibs/ibpp.lib/Makefile b/stglibs/ibpp.lib/Makefile
index 59eded2f..80a895e9 100644
--- a/stglibs/ibpp.lib/Makefile
+++ b/stglibs/ibpp.lib/Makefile
@@ -2,7 +2,7 @@
 # $Id: Makefile,v 1.6 2009/03/03 15:50:15 faust Exp $
 ###############################################################################
 
-LIB_NAME = ibpp
+LIB_NAME = stgibpp
 
 SRCS = array.cpp \
        blob.cpp \