Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # ################################################################
  2. # xxHash Makefile
  3. # Copyright (C) 2012-2021 Yann Collet
  4. #
  5. # GPL v2 License
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License along
  18. # with this program; if not, write to the Free Software Foundation, Inc.,
  19. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. #
  21. # You can contact the author at:
  22. # - xxHash homepage: https://www.xxhash.com
  23. # - xxHash source repository: https://github.com/Cyan4973/xxHash
  24. # ################################################################
  25. CFLAGS += -Wall -Wextra -Wundef -g
  26. CP = cp
  27. NM = nm
  28. GREP = grep
  29. XXHSUM_DIR = ..
  30. XXHSUM = $(XXHSUM_DIR)/xxhsum
  31. # Define *.exe as extension for Windows systems
  32. ifneq (,$(filter Windows%,$(OS)))
  33. EXT =.exe
  34. else
  35. EXT =
  36. endif
  37. ifneq (,$(filter %UTF-8,$(LANG)))
  38. ENABLE_UNICODE ?= 1
  39. else
  40. ENABLE_UNICODE ?= 0
  41. endif
  42. .PHONY: default
  43. default: all
  44. .PHONY: all
  45. all: test
  46. .PHONY: test
  47. test: test_multiInclude test_unicode test_sanity
  48. .PHONY: test_multiInclude
  49. test_multiInclude:
  50. @$(MAKE) clean
  51. # compile without xxhash.o, ensure symbols exist within target
  52. # Note: built using only default rules
  53. $(MAKE) multiInclude
  54. @$(MAKE) clean
  55. # compile with xxhash.o, to detect duplicated symbols
  56. $(MAKE) multiInclude_withxxhash
  57. @$(MAKE) clean
  58. # compile with XXH_NAMESPACE before XXH_INLINE_ALL
  59. CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude
  60. # no symbol prefixed TESTN_ should exist
  61. ! $(NM) multiInclude | $(GREP) TESTN_
  62. $(MAKE) clean
  63. # compile xxhash.o with XXH_NAMESPACE
  64. CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude_withxxhash
  65. # symbols prefixed TESTN_ should exist in xxhash.o (though not be invoked)
  66. $(NM) multiInclude_withxxhash | $(GREP) TESTN_
  67. $(MAKE) clean
  68. .PHONY: test_ppc_redefine
  69. test_ppc_redefine: ppc_define.c
  70. @$(MAKE) clean
  71. $(CC) $(CPPFLAGS) $(CFLAGS) -c $^
  72. .PHONY: $(XXHSUM)
  73. $(XXHSUM):
  74. $(MAKE) -C $(XXHSUM_DIR) xxhsum
  75. $(CP) $(XXHSUM) .
  76. # Make sure that Unicode filenames work.
  77. # https://github.com/Cyan4973/xxHash/issues/293
  78. .PHONY: test_unicode
  79. ifeq (0,$(ENABLE_UNICODE))
  80. test_unicode:
  81. @echo "Skipping Unicode test, your terminal doesn't appear to support UTF-8."
  82. @echo "Try with ENABLE_UNICODE=1"
  83. else
  84. test_unicode: $(XXHSUM) generate_unicode_test.c
  85. # Generate a Unicode filename test dynamically
  86. # to keep UTF-8 out of the source tree.
  87. $(CC) $(CFLAGS) $(LDFLAGS) generate_unicode_test.c -o generate_unicode_test$(EXT)
  88. ./generate_unicode_test$(EXT)
  89. $(SHELL) ./unicode_test.sh
  90. endif
  91. .PHONY: test_filename_escape
  92. test_filename_escape: $(XXHSUM)
  93. ./filename-escape.sh
  94. .PHONY: test_cli_comment_line
  95. test_cli_comment_line: $(XXHSUM)
  96. $(SHELL) ./cli-comment-line.sh
  97. .PHONY: test_cli_ignore_missing
  98. test_cli_ignore_missing: $(XXHSUM)
  99. $(SHELL) ./cli-ignore-missing.sh
  100. .PHONY: test_sanity
  101. test_sanity: sanity_test.c
  102. $(CC) $(CFLAGS) $(LDFLAGS) sanity_test.c -o sanity_test$(EXT)
  103. $(RUN_ENV) ./sanity_test$(EXT)
  104. .PHONY: sanity_test_vectors.h
  105. sanity_test_vectors.h: sanity_test_vectors_generator.c
  106. $(CC) $(CFLAGS) $(LDFLAGS) sanity_test_vectors_generator.c -o sanity_test_vectors_generator$(EXT)
  107. ./sanity_test_vectors_generator$(EXT)
  108. xxhash.o: ../xxhash.c ../xxhash.h
  109. $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -c -o $@ $<
  110. multiInclude_withxxhash: multiInclude.o xxhash.o
  111. $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^
  112. clean:
  113. @$(RM) *.o
  114. @$(RM) multiInclude multiInclude_withxxhash
  115. @$(RM) *.unicode generate_unicode_test$(EXT) unicode_test.* xxhsum*
  116. @$(RM) sanity_test$(EXT) sanity_test_vectors_generator$(EXT)