modify makefile for packing lib*.a

This commit is contained in:
gwdwyy 2013-07-11 17:45:00 +08:00
parent 8f64356c87
commit e5f4d05777
3 changed files with 55 additions and 14 deletions

View File

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

View File

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

View File

@ -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 $< > $@.$$$$; \