un-inception/clients/c/Makefile
russell@unturf.com 1e01d09883 feat: per-client Makefile infrastructure for 4-mode testing
Add per-client Makefiles for C, Python, and Go with:
- CLI mode: Tests --help, arg parsing, syntax validation
- Library mode: Unit tests, import verification
- Integration mode: API contract validation (with credentials)
- Functional mode: Real-world scenario tests

C client:
- 22 library tests (SHA-256, HMAC-SHA256, detect_language)
- Full unsandbox.c implementation with examples

Python client (sync + async):
- Delegates to sync/ and async/ subdirectories
- pytest-based test suites with coverage
- Examples for concurrent execution, streaming

Go client:
- Delegates to sync/ and async/ subdirectories
- go test integration with vet and fmt

Also update detect-changes.sh to detect changes in
both root-level un.* files AND clients/ directory.
2026-01-15 16:39:56 -05:00

115 lines
3.4 KiB
Makefile

# UN C Client - Build and Test
#
# Usage:
# make # Build un binary
# make test # Run all 4 test modes
# make test-cli # CLI mode only
# make test-library # Library mode only
# make test-integration # Integration mode only
# make test-functional # Functional mode only
# make clean # Remove build artifacts
#
# Dependencies:
# apt install build-essential libcurl4-openssl-dev libwebsockets-dev libssl-dev
.PHONY: all build test test-cli test-library test-integration test-functional clean help examples
# Paths
ROOT_DIR := $(shell cd ../.. && pwd)
SRC_DIR := src
SRC := $(SRC_DIR)/unsandbox.c
HEADER := $(SRC_DIR)/unsandbox.h
BIN := un
TEST_DIR := tests
EXAMPLES_DIR := examples
# Compiler settings
CC := gcc
CFLAGS := -O2 -Wall -Wextra -I$(SRC_DIR)
LDFLAGS := -lcurl -lssl -lcrypto
# Colors
GREEN := \033[32m
RED := \033[31m
YELLOW := \033[33m
NC := \033[0m
.DEFAULT_GOAL := build
help:
@echo "UN C Client - Build and Test"
@echo ""
@echo "Build:"
@echo " make Build library and examples"
@echo " make build Same as above"
@echo " make lib Build just the library"
@echo " make examples Build example programs"
@echo ""
@echo "Test:"
@echo " make test Run all tests"
@echo " make test-library Test library functions"
@echo ""
@echo "Utility:"
@echo " make clean Remove build artifacts"
@echo " make deps Show required dependencies"
@echo ""
all: build
build: lib examples
lib: $(SRC) $(HEADER)
@echo "$(GREEN)✓$(NC) Library files ready:"
@echo " - $(SRC_DIR)/unsandbox.c (implementation)"
@echo " - $(SRC_DIR)/unsandbox.h (header)"
examples: $(EXAMPLES_DIR)/hello_world $(EXAMPLES_DIR)/fibonacci
@echo "$(GREEN)✓$(NC) Examples built"
$(EXAMPLES_DIR)/hello_world: $(EXAMPLES_DIR)/hello_world.c $(SRC) $(HEADER)
@mkdir -p $(EXAMPLES_DIR)
@echo "Building hello_world example..."
$(CC) $(CFLAGS) -o $@ $< $(SRC) $(LDFLAGS)
@echo "$(GREEN)✓$(NC) Built: $@"
$(EXAMPLES_DIR)/fibonacci: $(EXAMPLES_DIR)/fibonacci.c $(SRC) $(HEADER)
@mkdir -p $(EXAMPLES_DIR)
@echo "Building fibonacci example..."
$(CC) $(CFLAGS) -o $@ $< $(SRC) $(LDFLAGS)
@echo "$(GREEN)✓$(NC) Built: $@"
deps:
@echo "Required packages:"
@echo " apt install build-essential libcurl4-openssl-dev libwebsockets-dev libssl-dev"
# ============================================================================
# TEST
# ============================================================================
test: build $(TEST_DIR)/test_library
@echo ""
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@echo "LIBRARY MODE: Testing unsandbox.c functions"
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@echo ""
@./$(TEST_DIR)/test_library
test-library: test
$(TEST_DIR)/test_library: $(TEST_DIR)/test_library.c $(SRC) $(HEADER)
@mkdir -p $(TEST_DIR)
@echo "Building test suite..."
$(CC) $(CFLAGS) -o $@ $< $(SRC) $(LDFLAGS)
@echo "$(GREEN)✓$(NC) Test binary ready"
# ============================================================================
# Clean
# ============================================================================
clean:
rm -f $(TEST_DIR)/test_library
rm -f $(EXAMPLES_DIR)/hello_world
rm -f $(EXAMPLES_DIR)/fibonacci
rm -f $(EXAMPLES_DIR)/*.o
rm -f $(TEST_DIR)/*.o
@echo "$(GREEN)✓$(NC) Cleaned build artifacts"