--- a/src/lib/Makefile
+++ b/src/lib/Makefile
@@ -1,5 +1,7 @@
+depth = ..
+include $(depth)/mk/sysconf
 
-UNACCFLAGS = -g -I. -I../unac $(INCICONV) -DUNAC_VERSION=\"1.0.7\"
+UNACCFLAGS = -g -I. -I$(depth)/unac $(INCICONV) -DUNAC_VERSION=\"1.0.7\"
 
 LIBS = librcl.a
 
@@ -15,101 +17,105 @@
      textsplit.o transcode.o \
      unacpp.o unac.o docseq.o sortseq.o copyfile.o
 
-SRCS =  ../utils/conftree.cpp \
-     ../index/csguess.cpp ../utils/debuglog.cpp \
-     ../utils/execmd.cpp ../utils/idfile.cpp ../utils/md5.cpp \
-     ../utils/wipedir.cpp ../utils/fstreewalk.cpp \
-     ../common/mh_html.cpp ../common/mh_mail.cpp ../common/mh_exec.cpp \
-     ../common/mh_text.cpp ../common/htmlparse.cpp \
-     ../index/indexer.cpp ../common/internfile.cpp \
-     ../common/mimehandler.cpp ../utils/mimeparse.cpp ../index/mimetype.cpp \
-     ../common/myhtmlparse.cpp ../common/pathhash.cpp ../utils/pathut.cpp \
-     ../common/rclconfig.cpp ../common/rcldb.cpp ../common/rclinit.cpp \
-     ../utils/base64.cpp ../utils/readfile.cpp ../utils/smallut.cpp \
-     ../common/textsplit.cpp ../utils/transcode.cpp \
-     ../common/unacpp.cpp ../unac/unac.c ../query/history.cpp \
-     ../query/docseq.cpp ../query/sortseq.cpp ../utils/copyfile.cpp
+SRCS =  \
+     $(depth)/utils/conftree.cpp $(depth)/index/csguess.cpp \
+     $(depth)/utils/debuglog.cpp $(depth)/utils/execmd.cpp \
+     $(depth)/utils/idfile.cpp $(depth)/utils/md5.cpp \
+     $(depth)/utils/wipedir.cpp $(depth)/utils/fstreewalk.cpp \
+     $(depth)/common/mh_html.cpp $(depth)/common/mh_mail.cpp \
+     $(depth)/common/mh_exec.cpp $(depth)/common/mh_text.cpp \
+     $(depth)/common/htmlparse.cpp $(depth)/index/indexer.cpp \
+     $(depth)/common/internfile.cpp $(depth)/common/mimehandler.cpp \
+     $(depth)/utils/mimeparse.cpp $(depth)/index/mimetype.cpp \
+     $(depth)/common/myhtmlparse.cpp $(depth)/common/pathhash.cpp \
+     $(depth)/utils/pathut.cpp $(depth)/common/rclconfig.cpp \
+     $(depth)/common/rcldb.cpp $(depth)/common/rclinit.cpp \
+     $(depth)/utils/base64.cpp $(depth)/utils/readfile.cpp \
+     $(depth)/utils/smallut.cpp $(depth)/common/textsplit.cpp \
+     $(depth)/utils/transcode.cpp $(depth)/common/unacpp.cpp \
+     $(depth)/unac/unac.c $(depth)/query/history.cpp \
+     $(depth)/query/docseq.cpp $(depth)/query/sortseq.cpp \
+     $(depth)/utils/copyfile.cpp
 
 librcl.a : $(OBJS)
 	ar ru librcl.a $(OBJS)
 	$(RANLIB) librcl.a
 
-unac.o : ../unac/unac.c ../unac/unac.h
+unac.o : $(depth)/unac/unac.c $(depth)/unac/unac.h
 	$(CC) $(UNACCFLAGS) -c $<
 
-#	$(CXX) $(CXXFLAGS) -c $<
-conftree.o : ../utils/conftree.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-csguess.o : ../index/csguess.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-debuglog.o : ../utils/debuglog.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-execmd.o : ../utils/execmd.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-wipedir.o : ../utils/wipedir.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-fstreewalk.o : ../utils/fstreewalk.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-history.o : ../query/history.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-sortseq.o : ../query/sortseq.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-docseq.o : ../query/docseq.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-mh_html.o : ../common/mh_html.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-mh_exec.o : ../common/mh_exec.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-mh_text.o : ../common/mh_text.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-htmlparse.o : ../common/htmlparse.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-idfile.o : ../utils/idfile.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-indexer.o : ../index/indexer.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-internfile.o : ../common/internfile.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-mh_mail.o : ../common/mh_mail.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-mimehandler.o : ../common/mimehandler.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-mimeparse.o : ../utils/mimeparse.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-mimetype.o : ../index/mimetype.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-myhtmlparse.o : ../common/myhtmlparse.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-pathut.o : ../utils/pathut.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-pathhash.o : ../common/pathhash.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-rclconfig.o : ../common/rclconfig.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-rclinit.o : ../common/rclinit.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-rcldb.o : ../common/rcldb.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-readfile.o : ../utils/readfile.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-base64.o : ../utils/base64.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-smallut.o : ../utils/smallut.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-textsplit.o : ../common/textsplit.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-transcode.o : ../utils/transcode.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-md5.o : ../utils/md5.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-unacpp.o : ../common/unacpp.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
-copyfile.o : ../utils/copyfile.cpp 
-	$(CXX) $(CXXFLAGS) -c $<
+conftree.o : $(depth)/utils/conftree.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+csguess.o : $(depth)/index/csguess.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+debuglog.o : $(depth)/utils/debuglog.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+execmd.o : $(depth)/utils/execmd.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+wipedir.o : $(depth)/utils/wipedir.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+fstreewalk.o : $(depth)/utils/fstreewalk.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+history.o : $(depth)/query/history.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+sortseq.o : $(depth)/query/sortseq.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+docseq.o : $(depth)/query/docseq.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+mh_html.o : $(depth)/common/mh_html.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+mh_exec.o : $(depth)/common/mh_exec.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+mh_text.o : $(depth)/common/mh_text.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+htmlparse.o : $(depth)/common/htmlparse.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+idfile.o : $(depth)/utils/idfile.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+indexer.o : $(depth)/index/indexer.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+internfile.o : $(depth)/common/internfile.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+mh_mail.o : $(depth)/common/mh_mail.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+mimehandler.o : $(depth)/common/mimehandler.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+mimeparse.o : $(depth)/utils/mimeparse.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+mimetype.o : $(depth)/index/mimetype.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+myhtmlparse.o : $(depth)/common/myhtmlparse.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+pathut.o : $(depth)/utils/pathut.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+pathhash.o : $(depth)/common/pathhash.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+rclconfig.o : $(depth)/common/rclconfig.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+rclinit.o : $(depth)/common/rclinit.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+rcldb.o : $(depth)/common/rcldb.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+readfile.o : $(depth)/utils/readfile.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+base64.o : $(depth)/utils/base64.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+smallut.o : $(depth)/utils/smallut.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+textsplit.o : $(depth)/common/textsplit.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+transcode.o : $(depth)/utils/transcode.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+md5.o : $(depth)/utils/md5.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+unacpp.o : $(depth)/common/unacpp.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
+copyfile.o : $(depth)/utils/copyfile.cpp 
+	$(CXX) $(ALL_CXXFLAGS) -c $<
 
 depend: alldeps.stamp
 alldeps.stamp : $(SRCS)
-	$(CXX) -M $(CXXFLAGS) $(SRCS) > alldeps
+	$(CXX) -M $(ALL_CXXFLAGS) $(SRCS) > alldeps
 	touch alldeps.stamp
 
 clean:
@@ -118,4 +124,3 @@
 	rm -f $(OBJS) $(LIBS)
 
 include alldeps
-include ../mk/sysconf