chore: remove legacy libtikker static library and simplify Makefile build targets
This commit is contained in:
@@ -1,115 +1,103 @@
|
||||
.PHONY: all clean test build-lib build-tools build-api install help dev coverage memcheck
|
||||
.PHONY: all clean test install help dev tikker plot process merge index popular
|
||||
|
||||
CC := gcc
|
||||
CFLAGS := -Wall -Wextra -pedantic -std=c11 -O2 -I./src/third_party -I./src/libtikker/include
|
||||
CFLAGS := -Ofast -Wall -Wextra
|
||||
DEBUG_FLAGS := -g -O0 -DDEBUG
|
||||
RELEASE_FLAGS := -O3
|
||||
COVERAGE_FLAGS := -fprofile-arcs -ftest-coverage
|
||||
LDFLAGS := -lsqlite3 -lm
|
||||
LDFLAGS := -lsqlite3 -lpthread
|
||||
|
||||
INSTALL_PREFIX ?= /usr/local
|
||||
BUILD_DIR := ./build
|
||||
BIN_DIR := $(BUILD_DIR)/bin
|
||||
LIB_DIR := $(BUILD_DIR)/lib
|
||||
|
||||
all: build-lib build-tools build-api
|
||||
@echo "✓ Complete build finished"
|
||||
PYTHON := python3
|
||||
VENV := .venv
|
||||
VENV_PYTHON := $(VENV)/bin/python
|
||||
|
||||
all: tikker
|
||||
@echo "Build complete"
|
||||
|
||||
help:
|
||||
@echo "Tikker Enterprise Build System"
|
||||
@echo "Tikker Build System"
|
||||
@echo ""
|
||||
@echo "Targets:"
|
||||
@echo " make all - Build everything (lib, tools, API)"
|
||||
@echo " make build-lib - Build libtikker static library"
|
||||
@echo " make build-tools - Build all CLI tools"
|
||||
@echo " make build-api - Setup Python API environment"
|
||||
@echo " make test - Run all tests"
|
||||
@echo " make coverage - Generate code coverage report"
|
||||
@echo " make memcheck - Run memory leak detection"
|
||||
@echo " make clean - Remove all build artifacts"
|
||||
@echo " make install - Install binaries"
|
||||
@echo " make dev - Build with debug symbols"
|
||||
@echo "Build Targets:"
|
||||
@echo " make tikker - Build tikker binary (default)"
|
||||
@echo " make all - Same as tikker"
|
||||
@echo " make dev - Build with debug symbols"
|
||||
@echo " make clean - Remove build artifacts"
|
||||
@echo " make install - Install binary to $(INSTALL_PREFIX)/bin"
|
||||
@echo ""
|
||||
@echo "Environment Variables:"
|
||||
@echo " CC - C compiler (default: gcc)"
|
||||
@echo " CFLAGS - Compiler flags"
|
||||
@echo " INSTALL_PREFIX - Installation directory (default: /usr/local)"
|
||||
@echo "Python Targets:"
|
||||
@echo " make ensure_env - Create Python virtual environment"
|
||||
@echo " make plot - Generate graphs and reports"
|
||||
@echo " make process - Run processing pipeline"
|
||||
@echo " make merge - Merge visualization outputs"
|
||||
@echo " make index - Index words in database"
|
||||
@echo " make popular - Show popular typed words"
|
||||
@echo ""
|
||||
@echo "Tikker Commands:"
|
||||
@echo " ./tikker - Start keyboard monitoring"
|
||||
@echo " ./tikker presses_today - Show today's keystrokes"
|
||||
@echo " ./tikker stats daily - Daily statistics"
|
||||
@echo " ./tikker stats hourly - Hourly breakdown"
|
||||
@echo " ./tikker stats weekly - Weekly statistics"
|
||||
@echo " ./tikker stats weekday - Weekday comparison"
|
||||
@echo " ./tikker stats top-keys N - Top N keys"
|
||||
@echo " ./tikker stats top-words N - Top N words"
|
||||
@echo " ./tikker stats summary - Overall summary"
|
||||
@echo " ./tikker decode FILE - Decode keystroke log"
|
||||
@echo " ./tikker help - Show usage"
|
||||
|
||||
$(BIN_DIR):
|
||||
@mkdir -p $(BIN_DIR)
|
||||
|
||||
$(LIB_DIR):
|
||||
@mkdir -p $(LIB_DIR)
|
||||
tikker: $(BIN_DIR)
|
||||
@echo "Building tikker..."
|
||||
@$(CC) $(CFLAGS) tikker.c -o $(BIN_DIR)/tikker $(LDFLAGS)
|
||||
@cp $(BIN_DIR)/tikker ./tikker
|
||||
@echo "Built: ./tikker"
|
||||
|
||||
build-lib: $(LIB_DIR)
|
||||
@echo "Building libtikker library..."
|
||||
@cd src/libtikker && make LIB_DIR=../../$(LIB_DIR) CC="$(CC)" CFLAGS="$(CFLAGS)"
|
||||
@echo "✓ libtikker built"
|
||||
dev: CFLAGS := $(DEBUG_FLAGS)
|
||||
dev: clean tikker
|
||||
@echo "Debug build complete"
|
||||
|
||||
build-tools: build-lib $(BIN_DIR)
|
||||
@echo "Building CLI tools..."
|
||||
@cd src/tools/decoder && make BIN_DIR=../../$(BIN_DIR) LIB_DIR=../../$(LIB_DIR) CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
|
||||
@cd src/tools/indexer && make BIN_DIR=../../$(BIN_DIR) LIB_DIR=../../$(LIB_DIR) CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
|
||||
@cd src/tools/aggregator && make BIN_DIR=../../$(BIN_DIR) LIB_DIR=../../$(LIB_DIR) CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
|
||||
@cd src/tools/report_gen && make BIN_DIR=../../$(BIN_DIR) LIB_DIR=../../$(LIB_DIR) CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
|
||||
@echo "✓ All CLI tools built"
|
||||
|
||||
build-api:
|
||||
@echo "Setting up Python API environment..."
|
||||
@if [ -f src/api/requirements.txt ]; then \
|
||||
python3 -m pip install --quiet -r src/api/requirements.txt 2>/dev/null || true; \
|
||||
echo "✓ Python dependencies installed"; \
|
||||
ensure_env:
|
||||
@if [ ! -d "$(VENV)" ]; then \
|
||||
$(PYTHON) -m venv $(VENV); \
|
||||
$(VENV_PYTHON) -m pip install --upgrade pip; \
|
||||
$(VENV_PYTHON) -m pip install matplotlib requests fastapi uvicorn openai dataset; \
|
||||
echo "Virtual environment created at $(VENV)"; \
|
||||
else \
|
||||
echo "⚠ No API requirements.txt found"; \
|
||||
echo "Virtual environment already exists"; \
|
||||
fi
|
||||
|
||||
test: build-lib
|
||||
@echo "Running tests..."
|
||||
@cd tests && make CC="$(CC)" CFLAGS="$(CFLAGS)"
|
||||
@echo "✓ Tests completed"
|
||||
plot: ensure_env
|
||||
@PYTHONPATH=/home/retoor/bin $(VENV_PYTHON) plot.py
|
||||
@$(VENV_PYTHON) merge.py
|
||||
|
||||
coverage: clean
|
||||
@echo "Building with coverage instrumentation..."
|
||||
@$(MAKE) CFLAGS="$(CFLAGS) $(COVERAGE_FLAGS)" test
|
||||
@echo "Generating coverage report..."
|
||||
@gcov src/libtikker/src/*.c 2>/dev/null || true
|
||||
@lcov --capture --directory . --output-file coverage.info 2>/dev/null || true
|
||||
@genhtml coverage.info --output-directory coverage_html 2>/dev/null || true
|
||||
@echo "✓ Coverage report generated in coverage_html/"
|
||||
process: ensure_env
|
||||
@PYTHONPATH=/home/retoor/bin $(VENV_PYTHON) process.py
|
||||
|
||||
memcheck: build-lib
|
||||
@echo "Running memory leak detection..."
|
||||
@valgrind --leak-check=full --show-leak-kinds=all \
|
||||
./$(BIN_DIR)/tikker-aggregator --help 2>&1 | tail -20
|
||||
@echo "✓ Memory check completed"
|
||||
merge: ensure_env
|
||||
@$(VENV_PYTHON) merge.py
|
||||
|
||||
dev: CFLAGS += $(DEBUG_FLAGS)
|
||||
dev: clean all
|
||||
@echo "✓ Debug build completed"
|
||||
index: ensure_env
|
||||
@$(VENV_PYTHON) tags.py --index
|
||||
|
||||
install: all
|
||||
@echo "Installing to $(INSTALL_PREFIX)..."
|
||||
popular: ensure_env
|
||||
@$(VENV_PYTHON) tags.py --popular
|
||||
|
||||
install: tikker
|
||||
@echo "Installing to $(INSTALL_PREFIX)/bin..."
|
||||
@mkdir -p $(INSTALL_PREFIX)/bin
|
||||
@mkdir -p $(INSTALL_PREFIX)/lib
|
||||
@mkdir -p $(INSTALL_PREFIX)/include
|
||||
@install -m 755 $(BIN_DIR)/tikker-decoder $(INSTALL_PREFIX)/bin/
|
||||
@install -m 755 $(BIN_DIR)/tikker-indexer $(INSTALL_PREFIX)/bin/
|
||||
@install -m 755 $(BIN_DIR)/tikker-aggregator $(INSTALL_PREFIX)/bin/
|
||||
@install -m 755 $(BIN_DIR)/tikker-report $(INSTALL_PREFIX)/bin/
|
||||
@install -m 644 $(LIB_DIR)/libtikker.a $(INSTALL_PREFIX)/lib/
|
||||
@install -m 644 src/libtikker/include/*.h $(INSTALL_PREFIX)/include/
|
||||
@echo "✓ Installation complete"
|
||||
@install -m 755 $(BIN_DIR)/tikker $(INSTALL_PREFIX)/bin/
|
||||
@echo "Installed: $(INSTALL_PREFIX)/bin/tikker"
|
||||
|
||||
clean:
|
||||
@echo "Cleaning build artifacts..."
|
||||
@rm -rf $(BUILD_DIR)
|
||||
@rm -f tikker
|
||||
@find . -name "*.o" -delete
|
||||
@find . -name "*.a" -delete
|
||||
@find . -name "*.gcov" -delete
|
||||
@find . -name "*.gcda" -delete
|
||||
@find . -name "*.gcno" -delete
|
||||
@find . -name "gmon.out" -delete
|
||||
@rm -rf coverage.info coverage_html/
|
||||
@echo "✓ Clean completed"
|
||||
|
||||
.PHONY: help $(BIN_DIR) $(LIB_DIR)
|
||||
@echo "Clean complete"
|
||||
|
||||
Reference in New Issue
Block a user