1# See README.txt.
2
3.PHONY: all cpp java python clean
4
5all: cpp java python
6
7cpp:    add_person_cpp    list_people_cpp
8dart:   add_person_dart   list_people_dart
9go:     add_person_go     list_people_go
10gotest: add_person_gotest list_people_gotest
11java:   add_person_java   list_people_java
12python: add_person_python list_people_python
13
14clean:
15	rm -f add_person_cpp list_people_cpp add_person_java list_people_java add_person_python list_people_python
16	rm -f javac_middleman AddPerson*.class ListPeople*.class com/example/tutorial/*.class
17	rm -f protoc_middleman addressbook.pb.cc addressbook.pb.h addressbook_pb2.py com/example/tutorial/AddressBookProtos.java
18	rm -f *.pyc
19	rm -f protoc_middleman_go tutorial/*.pb.go add_person_go list_people_go
20	rm -f protoc_middleman_dart dart_tutorial/*.pb*.dart
21	rmdir dart_tutorial 2>/dev/null || true
22	rmdir tutorial 2>/dev/null || true
23	rmdir com/example/tutorial 2>/dev/null || true
24	rmdir com/example 2>/dev/null || true
25	rmdir com 2>/dev/null || true
26
27protoc_middleman: addressbook.proto
28	protoc $$PROTO_PATH --cpp_out=. --java_out=. --python_out=. addressbook.proto
29	@touch protoc_middleman
30
31protoc_middleman_go: addressbook.proto
32	mkdir -p tutorial # make directory for go package
33	protoc $$PROTO_PATH --go_out=tutorial addressbook.proto
34	@touch protoc_middleman_go
35
36protoc_middleman_dart: addressbook.proto
37	mkdir -p dart_tutorial # make directory for the dart package
38	protoc -I ../src/:. --dart_out=dart_tutorial addressbook.proto ../src/google/protobuf/timestamp.proto
39	pub get
40	@touch protoc_middleman_dart
41
42add_person_cpp: add_person.cc protoc_middleman
43	pkg-config --cflags protobuf  # fails if protobuf is not installed
44	c++ add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
45
46list_people_cpp: list_people.cc protoc_middleman
47	pkg-config --cflags protobuf  # fails if protobuf is not installed
48	c++ list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
49
50add_person_dart: add_person.dart protoc_middleman_dart
51
52list_people_dart: list_people.dart protoc_middleman_dart
53
54add_person_go: add_person.go protoc_middleman_go
55	go build -o add_person_go add_person.go
56
57add_person_gotest: add_person_test.go add_person_go
58	go test add_person.go add_person_test.go
59
60list_people_go: list_people.go protoc_middleman_go
61	go build -o list_people_go list_people.go
62
63list_people_gotest: list_people.go list_people_go
64	go test list_people.go list_people_test.go
65
66javac_middleman: AddPerson.java ListPeople.java protoc_middleman
67	javac -cp $$CLASSPATH AddPerson.java ListPeople.java com/example/tutorial/AddressBookProtos.java
68	@touch javac_middleman
69
70add_person_java: javac_middleman
71	@echo "Writing shortcut script add_person_java..."
72	@echo '#! /bin/sh' > add_person_java
73	@echo 'java -classpath .:$$CLASSPATH AddPerson "$$@"' >> add_person_java
74	@chmod +x add_person_java
75
76list_people_java: javac_middleman
77	@echo "Writing shortcut script list_people_java..."
78	@echo '#! /bin/sh' > list_people_java
79	@echo 'java -classpath .:$$CLASSPATH ListPeople "$$@"' >> list_people_java
80	@chmod +x list_people_java
81
82add_person_python: add_person.py protoc_middleman
83	@echo "Writing shortcut script add_person_python..."
84	@echo '#! /bin/sh' > add_person_python
85	@echo './add_person.py "$$@"' >> add_person_python
86	@chmod +x add_person_python
87
88list_people_python: list_people.py protoc_middleman
89	@echo "Writing shortcut script list_people_python..."
90	@echo '#! /bin/sh' > list_people_python
91	@echo './list_people.py "$$@"' >> list_people_python
92	@chmod +x list_people_python
93