VOL-1903: Cleanup Makefile to use consistent versions of protoc/grpc-gateway

Change-Id: I10a9918cab7e5b34901f3529fb629f4fa0f0f185
(cherry picked from commit d52eaeea409ac4d88b9b9366c811e3f38ff42667)
diff --git a/Makefile b/Makefile
index 3357de7..37ae4a0 100644
--- a/Makefile
+++ b/Makefile
@@ -28,29 +28,31 @@
 DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
 DOCKER_LABEL_BUILD_DATE  ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
 
+GRPC_GW_PATH             ?= $(shell GO111MODULE=on go list -f '{{ .Dir }}' -m github.com/grpc-ecosystem/grpc-gateway)
+
 bbsim: dep bbsimapi
 	GO111MODULE=on go build -i -v -o $@
 
 dep:
-	GO111MODULE=off go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
-	GO111MODULE=off go get -v github.com/golang/protobuf/protoc-gen-go
-	GO111MODULE=off go get -v github.com/google/gopacket
+	GO111MODULE=on go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.9.5
 	GO111MODULE=on go mod download all
 
-bbsimapi: api/bbsim.proto
+
+bbsimapi: dep api/bbsim.pb.go api/bbsim.pb.gw.go
+	@echo using ${GRPC_GW_PATH}
+
+api/bbsim.pb.go api/bbsim.pb.gw.go: api/bbsim.proto
 	@protoc -I ./api \
-	-I${GOPATH}/src \
-	-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-	-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \
+	-I${GRPC_GW_PATH}/third_party/googleapis/ \
+	-I${GRPC_GW_PATH}/ \
 	--go_out=plugins=grpc:api/ \
 	--grpc-gateway_out=logtostderr=true,allow_delete_body=true:api/ \
 	api/bbsim.proto
 
 swagger:						 ## Generate swagger documentation for BBsim API
 	@protoc -I ./api \
-	-I${GOPATH}/src \
-	-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-	-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \
+	-I${GRPC_GW_PATH}/third_party/googleapis/ \
+	-I${GRPC_GW_PATH}/ \
 	--swagger_out=logtostderr=true,allow_delete_body=true:api/swagger/ \
 	bbsim.proto
 
@@ -69,8 +71,7 @@
 
 clean:
 	@rm -vf bbsim \
-			protos/openolt.pb.go \
-			api/bbsim.pb.go \
+		api/bbsim.pb.go \
 	        api/bbsim.pb.gw.go \
 	        api/swagger/*.json