summaryrefslogtreecommitdiff
path: root/grpc/third_party/xxhash/tests/Makefile
blob: 092711adb86bcae33ec836d90c67a5d29aa93f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
CFLAGS += -Wall -Wextra -Wundef -g

NM = nm
GREP = grep

# Define *.exe as extension for Windows systems
ifneq (,$(filter Windows%,$(OS)))
EXT =.exe
else
EXT =
endif

ifneq (,$(filter %UTF-8,$(LANG)))
ENABLE_UNICODE ?= 1
else
ENABLE_UNICODE ?= 0
endif

.PHONY: default
default: all

.PHONY: all
all: test

.PHONY: test
test: test_multiInclude test_unicode

.PHONY: test_multiInclude
test_multiInclude:
	@$(MAKE) clean
	# compile without xxhash.o, ensure symbols exist within target
	# Note: built using only default rules
	$(MAKE) multiInclude
	@$(MAKE) clean
	# compile with xxhash.o, to detect duplicated symbols
	$(MAKE) multiInclude_withxxhash
	@$(MAKE) clean
	# Note: XXH_INLINE_ALL with XXH_NAMESPACE is currently disabled
	# compile with XXH_NAMESPACE
	# CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude_withxxhash
	# no symbol prefixed TESTN_ should exist
	# ! $(NM) multiInclude_withxxhash | $(GREP) TESTN_
	#$(MAKE) clean
	# compile with XXH_NAMESPACE and without xxhash.o
	# CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude
	# no symbol prefixed TESTN_ should exist
	# ! $(NM) multiInclude | $(GREP) TESTN_
	#@$(MAKE) clean

.PHONY: test_ppc_redefine
test_ppc_redefine: ppc_define.c
	@$(MAKE) clean
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $^

xxhsum$(EXT): ../xxhash.c ../xxhash.h ../xxhsum.c
	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DXXH_INLINE_ALL ../xxhsum.c -o $@

# Make sure that Unicode filenames work.
# https://github.com/Cyan4973/xxHash/issues/293
.PHONY: test_unicode
ifeq (0,$(ENABLE_UNICODE))
test_unicode:
	@echo "Skipping Unicode test, your terminal doesn't appear to support UTF-8."
	@echo "Try with ENABLE_UNICODE=1"
else
test_unicode: xxhsum$(EXT) generate_unicode_test.c
	# Generate a Unicode filename test dynamically
	# to keep UTF-8 out of the source tree.
	$(CC) $(CFLAGS) $(LDFLAGS) generate_unicode_test.c -o generate_unicode_test$(EXT)
	./generate_unicode_test$(EXT)
	$(SHELL) ./unicode_test.sh
endif

xxhash.o: ../xxhash.c ../xxhash.h
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -c -o $@ $<

multiInclude_withxxhash: multiInclude.o xxhash.o
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^

clean:
	@$(RM) *.o
	@$(RM) multiInclude multiInclude_withxxhash
	@$(RM) *.unicode generate_unicode_test$(EXT) unicode_test.* xxhsum$(EXT)