-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (50 loc) · 2.16 KB
/
Makefile
File metadata and controls
65 lines (50 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
CC ?= cc
PREFIX ?= $(HOME)/.local
# Sources
SRCS := src/main.c src/lookup.c src/gitctx.c src/ai.c \
src/config.c src/display.c src/globals.c src/linedit.c
OBJS := $(SRCS:.c=.o)
TARGET := gitpal
CFLAGS := -std=c11 -Wall -Wextra -Wpedantic -O2 -D_POSIX_C_SOURCE=200809L
# ── Auto-detect libcurl ──────────────────────────────────────────────────
CURL_CFLAGS := $(shell pkg-config --cflags libcurl 2>/dev/null)
CURL_LIBS := $(shell pkg-config --libs libcurl 2>/dev/null)
ifeq ($(CURL_LIBS),)
# pkg-config not found — try linking directly
CURL_LIBS := -lcurl
endif
# Try a compile probe to decide whether curl is actually present
HAVE_CURL := $(shell printf '#include <curl/curl.h>\nint main(){return 0;}\n' > /tmp/_gp_curl_probe.c && \
$(CC) /tmp/_gp_curl_probe.c -o /dev/null $(CURL_CFLAGS) $(CURL_LIBS) 2>/dev/null \
&& echo yes || echo no)
ifeq ($(HAVE_CURL),yes)
CFLAGS += $(CURL_CFLAGS)
LDFLAGS += $(CURL_LIBS)
$(info [gitpal] Building WITH libcurl — AI backend enabled)
else
CFLAGS += -DGITPAL_NO_CURL
$(info [gitpal] libcurl not found — building WITHOUT AI backend)
endif
# ── macOS: silence deprecated POSIX warnings ────────────────────────────
UNAME := $(shell uname)
ifeq ($(UNAME),Darwin)
CFLAGS += -D_DARWIN_C_SOURCE
endif
# ── Targets ─────────────────────────────────────────────────────────────
.PHONY: all clean install uninstall
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# Header dependencies — changes to any .h trigger recompile of all .o
HEADERS := $(wildcard src/*.h)
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $<
install: $(TARGET)
install -d $(PREFIX)/bin
install -m 755 $(TARGET) $(PREFIX)/bin/$(TARGET)
@echo "Installed to $(PREFIX)/bin/$(TARGET)"
@echo "Ensure $(PREFIX)/bin is in your PATH."
uninstall:
rm -f $(PREFIX)/bin/$(TARGET)
clean:
rm -f $(OBJS) $(TARGET)