forked from deepfryed/beanstalk-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
63 lines (47 loc) · 1.74 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
SOURCES1 := $(wildcard test/*.cc)
SOURCES2 := $(wildcard examples/c/*.c)
SOURCES3 := $(wildcard examples/cpp/*.cc)
TESTS := $(SOURCES1:%.cc=%)
CEXAMPLES := $(SOURCES2:%.c=%)
CPPEXAMPLES := $(SOURCES3:%.cc=%)
VERSION = 1.0.0
SHAREDLIB = libbeanstalk.so
CFLAGS = -Wall -Wno-signed-compare -g -I.
LDFLAGS = -L. -lbeanstalk
CC = gcc
CPP = g++
all: $(CEXAMPLES) $(CPPEXAMPLES) benchmark
test: $(TESTS)
test/run-all
$(TESTS): test/%:test/%.o $(SHAREDLIB)
$(CPP) -o $@ $< $(LDFLAGS) -lgtest -lpthread
test/%.o: test/%.cc
$(CPP) $(CFLAGS) -c -o $@ $<
benchmark: benchmark.cc $(SHAREDLIB)
$(CPP) $(CFLAGS) -o benchmark benchmark.cc $(LDFLAGS) -lpthread
$(CEXAMPLES): examples/c/%:examples/c/%.o $(SHAREDLIB)
$(CC) -o $@ $< $(LDFLAGS)
examples/c/%.o: examples/c/%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(CPPEXAMPLES): examples/cpp/%:examples/cpp/%.o $(SHAREDLIB)
$(CPP) -o $@ $< $(LDFLAGS)
examples/cpp/%.o: examples/cpp/%.cc
$(CPP) $(CFLAGS) -c -o $@ $<
$(SHAREDLIB): beanstalk.o beanstalkcpp.o
$(CPP) -shared -o $(SHAREDLIB) beanstalk.o beanstalkcpp.o
beanstalk.o: beanstalk.c beanstalk.h makefile
$(CC) $(CFLAGS) -fPIC -c -o beanstalk.o beanstalk.c
beanstalkcpp.o: beanstalk.cc beanstalk.hpp makefile
$(CPP) $(CFLAGS) -fPIC -c -o beanstalkcpp.o beanstalk.cc
install: $(SHAREDLIB)
cp beanstalk.h /usr/include
cp beanstalk.hpp /usr/include
cp $(SHAREDLIB) /usr/lib/$(SHAREDLIB).$(VERSION)
ln -sfT /usr/lib/$(SHAREDLIB).$(VERSION) /usr/lib/$(SHAREDLIB).1
ln -sfT /usr/lib/$(SHAREDLIB).$(VERSION) /usr/lib/$(SHAREDLIB)
uninstall:
rm -f /usr/include/beanstalk.h
rm -f /usr/include/beanstalk.hpp
rm -f /usr/lib/$(SHAREDLIB)*
clean:
rm -f *.o *.so *.so.* test/test[0-9] test/*.o examples/**/*.o examples/**/example?