58 lines
935 B
Makefile
58 lines
935 B
Makefile
|
|
MAKEFLAGS += -j16
|
|
|
|
CFLAGS=-std=c17 -pedantic-errors -Wall -Wextra -Wconversion
|
|
LDFLAGS=
|
|
|
|
# Some of the sussy stuff needs this
|
|
CFLAGS+=-Wno-strict-aliasing
|
|
|
|
ASAN=0
|
|
ifeq ($(ASAN),1)
|
|
CFLAGS += -fsanitize=address
|
|
endif
|
|
|
|
LTO=0
|
|
ifeq ($(ASAN),1)
|
|
CFLAGS += -flto=auto
|
|
endif
|
|
|
|
RELEASE=0
|
|
ifeq ($(RELEASE),1)
|
|
CFLAGS += -O3
|
|
else
|
|
CFLAGS += -g -ggdb
|
|
endif
|
|
|
|
build_dir = build
|
|
obj_dir = $(build_dir)/obj
|
|
|
|
sources = \
|
|
src/main.c \
|
|
src/collections.c \
|
|
src/json_value.c \
|
|
src/json_parse.c \
|
|
src/json_query.c \
|
|
src/json_stringify.c
|
|
|
|
target=$(build_dir)/jq
|
|
|
|
all: $(target)
|
|
|
|
debug: $(target)
|
|
# gdb -ex 'r' --args build/jq '.' data.json
|
|
gdb -ex 'r' --args build/jq '[11350].payload.issues.user' large-file-formatted.json
|
|
|
|
$(target): $(sources:%.c=$(obj_dir)/%.o)
|
|
gcc -o $@ $(CFLAGS) $(LDFLAGS) $^
|
|
|
|
$(obj_dir)/%.o: %.c
|
|
@mkdir -p $(dir $@)
|
|
gcc $< -c -o $@ -MMD -MP $(CFLAGS)
|
|
|
|
clean:
|
|
rm -rf $(build_dir)
|
|
|
|
-include $(sources:%.c=$(obj_dir)/%.d)
|
|
|