zexc 1.2.1

zex native lossless compressor — CLI zexc, library zexc, files *.zex
Documentation
# =============================================================================
# Makefile — thin wrapper around zexc.toml
# =============================================================================
# Declare shared / static / standalone / features in **zexc.toml**, not here.
#   edit zexc.toml  →  make configure  →  make release
# =============================================================================

.PHONY: all configure show-config build release test bench bench-compare \
        stream docs install install-local clean release-tarball c-api help

VERSION := $(shell grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
TARGET  := $(shell rustc -vV | sed -n 's/^host: //p')

# Load flags generated from zexc.toml (FEATURES, PROFILE, …)
-include .zexc-build.mk

# Defaults if configure not run yet
ZEXC_CARGO_FEATURES      ?= --no-default-features --features std,simd,encryption,c-api,cli
ZEXC_CARGO_PROFILE_FLAG  ?= --release
ZEXC_TARGET_DIR          ?= target/release
ZEXC_PREFIX              ?= ./dist
ZEXC_STANDALONE          ?= 1
ZEXC_SHARED              ?= 1
ZEXC_STATIC              ?= 1

export RUSTFLAGS := $(ZEXC_RUSTFLAGS)

all: release

help:
	@echo "zexc build (config: zexc.toml)"
	@echo ""
	@echo "  make configure       apply zexc.toml → Cargo.toml + .zexc-build.mk"
	@echo "  make show-config     print effective zexc.toml settings"
	@echo "  make release         configure + optimized build"
	@echo "  make build           configure + debug build"
	@echo "  make test            configure + cargo test"
	@echo "  make install-local   install CLI/libs into \$$(paths.prefix) from zexc.toml"
	@echo "  make c-api           show libzexc artifacts"
	@echo "  make clean"
	@echo ""
	@echo "Edit zexc.toml for: library.shared/static/rlib, binary.standalone, features.*"

configure:
	@python3 scripts/zexc_config.py --make
	@echo "OK — open zexc.toml to change shared/static/standalone/features"

show-config:
	@python3 scripts/zexc_config.py --show

build: configure
	cargo build $(ZEXC_CARGO_FEATURES)

release: configure
	cargo build --release $(ZEXC_CARGO_FEATURES)

test: configure
	# tests need rlib; force-friendly feature set still from zexc.toml
	cargo test $(ZEXC_CARGO_FEATURES)

bench: configure
	cargo bench --bench compression $(ZEXC_CARGO_FEATURES)

bench-compare: release
	chmod +x scripts/bench_compare.sh
	./scripts/bench_compare.sh

stream: build
	cargo run $(ZEXC_CARGO_FEATURES) --example stream_compress

c-api: release
	@echo "Header: include/zexc.h"
	@echo "Config: library.shared=$(ZEXC_SHARED) static=$(ZEXC_STATIC) c-api via zexc.toml"
	@ls -la $(ZEXC_TARGET_DIR)/libzexc* 2>/dev/null || ls -la target/release/libzexc* 2>/dev/null || true

docs:
	@echo "docs/  |  config: zexc.toml  |  CLI: zexc  |  files: *.zex"
	@ls -1 docs/

install: release
	cargo install --path . --locked --force $(ZEXC_CARGO_FEATURES)

install-local: release
	@mkdir -p "$(ZEXC_PREFIX)"
	@if [ "$(ZEXC_STANDALONE)" = "1" ]; then \
		cp -f $(ZEXC_TARGET_DIR)/zexc "$(ZEXC_PREFIX)/zexc" 2>/dev/null || \
		cp -f target/release/zexc "$(ZEXC_PREFIX)/zexc"; \
		echo "CLI  → $(ZEXC_PREFIX)/zexc"; \
	fi
	@if [ "$(ZEXC_SHARED)" = "1" ]; then \
		cp -f $(ZEXC_TARGET_DIR)/libzexc.so "$(ZEXC_PREFIX)/" 2>/dev/null || true; \
		cp -f $(ZEXC_TARGET_DIR)/libzexc.dylib "$(ZEXC_PREFIX)/" 2>/dev/null || true; \
		echo "shared lib → $(ZEXC_PREFIX)/libzexc.*"; \
	fi
	@if [ "$(ZEXC_STATIC)" = "1" ]; then \
		cp -f $(ZEXC_TARGET_DIR)/libzexc.a "$(ZEXC_PREFIX)/" 2>/dev/null || true; \
		echo "static lib → $(ZEXC_PREFIX)/libzexc.a"; \
	fi
	@cp -f include/zexc.h "$(ZEXC_PREFIX)/" 2>/dev/null || true
	@echo "Done (prefix=$(ZEXC_PREFIX) from zexc.toml [paths])"

release-tarball: release
	mkdir -p dist
	rm -rf dist/zexc-$(VERSION)-$(TARGET)
	mkdir -p dist/zexc-$(VERSION)-$(TARGET)/docs dist/zexc-$(VERSION)-$(TARGET)/include
	-cp $(ZEXC_TARGET_DIR)/zexc dist/zexc-$(VERSION)-$(TARGET)/ 2>/dev/null || true
	-cp $(ZEXC_TARGET_DIR)/libzexc* dist/zexc-$(VERSION)-$(TARGET)/ 2>/dev/null || true
	cp zexc.toml README.md LICENSE Cargo.toml dist/zexc-$(VERSION)-$(TARGET)/
	cp docs/*.md dist/zexc-$(VERSION)-$(TARGET)/docs/
	-cp docs/zexc.1 dist/zexc-$(VERSION)-$(TARGET)/docs/
	-cp include/zexc.h dist/zexc-$(VERSION)-$(TARGET)/include/
	tar -C dist -czf dist/zexc-$(VERSION)-$(TARGET).tar.gz zexc-$(VERSION)-$(TARGET)
	(cd dist && sha256sum zexc-$(VERSION)-$(TARGET).tar.gz > zexc-$(VERSION)-$(TARGET).tar.gz.sha256)
	@echo "Created dist/zexc-$(VERSION)-$(TARGET).tar.gz"

clean:
	cargo clean
	rm -rf dist .zexc-build.mk