1
0
mirror of https://github.com/lz4/lz4.git synced 2026-10-24 01:48:57 +03:00
Files
Yann Collet 5d0c796189 lib/Makefile: Windows DLL built through multiconf, so that changing MULTITHREAD rebuilds it
The DLL was compiled directly from sources, without the objects' cache keyed by flags :
after make lib-nomt, make lib-mt kept the DLL without threads (and conversely).
It now uses c_dynamic_library(), as the Unix shared library, with the multi-threading flags
in the cache key ; the resource object is an additional dependency. The import library
is the same for both variants (same exports). With BUILD_SHARED=no, liblz4 builds nothing, as before.
Checked with mingw-w64 : MULTITHREAD=0 / 1 / back to 1 (cached) switch the DLL's thread imports ;
a program linked to the multi-threaded DLL compresses with nbWorkers=4 under wine.
2026-10-22 12:58:19 -07:00
..
2025-05-30 14:28:32 -04:00

multiconf.make

multiconf.make is a self-contained Makefile include that lets you build the same targets under many different flag sets—debug vs release, ASan vs UBSan, GCC vs Clang, etc.—without the usual “object-file soup.” It hashes every combination of CC/CXX, CFLAGS/CXXFLAGS, CPPFLAGS, LDFLAGS and LDLIBS into a dedicated cache directory, so objects compiled with one configuration are never reused by another. Swap flags, rebuild, swap back—previous objects are still there and never collide.


Key Benefits

Why it matters What multiconf.make does
Isolated configs Stores objects into cachedObjs/<hash>/, one directory per unique flag set.
Fast switching Reusing an old config is instant—link only, no recompilation.
Header deps Edits to headers trigger only needed rebuilds.
One-liner targets Macros (c_program, cxx_program, …) hide all rule boilerplate.
Parallel-ready Safe with make -j, no duplicate compiles of shared sources.

Quick Start

1 · List your sources

C_SRCDIRS   := src src/cdeps    # all .c are in these directories
CXX_SRCDIRS := src src/cxxdeps  # all .cpp are in these directories

2 · Add and include

# root/Makefile
include multiconf.make

3 · Declare targets

app:
$(eval $(call c_program,app,app.o obj1.o obj2.o))
test:
$(eval $(call cxx_program,test, test.o objcxx1.o objcxx2.o))

4 · Build any config you like

# Release with GCC
make CFLAGS="-O3"

# Debug with Clang + AddressSanitizer (new cache dir)
make CC=clang CFLAGS="-g -O0 -fsanitize=address"

# Switch back to GCC release (objects still valid, relink only)
make CFLAGS="-O3"

Objects for each command live in different sub-folders; nothing overlaps.


Additional capabilities

Command Description
make clean_cache Wipe all cached objects & deps (full rebuild next time)
V=1 Show full compile/link commands