diff --git a/.gitignore b/.gitignore index 94c2ec8..255c7e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ tags +*.demo *swp *.out *.o diff --git a/demo/Makefile b/demo/Makefile index 9c96624..4615465 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -18,32 +18,23 @@ endif DOLINK := $(LD) $(LDFLAGS) SOURCES := $(wildcard *.cpp) OBJS := $(patsubst %.cpp,%.o,$(SOURCES)) +DEMOS := $(patsubst %.cpp,%.demo,$(SOURCES)) -CPPJIEBADIR = ../cppjieba -LIBCPPJIEBA = $(CPPJIEBADIR)/libcppjieba.a +CPPJIEBADIR := ../cppjieba +LIBCPPJIEBA := $(CPPJIEBADIR)/libcppjieba.a -# remove the objs after compilation .PHONY: clean $(LIBCPPJIEBA) -# Main Targets -all: keywordext_demo segment_demo +all: $(DEMOS) -# This is a suffix rule -#.c.o: -%.o: %.cpp - $(CXX) -c $(CXXFLAGS) $< - -keywordext_demo: keywordext_demo.o $(LIBCPPJIEBA) - $(DOLINK) -o $@ $^ - -segment_demo: segment_demo.o $(LIBCPPJIEBA) - $(DOLINK) -o $@ $^ +%.demo: %.cpp $(LIBCPPJIEBA) + $(CXX) -o $@ $(CXXFLAGS) $^ $(INCS) $(LIBCPPJIEBA): cd $(CPPJIEBADIR) && $(MAKE) clean: - rm -f *.o *.ut *.d *.d.* keywordext_demo segment_demo + rm -f *.o *.ut *.d *.d.* $(DEMOS) cd $(CPPJIEBADIR) && make clean sinclude $(SOURCES:.cpp=.d) diff --git a/demo/example.sh b/demo/example.sh index 2fae9dd..466d702 100755 --- a/demo/example.sh +++ b/demo/example.sh @@ -1,3 +1,3 @@ -./segment_demo testlines.utf8 --dictpath ../dicts/jieba.dict.utf8 -./segment_demo testlines.utf8 --modelpath ../dicts/hmm_model.utf8 --algorithm cutHMM -./segment_demo testlines.utf8 --algorithm cutMix +./segment.demo testlines.utf8 --dictpath ../dicts/jieba.dict.utf8 +./segment.demo testlines.utf8 --modelpath ../dicts/hmm_model.utf8 --algorithm cutHMM +./segment.demo testlines.utf8 --algorithm cutMix diff --git a/demo/keywordext_demo.cpp b/demo/keywordext.cpp similarity index 97% rename from demo/keywordext_demo.cpp rename to demo/keywordext.cpp index cc4db47..2fd3bb3 100644 --- a/demo/keywordext_demo.cpp +++ b/demo/keywordext.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "../cppjieba/headers.h" using namespace CppJieba; diff --git a/demo/segment_demo.cpp b/demo/segment.cpp similarity index 99% rename from demo/segment_demo.cpp rename to demo/segment.cpp index da1d864..6c3b326 100644 --- a/demo/segment_demo.cpp +++ b/demo/segment.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "../cppjieba/headers.h" using namespace CppJieba;