| 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 |
|
| 26 |
CFLAGS += -Wall -Wextra -Wundef -g |
| 27 |
|
| 28 |
CP = cp |
| 29 |
NM = nm |
| 30 |
GREP = grep |
| 31 |
XXHSUM_DIR = .. |
| 32 |
XXHSUM = $(XXHSUM_DIR)/xxhsum |
| 33 |
|
| 34 |
# Define *.exe as extension for Windows systems |
| 35 |
ifneq (,$(filter Windows%,$(OS))) |
| 36 |
EXT =.exe |
| 37 |
else |
| 38 |
EXT = |
| 39 |
endif |
| 40 |
|
| 41 |
ifneq (,$(filter %UTF-8,$(LANG))) |
| 42 |
ENABLE_UNICODE ?= 1 |
| 43 |
else |
| 44 |
ENABLE_UNICODE ?= 0 |
| 45 |
endif |
| 46 |
|
| 47 |
.PHONY: default |
| 48 |
default: all |
| 49 |
|
| 50 |
.PHONY: all |
| 51 |
all: test |
| 52 |
|
| 53 |
.PHONY: test |
| 54 |
test: test_multiInclude test_unicode test_sanity |
| 55 |
|
| 56 |
.PHONY: test_multiInclude |
| 57 |
test_multiInclude: |
| 58 |
@$(MAKE) clean |
| 59 |
# compile without xxhash.o, ensure symbols exist within target |
| 60 |
# Note: built using only default rules |
| 61 |
$(MAKE) multiInclude |
| 62 |
@$(MAKE) clean |
| 63 |
# compile with xxhash.o, to detect duplicated symbols |
| 64 |
$(MAKE) multiInclude_withxxhash |
| 65 |
@$(MAKE) clean |
| 66 |
# compile with XXH_NAMESPACE before XXH_INLINE_ALL |
| 67 |
CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude |
| 68 |
# no symbol prefixed TESTN_ should exist |
| 69 |
! $(NM) multiInclude | $(GREP) TESTN_ |
| 70 |
$(MAKE) clean |
| 71 |
# compile xxhash.o with XXH_NAMESPACE |
| 72 |
CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude_withxxhash |
| 73 |
# symbols prefixed TESTN_ should exist in xxhash.o (though not be invoked) |
| 74 |
$(NM) multiInclude_withxxhash | $(GREP) TESTN_ |
| 75 |
$(MAKE) clean |
| 76 |
|
| 77 |
.PHONY: test_ppc_redefine |
| 78 |
test_ppc_redefine: ppc_define.c |
| 79 |
@$(MAKE) clean |
| 80 |
$(CC) $(CPPFLAGS) $(CFLAGS) -c $^ |
| 81 |
|
| 82 |
.PHONY: $(XXHSUM) |
| 83 |
$(XXHSUM): |
| 84 |
$(MAKE) -C $(XXHSUM_DIR) xxhsum |
| 85 |
$(CP) $(XXHSUM) . |
| 86 |
|
| 87 |
# Make sure that Unicode filenames work. |
| 88 |
# https://github.com/Cyan4973/xxHash/issues/293 |
| 89 |
.PHONY: test_unicode |
| 90 |
ifeq (0,$(ENABLE_UNICODE)) |
| 91 |
test_unicode: |
| 92 |
@echo "Skipping Unicode test, your terminal doesn't appear to support UTF-8." |
| 93 |
@echo "Try with ENABLE_UNICODE=1" |
| 94 |
else |
| 95 |
test_unicode: $(XXHSUM) generate_unicode_test.c |
| 96 |
# Generate a Unicode filename test dynamically |
| 97 |
# to keep UTF-8 out of the source tree. |
| 98 |
$(CC) $(CFLAGS) $(LDFLAGS) generate_unicode_test.c -o generate_unicode_test$(EXT) |
| 99 |
./generate_unicode_test$(EXT) |
| 100 |
$(SHELL) ./unicode_test.sh |
| 101 |
endif |
| 102 |
|
| 103 |
.PHONY: test_filename_escape |
| 104 |
test_filename_escape: $(XXHSUM) |
| 105 |
./filename-escape.sh |
| 106 |
|
| 107 |
.PHONY: test_cli_comment_line |
| 108 |
test_cli_comment_line: $(XXHSUM) |
| 109 |
$(SHELL) ./cli-comment-line.sh |
| 110 |
|
| 111 |
.PHONY: test_cli_ignore_missing |
| 112 |
test_cli_ignore_missing: $(XXHSUM) |
| 113 |
$(SHELL) ./cli-ignore-missing.sh |
| 114 |
|
| 115 |
.PHONY: test_sanity |
| 116 |
test_sanity: sanity_test.c |
| 117 |
$(CC) $(CFLAGS) $(LDFLAGS) sanity_test.c -o sanity_test$(EXT) |
| 118 |
$(RUN_ENV) ./sanity_test$(EXT) |
| 119 |
|
| 120 |
.PHONY: sanity_test_vectors.h |
| 121 |
sanity_test_vectors.h: sanity_test_vectors_generator.c |
| 122 |
$(CC) $(CFLAGS) $(LDFLAGS) sanity_test_vectors_generator.c -o sanity_test_vectors_generator$(EXT) |
| 123 |
./sanity_test_vectors_generator$(EXT) |
| 124 |
|
| 125 |
xxhash.o: ../xxhash.c ../xxhash.h |
| 126 |
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -c -o $@ $< |
| 127 |
|
| 128 |
multiInclude_withxxhash: multiInclude.o xxhash.o |
| 129 |
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^ |
| 130 |
|
| 131 |
clean: |
| 132 |
@$(RM) *.o |
| 133 |
@$(RM) multiInclude multiInclude_withxxhash |
| 134 |
@$(RM) *.unicode generate_unicode_test$(EXT) unicode_test.* xxhsum* |
| 135 |
@$(RM) sanity_test$(EXT) sanity_test_vectors_generator$(EXT) |