From 06d8b6f7578d31a5b25e84b502b2bba983a6b330 Mon Sep 17 00:00:00 2001 From: wyy Date: Sat, 14 Sep 2013 12:46:43 +0800 Subject: [PATCH] rename src -> cppjieba && mv cppcommon out of compile in makefile and link it in using in demo --- README.md | 24 +++++++++++++++++++++++- {src => cppjieba}/HMMSegment.cpp | 0 {src => cppjieba}/HMMSegment.h | 0 {src => cppjieba}/KeyWordExt.cpp | 0 {src => cppjieba}/KeyWordExt.h | 0 {src => cppjieba}/MPSegment.cpp | 0 {src => cppjieba}/MPSegment.h | 0 {src => cppjieba}/Makefile | 30 +++++++++++++++++------------- {src => cppjieba}/MixSegment.cpp | 0 {src => cppjieba}/MixSegment.h | 0 {src => cppjieba}/TransCode.cpp | 0 {src => cppjieba}/TransCode.h | 0 {src => cppjieba}/Trie.cpp | 0 {src => cppjieba}/Trie.h | 0 {src => cppjieba}/globals.h | 0 {src => cppjieba}/headers.h | 0 {src => cppjieba}/structs.h | 0 demo/Makefile | 23 +++++++++++++++-------- demo/keywordext_demo.cpp | 2 +- demo/segment_demo.cpp | 2 +- 20 files changed, 57 insertions(+), 24 deletions(-) rename {src => cppjieba}/HMMSegment.cpp (100%) rename {src => cppjieba}/HMMSegment.h (100%) rename {src => cppjieba}/KeyWordExt.cpp (100%) rename {src => cppjieba}/KeyWordExt.h (100%) rename {src => cppjieba}/MPSegment.cpp (100%) rename {src => cppjieba}/MPSegment.h (100%) rename {src => cppjieba}/Makefile (82%) rename {src => cppjieba}/MixSegment.cpp (100%) rename {src => cppjieba}/MixSegment.h (100%) rename {src => cppjieba}/TransCode.cpp (100%) rename {src => cppjieba}/TransCode.h (100%) rename {src => cppjieba}/Trie.cpp (100%) rename {src => cppjieba}/Trie.h (100%) rename {src => cppjieba}/globals.h (100%) rename {src => cppjieba}/headers.h (100%) rename {src => cppjieba}/structs.h (100%) diff --git a/README.md b/README.md index 071e1bc..4dedf93 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,30 @@ Output: ## Help -run `./segment_demo` to get help. +本项目主要是如下目录组成: +### cppcommon + +主要是一些工具函数,例如字符串操作等。 +make 之后产生一个libcm.a +要使用该libcm.a 只需要在代码里面增加 +```cpp +#include "cppcommon/headers.h" +using namespace CPPCOMMON; +``` +在链接时候`-Lcppcommon -lcm` 链接进即可。 +__详细使用细节请参见demo/目录下的代码__ + +### cppjieba +核心目录,包含主要源代码。 +make 之后产生libcppjieb.a +使用方法参考如上cppcommon + + + +### run `./segment_demo` to get help. + +如下: ``` usage: ./segment_demo[options] diff --git a/src/HMMSegment.cpp b/cppjieba/HMMSegment.cpp similarity index 100% rename from src/HMMSegment.cpp rename to cppjieba/HMMSegment.cpp diff --git a/src/HMMSegment.h b/cppjieba/HMMSegment.h similarity index 100% rename from src/HMMSegment.h rename to cppjieba/HMMSegment.h diff --git a/src/KeyWordExt.cpp b/cppjieba/KeyWordExt.cpp similarity index 100% rename from src/KeyWordExt.cpp rename to cppjieba/KeyWordExt.cpp diff --git a/src/KeyWordExt.h b/cppjieba/KeyWordExt.h similarity index 100% rename from src/KeyWordExt.h rename to cppjieba/KeyWordExt.h diff --git a/src/MPSegment.cpp b/cppjieba/MPSegment.cpp similarity index 100% rename from src/MPSegment.cpp rename to cppjieba/MPSegment.cpp diff --git a/src/MPSegment.h b/cppjieba/MPSegment.h similarity index 100% rename from src/MPSegment.h rename to cppjieba/MPSegment.h diff --git a/src/Makefile b/cppjieba/Makefile similarity index 82% rename from src/Makefile rename to cppjieba/Makefile index a64d354..8a08498 100644 --- a/src/Makefile +++ b/cppjieba/Makefile @@ -18,8 +18,8 @@ DOPACK := $(AR) SOURCES := $(wildcard *.cpp) OBJS := $(patsubst %.cpp,%.o,$(SOURCES)) -CMDIR := ../cppcommon -CMLIB := $(CMDIR)/libcm.a +#CMDIR := ../cppcommon +#CMLIB := $(CMDIR)/libcm.a TMPDIR := ./cppjiebatmp @@ -27,7 +27,8 @@ LIBA := libcppjieba.a # remove the objs after compilation .INTERMEDIATE: -.PHONY: clean $(CMLIB) +#.PHONY: clean $(CMLIB) +.PHONY: clean all: $(LIBA) @@ -36,16 +37,19 @@ all: $(LIBA) %.o: %.cpp $(CXX) -c $(CXXFLAGS) $< -${LIBA}: $(TMPDIR) $(OBJS) $(CMLIB) - cp $(CMLIB) $(TMPDIR) && cd $(TMPDIR) && ar x `basename $(CMLIB)` - $(DOPACK) $@ $(OBJS) $(TMPDIR)/*.o - rm -rf $(TMPDIR) +#${LIBA}: $(TMPDIR) $(OBJS) $(CMLIB) +# cp $(CMLIB) $(TMPDIR) && cd $(TMPDIR) && ar x `basename $(CMLIB)` +# $(DOPACK) $@ $(OBJS) $(TMPDIR)/*.o +# rm -rf $(TMPDIR) -$(TMPDIR): - mkdir $@ +${LIBA}: $(OBJS) + $(DOPACK) $@ $(OBJS) -$(CMLIB): - cd $(CMDIR) && $(MAKE) +#$(TMPDIR): +# mkdir $@ + +#$(CMLIB): +# cd $(CMDIR) && $(MAKE) #unit test Trie.ut: Trie.cpp Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB) @@ -66,8 +70,8 @@ MixSegment.ut: MixSegment.cpp MixSegment.h HMMSegment.cpp MPSegment.cpp Trie.cpp clean: rm -f *.o *.d *.ut $(LIBA) - rm -rf $(TMPDIR) - cd $(CMDIR) && make clean +# rm -rf $(TMPDIR) +# cd $(CMDIR) && make clean sinclude $(SOURCES:.cpp=.d) %.d:%.cpp diff --git a/src/MixSegment.cpp b/cppjieba/MixSegment.cpp similarity index 100% rename from src/MixSegment.cpp rename to cppjieba/MixSegment.cpp diff --git a/src/MixSegment.h b/cppjieba/MixSegment.h similarity index 100% rename from src/MixSegment.h rename to cppjieba/MixSegment.h diff --git a/src/TransCode.cpp b/cppjieba/TransCode.cpp similarity index 100% rename from src/TransCode.cpp rename to cppjieba/TransCode.cpp diff --git a/src/TransCode.h b/cppjieba/TransCode.h similarity index 100% rename from src/TransCode.h rename to cppjieba/TransCode.h diff --git a/src/Trie.cpp b/cppjieba/Trie.cpp similarity index 100% rename from src/Trie.cpp rename to cppjieba/Trie.cpp diff --git a/src/Trie.h b/cppjieba/Trie.h similarity index 100% rename from src/Trie.h rename to cppjieba/Trie.h diff --git a/src/globals.h b/cppjieba/globals.h similarity index 100% rename from src/globals.h rename to cppjieba/globals.h diff --git a/src/headers.h b/cppjieba/headers.h similarity index 100% rename from src/headers.h rename to cppjieba/headers.h diff --git a/src/structs.h b/cppjieba/structs.h similarity index 100% rename from src/structs.h rename to cppjieba/structs.h diff --git a/demo/Makefile b/demo/Makefile index febcf92..968cca8 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -20,11 +20,14 @@ DOPACK := $(AR) SOURCES := $(wildcard *.cpp) OBJS := $(patsubst %.cpp,%.o,$(SOURCES)) -SRCDIR = ../src -SRCLIB = $(SRCDIR)/libcppjieba.a +CPPJIEBADIR = ../cppjieba +LIBCPPJIEBA = $(CPPJIEBADIR)/libcppjieba.a + +CPPCOMMONDIR = ../cppcommon +LIBCPPCM = $(CPPCOMMONDIR)/libcm.a # remove the objs after compilation -.PHONY: clean $(SRCLIB) +.PHONY: clean $(LIBCPPJIEBA) $(LIBCPPCM) # Main Targets all: keywordext_demo segment_demo @@ -34,18 +37,22 @@ all: keywordext_demo segment_demo %.o: %.cpp $(CXX) -c $(CXXFLAGS) $< -keywordext_demo: keywordext_demo.o $(SRCLIB) +keywordext_demo: keywordext_demo.o $(LIBCPPJIEBA) $(LIBCPPCM) $(DOLINK) -o $@ $^ -segment_demo: segment_demo.o $(SRCLIB) +segment_demo: segment_demo.o $(LIBCPPJIEBA) $(LIBCPPCM) $(DOLINK) -o $@ $^ -$(SRCLIB): - cd $(SRCDIR) && $(MAKE) +$(LIBCPPJIEBA): + cd $(CPPJIEBADIR) && $(MAKE) + +$(LIBCPPCM): + cd $(CPPCOMMONDIR) && $(MAKE) clean: rm -f *.o *.ut *.d *.d.* keywordext_demo segment_demo - cd $(SRCDIR) && make clean + cd $(CPPJIEBADIR) && make clean + cd $(CPPCOMMONDIR) && make clean sinclude $(SOURCES:.cpp=.d) %.d:%.cpp diff --git a/demo/keywordext_demo.cpp b/demo/keywordext_demo.cpp index 8834cf9..1d42500 100644 --- a/demo/keywordext_demo.cpp +++ b/demo/keywordext_demo.cpp @@ -1,6 +1,6 @@ #include #include -#include "../src/headers.h" +#include "../cppjieba/headers.h" using namespace CppJieba; diff --git a/demo/segment_demo.cpp b/demo/segment_demo.cpp index b9fd1e5..1bd660c 100644 --- a/demo/segment_demo.cpp +++ b/demo/segment_demo.cpp @@ -1,6 +1,6 @@ #include #include -#include "../src/headers.h" +#include "../cppjieba/headers.h" using namespace CppJieba;