- add COPYING (GPL-3.0-or-later) and license headers to all elisp and C sources; real author/maintainer info replaces placeholders - convert user-facing options to defcustom under new group `ekp' (spacing internals managed by ekp-param-set stay defvars) - autoload user commands: ekp-param-reset, ekp-clear-caches, ekp-c-module-load, ekp-c-module-build - ekp--load-dicts: a missing dictionaries/ directory now only disables hyphenation instead of breaking (require 'ekp); ekp--split-with-hyphen degrades gracefully (and resolves the hyphenator once per call instead of once per word) - package summary no longer redundantly says "for Emacs" - Makefile: drop personal Windows EMACS_ROOT default; add guidance - ekp_c/README.md: fix stale 1.1 version references (module is 1.4) - DEVELOPER*.md: remove archive/ from file map (not in the repo) - remove unreferenced 10 MB demo GIF Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
121 lines
3.0 KiB
Makefile
121 lines
3.0 KiB
Makefile
# Makefile for EKP C dynamic module
|
|
#
|
|
# Copyright (C) 2024-2026 Kinney Zhang
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
#
|
|
# Builds ekp.so (or ekp.dylib on macOS) for Emacs dynamic loading.
|
|
# Uses pthread for multi-threading, optimizes for native CPU.
|
|
|
|
# Detect OS
|
|
ifeq ($(OS),Windows_NT)
|
|
UNAME := Windows
|
|
else
|
|
UNAME := $(shell uname 2>/dev/null || echo Unknown)
|
|
endif
|
|
|
|
# Compiler settings
|
|
# Default to gcc on Windows if cc is not found
|
|
ifeq ($(UNAME), Windows)
|
|
CC = gcc
|
|
# Point EMACS_ROOT at your Emacs installation (the directory that
|
|
# contains include/emacs-module.h), e.g.:
|
|
# make EMACS_ROOT=C:/path/to/emacs-30.2
|
|
EMACS_ROOT ?=
|
|
ifeq ($(EMACS_ROOT),)
|
|
$(warning EMACS_ROOT is not set; emacs-module.h may not be found. \
|
|
Set it to your Emacs installation directory.)
|
|
endif
|
|
EMACS ?= emacs.exe
|
|
else
|
|
CC ?= cc
|
|
EMACS ?= emacs
|
|
endif
|
|
|
|
CFLAGS := -std=c11 -Wall -Wextra -Wpedantic -O3 -fPIC
|
|
CFLAGS += -march=native -flto
|
|
CFLAGS += -D_POSIX_C_SOURCE=200809L
|
|
|
|
# Debug build
|
|
ifdef DEBUG
|
|
CFLAGS := -std=c11 -Wall -Wextra -Wpedantic -O0 -g -fPIC
|
|
CFLAGS += -fsanitize=address,undefined
|
|
endif
|
|
|
|
# Platform-specific settings
|
|
ifeq ($(UNAME), Darwin)
|
|
# macOS
|
|
MODULE_EXT := dylib
|
|
LDFLAGS := -shared -lpthread
|
|
# Find Emacs headers (check Emacs.app, homebrew, /usr/local)
|
|
EMACS_INCLUDE := $(shell find /Applications/Emacs.app/Contents/Resources/include /opt/homebrew /usr/local -name emacs-module.h -exec dirname {} \; 2>/dev/null | head -1)
|
|
ifdef EMACS_INCLUDE
|
|
CFLAGS += -I$(EMACS_INCLUDE)
|
|
endif
|
|
else ifeq ($(UNAME), Linux)
|
|
# Linux
|
|
MODULE_EXT := so
|
|
LDFLAGS := -shared -lpthread -lm
|
|
else ifeq ($(UNAME), Windows)
|
|
# Windows (MinGW)
|
|
MODULE_EXT := dll
|
|
LDFLAGS := -shared -lpthread
|
|
CFLAGS += -I$(EMACS_ROOT)/include
|
|
else
|
|
# Fallback / Unknown
|
|
MODULE_EXT := so
|
|
LDFLAGS := -shared -lpthread
|
|
endif
|
|
|
|
# Source files
|
|
SRCS := ekp.c ekp_kp.c ekp_hyphen.c ekp_paragraph.c ekp_thread_pool.c
|
|
OBJS := $(SRCS:.c=.o)
|
|
|
|
# Output
|
|
MODULE := ekp.$(MODULE_EXT)
|
|
|
|
# Targets
|
|
.PHONY: all clean install test
|
|
|
|
all: $(MODULE)
|
|
|
|
$(MODULE): $(OBJS)
|
|
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
@rm -f $(OBJS)
|
|
@echo "Built $@"
|
|
|
|
%.o: %.c ekp_module.h
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
clean:
|
|
rm -f $(OBJS) $(MODULE)
|
|
|
|
# Install to Emacs load path (customize DESTDIR as needed)
|
|
DESTDIR ?= $(HOME)/.emacs.d/modules
|
|
install: $(MODULE)
|
|
@mkdir -p $(DESTDIR)
|
|
cp $(MODULE) $(DESTDIR)/
|
|
@echo "Installed to $(DESTDIR)/$(MODULE)"
|
|
|
|
# Test with Emacs
|
|
test: $(MODULE)
|
|
$(EMACS) -Q --batch \
|
|
-L . \
|
|
--eval '(module-load (expand-file-name "./$(MODULE)"))' \
|
|
--eval '(message "ekp-c version: %s" (ekp-c-version))' \
|
|
--eval '(ekp-c-init)' \
|
|
--eval '(message "ekp-c initialized with %d threads" (ekp-c-thread-count))' \
|
|
--eval '(ekp-c-cleanup)' \
|
|
--eval '(message "Test passed!")'
|
|
|
|
# Show compiler info
|
|
info:
|
|
@echo "CC: $(CC)"
|
|
@echo "CFLAGS: $(CFLAGS)"
|
|
@echo "LDFLAGS: $(LDFLAGS)"
|
|
@echo "MODULE: $(MODULE)"
|
|
@echo "UNAME: $(UNAME)"
|
|
@echo "EMACS: $(EMACS)"
|
|
ifdef EMACS_INCLUDE
|
|
@echo "EMACS_INCLUDE: $(EMACS_INCLUDE)"
|
|
endif
|