REPO_URL = https://github.com/logos-messaging/logos-messaging-nim
REPO_DIR = logos-messaging-nim
OUTPUT_DIR = libs
ifeq ($(shell uname),Darwin)
LIB_NAME = libwaku.dylib
export SDKROOT ?= $(shell xcrun --show-sdk-path)
else
LIB_NAME = libwaku.so
endif
.PHONY: all clean setup build copy
all: setup build copy
setup:
@echo "--- [1/3] Checking dependencies ---"
@if ! command -v nim > /dev/null; then \
echo "Error: Nim is not installed. Please run: brew install nim"; \
exit 1; \
fi
@echo "--- Checking repository ---"
@if [ ! -d "$(REPO_DIR)" ]; then \
echo "Cloning logos-messaging-nim..."; \
git clone $(REPO_URL) $(REPO_DIR); \
else \
echo "Repository exists. Updating..."; \
cd $(REPO_DIR) && git pull; \
fi
@echo "--- Initializing Submodules ---"
cd $(REPO_DIR) && git submodule update --init --recursive
build:
@echo "--- [2/3] Building libwaku ---"
@echo "Using SDKROOT: $(SDKROOT)"
@ cd $(REPO_DIR) && $(MAKE) update
@ cd $(REPO_DIR) && $(MAKE) libwaku
copy:
@echo "--- [3/3] Retrieving library ---"
@mkdir -p $(OUTPUT_DIR)
@if [ -f "$(REPO_DIR)/build/$(LIB_NAME)" ]; then \
cp "$(REPO_DIR)/build/$(LIB_NAME)" "$(OUTPUT_DIR)/$(LIB_NAME)"; \
else \
echo "Error: Could not find $(LIB_NAME) in $(REPO_DIR)/build/"; \
exit 1; \
fi
@echo "Success! Library located at: ./$(OUTPUT_DIR)/$(LIB_NAME)"
clean:
rm -rf $(OUTPUT_DIR)
rm -rf $(REPO_DIR)