Files
qdl/Makefile
Bjorn Andersson a10d2bf57b Makefile: Generate compile_commands.json
Introduce a make target for generating compile_commands.json to feed
clangd and the Language Server Protocol, to gain better editor
integration.

Add the relevant files to .gitignore.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2024-05-08 18:29:38 +02:00

33 lines
781 B
Makefile

OUT := qdl
CFLAGS := -O2 -Wall -g `pkg-config --cflags libxml-2.0`
LDFLAGS := `pkg-config --libs libxml-2.0 libudev`
prefix := /usr/local
SRCS := firehose.c qdl.c sahara.c util.c patch.c program.c ufs.c
OBJS := $(SRCS:.c=.o)
KS_OUT := ks
KS_SRCS := ks.c sahara.c util.c
KS_OBJS := $(KS_SRCS:.c=.o)
default: $(OUT) $(KS_OUT)
$(OUT): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
$(KS_OUT): $(KS_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
compile_commands.json: $(SRCS) $(KS_SRCS)
@echo -n $^ | jq -snR "[inputs|split(\" \")[]|{directory:\"$(PWD)\", command: \"$(CC) $(CFLAGS) -c \(.)\", file:.}]" > $@
clean:
rm -f $(OUT) $(OBJS)
rm -f $(KS_OUT) $(KS_OBJS)
rm -f compile_commands.json
install: $(OUT) $(KS_OUT)
install -d $(DESTDIR)$(prefix)/bin
install -m 755 $^ $(DESTDIR)$(prefix)/bin