2021-01-08 14:23:16 +03:00
|
|
|
CFLAGS ?= -g -O3 -Wall -Wextra -pedantic -Wno-unused-parameter
|
2020-12-26 03:32:21 +03:00
|
|
|
|
2021-01-08 14:23:16 +03:00
|
|
|
TARGET = kuroko
|
|
|
|
OBJS = $(patsubst %.c, %.o, $(filter-out rline.c,$(filter-out kuroko.c,$(sort $(wildcard *.c)))))
|
|
|
|
MODULES = $(patsubst src/%.c, modules/%.so, $(sort $(wildcard src/*.c)))
|
2020-12-31 09:48:39 +03:00
|
|
|
|
2021-01-08 14:23:16 +03:00
|
|
|
ifndef KRK_ENABLE_STATIC
|
|
|
|
CFLAGS += -fPIC
|
|
|
|
LDFLAGS += -L. -Wl,-rpath -Wl,'$$ORIGIN' -Wl,-z,origin
|
|
|
|
LDLIBS += -lkuroko -ldl
|
2020-12-31 09:48:39 +03:00
|
|
|
all: ${TARGET} ${MODULES}
|
2021-01-08 14:23:16 +03:00
|
|
|
KUROKO_LIBS = libkuroko.so
|
|
|
|
else
|
|
|
|
CFLAGS +=-DSTATIC_ONLY
|
|
|
|
LDFLAGS += -static
|
|
|
|
all: ${TARGET}
|
|
|
|
OBJS += kuroko.o
|
|
|
|
KUROKO_LIBS = ${OBJS}
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef KRK_DISABLE_RLINE
|
|
|
|
KUROKO_LIBS += rline.o
|
|
|
|
else
|
|
|
|
CFLAGS += -DNO_RLINE
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef KRK_DISABLE_DEBUG
|
|
|
|
CFLAGS += -DDEBUG
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef KRK_ENABLE_BUNDLE
|
|
|
|
MODULES =
|
|
|
|
KUROKO_LIBS += $(patsubst %.c,%.o,$(sort $(wildcard src/*.c)))
|
|
|
|
CFLAGS += -DBUNDLE_LIBS=1
|
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
|
|
|
|
help:
|
|
|
|
@echo "Configuration options available:"
|
|
|
|
@echo " KRK_DISABLE_RLINE=1 Do not build with the rich line editing library enabled."
|
|
|
|
@echo " KRK_DISABLE_DEBUG=1 Disable debugging features (might be faster)."
|
|
|
|
@echo " KRK_ENABLE_STATIC=1 Build a single static binary."
|
|
|
|
@echo " KRK_ENABLE_BUNDLE=1 Link C modules directly into the interpreter."
|
|
|
|
|
|
|
|
kuroko: ${KUROKO_LIBS}
|
2020-12-31 09:48:39 +03:00
|
|
|
|
2021-01-08 10:53:17 +03:00
|
|
|
%.o: *.h
|
|
|
|
|
2020-12-31 09:48:39 +03:00
|
|
|
modules/%.so: src/%.c
|
2021-01-07 14:42:25 +03:00
|
|
|
${CC} ${CFLAGS} -shared -o $@ $<
|
2020-12-26 03:32:21 +03:00
|
|
|
|
2021-01-02 08:51:01 +03:00
|
|
|
libkuroko.so: ${OBJS}
|
2021-01-07 14:42:25 +03:00
|
|
|
${CC} ${CLFAGS} -shared -o $@ ${OBJS}
|
2021-01-02 08:51:01 +03:00
|
|
|
|
2020-12-29 12:04:02 +03:00
|
|
|
builtins.c: builtins.krk
|
2021-01-08 00:49:27 +03:00
|
|
|
echo "const char krk_builtinsSrc[] = " > builtins.c
|
2021-01-07 02:39:46 +03:00
|
|
|
cat builtins.krk | sed s'/\(.*\)/\"\0\\n\"/' >> builtins.c
|
|
|
|
echo ";" >> builtins.c
|
2020-12-29 12:04:02 +03:00
|
|
|
|
2020-12-26 03:32:21 +03:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2021-01-08 06:15:53 +03:00
|
|
|
@rm -f ${OBJS} ${TARGET} ${MODULES} libkuroko.so rline.o kuroko.o src/*.o
|
2020-12-26 03:32:21 +03:00
|
|
|
|
|
|
|
tags: $(wildcard *.c) $(wildcard *.h)
|
|
|
|
@ctags --c-kinds=+lx *.c *.h
|
2021-01-04 15:49:23 +03:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
|
|
|
|
test:
|
2021-01-08 10:40:43 +03:00
|
|
|
@for i in test/*.krk; do echo $$i; KUROKO_TEST_ENV=1 ./kuroko $$i > $$i.expect; done
|
2021-01-04 15:49:23 +03:00
|
|
|
@git diff test/*.expect
|