Skip to content

Commit 77a7892

Browse files
committed
recursive makefiles, fuck yes
1 parent cd69a55 commit 77a7892

File tree

9 files changed

+120
-53
lines changed

9 files changed

+120
-53
lines changed

CPP/Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
BINS := client_sync server_sync server_async
2+
BINDIR := bin
3+
# consider also -lboost_thread-mt -lpthread
4+
CPP_LIBS = -lboost_system-mt -lprotobuf
5+
CPP_FLAGS = -Wall -O2 --std=c++11 -L/usr/local/lib
6+
7+
8+
OUTBINS := $(addprefix $(BINDIR)/,$(BINS))
9+
10+
11+
12+
.PHONY: all
13+
all: $(BINS)
14+
15+
.PHONY: $(BINS)
16+
$(BINS): %: $(BINDIR)/%
17+
18+
$(OUTBINS): $(BINDIR)/%: src/%.cc gen/msg.pb.cc src/asio_server.h | $(BINDIR)
19+
clang++ $(CPP_FLAGS) src/$*.cc gen/msg.pb.cc -o bin/$* $(CPP_LIBS)
20+
21+
$(BINDIR):
22+
mkdir -p $(BINDIR)
23+
24+
gen/msg.pb.cc: ../msg.proto
25+
mkdir -p gen
26+
protoc --cpp_out=gen -I .. ../msg.proto
27+
28+
29+
30+
.PHONY: clean
31+
clean:
32+
rm -f bin/* gen/*
33+
34+
.PHONY: really_clean
35+
really_clean:
36+
rm -rf gen $(BINDIR)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Go/Makefile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
BINS = client server
2+
BINDIR := bin
3+
4+
OUTBINS := $(addprefix $(BINDIR)/,$(BINS))
5+
6+
7+
8+
.PHONY: all
9+
all: $(BINS)
10+
11+
.PHONY: $(BINS)
12+
$(BINS): %: $(BINDIR)/%
13+
14+
$(OUTBINS): $(BINDIR)/%: src/%/main.go src/example_mess/msg.pb.go src/code.google.com/p/goprotobuf
15+
GOPATH=$(CURDIR) go install $*
16+
17+
src/example_mess/msg.pb.go: ../msg.proto
18+
mkdir -p src/example_mess
19+
protoc --go_out=src/example_mess -I .. ../msg.proto
20+
21+
src/code.google.com/p/goprotobuf:
22+
GOPATH=$(CURDIR) go get code.google.com/p/goprotobuf/proto
23+
24+
25+
26+
27+
.PHONY: clean
28+
clean:
29+
rm -f pkg/*/example_mess.a bin/*
30+
31+
.PHONY: really_clean
32+
really_clean: clean
33+
rm -f src/example_mess/msg.pb.go # in here because protoc go compiler not always installed
34+
rm -rf pkg bin src/code.google.com src/example_mess

Makefile

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
TARGETS := CPP Python Go
3+
4+
all: $(TARGETS) links
5+
6+
.PHONY: $(TARGETS)
7+
$(TARGETS):
8+
cd $@ && $(MAKE)
9+
10+
11+
12+
13+
.PHONY: links
14+
links:
15+
mkdir -p bin
16+
$(foreach target,CPP Go, \
17+
$(foreach bin,$(wildcard $(target)/bin/*), cp $(bin) bin/$(target)_$(notdir $(bin));) \
18+
)
19+
if [ -a Python/gen/msg_pb2.py ] ; then \
20+
echo "#!/bin/sh\n\npython $(CURDIR)/Python/client.py" > bin/Python_client.sh; \
21+
chmod +x bin/Python_client.sh; \
22+
echo "#!/bin/sh\n\npython $(CURDIR)/Python/server.py" > bin/Python_server.sh; \
23+
chmod +x bin/Python_server.sh; \
24+
fi;
25+
26+
.PHONY: clean
27+
clean:
28+
$(foreach target,$(TARGETS),$(MAKE) -C $(target) clean;)
29+
rm -f bin/*
30+
31+
32+
.PHONY: really_clean
33+
really_clean: clean
34+
$(foreach target,$(TARGETS),$(MAKE) -C $(target) really_clean;)
35+
rm -rf bin

Python/Makefile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.PHONY: all
2+
all: gen/msg_pb2.py
3+
4+
gen/msg_pb2.py: ../msg.proto
5+
mkdir -p gen
6+
touch gen/__init__.py # I hate this.
7+
protoc --python_out=gen -I .. ../msg.proto
8+
9+
.PHONY: clean
10+
clean:
11+
rm -f gen/*
12+
13+
.PHONY: really_clean
14+
really_clean:
15+
rm -rf gen

makefile

-53
This file was deleted.

0 commit comments

Comments
 (0)