rename src -> cppjieba && mv cppcommon out of compile in makefile and link it in using in demo

This commit is contained in:
wyy 2013-09-14 12:46:43 +08:00
parent 4ab7002a6f
commit 06d8b6f757
20 changed files with 57 additions and 24 deletions

View File

@ -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] <filename>

View File

@ -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

View File

@ -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

View File

@ -1,6 +1,6 @@
#include <iostream>
#include <fstream>
#include "../src/headers.h"
#include "../cppjieba/headers.h"
using namespace CppJieba;

View File

@ -1,6 +1,6 @@
#include <iostream>
#include <fstream>
#include "../src/headers.h"
#include "../cppjieba/headers.h"
using namespace CppJieba;