Makefile 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. .PHONY: help default clean bench pcap test all
  2. default: bench test
  3. clean:
  4. rm -rf ./objs
  5. all: bench test pcap test
  6. #########################################################################################################
  7. # SRS benchmark tool for SRS, janus, GB28181.
  8. ./objs/.format.bench.txt: *.go janus/*.go ./objs/.format.srs.txt ./objs/.format.gb28181.txt
  9. gofmt -w *.go janus
  10. mkdir -p objs && echo "done" > ./objs/.format.bench.txt
  11. bench: ./objs/srs_bench
  12. UNAME_S := $(shell uname -s)
  13. ifeq ($(UNAME_S),Darwin)
  14. SRT_PREFIX := $(shell brew --prefix srt)
  15. CGO_CFLAGS := -I$(SRT_PREFIX)/include
  16. CGO_LDFLAGS := -L$(SRT_PREFIX)/lib -lsrt
  17. else ifeq ($(UNAME_S),Linux)
  18. CGO_CFLAGS := -I/usr/local/include
  19. CGO_LDFLAGS := -L/usr/local/lib -lsrt -L/usr/local/ssl/lib -lcrypto -lstdc++ -lm -ldl
  20. endif
  21. ./objs/srs_bench: ./objs/.format.bench.txt *.go janus/*.go srs/*.go vnet/*.go gb28181/*.go live/*.go Makefile
  22. CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -mod=vendor -o objs/srs_bench .
  23. #########################################################################################################
  24. # For all regression tests.
  25. test: ./objs/srs_test ./objs/srs_gb28181_test ./objs/srs_blackbox_test
  26. #########################################################################################################
  27. # For SRS regression test.
  28. ./objs/.format.srs.txt: srs/*.go vnet/*.go
  29. gofmt -w srs vnet
  30. mkdir -p objs && echo "done" > ./objs/.format.srs.txt
  31. ./objs/srs_test: ./objs/.format.srs.txt *.go srs/*.go vnet/*.go Makefile
  32. go test ./srs -mod=vendor -c -o ./objs/srs_test
  33. #########################################################################################################
  34. # For pcap simulator test.
  35. ./objs/.format.pcap.txt: pcap/*.go
  36. gofmt -w pcap
  37. mkdir -p objs && echo "done" > ./objs/.format.pcap.txt
  38. pcap: ./objs/pcap_simulator
  39. ./objs/pcap_simulator: ./objs/.format.pcap.txt pcap/*.go Makefile
  40. go build -mod=vendor -o ./objs/pcap_simulator ./pcap
  41. #########################################################################################################
  42. # For gb28181 test.
  43. ./objs/.format.gb28181.txt: gb28181/*.go
  44. gofmt -w gb28181
  45. mkdir -p objs && echo "done" > ./objs/.format.gb28181.txt
  46. ./objs/srs_gb28181_test: ./objs/.format.gb28181.txt *.go gb28181/*.go Makefile
  47. go test ./gb28181 -mod=vendor -c -o ./objs/srs_gb28181_test
  48. #########################################################################################################
  49. # For blackbox test.
  50. ./objs/.format.blackbox.txt: blackbox/*.go
  51. gofmt -w blackbox
  52. mkdir -p objs && echo "done" > ./objs/.format.blackbox.txt
  53. ./objs/srs_blackbox_test: ./objs/.format.blackbox.txt *.go blackbox/*.go Makefile
  54. go test ./blackbox -mod=vendor -c -o ./objs/srs_blackbox_test
  55. #########################################################################################################
  56. # Help menu.
  57. help:
  58. @echo "Usage: make [default|bench|pcap|test|clean]"
  59. @echo " default The default entry for make is bench+test"
  60. @echo " bench Make the bench to ./objs/srs_bench"
  61. @echo " pcap Make the pcap simulator to ./objs/pcap_simulator"
  62. @echo " test Make the test tool to ./objs/srs_test and ./objs/srs_gb28181_test ./objs/srs_blackbox_test"
  63. @echo " clean Remove all tools at ./objs"