# C-Relay Makefile CC = gcc CFLAGS = -Wall -Wextra -std=c99 -g -O2 INCLUDES = -I. -Inostr_core_lib -Inostr_core_lib/nostr_core -Inostr_core_lib/cjson -Inostr_core_lib/nostr_websocket LIBS = -lsqlite3 -lwebsockets -lz -ldl -lpthread -lm -L/usr/local/lib -lsecp256k1 -lssl -lcrypto -L/usr/local/lib -lcurl # Source files MAIN_SRC = src/main.c NOSTR_CORE_LIB = nostr_core_lib/libnostr_core_x64.a # Target binary TARGET = src/main # Default target all: $(TARGET) # Check if nostr_core_lib is built $(NOSTR_CORE_LIB): @echo "Building nostr_core_lib..." cd nostr_core_lib && ./build.sh # Build the relay $(TARGET): $(MAIN_SRC) $(NOSTR_CORE_LIB) @echo "Compiling C-Relay..." $(CC) $(CFLAGS) $(INCLUDES) $(MAIN_SRC) -o $(TARGET) $(NOSTR_CORE_LIB) $(LIBS) @echo "Build complete: $(TARGET)" # Run tests test: $(TARGET) @echo "Running tests..." ./tests/1_nip_test.sh # Initialize database init-db: @echo "Initializing database..." ./db/init.sh --force # Clean build artifacts clean: rm -f $(TARGET) @echo "Clean complete" # Clean everything including nostr_core_lib clean-all: clean cd nostr_core_lib && make clean 2>/dev/null || true # Install dependencies (Ubuntu/Debian) install-deps: @echo "Installing dependencies..." sudo apt update sudo apt install -y build-essential libsqlite3-dev libssl-dev libcurl4-openssl-dev libsecp256k1-dev zlib1g-dev jq curl # Help help: @echo "C-Relay Build System" @echo "" @echo "Targets:" @echo " all Build the relay (default)" @echo " test Build and run tests" @echo " init-db Initialize the database" @echo " clean Clean build artifacts" @echo " clean-all Clean everything including dependencies" @echo " install-deps Install system dependencies" @echo " help Show this help" @echo "" @echo "Usage:" @echo " make # Build the relay" @echo " make test # Run tests" @echo " make init-db # Set up database" .PHONY: all test init-db clean clean-all install-deps help