aboutsummaryrefslogtreecommitdiff
path: root/examples/redis-unstable/deps/xxhash/build/make
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:40:55 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:40:55 +0100
commit5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda (patch)
tree1acdfa5220cd13b7be43a2a01368e80d306473ca /examples/redis-unstable/deps/xxhash/build/make
parentc7ab12bba64d9c20ccd79b132dac475f7bc3923e (diff)
downloadcrep-5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda.tar.gz
Add Redis source code for testing
Diffstat (limited to 'examples/redis-unstable/deps/xxhash/build/make')
-rw-r--r--examples/redis-unstable/deps/xxhash/build/make/README.md71
-rw-r--r--examples/redis-unstable/deps/xxhash/build/make/multiconf.make293
2 files changed, 364 insertions, 0 deletions
diff --git a/examples/redis-unstable/deps/xxhash/build/make/README.md b/examples/redis-unstable/deps/xxhash/build/make/README.md
new file mode 100644
index 0000000..fe4a177
--- /dev/null
+++ b/examples/redis-unstable/deps/xxhash/build/make/README.md
@@ -0,0 +1,71 @@
1# multiconf.make
2
3**multiconf.make** is a self-contained Makefile include that lets you build the **same targets under many different flag sets**. For example debug vs release, ASan vs UBSan, GCC vs Clang.
4Each different set of flags generates object files into its own **dedicated cache directory**, so objects compiled with one configuration are never reused by another.
5Object files from previous configurations are preserved, so swapping back to a previous configuration only requires compiling objects which have actually changed.
6
7---
8
9## Benefits at a glance
10
11| Benefit | What `multiconf.make` does |
12| --- | --- |
13| **Isolated configs** | Stores objects into `cachedObjs/<hash>/`, one directory per unique flag set. |
14| **Fast switching** | Reusing an old config is instant—link only, no recompilation. |
15| **Header deps** | Edits to headers trigger only needed rebuilds. |
16| **One-liner targets** | Macros (`c_program`, `cxx_program`, …) hide all rule boilerplate. |
17| **Parallel-ready** | Safe with `make -j`, no duplicate compiles of shared sources. |
18| **Controlled verbosity** | Default only lists objects, while `V=1` display full commands. |
19| **`clean` included** | `make clean` deletes all objects, binaries and links. |
20
21---
22
23## Quick Start
24
25### 1 · List your sources
26
27```make
28C_SRCDIRS := src src/cdeps # all .c are in these directories
29CXX_SRCDIRS := src src/cxxdeps # all .cpp are in these directories
30```
31
32### 2 · Add and include
33
34```make
35# root/Makefile
36include multiconf.make
37```
38
39### 3 · Declare targets
40
41```make
42app:
43$(eval $(call c_program,app,app.o cdeps/obj.o))
44
45test:
46$(eval $(call cxx_program,test, test.o cxxdeps/objcxx.o))
47
48lib.a:
49$(eval $(call static_library,lib.a, lib.o cdeps/obj.o))
50
51lib.so:
52$(eval $(call c_dynamic_library,lib.so, lib.o cdeps/obj.o))
53```
54
55### 4 · Build any config you like
56
57```sh
58# Release with GCC
59make CFLAGS="-O3"
60
61# Debug with Clang + AddressSanitizer (new cache dir)
62make CC=clang CFLAGS="-g -O0 -fsanitize=address"
63
64# Switch back to GCC release (objects still valid, relink only)
65make CFLAGS="-O3"
66```
67
68Objects for each command live in different sub-folders; nothing overlaps.
69
70---
71
diff --git a/examples/redis-unstable/deps/xxhash/build/make/multiconf.make b/examples/redis-unstable/deps/xxhash/build/make/multiconf.make
new file mode 100644
index 0000000..3b7419c
--- /dev/null
+++ b/examples/redis-unstable/deps/xxhash/build/make/multiconf.make
@@ -0,0 +1,293 @@
1# ##########################################################################
2# multiconf.make
3# Copyright (C) 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# ##########################################################################
22
23
24# Provides c_program(_shared_o) and cxx_program(_shared_o) target generation macros
25# Provides static_library and c_dynamic_library target generation macros
26# Support recompilation of only impacted units when an associated *.h is updated.
27# Provides V=1 / VERBOSE=1 support. V=2 is used for debugging purposes.
28# Complement target clean: delete objects and binaries created by this script
29
30# Requires:
31# - C_SRCDIRS, CXX_SRCDIRS, ASM_SRCDIRS defined
32# OR
33# C_SRCS, CXX_SRCS and ASM_SRCS variables defined
34# *and* vpath set to find all source files
35# OR
36# C_OBJS, CXX_OBJS and ASM_OBJS variables defined
37# *and* vpath set to find all source files
38# - directory `cachedObjs/` available to cache object files.
39# alternatively: set CACHE_ROOT to some different value.
40# Optional:
41# - HASH can be set to a different custom hash program.
42
43# *_program*: generates a recipe for a target that will be built in a cache directory.
44# The cache directory is automatically derived from CACHE_ROOT and list of flags and compilers.
45# *_shared_o* variants are optional optimization variants, that share the same objects across multiple targets.
46# However, as a consequence, all these objects must have exactly the same list of flags,
47# which in practice means that there must be no target-level modification (like: target: CFLAGS += someFlag).
48# If unsure, only use the standard variants, c_program and cxx_program.
49
50# All *_program* macro functions take up to 4 argument:
51# - The name of the target
52# - The list of object files to build in the cache directory
53# - An optional list of dependencies for linking, that will not be built
54# - An optional complementary recipe code, that will run after compilation and link
55
56
57# Silent mode is default; use V = 1 or VERBOSE = 1 to see compilation lines
58VERBOSE ?= $(V)
59$(VERBOSE).SILENT:
60
61# Directory where object files will be built
62CACHE_ROOT ?= cachedObjs
63
64# --------------------------------------------------------------------------------------------
65
66# Dependency management
67DEPFLAGS = -MT $@ -MMD -MP -MF
68
69# Include dependency files
70include $(wildcard $(CACHE_ROOT)/**/*.d)
71include $(wildcard $(CACHE_ROOT)/generic/*/*.d)
72
73# --------------------------------------------------------------------------------------------
74
75# Automatic determination of build artifacts cache directory, keyed on build
76# flags, so that we can do incremental, parallel builds of different binaries
77# with different build flags without collisions.
78
79UNAME ?= $(shell uname)
80ifeq ($(UNAME), Darwin)
81 HASH ?= md5
82else ifeq ($(UNAME), FreeBSD)
83 HASH ?= gmd5sum
84else ifeq ($(UNAME), OpenBSD)
85 HASH ?= md5
86endif
87HASH ?= md5sum
88
89HAVE_HASH := $(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
90ifeq ($(HAVE_HASH),0)
91 $(info warning : could not find HASH ($(HASH)), required to differentiate builds using different flags)
92 HASH_FUNC = generic/$(1)
93else
94 HASH_FUNC = $(firstword $(shell echo $(2) | $(HASH) ))
95endif
96
97
98MKDIR ?= mkdir
99LN ?= ln
100
101# --------------------------------------------------------------------------------------------
102# The following macros are used to create object files in the cache directory.
103# The object files are named after the source file, but with a different path.
104
105# Create build directories on-demand.
106#
107# For some reason, make treats the directory as an intermediate file and tries
108# to delete it. So we work around that by marking it "precious". Solution found
109# here:
110# http://ismail.badawi.io/blog/2017/03/28/automatic-directory-creation-in-make/
111.PRECIOUS: $(CACHE_ROOT)/%/.
112$(CACHE_ROOT)/%/. :
113 $(MKDIR) -p $@
114
115
116define addTargetAsmObject # targetName, addlDeps
117$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2))))
118
119.PRECIOUS: $$(CACHE_ROOT)/%/$(1)
120$$(CACHE_ROOT)/%/$(1) : $(1:.o=.S) $(2) | $$(CACHE_ROOT)/%/.
121 @echo AS $$@
122 $$(CC) $$(CPPFLAGS) $$(CXXFLAGS) $$(DEPFLAGS) $$(CACHE_ROOT)/$$*/$(1:.o=.d) -c $$< -o $$@
123
124endef # addTargetAsmObject
125
126define addTargetCObject # targetName, addlDeps
127$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2)))) #debug print
128
129.PRECIOUS: $$(CACHE_ROOT)/%/$(1)
130$$(CACHE_ROOT)/%/$(1) : $(1:.o=.c) $(2) | $$(CACHE_ROOT)/%/.
131 @echo CC $$@
132 $$(CC) $$(CPPFLAGS) $$(CFLAGS) $$(DEPFLAGS) $$(CACHE_ROOT)/$$*/$(1:.o=.d) -c $$< -o $$@
133
134endef # addTargetCObject
135
136define addTargetCxxObject # targetName, suffix, addlDeps
137$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2),$(3))))
138
139.PRECIOUS: $$(CACHE_ROOT)/%/$(1)
140$$(CACHE_ROOT)/%/$(1) : $(1:.o=.$(2)) $(3) | $$(CACHE_ROOT)/%/.
141 @echo CXX $$@
142 $$(CXX) $$(CPPFLAGS) $$(CXXFLAGS) $$(DEPFLAGS) $$(CACHE_ROOT)/$$*/$(1:.o=.d) -c $$< -o $$@
143
144endef # addTargetCxxObject
145
146# Create targets for individual object files
147C_SRCDIRS += .
148vpath %.c $(C_SRCDIRS)
149CXX_SRCDIRS += .
150vpath %.cpp $(CXX_SRCDIRS)
151vpath %.cc $(CXX_SRCDIRS)
152ASM_SRCDIRS += .
153vpath %.S $(ASM_SRCDIRS)
154
155# If C_SRCDIRS, CXX_SRCDIRS and ASM_SRCDIRS are not defined, use C_SRCS, CXX_SRCS and ASM_SRCS
156C_SRCS ?= $(notdir $(foreach dir,$(C_SRCDIRS),$(wildcard $(dir)/*.c)))
157CPP_SRCS ?= $(notdir $(foreach dir,$(CXX_SRCDIRS),$(wildcard $(dir)/*.cpp)))
158CC_SRCS ?= $(notdir $(foreach dir,$(CXX_SRCDIRS),$(wildcard $(dir)/*.cc)))
159CXX_SRCS ?= $(CPP_SRCS) $(CC_SRCS)
160ASM_SRCS ?= $(notdir $(foreach dir,$(ASM_SRCDIRS),$(wildcard $(dir)/*.S)))
161
162# If C_SRCS, CXX_SRCS and ASM_SRCS are not defined, use C_OBJS, CXX_OBJS and ASM_OBJS
163C_OBJS ?= $(patsubst %.c,%.o,$(C_SRCS))
164CPP_OBJS ?= $(patsubst %.cpp,%.o,$(CPP_SRCS))
165CC_OBJS ?= $(patsubst %.cc,%.o,$(CC_SRCS))
166CXX_OBJS ?= $(CPP_OBJS) $(CC_OBJS) # Note: not used
167ASM_OBJS ?= $(patsubst %.S,%.o,$(ASM_SRCS))
168
169$(foreach OBJ,$(C_OBJS),$(eval $(call addTargetCObject,$(OBJ))))
170$(foreach OBJ,$(CPP_OBJS),$(eval $(call addTargetCxxObject,$(OBJ),cpp)))
171$(foreach OBJ,$(CC_OBJS),$(eval $(call addTargetCxxObject,$(OBJ),cc)))
172$(foreach OBJ,$(ASM_OBJS),$(eval $(call addTargetAsmObject,$(OBJ))))
173
174# --------------------------------------------------------------------------------------------
175# The following macros are used to create targets in the user Makefile.
176# Binaries are built in the cache directory, and then symlinked to the current directory.
177# The cache directory is automatically derived from CACHE_ROOT and list of flags and compilers.
178
179
180# static_library - Create build rules for a static library with caching
181# Parameters:
182# 1. libName - Library name (becomes output file and phony target)
183# 2. objectDeps - Object file dependencies (will be built in cache path)
184# The following parameters are all optional:
185# 3. extraDeps - Additional dependencies (no cache path prefix)
186# 4. postBuildCmds - Extra commands to run after AR
187# 5. extraHash - Additional key to compute the unique cache path
188# Example:
189# $(call static_library,libmath.a,vector.o matrix.o,$(CONFIG_H),strip $@,$(VERSION))
190define static_library # libName, objectDeps, extraDeps, postBuildCmds, extraHash
191
192$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2),$(3),$(4),$(5))))
193MCM_ALL_BINS += $(1)
194
195$$(CACHE_ROOT)/%/$(1) : $$(addprefix $$(CACHE_ROOT)/%/,$(2)) $(3)
196 @echo AR $$@
197 $$(AR) $$(ARFLAGS) $$@ $$^
198 $(4)
199
200.PHONY: $(1)
201$(1) : ARFLAGS = rcs
202$(1) : $$(CACHE_ROOT)/$$(call HASH_FUNC,$(1),$(2) $$(CPPFLAGS) $$(CC) $$(CFLAGS) $$(CXX) $$(CXXFLAGS) $$(AR) $$(ARFLAGS) $(5))/$(1)
203 $$(LN) -sf $$< $$@
204
205endef # static_library
206
207
208# c_dynamic_library - Create build rules for a C dynamic/shared library with caching
209# Parameters:
210# 1. libName - Library name (becomes output file and phony target)
211# 2. objectDeps - Object file dependencies (will be built in cache path)
212# The following parameters are all optional:
213# 3. extraDeps - Additional dependencies (no cache path prefix)
214# 4. postLinkCmds - Extra commands to run after linking
215# 5. extraHash - Additional key to compute the unique cache path
216# Example:
217# $(call c_dynamic_library,libmath.so,vector.o matrix.o,$(CONFIG_H),strip $@,$(VERSION))
218define c_dynamic_library # libName, objectDeps, extraDeps, postLinkCmds, extraHash
219
220$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2),$(3),$(4),$(5))))
221MCM_ALL_BINS += $(1)
222
223$$(CACHE_ROOT)/%/$(1) : $$(addprefix $$(CACHE_ROOT)/%/,$(2)) $(3)
224 @echo LD $$@
225 $$(CC) $$(CPPFLAGS) $$(CFLAGS) $$(LDFLAGS) -shared -o $$@ $$^ $$(LDLIBS)
226 $(4)
227
228.PHONY: $(1)
229$(1) : CFLAGS += -fPIC
230$(1) : $$(CACHE_ROOT)/$$(call HASH_FUNC,$(1),$(2) $$(CPPFLAGS) $$(CC) $$(CFLAGS) $$(LDFLAGS) $$(LDLIBS) $(5))/$(1)
231 $$(LN) -sf $$< $$@
232
233endef # c_dynamic_library
234
235
236# program_base - Create build rules for an executable program with caching
237# Parameters:
238# 1. progName - Executable name (becomes output file and phony target)
239# 2. objectDeps - Object file dependencies (will be prefixed with cache path)
240# Parameters 3 to 5 are optional:
241# 3. extraDeps - Additional dependencies (without cache path prefix)
242# 4. postLinkCmds - Extra commands to run after linking
243# 5. extraHash - Additional data to include in cache path hash
244# Parameters 6 & 7 are compulsory:
245# 6. compiler - Variable name of compiler to use (CC or CXX)
246# 7. compilerFlags - Variable name of compiler flags to use (CFLAGS or CXXFLAGS)
247# Example:
248# $(call program_base,myapp,main.o utils.o,$(CONFIG_H),strip $@,$(VERSION),CC,CFLAGS)
249# $(call program_base,mycppapp,main.o utils.o,$(CONFIG_H),strip $@,$(VERSION),CXX,CXXFLAGS)
250define program_base # progName, objectDeps, extraDeps, postLinkCmds, extraHash, compiler, compilerFlags
251
252$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2),$(3),$(4),$(5),$(6),$(7))))
253MCM_ALL_BINS += $(1)
254
255$$(CACHE_ROOT)/%/$(1) : $$(addprefix $$(CACHE_ROOT)/%/,$(2)) $(3)
256 @echo LD $$@
257 $$($(6)) $$(CPPFLAGS) $$($(7)) $$^ -o $$@ $$(LDFLAGS) $$(LDLIBS)
258 $(4)
259
260.PHONY: $(1)
261$(1) : $$(CACHE_ROOT)/$$(call HASH_FUNC,$(1),$$($(6)) $$(CPPFLAGS) $$($(7)) $$(LDFLAGS) $$(LDLIBS) $(5))/$(1)
262 $$(LN) -sf $$< $$@$(EXT)
263
264endef # program_base
265# Note: $(EXT) must be set to .exe for Windows
266
267define c_program # progName, objectDeps, extraDeps, postLinkCmds
268$$(eval $$(call program_base,$(1),$(2),$(3),$(4),$(1)$(2),CC,CFLAGS))
269endef # c_program
270
271define c_program_shared_o # progName, objectDeps, extraDeps, postLinkCmds
272$$(eval $$(call program_base,$(1),$(2),$(3),$(4),,CC,CFLAGS))
273endef # c_program_shared_o
274
275define cxx_program # progName, objectDeps, extraDeps, postLinkCmds
276$$(eval $$(call program_base,$(1),$(2),$(3),$(4),$(1)$(2),CXX,CXXFLAGS))
277endef # cxx_program
278
279define cxx_program_shared_o # progName, objectDeps, extraDeps, postLinkCmds
280$$(eval $$(call program_base,$(1),$(2),$(3),$(4),,CXX,CXXFLAGS))
281endef # cxx_program_shared_o
282
283# --------------------------------------------------------------------------------------------
284
285# Cleaning: delete all objects and binaries created by this script
286.PHONY: clean_cache
287clean_cache:
288 $(RM) -rf $(CACHE_ROOT)
289 $(RM) $(MCM_ALL_BINS)
290
291# automatically attach to standard clean target
292.PHONY: clean
293clean: clean_cache