mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
modify makefile for packing lib*.a
This commit is contained in:
parent
8f64356c87
commit
e5f4d05777
13
Makefile
13
Makefile
@ -9,10 +9,10 @@ SOURCES := $(wildcard *.cpp)
|
||||
OBJS := $(patsubst %.cpp,%.o,$(SOURCES))
|
||||
|
||||
SRCDIR = ./src
|
||||
SRCLIB = $(SRCDIR)/cppjiebalib.a
|
||||
SRCLIB = $(SRCDIR)/libcppjieba.a
|
||||
|
||||
# remove the objs after compilation
|
||||
.INTERMEDIATE: $(OBJS)
|
||||
.INTERMEDIATE: $(OBJS) *.o
|
||||
.PHONY: clean $(SRCLIB)
|
||||
|
||||
# Main Targets
|
||||
@ -24,10 +24,17 @@ all: demo
|
||||
$(CC) $(CCOPT) $<
|
||||
|
||||
demo: $(OBJS) $(SRCLIB)
|
||||
$(DOLINK)
|
||||
$(DOLINK)
|
||||
|
||||
$(SRCLIB): $(SRCLIB_DEPS)
|
||||
cd $(SRCDIR) && $(MAKE)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.ut demo
|
||||
|
||||
sinclude $(SOURCES:.cpp=.d)
|
||||
%.d:%.cpp
|
||||
@set -e; rm -f $@; \
|
||||
$(CC) -MM $< > $@.$$$$; \
|
||||
sed 's,\($*\).o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
||||
rm -f $@.$$$$
|
||||
|
33
demo.cpp
33
demo.cpp
@ -1,9 +1,40 @@
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <fstream>
|
||||
#include "src/Segment.h"
|
||||
using namespace std;
|
||||
|
||||
using namespace CppJieba;
|
||||
|
||||
int main()
|
||||
{
|
||||
Segment segment;
|
||||
/*
|
||||
if(!segment.init("./dicts/segdict.utf8.v2.1"))
|
||||
{
|
||||
cerr<<"1"<<endl;
|
||||
return 1;
|
||||
}
|
||||
//segment.init("dicts/jieba.dict.utf8");
|
||||
|
||||
vector<string> res;
|
||||
string title;
|
||||
title = "我来到北京清华大学";
|
||||
res.clear();
|
||||
segment.extract(title, res);
|
||||
|
||||
title = "特价!camel骆驼 柔软舒适头层牛皮平底凉鞋女 休闲平跟妈妈鞋夏";
|
||||
res.clear();
|
||||
segment.extract(title, res);
|
||||
|
||||
title = "包邮拉菲草18cm大檐进口草帽子超强遮阳防晒欧美日韩新款夏天 女";
|
||||
res.clear();
|
||||
segment.extract(title, res);
|
||||
|
||||
title = "2013新款19CM超大檐帽 遮阳草帽子 沙滩帽防晒大檐欧美新款夏天女";
|
||||
res.clear();
|
||||
segment.extract(title, res);
|
||||
|
||||
segment.destroy();
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
23
src/Makefile
23
src/Makefile
@ -5,30 +5,33 @@ LINKOPT =
|
||||
PACKA = ar
|
||||
PACKAOPT = rc
|
||||
DOLINK = $(LINK) $(LINKOPT) -o $@ $^
|
||||
DOPACK = $(PACKA) $(PACKAOPT) $@ $?
|
||||
DOPACK = $(PACKA) $(PACKAOPT) $@
|
||||
SOURCES := $(wildcard *.cpp)
|
||||
OBJS := $(patsubst %.cpp,%.o,$(SOURCES))
|
||||
|
||||
CMDIR = ./cppcommon
|
||||
CMLIB = $(CMDIR)/cmlib.a
|
||||
CMLIB = $(CMDIR)/libcm.a
|
||||
|
||||
LIBA = cppjiebalib.a
|
||||
TMPDIR = ./cppjiebatmp
|
||||
|
||||
LIBA = libcppjieba.a
|
||||
|
||||
# remove the objs after compilation
|
||||
.INTERMEDIATE:
|
||||
.PHONY: clean $(CMLIB)
|
||||
.PHONY: clean $(CMLIB)
|
||||
|
||||
all: $(LIBA)
|
||||
|
||||
|
||||
# This is a suffix rule
|
||||
#.c.o:
|
||||
%.o: %.cpp
|
||||
$(CC) $(CCOPT) $<
|
||||
|
||||
|
||||
$(LIBA): $(OBJS) $(CMLIB)
|
||||
$(DOPACK)
|
||||
$(LIBA): $(OBJS) $(CMLIB)
|
||||
mkdir $(TMPDIR)
|
||||
cp $(CMLIB) $(TMPDIR) && cd $(TMPDIR) && ar x `basename $(CMLIB)`
|
||||
$(DOPACK) $(OBJS) $(TMPDIR)/*.o
|
||||
rm -rf $(TMPDIR)
|
||||
|
||||
$(CMLIB):
|
||||
cd $(CMDIR) && $(MAKE)
|
||||
@ -41,10 +44,10 @@ Segment.ut: Segment.cpp Trie.cpp Segment.h Trie.h globals.h $(CMLIB)
|
||||
$(CC) -o $@ Segment.cpp Trie.cpp -DSEGMENT_UT $(CMLIB)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.d *.ut $(LIBA)
|
||||
rm -f *.o *.d *.ut $(LIBA)
|
||||
rm -rf $(TMPDIR)
|
||||
cd $(CMDIR) && make clean
|
||||
|
||||
sinclude $(SOURCES:.cpp=.d)
|
||||
%.d:%.cpp
|
||||
@set -e; rm -f $@; \
|
||||
$(CC) -MM $< > $@.$$$$; \
|
||||
|
Loading…
x
Reference in New Issue
Block a user