Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #
  2. # Copyright 2022 Dgraph Labs, Inc. and Contributors
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. USER_ID = $(shell id -u)
  17. HAS_JEMALLOC = $(shell test -f /usr/local/lib/libjemalloc.a && echo "jemalloc")
  18. JEMALLOC_URL = "https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2"
  19. .PHONY: all badger test jemalloc dependency
  20. badger: jemalloc
  21. @echo "Compiling Badger binary..."
  22. @$(MAKE) -C badger badger
  23. @echo "Badger binary located in badger directory."
  24. test: jemalloc
  25. @echo "Running Badger tests..."
  26. @./test.sh
  27. jemalloc:
  28. @if [ -z "$(HAS_JEMALLOC)" ] ; then \
  29. mkdir -p /tmp/jemalloc-temp && cd /tmp/jemalloc-temp ; \
  30. echo "Downloading jemalloc..." ; \
  31. curl -s -L ${JEMALLOC_URL} -o jemalloc.tar.bz2 ; \
  32. tar xjf ./jemalloc.tar.bz2 ; \
  33. cd jemalloc-5.2.1 ; \
  34. ./configure --with-jemalloc-prefix='je_' --with-malloc-conf='background_thread:true,metadata_thp:auto'; \
  35. make ; \
  36. if [ "$(USER_ID)" -eq "0" ]; then \
  37. make install ; \
  38. else \
  39. echo "==== Need sudo access to install jemalloc" ; \
  40. sudo make install ; \
  41. fi \
  42. fi
  43. dependency:
  44. @echo "Installing dependencies..."
  45. @sudo apt-get update
  46. @sudo apt-get -y install \
  47. ca-certificates \
  48. curl \
  49. gnupg \
  50. lsb-release \
  51. build-essential \
  52. protobuf-compiler \