• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1CFLAGS += -Wall -Wextra -Wundef -g
2
3NM = nm
4GREP = grep
5
6# Define *.exe as extension for Windows systems
7ifneq (,$(filter Windows%,$(OS)))
8EXT =.exe
9else
10EXT =
11endif
12
13ifneq (,$(filter %UTF-8,$(LANG)))
14ENABLE_UNICODE ?= 1
15else
16ENABLE_UNICODE ?= 0
17endif
18
19.PHONY: default
20default: all
21
22.PHONY: all
23all: test
24
25.PHONY: test
26test: test_multiInclude test_unicode
27
28.PHONY: test_multiInclude
29test_multiInclude:
30	@$(MAKE) clean
31	# compile without xxhash.o, ensure symbols exist within target
32	# Note: built using only default rules
33	$(MAKE) multiInclude
34	@$(MAKE) clean
35	# compile with xxhash.o, to detect duplicated symbols
36	$(MAKE) multiInclude_withxxhash
37	@$(MAKE) clean
38	# Note: XXH_INLINE_ALL with XXH_NAMESPACE is currently disabled
39	# compile with XXH_NAMESPACE
40	# CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude_withxxhash
41	# no symbol prefixed TESTN_ should exist
42	# ! $(NM) multiInclude_withxxhash | $(GREP) TESTN_
43	#$(MAKE) clean
44	# compile with XXH_NAMESPACE and without xxhash.o
45	# CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude
46	# no symbol prefixed TESTN_ should exist
47	# ! $(NM) multiInclude | $(GREP) TESTN_
48	#@$(MAKE) clean
49
50.PHONY: test_ppc_redefine
51test_ppc_redefine: ppc_define.c
52	@$(MAKE) clean
53	$(CC) $(CPPFLAGS) $(CFLAGS) -c $^
54
55xxhsum$(EXT): ../xxhash.c ../xxhash.h ../xxhsum.c
56	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DXXH_INLINE_ALL ../xxhsum.c -o $@
57
58# Make sure that Unicode filenames work.
59# https://github.com/Cyan4973/xxHash/issues/293
60.PHONY: test_unicode
61ifeq (0,$(ENABLE_UNICODE))
62test_unicode:
63	@echo "Skipping Unicode test, your terminal doesn't appear to support UTF-8."
64	@echo "Try with ENABLE_UNICODE=1"
65else
66test_unicode: xxhsum$(EXT) generate_unicode_test.c
67	# Generate a Unicode filename test dynamically
68	# to keep UTF-8 out of the source tree.
69	$(CC) $(CFLAGS) $(LDFLAGS) generate_unicode_test.c -o generate_unicode_test$(EXT)
70	./generate_unicode_test$(EXT)
71	$(SHELL) ./unicode_test.sh
72endif
73
74xxhash.o: ../xxhash.c ../xxhash.h
75	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -c -o $@ $<
76
77multiInclude_withxxhash: multiInclude.o xxhash.o
78	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^
79
80clean:
81	@$(RM) *.o
82	@$(RM) multiInclude multiInclude_withxxhash
83	@$(RM) *.unicode generate_unicode_test$(EXT) unicode_test.* xxhsum$(EXT)
84